| OLD | NEW |
| (Empty) | |
| 1 #!/bin/bash |
| 2 # Copyright 2010, Google Inc. |
| 3 # All rights reserved. |
| 4 # |
| 5 # Redistribution and use in source and binary forms, with or without |
| 6 # modification, are permitted provided that the following conditions are |
| 7 # met: |
| 8 # |
| 9 # * Redistributions of source code must retain the above copyright |
| 10 # notice, this list of conditions and the following disclaimer. |
| 11 # * Redistributions in binary form must reproduce the above |
| 12 # copyright notice, this list of conditions and the following disclaimer |
| 13 # in the documentation and/or other materials provided with the |
| 14 # distribution. |
| 15 # * Neither the name of Google Inc. nor the names of its |
| 16 # contributors may be used to endorse or promote products derived from |
| 17 # this software without specific prior written permission. |
| 18 # |
| 19 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 20 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 21 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 22 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 23 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 24 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 25 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 26 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 |
| 31 declare NSIS=0 verboase=0 |
| 32 |
| 33 while getopts "nv" flag ; do |
| 34 case "$flag" in |
| 35 n) NSIS=1 ;; |
| 36 v) verbose=1 ;; |
| 37 ?) cat <<END |
| 38 Usage: $0 [-n] [-v] |
| 39 Flags: |
| 40 -n: run NSIS to create actual installer |
| 41 -v: be more verbose when processing data |
| 42 Place CygWin decription file (setup.ini) in current directory, run script. |
| 43 You'll get: |
| 44 1. Downloaded binary files in subdirectory "packages" |
| 45 2. Downloaded source files in subdirectory "packages.src" |
| 46 3. Unpacked files in subdirectory "packages.unpacked" |
| 47 4. Setup log files in subdirectory "setup" |
| 48 5. Ready to use file make_installer.nsi for NSIS installer |
| 49 setup.ini is here: http://mirrors.kernel.org/sourceware/cygwin/setup.ini |
| 50 It's not downloaded by script to keep it hermetic. |
| 51 |
| 52 NSIS file format is described here: http://nsis.sourceforge.net/Docs |
| 53 END |
| 54 exit 1;; |
| 55 esac |
| 56 done |
| 57 |
| 58 declare CygWin=0 |
| 59 if [[ "`uname -s`" != "Darwin" ]] ; then |
| 60 if [[ "`uname -o`" = "Cygwin" ]] ; then |
| 61 CygWin=1 |
| 62 declare need_restart=0 |
| 63 if ((BASH_VERSINFO[0]<4)) ; then |
| 64 need_restart=1 |
| 65 fi |
| 66 if ((NSIS)) && ! [ -x NSIS/makensis.exe ] && ! [ -x /bin/7z ] ; then |
| 67 need_restart=1 |
| 68 fi |
| 69 fi |
| 70 fi |
| 71 |
| 72 if ((need_restart)) ; then |
| 73 if ! [ -x "$PWD/hermetic_cygwin/bin/7z" ] && ! [ -x "$PWD/hermetic_cygwin/bin/
7z.exe" ] ; then |
| 74 wget http://build.chromium.org/mirror/nacl/cygwin_mirror/hermetic_cygwin_1_7
_5-1_0.exe -O cygwin_mini_setup.exe |
| 75 chmod a+x cygwin_mini_setup.exe |
| 76 "`cygpath $COMSPEC`" /C start /WAIT ".\\cygwin_mini_setup" /CYGPORT /S "/D=`
cygpath -w $PWD/hermetic_cygwin`" |
| 77 fi |
| 78 exec "`cygpath $COMSPEC`" /C "`cygpath -w $PWD/hermetic_cygwin/bin/bash`" "`cy
gpath -w $0`" "$@" |
| 79 fi |
| 80 |
| 81 if ((BASH_VERSINFO[0]<4)) ; then |
| 82 echo "You need Bash4 to use this script" >&2 |
| 83 exit 1 |
| 84 fi |
| 85 |
| 86 if ((NSIS)) && ((CygWin)) && ! [ -d NSIS ] ; then |
| 87 7z -oNSIS x ../../../third_party/NSIS/nsis-2.45.1-Unicode-setup.exe |
| 88 mkdir -p NSIS/Contrib/Graphics/{Checks,Header,Icons,Wizard} |
| 89 for dirname in Checks Header Icons Wizard ; do |
| 90 mv NSIS/\$_OUTDIR/$dirname/* NSIS/Contrib/Graphics/$dirname |
| 91 done |
| 92 rmdir NSIS/\$_OUTDIR/{Checks,Header,Icons,Wizard,} |
| 93 rm NSIS/\$PLUGINSDIR/* |
| 94 rmdir NSIS/\$PLUGINSDIR |
| 95 mkdir -p "MkLink/nsis" |
| 96 cp -aiv "NSIS/Examples/Plugin/nsis/*" "Mklink/nsis" |
| 97 cp -aiv "MkLink/Release Unicode/MkLink.dll" "NSIS/Plugins" |
| 98 fi |
| 99 |
| 100 declare -A description packages |
| 101 . "${0/.sh/.conf}" |
| 102 . "`dirname \"$0\"`"/make_installer.inc |
| 103 |
| 104 CYGWIN_VERSION=1.7.5-1.0 |
| 105 |
| 106 mkdir -p packages{,.src,.unpacked} setup |
| 107 |
| 108 parse_setup_ini |
| 109 fix_setup_inf_info |
| 110 rm setup/*.lst.gz |
| 111 download_package "Base" "`seq -s ' ' \"$((${#packages[@]}+3))\"`" |
| 112 download_addon_packages 2 |
| 113 if ((include_all_packages)) ; then |
| 114 download_all_packages 1 |
| 115 else |
| 116 for pkgname in "${!sectionin[@]}" ; do |
| 117 sectionin["$pkgname"]=" 1${sectionin[$pkgname]}" |
| 118 done |
| 119 for pkgname in "${!seed[@]}" ; do |
| 120 seed["$pkgname"]=" 1${seed[$pkgname]}" |
| 121 done |
| 122 fi |
| 123 fill_required_packages |
| 124 fill_filetype_info |
| 125 |
| 126 ( |
| 127 cat <<END |
| 128 RequestExecutionLevel user |
| 129 SetCompressor $compressor |
| 130 SetCompressorDictSize 128 |
| 131 Name "Hermetic CygWin" |
| 132 OutFile hermetic_cygwin_${CYGWIN_VERSION//./_}.exe |
| 133 END |
| 134 declare_nsis_variables |
| 135 cat <<END |
| 136 |
| 137 InstallDir "c:\\cygwin" |
| 138 |
| 139 !include "MUI2.nsh" |
| 140 !include "Sections.nsh" |
| 141 |
| 142 !define MUI_HEADERIMAGE |
| 143 !define MUI_WELCOMEFINISHPAGE_BITMAP "\${NSISDIR}\\Contrib\\Graphics\\Wizard\\wi
n.bmp" |
| 144 |
| 145 !define MUI_WELCOMEPAGE_TITLE "Welcome to Hermetic CygWin" |
| 146 !define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installatio
n of Hermetic CygWin $CYGWIN_VERSION.\$\\r\$\\n\$\\r\$\\nHermetic CygWin is simp
le and reliable way to install pre-defined version of CygWin.\$\\r\$\\n\$\\r\$\\
n\$_CLICK" |
| 147 |
| 148 !define MUI_COMPONENTSPAGE_SMALLDESC |
| 149 |
| 150 !insertmacro MUI_PAGE_WELCOME |
| 151 !insertmacro MUI_PAGE_COMPONENTS |
| 152 !insertmacro MUI_PAGE_DIRECTORY |
| 153 !insertmacro MUI_PAGE_INSTFILES |
| 154 |
| 155 !define MUI_FINISHPAGE_LINK "Visit the Native Client site for the news, FAQs and
support" |
| 156 !define MUI_FINISHPAGE_LINK_LOCATION "http://code.google.com/p/nativeclient-sdk/
wiki/GettingStarted" |
| 157 |
| 158 !insertmacro MUI_PAGE_FINISH |
| 159 |
| 160 !insertmacro MUI_LANGUAGE "English" |
| 161 |
| 162 Section "" sec_Preinstall |
| 163 SectionIn `seq -s ' ' $((${#packages[@]}+3))` |
| 164 Push \$R0 |
| 165 CreateDirectory "\$INSTDIR\\etc" |
| 166 CreateDirectory "\$INSTDIR\\etc\\setup" |
| 167 FileOpen \$R0 \$INSTDIR\\postinstall.sh w |
| 168 FileWrite \$R0 'export PATH=/usr/local/bin:/usr/bin:/bin\$\nexport CYGWIN="\$\
$CYGWIN nodosfilewarning"\$\n' |
| 169 FileClose \$R0 |
| 170 FileOpen \$R0 \$INSTDIR\\etc\\setup\\installed.log w |
| 171 FileWrite \$R0 "INSTALLED.DB 2\$\n" |
| 172 FileClose \$R0 |
| 173 Pop \$R0 |
| 174 SectionEnd |
| 175 END |
| 176 generate_section_list |
| 177 cat <<END |
| 178 Section "" sec_PostInstall |
| 179 SectionIn `seq -s ' ' $((${#packages[@]}+3))` |
| 180 Push \$R0 |
| 181 Push \$R1 |
| 182 FileOpen \$R0 \$INSTDIR\\postinstall.sh a |
| 183 FileSeek \$R0 0 END |
| 184 FileWrite \$R0 "/bin/sort /etc/setup/installed.log -o /etc/setup/installed.db\
$\nrm /etc/setup/installed.log\$\n" |
| 185 FileClose \$R0 |
| 186 SetOutPath \$INSTDIR |
| 187 nsExec::ExecToLog '"bin\\bash" -c ./postinstall.sh' |
| 188 Delete \$INSTDIR\\postinstall.sh |
| 189 FileOpen \$R0 \$INSTDIR\\CygWin.bat w |
| 190 StrCpy \$R1 \$INSTDIR 1 |
| 191 FileWrite \$R0 "@echo off\$\r\$\n\$\r\$\n\$R1:$\r\$\nchdir \$INSTDIR\$\r\$\nba
sh --login -i$\r\$\n" |
| 192 FileClose \$R0 |
| 193 Pop \$R1 |
| 194 Pop \$R0 |
| 195 SectionEnd |
| 196 END |
| 197 generate_init_function 2 |
| 198 generate_onselchange_function |
| 199 ) > make_hermetic_cygwin.nsi |
| 200 if ((NSIS)) ; then |
| 201 if [ -e NSIS/makensis.exe ] ; then |
| 202 NSIS/makensis.exe /V2 make_hermetic_cygwin.nsi |
| 203 else |
| 204 makensis /V2 make_hermetic_cygwin.nsi |
| 205 fi |
| 206 fi |
| OLD | NEW |