diff --git a/cygwin-easy/etc/easy-update.conf b/cygwin-easy/etc/easy-update.conf new file mode 100644 index 0000000..bf3549f --- /dev/null +++ b/cygwin-easy/etc/easy-update.conf @@ -0,0 +1,25 @@ +# easy-update configuration file + +self_update=1 +self_dir="/usr/share/cygwin-easy" +self_files=(autorun.sh profile.patch) + +setup_update=1 +setup_url="http://cygwin.com/setup/snapshots/?C=M;O=D" +setup_download_url="http://cygwin.com/setup/snapshots" +setup_default_url="http://www.cygwin.com/setup.exe" + +console_update=1 +console_dir="console" +console_url="http://sourceforge.net/export/rss2_projfiles.php?group_id=43764" +console_download_url="http://downloads.sourceforge.net/console" + +cygeasy_update=1 +cygeasy_files=(autorun.bat autorun.inf changelog.txt license.txt leggimi.txt readme.txt) +cygeasy_download_url="http://cygwin-easy.googlecode.com/svn/trunk" +cygeasy_custom=0 + +readme_update=1 +readme_files=(leggimi.txt readme.txt) +pkglist_update=1 +autoplay_update=1 diff --git a/cygwin-easy/etc/postinstall/cygwin-easy.sh b/cygwin-easy/etc/postinstall/cygwin-easy.sh new file mode 100644 index 0000000..dc8c945 --- /dev/null +++ b/cygwin-easy/etc/postinstall/cygwin-easy.sh @@ -0,0 +1,45 @@ +#! /bin/sh + +# cygwin-easy.sh - Copyright 2007-2008 Stefano Cotta Ramusino. +# ============================================================ +# Written by Stefano Cotta Ramusino, March 2007. +# Modified by Stefano Cotta Ramusino, February 2008. +# +# Based on lnk.update.sh posted to the Cygwin mailing list by Fergus +# http://www.cygwin.com/ml.cygwin/2003-07/msg01117.html. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 3 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . + +if [[ "$1" == "--force" || ! -e /etc/postinstall/cygwin-easy.sh.done ]] +then + + if [[ ! -e /usr/share/icons/cygwin.ico && -e /cygwin.ico ]] + then + + [ ! -e /usr/share/icons ] && mkdir -p /usr/share/icons + cp -f /cygwin.ico /usr/share/icons/cygwin.ico + + fi + + [ ! -e /tmp ] && mkdir /tmp + + find / -mount \( -path /usr/lib -o -path /usr/bin \) -prune -o -type l \ + ! \( -path /etc/hosts -o -path /etc/protocols -o -path /etc/services -o -path /etc/networks \) \ + -printf "/bin/rm %p\n/bin/ln -s %l %p\n" > /tmp/cygrelnk + + source /tmp/cygrelnk + + rm -f /tmp/cygrelnk + +fi \ No newline at end of file diff --git a/cygwin-easy/usr/bin/easy-update b/cygwin-easy/usr/bin/easy-update new file mode 100644 index 0000000..1129018 --- /dev/null +++ b/cygwin-easy/usr/bin/easy-update @@ -0,0 +1,765 @@ +#!/bin/bash + +# easy-update - Copyright 2008 Stefano Cotta Ramusino. +# ==================================================== +# Written by Stefano Cotta Ramusino, January 2008. +# Modified by Stefano Cotta Ramusino, February 2008. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 3 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . + +function show_copyright() +{ + + echo "This program is free software; you can redistribute it and/or modify it under" 2> /dev/null + echo "the terms of the GNU General Public License version 3 as published by the Free" 2> /dev/null + echo "Software Foundation. There is NO warranty; not even for MERCHANTABILITY or" 2> /dev/null + echo "FITNESS FOR A PARTICULAR PURPOSE." 2> /dev/null + +} + +function show_version() +{ + + echo "$myself $cygeasy_version" 2> /dev/null + echo "Copyright (C) 2008 Stefano Cotta Ramusino " 2> /dev/null + +} + +function show_help() +{ + + show_version 2> /dev/null + echo 2> /dev/null + echo "Automatically update Cygwin Easy and let install Cygwin packages." 2> /dev/null + echo 2> /dev/null + echo "Usage:" 2> /dev/null + echo "$myself [--freeze]" 2> /dev/null + echo 2> /dev/null + echo "where the above options mean:" 2> /dev/null + echo " --freeze Congelate current state of Cygwin Easy to let copy it in a read-only" 2> /dev/null + echo " disk" 2> /dev/null + echo 2> /dev/null + echo "Report bugs to ." 2> /dev/null + +} + +function update_conf() +{ + + cat > /etc/$myself.conf << EOF +# easy-update configuration file + +self_update=$self_update +self_dir="$self_dir" +self_files=(${self_files[@]}) + +setup_update=$setup_update +setup_version="$setup_version" +setup_url="$setup_url" +setup_download_url="$setup_download_url" +setup_default_url="$setup_default_url" + +console_update=$console_update +console_dir="$console_dir" +console_version="$console_version" +console_url="$console_url" +console_download_url="$console_download_url" + +cygeasy_update=$cygeasy_update +cygeasy_version="$cygeasy_version" +cygeasy_files=(${cygeasy_files[@]}) +cygeasy_download_url="$cygeasy_download_url" +cygeasy_custom=$cygeasy_custom + +readme_update=$readme_update +readme_files=(${readme_files[@]}) +pkglist_update=$pkglist_update +autoplay_update=$autoplay_update +EOF + +} + +function freeze_now() +{ + + [ ! -e /etc/postinstall/cygwin-easy.sh.done ] && [ ! -e /etc/postinstall/cygwin-easy.sh ] && + { echo -e "Postinstall script of 'cygwin-easy' package is missing.\nPlease reinstall the package." >&2; exit 1; } + + echo -en "\nFreeze process can take few minutes. Please wait ... " 2> /dev/null + + retval=1 + + if [ -e /etc/postinstall/cygwin-easy.sh.done ] + then + chmod +x /etc/postinstall/cygwin-easy.sh.done &> /dev/null + /etc/postinstall/cygwin-easy.sh.done --force + retval=$? + else + if [ -e /etc/postinstall/cygwin-easy.sh ] + then + chmod +x /etc/postinstall/cygwin-easy.sh &> /dev/null + /etc/postinstall/cygwin-easy.sh + retval=$? + fi + fi + + if [ "$retval" == "0" ] + then + echo -e "\n'Cygwin Easy $cygeasy_version' is now ready to be copied in a read-only disk." 2> /dev/null + else + echo -e "\nSome errors occurred." >&2 + fi + +} + +function auto_update() +{ + + echo "New version of '$myself' downloaded. Automatic restart of '$myself'." 2> /dev/null + echo "mv -f $self_dir/$myself $(which $myself)" > "$self_dir/autoupdate" 2> /dev/null + echo "exec $(which $myself)" >> "$self_dir/autoupdate" 2> /dev/null + chmod +x $self_dir/autoupdate &> /dev/null + echo 2> /dev/null + exec $self_dir/autoupdate $@ + +} + +function update_myself() +{ + + echo -n "Searching for a new version of '$myself' ... " 2> /dev/null + curl -L -f -z "$(which $myself 2> /dev/null)" -o "$self_dir/$myself" \ + "$cygeasy_download_url/cygwin-easy/usr/bin/$myself" &> /dev/null + let "retval = $?" + if [ -e "$self_dir/$myself" ] + then + case "$retval" in + 0) echo "found!" 2> /dev/null + auto_update + echo "Automatic update of '$myself' failed" >&2 ;; + 7) echo "failed to connect to host" >&2 ;; + *) echo "curl error (exit code: $retval)" >&2 ;; + esac + else + echo "not found." 2> /dev/null + fi + +} + +function differ() +{ + + retcode=$(du -b "$1" "$2" 2> /dev/null | \ + cut -f1 2> /dev/null | uniq 2> /dev/null | wc -l 2> /dev/null) + case "$retcode" in + 1) return 0 ;; + 2) return 1 ;; + *) return -1 ;; + esac + return -1 + +} + +function update_cygeasy() +{ + + local file latest_file new_version + + [ ! -e "$self_dir/cache" ] && mkdir -p "$self_dir/cache" &> /dev/null + + pushd "$cygeasy_dir" &> /dev/null + for file in ${cygeasy_files[*]} + do + rm -f $self_dir/cache/$file &> /dev/null + if [[ ! -e "$file" || "$ask_all" ]] + then + answer= + echo -ne "\nDo you want to download '$file' in '$cygeasy_dir' [Y/n]? " 2> /dev/null + read -n1 answer &> /dev/null + echo 2> /dev/null + [[ "$answer" == "n" || "$answer" == "N" ]] && continue + fi + echo -n "Searching for a new version of '$file' ... " 2> /dev/null + curl -L -f -z $file -o $self_dir/cache/$file \ + $cygeasy_download_url/$file &> /dev/null + let "retval = $?" + if [ -e "$self_dir/cache/$file" ] + then + case "$retval" in + 0) echo "found!" 2> /dev/null + mv -f "$self_dir/cache/$file" "$file" &> /dev/null + let "retval2 = $?" + if [ "$retval2" == "0" ] + then + echo "File '$file' updated." 2> /dev/null + rm -f "$self_dir/cache/$file" &> /dev/null + else + echo "Error updating file '$file': mv error (exit code: $retval2)" >&2 + fi ;; + 7) echo "failed to connect to host" >&2 ;; + *) echo "curl error (exit code: $retval)" >&2 ;; + esac + else + echo "not found." 2> /dev/null + fi + if [[ "$file" == "autorun.bat" || "$file" == "changelog.txt" ]] + then + [ "$new_version" ] || new_version=$(date '+%s' -r $file 2> /dev/null) + [ "$latest_file" ] || latest_file=$file + if [ "$new_version" -lt "$(date '+%s' -r $file 2> /dev/null)" ] + then + new_version=$(date '+%s' -r $file 2> /dev/null) + latest_file=$file + fi + fi + done + popd &> /dev/null + + unset file &> /dev/null + + pushd "$self_dir" &> /dev/null + for file in ${self_files[*]} + do + echo -n "Searching for a new version of '$file' ... " 2> /dev/null + curl -L -f -z $file -o cache/$file \ + $cygeasy_download_url/cygwin-easy/usr/share/cygwin-easy/$file &> /dev/null + let "retval = $?" + if [ -e "cache/$file" ] + then + case "$retval" in + 0) echo "found!" 2> /dev/null + mv -f "cache/$file" "$file" &> /dev/null + let "retval2 = $?" + if [ "$retval2" == "0" ] + then + echo "File '$file' updated." 2> /dev/null + rm -f "cache/$file" &> /dev/null + else + echo "Error updating file '$file': mv error (exit code: $retval2)" >&2 + fi ;; + 7) echo "failed to connect to host" >&2 ;; + *) echo "curl error (exit code: $retval)" >&2 ;; + esac + else + echo "not found." 2> /dev/null + fi + if [ "$new_version" -lt "$(date '+%s' -r $file 2> /dev/null)" ] + then + new_version=$(date '+%s' -r $file 2> /dev/null) + latest_file=$file + fi + done + [ -e "cache" ] && rm -fr "cache" &> /dev/null + popd &> /dev/null + + [[ $new_version -lt $(date '+%s' -r $(which $myself 2> /dev/null)) ]] && + latest_file=$(which $myself 2> /dev/null) + + if [ -e "$cygeasy_dir/$latest_file" ] + then + new_version="$(date '+%Y.%m.%d' -r $cygeasy_dir/$latest_file)" + else + if [ -e "$self_dir/$latest_file" ] + then + new_version="$(date '+%Y.%m.%d' -r $self_dir/$latest_file)" + else + new_version="$(date '+%Y.%m.%d' -r $latest_file)" + fi + fi + + unset file latest_file + if [ "$cygeasy_version" != "$new_version" ] + then + cygeasy_version="$new_version" + update_conf + fi + +} + +function install_console() +{ + + unzip -ujoqq $self_dir/console.zip -d $console_full_dir &> /dev/null + let "retval = $?" + if [ $retval -eq 0 ] + then + console_version=$last_version + update_conf + for file in "$console_full_dir/*" + do + mv -f $file $(echo $file 2> /dev/null | tr A-Z a-z 2> /dev/null) &> /dev/null + done + [ "$1" == "1" ] && echo "Latest Console already downloaded." 2> /dev/null + [ "$1" == "" ] && echo "Console updated." 2> /dev/null + rm -fr $self_dir/$(basename $console_full_dir 2> /dev/null) &> /dev/null + rm -f $self_dir/console.zip &> /dev/null + echo -n "Customizing 'Console' preferences file for Cygwin Easy ... " 2> /dev/null + cygwin_dir=$(mount 2> /dev/null | grep ' / ' 2> /dev/null | cut -f1 -d' ' 2> /dev/null | \ + cut -f2 -d: 2> /dev/null | sed "s,\\\,\\\\\\\\,g" 2> /dev/null) + awk ' + BEGIN { code=112 } + /window title/ { + gsub("Console","Cygwin Easy") + gsub("icon=\"\"","icon=\"$cygwin_dir\\usr\\share\\icons\\cygwin.ico\"") + } + /command="exit"/ { $0=$1 " ctrl=\"1\" shift=\"0\" alt=\"0\" extended=\"0\" code=\"8\" " $7 } + /command="switchtab/ { $0=$1 " ctrl=\"0\" shift=\"0\" alt=\"1\" extended=\"0\" code=\"" code++ "\" " $7 } + /tab title/ { gsub("Console2\"","Cygwin Easy\" icon=\"$cygwin_dir\\usr\\share\\icons\\cygwin.ico\"") } + /console shell/ { $0=" $console_full_dir/console.xml.cygwin-easy 2> /dev/null + let "retval = $?" + if [[ "$retval" == "0" && -e "$console_full_dir/console.xml.cygwin-easy" ]] + then + mv -f "$console_full_dir/console.xml.cygwin-easy" "$console_full_dir/console.xml" &> /dev/null + u2d "$console_full_dir/console.xml" &> /dev/null + echo "done!" 2> /dev/null + else + echo "an error occurred (exit code: $retval)" >&2 + fi + rm -f "$console_full_dir/console.xml.cygwin-easy" &> /dev/null + else + echo "unzip error (exit code: $retval)" >&2 + fi + return $retval + +} + +function update_tools() +{ + + local last_version + + [ "$setup_update" ] || setup_update=1 + + if [[ "$setup_update" == "1" || ! -e $self_dir/setup.exe ]] + then + + echo -n "Searching for a new version of Cygwin setup utility ... " 2> /dev/null + + [ "$setup_url" ] || + setup_url="http://cygwin.com/setup/snapshots/?C=M;O=D" + + last_version=$(curl -s -L "$setup_url" 2> /dev/null | \ + grep -im1 'href="setup-[0-9\.]*\.exe"' 2> /dev/null | \ + sed "s,.*setup-\([0-9\.]*\)\.exe.*,\1,i" 2> /dev/null) + + [ "$last_version" ] || echo "not found." + + [ "$last_version" ] && + if [[ ! -e $self_dir/setup.exe || "$last_version" != "$setup_version" ]] + then + echo "found!" 2> /dev/null + [ "$setup_download_url" ] || + setup_download_url="http://cygwin.com/setup/snapshots" + [ -e $self_dir/setup.exe ] && setup_exist=1 + cp -f $self_dir/setup.exe $self_dir/setup.exe.backup &> /dev/null + echo "Download version $last_version" 2> /dev/null + curl -L -f -# -o $self_dir/setup.exe \ + $setup_download_url/setup-$last_version.exe > /dev/null + let "retval = $?" + case "$retval" in + 0) setup_version=$last_version + update_conf + echo "Cygwin setup utility updated." 2> /dev/null + rm -f $self_dir/setup.exe.backup &> /dev/null ;; + 18) if [ "$setup_exist" ] + then + setup_version=$last_version + update_conf + echo "Latest Cygwin setup utility already downloaded." 2> /dev/null + rm -f $self_dir/setup.exe.backup &> /dev/null + fi ;; + esac + cp -f $self_dir/setup.exe.backup $self_dir/setup.exe &> /dev/null + else + echo "not found." 2> /dev/null + fi + + fi + + [ "$console_update" ] || console_update=1 + + if [ "$console_update" == "1" ] + then + + [ $(type -f unzip &> /dev/null; echo $?) -eq 0 ] || return + + unset last_version &> /dev/null + + [ "$console_dir" ] || console_dir=console + console_full_dir="$cygeasy_dir/$console_dir" + + if [ ! -e "$console_full_dir" ] + then + answer= + echo -e "\nConsole directory not found in '$cygeasy_dir'." 2> /dev/null + echo -ne "\nDo you want to install Console in '$console_full_dir' [Y/n]? " 2> /dev/null + read -n1 answer &> /dev/null + echo 2> /dev/null + if [[ "$answer" == "n" || "$answer" == "N" ]] + then + answer= + echo -ne "\nDo you want to download and install Console next time [Y/n]? " 2> /dev/null + read -n1 answer &> /dev/null + echo 2> /dev/null + [[ "$answer" != "n" && "$answer" != "N" ]] && return + console_update=0 + return + fi + fi + + echo -n "Searching for a new version of Console ... " 2> /dev/null + + [ "$console_url" ] || + console_url="http://sourceforge.net/export/rss2_projfiles.php?group_id=43764" + + last_version=$(curl -s -L "$console_url" 2> /dev/null | \ + grep -i -m1 "Includes files: Console-" 2> /dev/null | \ + sed -n "s,.*Includes files: Console-\([^ ]*\)\.zip .*,\1,pi" 2> /dev/null) + + [ "$last_version" ] || echo "not found." 2> /dev/null + + if [ "$last_version" ] + then + if [[ ! -e $console_full_dir/console.exe || "$last_version" != "$console_version" ]] + then + echo "found!" + [ "$console_download_url" ] || + console_download_url="http://downloads.sourceforge.net/console" + [ -e $self_dir/console.zip ] && console_exist=1 + cp -fa $console_full_dir $self_dir &> /dev/null + echo "Download version $last_version" 2> /dev/null + curl -f -L -# -C - -o $self_dir/console.zip \ + $console_download_url/Console-$last_version.zip > /dev/null + let "retval = $?" + case "$retval" in + 0) install_console ;; + 18) if [ "$console_exist" ] + then + install_console 1 + fi ;; + esac + cp -f $self_dir/$(basename $console_full_dir) $console_full_dir &> /dev/null + else + echo "not found." 2> /dev/null + fi + fi + + fi + +} + +function setup_missing() +{ + + echo "Cygwin setup utility not found." >&2 + echo "Please download it from '$setup_full_url'" >&2 + echo "and put it in '$(cygpath -w $self_dir 2> /dev/null)' directory." >&2 + exit 1 + +} + +myself=${0##*/} + +[ "$cygeasy_version" ] || + cygeasy_version="$(date '+%Y.%m.%d' -r $(which $myself) 2> /dev/null)" + +[ "$1" == "--help" ] && { show_help 2> /dev/null; exit $?; } +[ "$1" == "--version" ] && { show_version 2> /dev/null; echo 2> /dev/null; show_copyright 2> /dev/null; exit $?; } + +[ -e "$self_dir/autoupdate" ] && + { + echo -e "Successfully updated to version $cygeasy_version.\n" 2> /dev/null; + rm -f "$self_dir/autoupdate" &> /dev/null; + } + +[ $(cygcheck -l cygwin-easy 2> /dev/null | wc -l 2> /dev/null) -eq 0 ] && + { echo "Package 'cygwin-easy' not found. Please use 'mkeasy.sh' script" >&2; \ + echo "to install latest version available." >&2; exit 1; } + +[ ! -e /etc/profile.cygwin-easy ] && ask_all=1 + +[ $(mount 2> /dev/null | grep /etc 2> /dev/null; echo $?) -eq 0 ] && + { echo "Read only mode detected. Please run in writable mode or your" >&2; \ + echo "changes will be lost." >&2; exit 1; } + +[ -r /etc/$myself.conf ] && + . /etc/$myself.conf &> /dev/null + +[ "$self_dir" ] || + self_dir=/usr/share/cygwin-easy +[ "$self_files" ] || + self_files=("autorun.sh" "profile.patch") +[ "$readme_files" ] || + readme_files=("leggimi.txt" "readme.txt") +[ "$cygeasy_files" ] || + cygeasy_files=("autorun.bat" "autorun.inf" "changelog.txt" "license.txt" ${readme_files[*]}) +[ "$cygeasy_download_url" ] || + cygeasy_download_url="http://cygwin-easy.googlecode.com/svn/trunk" + +cygeasy_dir=$(mount 2> /dev/null | grep ' / ' 2> /dev/null | cut -f1 -d'\' 2> /dev/null) + +[ ! -e "$self_dir" ] && + mkdir -p "$self_dir" &> /dev/null + +nocurl=$(type -f curl &>/dev/null; echo $?) +online=$(curl -s -o /dev/null http://www.cygwineasy.tk &> /dev/null; echo $?) + +if [[ $nocurl -eq 0 && $online -eq 0 ]] +then + [ "$self_update" ] || self_update=1 + [ "$self_update" == "1" ] && update_myself $@ + [ "$cygeasy_update" ] || cygeasy_update=1 + [ "$cygeasy_update" == "1" ] && update_cygeasy + update_tools +fi + +if [ ! -e $self_dir/setup.exe ] +then + if [ "$setup_version" ] + then + [ "$setup_download_url" ] || + setup_download_url="http://cygwin.com/setup/snapshots" + setup_full_url="$setup_download_url/setup-$setup_version.exe" + else + [ "$setup_default_url" ] || + setup_default_url="http://www.cygwin.com/setup.exe" + setup_full_url="$setup_default_url" + fi + if [[ $online -eq 0 || $nocurl -ne 0 ]] + then + echo "Cygwin setup utility is missing and I can't download it automatically." 2> /dev/null + echo "Please follow this step by step tutorial to get this file." 2> /dev/null + echo -ne "\nHave you already a version of 'setup.exe' [y/N]? " 2> /dev/null + read -n1 answer &> /dev/null + echo 2> /dev/null + if [[ "$answer" == "y" || "$answer" == "Y" ]] + then + answer= + echo -e "\nVery well. Now you have to copy this file in:" 2> /dev/null + echo 2> /dev/null + cygpath -w "$self_dir" 2> /dev/null + echo -ne "\nDo you want to open this directory for you [Y/n]? " 2> /dev/null + read -n1 answer &> /dev/null + echo 2> /dev/null + [[ "$answer" != "n" && "$answer" != "N" ]] && + cygstart "$self_dir" + else + answer= + echo -e "\nNo problem. You can download this file from:" 2> /dev/null + echo 2> /dev/null + echo "$setup_full_url" 2> /dev/null + echo 2> /dev/null + echo "and put it in this directory:" 2> /dev/null + echo 2> /dev/null + cygpath -w "$self_dir" 2> /dev/null + echo 2> /dev/null + echo "Do you want to download it with your default browser" 2> /dev/null + echo -n "(destination directory path will be in your clipboard) [Y/n]? " 2> /dev/null + read -n1 answer &> /dev/null + echo 2> /dev/null + [[ "$answer" != "n" && "$answer" != "N" ]] && + { cygpath -w "$self_dir" 2> /dev/null | putclip &> /dev/null; \ + cygstart -d "$self_dir" "$setup_full_url"; } + fi + echo -ne "\nWhen you have terminated press ENTER" 2> /dev/null + read -n1 &> /dev/null + echo 2> /dev/null + [[ "$setup_version" && -e "$self_dir/setup-$setup_version.exe" ]] && + mv -f "$self_dir/setup-$setup_version.exe" "$self_dir/setup.exe" &> /dev/null + [ ! -e "$self_dir/setup.exe" ] && setup_missing > /dev/null + else + setup_missing > /dev/null + fi +fi + +[ "$readme_update" ] || readme_update=1 + +if [ "$readme_update" == "1" ] +then + + for readme in ${readme_files[*]} + do + if [ -e "$cygeasy_dir/$readme" ] + then + readme_version=$(sed -n "s,Cygwin Easy \(.*\),\1,ip" "$cygeasy_dir/$readme" 2> /dev/null | head -1 2> /dev/null) + if [ "$readme_version" != "$cygeasy_version" ] + then + echo -n "Updating '$readme' ... " 2> /dev/null + mv -f "$cygeasy_dir/$readme" \ + "$self_dir/$readme" &> /dev/null + echo -e "Cygwin Easy $cygeasy_version\r" > "$cygeasy_dir/$readme" 2> /dev/null + echo -e "----------------------\r" >> "$cygeasy_dir/$readme" 2> /dev/null + tail +3 "$self_dir/$readme" >> "$cygeasy_dir/$readme" 2> /dev/null + if [ -e "$cygeasy_dir/$readme" ] + then + echo "done!" + rm -f "$self_dir/$readme" &> /dev/null + else + mv -f "$self_dir/$readme" \ + "$cygeasy_dir/$readme" &> /dev/null + echo "some error occurred" >&2 + fi + fi + fi + done + +fi + +[ "$pkglist_update" ] || pkglist_update=1 + +if [[ "$pkglist_update" == "1" && -e "$cygeasy_dir/packages.txt" ]] +then + + [ "$cygeasy_custom" ] || cygeasy_custom=0 + + echo -n "Updating packages list ... " 2> /dev/null + mv -f "$cygeasy_dir/packages.txt" \ + "$self_dir/packages.txt" &> /dev/null + cygcheck -c -d | sed -e \ + "s,\(Package Info.*\),Easy $cygeasy_version \1\n------------------------------------------\n,i; + s,\(Version\),\1\n,i" > "$cygeasy_dir/packages.txt" 2> /dev/null + if [ -e "$cygeasy_dir/packages.txt" ] + then + u2d "$cygeasy_dir/packages.txt" &> /dev/null + if [ "$cygeasy_custom" == "0" ] + then + tail +6 "$self_dir/packages.txt" > "$self_dir/pkg1.txt" 2> /dev/null + tail +6 "$cygeasy_dir/packages.txt" > "$self_dir/pkg2.txt" 2> /dev/null + differ $self_dir/pkg1.txt $self_dir/pkg2.txt &> /dev/null + if [ $? -eq 1 ] + then + cygeasy_custom=1 + update_conf + fi + rm -f "$self_dir/pkg1.txt" "$self_dir/pkg2.txt" &> /dev/null + fi + if [ "$cygeasy_custom" == "1" ] + then + sed -i "s,\([0-9] \)\(Package Info.*\),\1\(custom\) \2,i; + s,--$,-----------,i" "$cygeasy_dir/packages.txt" &> /dev/null + u2d "$cygeasy_dir/packages.txt" &> /dev/null + fi + echo "done!" 2> /dev/null + rm -f "$self_dir/packages.txt" &> /dev/null + else + mv -f "$self_dir/packages.txt" \ + "$cygeasy_dir/packages.txt" &> /dev/null + echo "some error occurred" >&2 + fi +fi + +[ "$autoplay_update" ] || autoplay_update=1 + +if [[ "$autoplay_update" == "1" && -e "$cygeasy_dir/autorun.inf" ]] +then + + unset retval retval2 + cp -f "$cygeasy_dir/autorun.inf" "$self_dir/autorun.inf" &> /dev/null + retval=$? + echo -n "Updating autoplay configuration file ... " 2> /dev/null + if [ "$cygeasy_custom" == "1" ] + then + [ "$(grep custom $self_dir/autorun.inf &> /dev/null; echo $? 2> /dev/null)" != "0" ] && + sed -i "s,\(Cygwin Easy\),\1 (custom),i" "$self_dir/autorun.inf" &> /dev/null + fi + cygwin_dir=$(mount 2> /dev/null | grep ' / ' 2> /dev/null | cut -f1 -d' ' 2> /dev/null | \ + cut -f2 -d'\' 2> /dev/null | sed "s,\\\,\\\\\\\\,g" 2> /dev/null) + sed -i "s,\(icon=\).*,\1$cygwin_dir\\\usr\\\share\\\icons\\\cygwin.ico,i" "$self_dir/autorun.inf" &> /dev/null + retval2=$? + [ "$retval" == "0" ] && retval=$retval2 + + xwin_in=$(grep -i xwin "$self_dir/autorun.inf" &> /dev/null; echo $? 2> /dev/null) + + if [[ "$xwin_in" == "0" && ! -e "/usr/X11R6/bin/startxwin.sh" ]] + then + sed -i "s,.*xwin.*,,i" "$self_dir/autorun.inf" &> /dev/null + retval2=$? + [ "$retval" == "0" ] && retval=$retval2 + fi + + if [[ "$xwin_in" != "0" && -e "/usr/X11R6/bin/startxwin.sh" ]] + then + cat >> "$self_dir/autorun.inf" << EOF +shell\xwin=X Windows +shell\xwin\command=autorun.bat x +EOF + retval2=$? + [ "$retval" == "0" ] && retval=$retval2 + fi + + [ "$console_dir" ] || console_dir=console + wcons_dir=$(cygpath -w $console_dir 2> /dev/null) + + console_in=$(grep -i console "$self_dir/autorun.inf" &> /dev/null; echo $? 2> /dev/null) + + if [ "$console_in" == "0" ] + then + + if [ ! -e "$cygeasy_dir/$console_dir/console.exe" ] + then + sed -i "s,.*console.*,,i" "$self_dir/autorun.inf" &> /dev/null + retval2=$? + [ "$retval" == "0" ] && retval=$retval2 + fi + + if [ -e "$cygeasy_dir/$console_dir/console.exe" ] + then + sed -i "s,\(command=\).*\(\\\console\.exe\),\1$wcons_dir\2,i" "$self_dir/autorun.inf" &> /dev/null + retval2=$? + [ "$retval" == "0" ] && retval=$retval2 + fi + + fi + + if [[ "$console_in" != "0" && -e "$cygeasy_dir/$console_dir/console.exe" ]] + then + cat >> "$self_dir/autorun.inf" << EOF +shell\console=Console +shell\console\command=$wcons_dir\console.exe +EOF + retval2=$? + [ "$retval" == "0" ] && retval=$retval2 + fi + + unset retval2 + + grep '^[a-z\[].*' "$self_dir/autorun.inf" > "$self_dir/autorun.inf.new" + retval2=$? + [ "$retval" == "0" ] && retval=$retval2 + mv -f "$self_dir/autorun.inf.new" "$self_dir/autorun.inf" &> /dev/null + u2d "$self_dir/autorun.inf" &> /dev/null + retval2=$? + [ "$retval" == "0" ] && retval=$retval2 + + if [ "$retval" == "0" ] + then + mv -f "$self_dir/autorun.inf" "$cygeasy_dir/autorun.inf" &> /dev/null + echo "done!" 2> /dev/null + else + rm -f "$self_dir/autorun.inf" &> /dev/null + echo "some errors occurred" + fi + +fi + +[ -e /etc/$myself.conf ] || update_conf + +[ "$1" == "--freeze" ] && { freeze_now; exit $?; } + +echo "Launch Cygwin setup utility" +cygstart $self_dir/setup.exe + +exit $? \ No newline at end of file diff --git a/cygwin-easy/usr/share/cygwin-easy/autorun.sh b/cygwin-easy/usr/share/cygwin-easy/autorun.sh new file mode 100644 index 0000000..75cf0e3 --- /dev/null +++ b/cygwin-easy/usr/share/cygwin-easy/autorun.sh @@ -0,0 +1,136 @@ +#!/bin/bash + +# autorun.sh - Copyright 2007-2008 Stefano Cotta Ramusino. +# ======================================================== +# Written by Stefano Cotta Ramusino, March 2007. +# Modified by Stefano Cotta Ramusino, January 2008. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 3 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . + +if [[ "$1" != "" && ! -e "$TEMP/etc/profile.cygwin-easy" ]] +then + + PATH=/usr/bin:/bin + + if [[ "$2" != "1" && "$3" != "" ]] + then + + for file in $(find $1$3/etc -mindepth 1 -maxdepth 1 ! -name profile ! -type d -printf "%f\n") + do + ln -f -s $1$3/etc/$file "$TEMP/etc/$file" &> /dev/null + done + + for directory in $(find $1$3/etc -mindepth 1 -maxdepth 1 -type d -printf "%f\n") + do + mount -bfu "$(cygpath -w $1$3/etc)/$directory" /etc/$directory &> /dev/null + done + + cp $1$3/etc/profile "$TEMP/etc/profile" &> /dev/null + pushd "$TEMP/etc" &> /dev/null + patch -p0 -b -z .cygwin-easy < /usr/share/cygwin-easy/profile.patch &> /dev/null + popd &> /dev/null + + mount -bfu "$(cygpath -w $TEMP)/etc" /etc &> /dev/null + + else + + if [ "$4" == "" ] + then + pushd "/etc" &> /dev/null + else + pushd "$1$3/etc" &> /dev/null + fi + [ -e profile.cygwin-easy ] && mv -f profile.cygwin-easy profile &> /dev/null + [ -e profile.rej ] && rm -f profile.rej &> /dev/null + if [ "$4" == "" ] + then + patch -p0 -b -z .cygwin-easy < /usr/share/cygwin-easy/profile.patch &> /dev/null + else + rm -f {hosts,networks,services,protocols,passwd,group} &> /dev/null + fi + popd &> /dev/null + + fi + + if [ "$4" == "" ] + then + + if [ -e /etc/postinstall/base-files-mketc.sh.done ] + then + /etc/postinstall/base-files-mketc.sh.done &> /dev/null + fi + + if [ -e /etc/postinstall/passwd-grp.sh.done ] + then + /etc/postinstall/passwd-grp.sh.done &> /dev/null + else + mkgroup -l > /etc/group 2> /dev/null + mkpasswd -l > /etc/passwd 2> /dev/null + fi + + grep mount "$TEMP/remount.bat" &> /dev/null + if [ $? -ne 0 ] + then + rm -f "$TEMP/remount.bat" &> /dev/null + fi + + mount -bfu "$(cygpath -w $TEMP)/lnk" /usr/share/cygwin-easy/lnk &> /dev/null + + [ "$OS" == "Windows_NT" ] && del_flag="/q " + + [ -e /usr/share/cygwin-easy/lnk/cygwin.bat ] && + if [[ ! -e "$(cygpath -D -u)/Cygwin Shell.lnk" || ! -e "$TEMP/dellnk.bat" ]] + then + + mkshortcut \ + -D \ + -i /usr/share/icons/cygwin.ico \ + -n "Cygwin Shell" \ + /usr/share/cygwin-easy/lnk/cygwin.bat &> /dev/null + + echo -e "del $del_flag\"$(cygpath -D -w)\\Cygwin Shell.lnk\"\r" >> "$TEMP/dellnk.bat" 2> /dev/null + + fi + + if [[ -e /usr/X11R6/bin/startxwin.sh && ! -e "$(cygpath -D -u)/Cygwin X Windows.lnk" ]] + then + + mkshortcut \ + -D \ + -i /usr/share/icons/cygwin.ico \ + -n "Cygwin X Windows" \ + -s min \ + /usr/share/cygwin-easy/lnk/X.bat &> /dev/null + + echo -e "del $del_flag\"$(cygpath -D -w)\\Cygwin X Windows.lnk\"\r" >> "$TEMP/dellnk.bat" 2> /dev/null + + fi + + if [ ! -e "$(cygpath -D -u)/Remove Cygwin Easy.lnk" ] + then + + mkshortcut \ + -D \ + -i /usr/share/icons/cygwin.ico \ + -n "Remove Cygwin Easy" \ + -s min \ + /usr/share/cygwin-easy/lnk/remove.bat &> /dev/null + + echo -e "del $del_flag\"$(cygpath -D -w)\\Remove Cygwin Easy.lnk\"\r" >> "$TEMP/dellnk.bat" 2> /dev/null + + fi + + fi + +fi \ No newline at end of file diff --git a/cygwin-easy/usr/share/cygwin-easy/profile.patch b/cygwin-easy/usr/share/cygwin-easy/profile.patch new file mode 100644 index 0000000..85e9c42 --- /dev/null +++ b/cygwin-easy/usr/share/cygwin-easy/profile.patch @@ -0,0 +1,111 @@ +--- profile.cygwin-easy 2007-02-20 14:57:12.000000000 +0100 ++++ profile 2007-03-02 01:36:33.328125000 +0100 +@@ -49,18 +49,19 @@ + + # If the home directory doesn't exist, create it. + if [ ! -d "${HOME}" ]; then +- mkdir -p "${HOME}" +- echo "Copying skeleton files." +- echo "These files are for the user to personalise" +- echo "their cygwin experience." +- echo +- echo "These will never be overwritten." +- echo ++ mkdir -p "${HOME}" &> /dev/null ++ # echo "Copying skeleton files." ++ # echo "These files are for the user to personalise" ++ # echo "their cygwin experience." ++ # echo ++ # echo "These will never be overwritten." ++ # echo + cd /etc/skel + /bin/find . -type f | while read f; do + fDest=`echo ${f} | sed -e 's/^\.//g'` + if [ ! -e "${HOME}${fDest}" -a ! -L "${HOME}${fDest}" ]; then +- /usr/bin/install -D -p -v "${f}" "${HOME}/${fDest}" ++ /usr/bin/install -D -p -v "${f}" "${HOME}/${fDest}" &> /dev/null ++ attrib +H "$(cygpath -w "$HOME")\\${fDest}" &> /dev/null + fi + done + fi +@@ -176,41 +177,41 @@ fi + # about this on the lists! + # If this message keeps appearing and you are sure it's a mistake (ie, don't + # email about it!), comment out the test below. +-case `id -ng` in +-mkpasswd ) +- echo "Your group is currently \"mkpasswd\". This indicates that" +- echo "the /etc/passwd (and possibly /etc/group) files should be rebuilt." +- echo "See the man pages for mkpasswd and mkgroup then, for example, run" +- echo "mkpasswd -l [-d] > /etc/passwd" +- echo "mkgroup -l [-d] > /etc/group" +- echo "Note that the -d switch is necessary for domain users." +- ;; +- +-mkgroup ) +- echo "Your group is currently \"mkgroup\". This indicates that" +- echo "the /etc/group (and possibly /etc/passwd) files should be rebuilt." +- echo "See the man pages for mkpasswd and mkgroup then, for example, run" +- echo "mkpasswd -l [-d] > /etc/passwd" +- echo "mkgroup -l [-d] > /etc/group" +- echo "Note that the -d switch is necessary for domain users." +- ;; +- +-mkgroup_l_d ) +- echo "Your group name is currently \"mkgroup_l_d\". This indicates that not" +- echo "all domain users and groups are listed in the /etc/passwd and" +- echo "/etc/group files." +- echo "See the man pages for mkpasswd and mkgroup then, for example, run" +- echo "mkpasswd -l -d > /etc/passwd" +- echo "mkgroup -l -d > /etc/group" +- echo +- echo "This message is only displayed once (unless you recreate /etc/group)" +- echo "and can be safely ignored." +- +- # only display the above once +- cp -f /etc/group "${HOME}/group.mkgroup_l_d" \ +- && ( [ -w /etc/group ] || chmod --silent a+w /etc/group ; )\ +- && sed -e 's/^mkgroup_l_d/mkgroup-l-d/' "${HOME}/group.mkgroup_l_d" > /etc/group \ +- && chmod --silent --reference=/etc/passwd /etc/group +- rm -f "${HOME}/group.mkgroup_l_d" +- ;; +-esac ++# case `id -ng` in ++# mkpasswd ) ++# echo "Your group is currently \"mkpasswd\". This indicates that" ++# echo "the /etc/passwd (and possibly /etc/group) files should be rebuilt." ++# echo "See the man pages for mkpasswd and mkgroup then, for example, run" ++# echo "mkpasswd -l [-d] > /etc/passwd" ++# echo "mkgroup -l [-d] > /etc/group" ++# echo "Note that the -d switch is necessary for domain users." ++# ;; ++# ++# mkgroup ) ++# echo "Your group is currently \"mkgroup\". This indicates that" ++# echo "the /etc/group (and possibly /etc/passwd) files should be rebuilt." ++# echo "See the man pages for mkpasswd and mkgroup then, for example, run" ++# echo "mkpasswd -l [-d] > /etc/passwd" ++# echo "mkgroup -l [-d] > /etc/group" ++# echo "Note that the -d switch is necessary for domain users." ++# ;; ++# ++# mkgroup_l_d ) ++# echo "Your group name is currently \"mkgroup_l_d\". This indicates that not" ++# echo "all domain users and groups are listed in the /etc/passwd and" ++# echo "/etc/group files." ++# echo "See the man pages for mkpasswd and mkgroup then, for example, run" ++# echo "mkpasswd -l -d > /etc/passwd" ++# echo "mkgroup -l -d > /etc/group" ++# echo ++# echo "This message is only displayed once (unless you recreate /etc/group)" ++# echo "and can be safely ignored." ++# ++# # only display the above once ++# cp -f /etc/group "${HOME}/group.mkgroup_l_d" \ ++# && ( [ -w /etc/group ] || chmod --silent a+w /etc/group ; )\ ++# && sed -e 's/^mkgroup_l_d/mkgroup-l-d/' "${HOME}/group.mkgroup_l_d" > /etc/group \ ++# && chmod --silent --reference=/etc/passwd /etc/group ++# rm -f "${HOME}/group.mkgroup_l_d" ++# ;; ++# esac; +\ No newline at end of file