1 | #!/bin/sh
|
---|
2 |
|
---|
3 | RC=/usr/etc/rc.package
|
---|
4 | CDDIR=PACKAGES
|
---|
5 | CDMP=/mnt
|
---|
6 | CDPACK=${CDMP}/install/packages
|
---|
7 | CDSRC=${CDMP}/install/package-sources
|
---|
8 | SRC=/usr/src/commands
|
---|
9 | LISTFILE=/etc/packages
|
---|
10 | LISTURL=http://www.minix3.org/packages/List
|
---|
11 | TMPDIR=/usr/tmp/packages
|
---|
12 | mkdir -p $TMPDIR
|
---|
13 | URL1=http://www.minix3.org/packages
|
---|
14 | URL2=http://www.minix3.org/beta_packages
|
---|
15 | SRCURL1=http://www.minix3.org/software
|
---|
16 | SRCURL2=http://www.minix3.org/beta_software
|
---|
17 |
|
---|
18 | # can we execute bunzip2?
|
---|
19 | if bunzip2 --help 2>&1 | grep usage >/dev/null
|
---|
20 | then BUNZIP2=bunzip2
|
---|
21 | else BUNZIP2=smallbunzip2
|
---|
22 | fi
|
---|
23 |
|
---|
24 | if id | fgrep "uid=0(" >/dev/null
|
---|
25 | then :
|
---|
26 | else echo "Please run $0 as root."
|
---|
27 | exit 1
|
---|
28 | fi
|
---|
29 |
|
---|
30 | chmod 700 $TMPDIR
|
---|
31 |
|
---|
32 | if [ -f "$RC" ]
|
---|
33 | then . "$RC"
|
---|
34 | fi
|
---|
35 |
|
---|
36 | cd /
|
---|
37 |
|
---|
38 | cdpackages=""
|
---|
39 | if [ -n "$cddrive" ]
|
---|
40 | then pack=${cddrive}p2
|
---|
41 | umount $pack >/dev/null 2>&1 || true
|
---|
42 | if mount -r $pack $CDMP
|
---|
43 | then fn="$CDPACK/List"
|
---|
44 | cdpackages=$fn
|
---|
45 | if [ ! -f $cdpackages ]
|
---|
46 | then cdpackages=""
|
---|
47 | echo "No package list found on CD in $fn."
|
---|
48 | fi
|
---|
49 | else echo "CD mount failed."
|
---|
50 | fi
|
---|
51 | else echo "Don't know where the install CD is. You can set it in $RC."
|
---|
52 | fi
|
---|
53 |
|
---|
54 | # For local testing
|
---|
55 | #cdpackages=/usr/bigports/Packages/List
|
---|
56 | #CDPACK=/usr/bigports/Packages
|
---|
57 | #CDSRC=/usr/bigports/Sources
|
---|
58 |
|
---|
59 | if [ "$cdpackages" = "" ]
|
---|
60 | then echo "Skipping CD packages."
|
---|
61 | else cont=y
|
---|
62 | while [ $cont = y ]
|
---|
63 | do n="`wc -l $cdpackages | awk '{ print $1 }'`"
|
---|
64 | sourcef=$CDSRC/SizeMB
|
---|
65 | binf=$CDPACK/SizeMB
|
---|
66 | if [ -f $binf -a -f $sourcef ]
|
---|
67 | then sourcemb="`cat $sourcef`"
|
---|
68 | binmb="`cat $binf`"
|
---|
69 | sourcesize=" (`expr $binmb + $sourcemb` MB uncompressed)"
|
---|
70 | else sourcesize=""
|
---|
71 | fi
|
---|
72 | if [ -f $binf ]
|
---|
73 | then binmb="`cat $binf`"
|
---|
74 | binsize=" ($binmb MB uncompressed)"
|
---|
75 | else binsize=""
|
---|
76 | fi
|
---|
77 |
|
---|
78 | echo "There are $n CD packages."
|
---|
79 | echo "Please choose:"
|
---|
80 | echo " 1 Install all $n binary packages$binsize from CD"
|
---|
81 | echo " 2 Install all $n binary packages + sources from CD$sourcesize"
|
---|
82 | echo " 3 Display the list of packages on CD"
|
---|
83 | echo " 4 Let me select individual packages to install from CD or network."
|
---|
84 | echo " 5 Exit."
|
---|
85 | echo -n "Choice: [4] "
|
---|
86 | read in
|
---|
87 | case "$in" in
|
---|
88 | 1|2)
|
---|
89 | cd $CDPACK || exit
|
---|
90 | echo " * Installing binaries .."
|
---|
91 | for f in *.tar.bz2
|
---|
92 | do echo "Installing $f binaries .."
|
---|
93 | packit $f && echo Installed $f
|
---|
94 | done
|
---|
95 | if [ "$in" = 2 ]
|
---|
96 | then
|
---|
97 | cd $SRC || exit
|
---|
98 | echo " * Installing sources in $SRC .."
|
---|
99 | for f in $CDSRC/*.tar.bz2
|
---|
100 | do echo "$f .."
|
---|
101 | $BUNZIP2 -dc $f | tar xf -
|
---|
102 | done
|
---|
103 | fi
|
---|
104 | ;;
|
---|
105 | 3)
|
---|
106 | ( echo "Displaying list; press q to leave it, space for more."
|
---|
107 | cat "$CDPACK/List" | awk -F'|' '{ printf "%-20s %s\n", $1, $2 }'
|
---|
108 | ) | more
|
---|
109 | ;;
|
---|
110 | ""|4)
|
---|
111 | echo "Ok, showing packages to install." ; echo
|
---|
112 | cont=n
|
---|
113 | ;;
|
---|
114 | 5)
|
---|
115 | exit 0
|
---|
116 | ;;
|
---|
117 | esac
|
---|
118 | done
|
---|
119 | echo -n "Press RETURN to continue .. "
|
---|
120 | read xyzzy
|
---|
121 | fi
|
---|
122 |
|
---|
123 | TMPF=$TMPDIR/.list.$$
|
---|
124 | rm -f $TMPF
|
---|
125 | rm -f $TMPDIR/.* # Remove any remaining .postinstall script or .list*
|
---|
126 |
|
---|
127 | netpackages=""
|
---|
128 | if ( : </dev/tcp ) 2>/dev/null
|
---|
129 | then if [ -f $LISTFILE ]
|
---|
130 | then echo -n "Update package list from network? (y/N) "
|
---|
131 | read y
|
---|
132 | else echo "No package list found - retrieving initial version."
|
---|
133 | y=y
|
---|
134 | fi
|
---|
135 | if [ "$y" = y -o "$y" = Y ]
|
---|
136 | then echo "Fetching package list."
|
---|
137 | urlget $LISTURL >$TMPF && mv $TMPF $LISTFILE || echo "Update not successful."
|
---|
138 | fi
|
---|
139 | netpackages=$LISTFILE
|
---|
140 | if [ ! -f "$netpackages" -o ! `cat "$netpackages" 2>/dev/null | wc -l | awk '{ print $1 }'` -gt 1 ]
|
---|
141 | then netpackages=""
|
---|
142 | fi
|
---|
143 | else echo "No working network detected."
|
---|
144 | fi
|
---|
145 |
|
---|
146 | if [ "$netpackages" = "" ]
|
---|
147 | then echo "Skipping network packages."
|
---|
148 | if [ "$cdpackages" = "" ]
|
---|
149 | then echo "No packages found."
|
---|
150 | exit 1
|
---|
151 | fi
|
---|
152 | fi
|
---|
153 |
|
---|
154 | cont=y
|
---|
155 | while [ "$cont" = y ]
|
---|
156 | do cd $TMPDIR
|
---|
157 | echo ""
|
---|
158 | echo "Showing you a list of packages using more. Press q when"
|
---|
159 | echo "you want to leave the list."
|
---|
160 | echo -n "Press RETURN to continue.."
|
---|
161 | read xyzzy
|
---|
162 | echo "Package list:"
|
---|
163 | ( echo "No.|Source|Package|Description"
|
---|
164 | (
|
---|
165 | if [ -f "$netpackages" ]
|
---|
166 | then sed <$netpackages 's/^/net\|/'
|
---|
167 | fi
|
---|
168 | if [ -f "$cdpackages" ]
|
---|
169 | then sed <$cdpackages 's/^/cdrom\|/'
|
---|
170 | fi
|
---|
171 | ) | sort -t'|' +1 | awk '{ n++; printf "%d|%s\n", n, $0 }'
|
---|
172 | ) >$TMPF
|
---|
173 | awk -F'|' <$TMPF '{ printf "%3s %-6s %-15s %s\n", $1, $2, $3, $4 }' | more
|
---|
174 | echo -n "Package to install? [RETURN for none] "
|
---|
175 | read packno
|
---|
176 | ok=y
|
---|
177 | pat="^$packno|"
|
---|
178 | if [ "`grep $pat $TMPF | wc -l | awk '{ print $1 }'`" -ne 1 ]
|
---|
179 | then if [ "$packno" ]
|
---|
180 | then echo "Wrong package number."
|
---|
181 | fi
|
---|
182 | ok=n
|
---|
183 | fi
|
---|
184 | if [ $ok = y ]
|
---|
185 | then source="`grep $pat $TMPF | awk -F'|' '{ print $2 }'`"
|
---|
186 | packagename="`grep $pat $TMPF | awk -F'|' '{ print $3 }'`"
|
---|
187 | file=$packagename.tar.bz2
|
---|
188 | case $source in
|
---|
189 | net*) echo -n "Get source of $packagename? (y/N) "
|
---|
190 | read src
|
---|
191 | echo "Retrieving binary from primary location into $TMPDIR .."
|
---|
192 | srcurl=""
|
---|
193 | if urlget $URL1/$file >$file
|
---|
194 | then echo "Retrieved ok. Installing .."
|
---|
195 | packit $file && echo Installed ok.
|
---|
196 | srcurl=$SRCURL1/$file
|
---|
197 | else echo "Retrying from Beta binary location.."
|
---|
198 | if urlget $URL2/$file >$file
|
---|
199 | then echo "Retrieved ok. Installing .."
|
---|
200 | packit $file && echo Installed ok.
|
---|
201 | srcurl=$SRCURL2/$file
|
---|
202 | else echo "Retrieval failed."
|
---|
203 | fi
|
---|
204 | fi
|
---|
205 | if [ "$src" = y -o "$src" = Y ]
|
---|
206 | then ( cd $SRC || exit
|
---|
207 | srcfile=${packagename}-src.tar.bz2
|
---|
208 | echo "Retrieving source from $srcurl .."
|
---|
209 | urlget $srcurl >$srcfile || exit
|
---|
210 | echo "Source retrieved in $SRC/$srcfile."
|
---|
211 | $BUNZIP2 -dc $srcfile | tar xf - >/dev/null || exit
|
---|
212 | echo "Source unpacked in $SRC."
|
---|
213 | )
|
---|
214 | fi
|
---|
215 | ;;
|
---|
216 | cdrom*)
|
---|
217 | if [ -f $CDPACK/$file ]
|
---|
218 | then echo "Installing from $CDPACK/$file .."
|
---|
219 | packit $CDPACK/$file
|
---|
220 | else echo "$CDPACK/$file not found."
|
---|
221 | fi
|
---|
222 | srcfile=$CDSRC/${packagename}-src.tar.bz2
|
---|
223 | if [ -f $srcfile ]
|
---|
224 | then
|
---|
225 | echo -n "Get source of $packagename? (y/N) "
|
---|
226 | read src
|
---|
227 | if [ "$src" = y -o "$src" = Y ]
|
---|
228 | then ( cd $SRC || exit
|
---|
229 | $BUNZIP2 -dc $srcfile | tar xf - || exit
|
---|
230 | echo "Source $srcfile unpacked in $SRC."
|
---|
231 | )
|
---|
232 | fi
|
---|
233 | else echo "No source on CD for $packagename."
|
---|
234 | fi
|
---|
235 | ;;
|
---|
236 | esac
|
---|
237 | else cont=n
|
---|
238 | fi
|
---|
239 | done
|
---|
240 |
|
---|
241 | rm -f $TMPDIR/.* # Remove any remaining .postinstall script or .list*
|
---|