717a98bf16ca2d8b8fc4aedfb6d5e66df620081e
5 # Copyright (c) 2001-2005 by Per Liden <per@fukt.bth.se>
7 # Adapted for CRUX-ARM by Jose V Beneyto <sepen@crux.nu>
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
28 dialog
--backtitle "CRUX $VERSION Setup" --no-shadow "$@"
32 do_dialog
--aspect 50 --defaultno --yesno "Abort installation?" 0 0 && exit 1
47 do_select
--aspect 5 --yesno "Welcome!\n\nThis script will guide you through the installation of CRUX packages.\n\nBefore starting the installation make sure you have read and understood the \"CRUX Installation Guide\". If you have done that then please continue, else abort the installation and come back later.\n\nAre you really sure you want to continue?" 0 0
51 do_select
--menu "Install or upgrade?" 9 45 2 \
52 "1" "Install CRUX $VERSION" \
53 "2" "Upgrade to CRUX $VERSION" 2> $tmpfile
55 if [ "$ACTION" = "1" ]; then
59 do_select
--aspect 5 --yesno "NOTE!\n\nBefore upgrading make sure /etc/pkgadd.conf in the old installation is tuned to fit your needs, important files might otherwise be overwritten. Further, when this script has completed the upgrade you need to go though the rejected files in /var/lib/pkg/rejected/ and upgrade them manually if needed. See the pkgadd(8) man page for more information about /etc/pkgadd.conf.\n\nAre you really sure you want to continue?" 0 0
61 echo "ACTION: $ACTION" > /tmp
/action
66 do_select
--aspect 40 --inputbox "Enter directory where your CRUX root partition is mounted:" 0 0 "/mnt" 2> $tmpfile
68 if [ -d "$ROOT" ]; then
69 if [ "$ACTION" = "INSTALL" ] || [ -f "$ROOT/var/lib/pkg/db" ]; then
72 do_dialog
--aspect 50 --msgbox "Directory does not look like a CRUX root directory. Try again." 0 0
74 do_dialog
--aspect 50 --msgbox "Directory not found. Try again." 0 0
79 get_extra_collections
() {
80 for i
in $crux_dir/*; do
82 if [ "$i" != "core" ] && [ "$i" != "kernel" ]; then
83 EXTRA_COLLECTIONS
="$EXTRA_COLLECTIONS $i"
89 select_collections
() {
90 if [ "$ACTION" != "INSTALL" ]; then
93 if [ ! -d core
] || [ ! -d kernel
]; then
94 do_dialog
--aspect 50 --msgbox "Package directories (core and kernel) were not found in $crux_dir. Aborting." 0 0
97 TITLE
="Select collections to install:\n(detailed package selection will follow)"
98 do_select
--separate-output --checklist "$TITLE" 13 60 6 \
99 core
"The core packages (required)" ON \
100 $
(for col in $EXTRA_COLLECTIONS; do echo -ne "$col \"$col packages\" OFF "; done) 2> $collfile
104 if [ "$ACTION" != "INSTALL" ]; then
107 do_dialog
--aspect 50 --defaultno --yesno "Do you want the chance to select packages individually?" 0 0 && DO_DETAILED
="yes"
111 if [ ! -d core
] || [ ! -d kernel
]; then
112 do_dialog
--aspect 50 --msgbox "Package directories (core and kernel) were not found in $crux_dir. Aborting." 0 0
115 if [ "$ACTION" = "INSTALL" ]; then
116 if [ "$DO_DETAILED" = "yes" ]; then
117 for collection
in core
$EXTRA_COLLECTIONS; do
118 [ ! -d $collection ] && continue
119 presel
=`grep $collection $collfile`
120 if [ "$presel" == "$collection" ]; then
125 do_dialog
--aspect 50 --infobox "Searching for packages, please wait..." 0 0
126 TITLE
="Select $collection packages to install:"
127 PKG_LIST
=`find $collection -name '*.pkg.tar.*' | cut -d'/' -f2 | sed "s|.pkg.tar.[^ ]*|\t($collection) $checked\n|g" | sort | xargs echo ' '`
128 do_select
--separate-output --checklist "$TITLE" 19 60 12 $PKG_LIST 2>> $pkgfile
130 else # no detailed selection
131 for collection
in core
$EXTRA_COLLECTIONS; do
133 [ ! -d $collection ] && continue
134 presel
=`grep $collection $collfile`
135 if [ "$presel" == "$collection" ]; then
136 find $collection -name '*.pkg.tar.*' | cut
-d'/' -f2 | sed "s|.pkg.tar.[^ ]*|\t($collection) $checked\n|g" | sort >> $pkgfile
142 do_dialog
--aspect 50 --infobox "Searching for packages, please wait..." 0 0
143 TITLE
="Select packages to upgrade:"
144 INSTALLED_PACKAGES
=`pkginfo -r $ROOT -i | gawk '{ print $1; }'`
145 for package
in $INSTALLED_PACKAGES; do
146 CORE_LIST
="$CORE_LIST `find core \( -name \"${package}#*.pkg.tar.gz\" -o -name \"${package}#*.pkg.tar.bz2\" -o -name \"${package}#*.pkg.tar.xz\" \) -printf '%f (core) ON\n' | sed 's/.pkg.tar.[^ ]*/ /g' | sort | xargs echo ' '`"
147 OPT_LIST
="$OPT_LIST `find opt \( -name \"${package}#*.pkg.tar.gz\" -o -name \"${package}#*.pkg.tar.bz2\" -o -name \"${package}#*.pkg.tar.xz\" \) -printf '%f (opt) ON\n' | sed 's/.pkg.tar.[^ ]*/ /g' | sort | xargs echo ' '`"
148 XORG_LIST
="$XORG_LIST `find xorg \( -name \"${package}#*.pkg.tar.gz\" -o -name \"${package}#*.pkg.tar.bz2\" -o -name \"${package}#*.pkg.tar.xz\" \) -printf '%f (xorg) ON\n' | sed 's/.pkg.tar.[^ ]*/ /g' | sort | xargs echo ' '`"
150 do_select
--separate-output --checklist "$TITLE" 19 60 12 $CORE_LIST $OPT_LIST $XORG_LIST 2> $pkgfile
154 check_dependencies
() {
155 if [ "$ACTION" != "INSTALL" ]; then
158 do_dialog
--aspect 50 --infobox "Checking dependencies, please wait..." 0 0
160 if [ -n "$MISSING_DEPS" ]; then
161 for package
in $MISSING_DEPS; do
162 _package
="`find . -name '${package}#*.pkg.tar.*' | sed 's/.pkg.tar.[^ ]*/ /g'`"
163 _collection
="`dirname $_package | cut -d'/' -f2`"
164 # every item should be in the form: "acl#2.2.51-1 (core)"
165 MISSING_LIST
="$MISSING_LIST $_package ($_collection)"
167 TITLE
="The following packages are needed by the ones you selected"
168 do_select
--separate-output --checklist "$TITLE" 19 60 12 $MISSING_LIST 2>> $pkgfile
174 toinstall
=`sed 's/\#.*//g' $pkgfile`
175 for f
in $toinstall; do
176 pdeps
=`grep "^$f\:" $depsfile|sed "s|^$f: ||g"`
181 sed 's/\#.*//g' $pkgfile|sort -u > $markedfile
182 echo $needed|tr ' ' '\n'|sort -u > $neededfile
183 MISSING_DEPS
=`comm -1 -3 $markedfile $neededfile`
187 if [ "$ACTION" = "INSTALL" ]; then
189 do_select
--aspect 25 --yesno "Selected packages will now be installed. Are you sure you want to continue?" 0 0
192 do_select
--aspect 25 --yesno "Selected packages will now be upgraded. Are you sure you want to continue?" 0 0
198 expr $COUNT '*' 100 / $TOTAL
205 if [ ! -d $ROOT/var
/lib
/pkg
]; then
206 mkdir
-p $ROOT/var
/lib
/pkg
207 touch $ROOT/var
/lib
/pkg
/db
210 if [ -d $ROOT/var
/lib
/pkg
/rejected
]; then
211 rm -rf $ROOT/var
/lib
/pkg
/rejected
214 if [ "$ACTION" = "INSTALL" ]; then
217 # We use -f here since we want to avoid pkgadd conflicts.
218 # Unwanted/Unexpected conflicts could arise if files are
219 # moved from one package to another, or if the user added
220 # the files himself. Instead of failing the whole upgrade
221 # we force the upgrade. This should be fairly safe and it
222 # will probably help to avoid some "semi-bogus" errors from
223 # pkgadd. The rules in /etc/pkgadd.conf will still be used.
229 echo "Log ($logfile)" > $logfile
230 echo "----------------------------------------------------------" >> $logfile
233 KERNEL
=.
/kernel
/linux-
*.
tar.bz2
234 KERNEL_VERSION
=`basename $KERNEL .tar.bz2 | sed "s/linux-//"`
235 TOTAL
=`cat $pkgfile | wc -l`
239 for FILE
in `cat $pkgfile | awk '{print $1}'`; do
240 progressbar
"Installing $FILE..."
241 echo -n "Installing $FILE....." >> $logfile
242 PKG_FILE
=`find . \( -name "$FILE.pkg.tar.gz" -o -name "$FILE.pkg.tar.bz2" -o -name "$FILE.pkg.tar.xz" \)`
243 if [ -f $PKG_FILE ]; then
244 pkgadd
-r $ROOT $PKGARGS $PKG_FILE > $tmpfile 2>&1
246 echo "OK" >> $logfile
249 echo "ERROR" >> $logfile
251 cat $tmpfile >> $logfile
258 if [ ! -d $ROOT/usr
/src
/linux-
$KERNEL_VERSION ]; then
259 progressbar
"Installing `basename $KERNEL .tar.bz2`..."
260 echo -n "Installing `basename $KERNEL .tar.bz2`....." >> $logfile
263 tar -C $ROOT/usr
/src
-xjf $KERNEL
264 cp -f .
/kernel
/linux-
$KERNEL_VERSION.config
$ROOT/usr
/src
/linux-
$KERNEL_VERSION/.config
267 echo "OK" >> $logfile
270 echo "ERROR" >> $logfile
272 cat $tmpfile >> $logfile
276 echo "Directory $ROOT/usr/src/linux-$KERNEL_VERSION already exists." >> $logfile
277 echo "Assuming linux-$KERNEL_VERSION is already installed." >> $logfile
281 echo "----------------------------------------------------------" >> $logfile
282 echo "$ERRORS error(s) found" >> $logfile
284 cat $logfile > $tmpfile
287 if [ "$ERRORS" = "0" ]; then
288 echo "$ACTION COMPLETED SUCCESSFULLY!" >> $logfile
290 echo "$ACTION FAILED!" >> $logfile
294 cat $tmpfile >> $logfile
296 ) | do_dialog
--title " Please wait " --gauge "" 8 60 0
299 do_dialog
--exit-label "OK" --textbox $logfile 19 68
306 get_extra_collections
312 if [ "$ACTION" = "UPGRADE" ] && [ -f /usr
/bin
/setup-helper
]
314 (/usr
/bin
/setup-helper
$ROOT &> $helperlogfile) | do_dialog \
315 --title " Please wait [2.7 -> 2.8 check]" --gauge "" 8 60 0
318 cat $helperlogfile 2> /dev
/null
322 collfile
=/tmp
/collections.$$
323 pkgfile
=/tmp
/packages.$$
325 helperlogfile
=/tmp
/log-helper.$$
327 neededfile
=/tmp
/needed.$$
328 markedfile
=/tmp
/marked.$$
330 # Detailed selection of packages
336 trap "rm -f $tmpfile $pkgfile $collfile $neededfile $markedfile" 0 1 2 5 15
338 if [ "$1" != "" ]; then
342 depsfile
=$crux_dir/setup.dependencies
344 if [ -d $crux_dir ]; then
347 do_dialog
--aspect 50 --msgbox "Directory $crux_dir not found. Aborting." 0 0