c1cba240e52c2dd8c8dd1abbe8d1e5698f10c019
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 select_collections
() {
80 if [ "$ACTION" != "INSTALL" ]; then
83 if [ ! -d core
] || [ ! -d kernel
]; then
84 do_dialog
--aspect 50 --msgbox "Package directories (core and kernel) were not found in $crux_dir. Aborting." 0 0
87 TITLE
="Select collections to install:\n(detailed package selection will follow)"
88 do_select
--separate-output --checklist "$TITLE" 13 60 6 \
89 core
"The core packages (required)" ON \
90 opt
"Optional packages" OFF \
91 xorg
"X.org packages" OFF
2> $collfile
95 if [ "$ACTION" != "INSTALL" ]; then
98 do_dialog
--aspect 50 --defaultno --yesno "Do you want the chance to select packages individually?" 0 0 && DO_DETAILED
="yes"
102 if [ ! -d core
] || [ ! -d kernel
]; then
103 do_dialog
--aspect 50 --msgbox "Package directories (core and kernel) were not found in $crux_dir. Aborting." 0 0
106 if [ "$ACTION" = "INSTALL" ]; then
107 if [ "$DO_DETAILED" = "yes" ]; then
108 for collection
in core opt xorg
; do
109 [ ! -d $collection ] && continue
110 presel
=`grep $collection $collfile`
111 if [ "$presel" == "$collection" ]; then
116 do_dialog
--aspect 50 --infobox "Searching for packages, please wait..." 0 0
117 TITLE
="Select $collection packages to install:"
118 PKG_LIST
=`find $collection -name '*.pkg.tar.*' | cut -d'/' -f2 | sed "s|.pkg.tar.[^ ]*|\t($collection) $checked\n|g" | sort | xargs echo ' '`
119 do_select
--separate-output --checklist "$TITLE" 19 60 12 $PKG_LIST 2>> $pkgfile
121 else # no detailed selection
122 for collection
in core opt xorg
; do
123 [ ! -d $collection ] && continue
124 presel
=`grep $collection $collfile`
125 if [ "$presel" == "$collection" ]; then
126 find $collection -name '*.pkg.tar.*' | cut
-d'/' -f2 | sed "s|.pkg.tar.[^ ]*|\t($collection) $checked\n|g" | sort >> $pkgfile
132 do_dialog
--aspect 50 --infobox "Searching for packages, please wait..." 0 0
133 TITLE
="Select packages to upgrade:"
134 INSTALLED_PACKAGES
=`pkginfo -r $ROOT -i | gawk '{ print $1; }'`
135 for package
in $INSTALLED_PACKAGES; do
136 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 ' '`"
137 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 ' '`"
138 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 ' '`"
140 do_select
--separate-output --checklist "$TITLE" 19 60 12 $CORE_LIST $OPT_LIST $XORG_LIST 2> $pkgfile
144 check_dependencies
() {
145 if [ "$ACTION" != "INSTALL" ]; then
148 do_dialog
--aspect 50 --infobox "Checking dependencies, please wait..." 0 0
150 if [ -n "$MISSING_DEPS" ]; then
151 for package
in $MISSING_DEPS; do
152 _package
="`find . -name '${package}#*.pkg.tar.*' | sed 's/.pkg.tar.[^ ]*/ /g'`"
153 _collection
="`dirname $_package | cut -d'/' -f2`"
154 # every item should be in the form: "acl#2.2.51-1 (core)"
155 MISSING_LIST
="$MISSING_LIST $_package ($_collection)"
157 TITLE
="The following packages are needed by the ones you selected"
158 do_select
--separate-output --checklist "$TITLE" 19 60 12 $MISSING_LIST 2>> $pkgfile
164 toinstall
=`sed 's/\#.*//g' $pkgfile`
165 for f
in $toinstall; do
166 pdeps
=`grep "^$f\:" $depsfile|sed "s|^$f: ||g"`
171 sed 's/\#.*//g' $pkgfile|sort -u > $markedfile
172 echo $needed|tr ' ' '\n'|sort -u > $neededfile
173 MISSING_DEPS
=`comm -1 -3 $markedfile $neededfile`
177 if [ "$ACTION" = "INSTALL" ]; then
179 do_select
--aspect 25 --yesno "Selected packages will now be installed. Are you sure you want to continue?" 0 0
182 do_select
--aspect 25 --yesno "Selected packages will now be upgraded. Are you sure you want to continue?" 0 0
188 expr $COUNT '*' 100 / $TOTAL
195 if [ ! -d $ROOT/var
/lib
/pkg
]; then
196 mkdir
-p $ROOT/var
/lib
/pkg
197 touch $ROOT/var
/lib
/pkg
/db
200 if [ -d $ROOT/var
/lib
/pkg
/rejected
]; then
201 rm -rf $ROOT/var
/lib
/pkg
/rejected
204 if [ "$ACTION" = "INSTALL" ]; then
207 # We use -f here since we want to avoid pkgadd conflicts.
208 # Unwanted/Unexpected conflicts could arise if files are
209 # moved from one package to another, or if the user added
210 # the files himself. Instead of failing the whole upgrade
211 # we force the upgrade. This should be fairly safe and it
212 # will probably help to avoid some "semi-bogus" errors from
213 # pkgadd. The rules in /etc/pkgadd.conf will still be used.
219 echo "Log ($logfile)" > $logfile
220 echo "----------------------------------------------------------" >> $logfile
223 KERNEL
=.
/kernel
/linux-
*.
tar.bz2
224 KERNEL_VERSION
=`basename $KERNEL .tar.bz2 | sed "s/linux-//"`
225 TOTAL
=`cat $pkgfile | wc -l`
229 for FILE
in `cat $pkgfile | awk '{print $1}'`; do
230 progressbar
"Installing $FILE..."
231 echo -n "Installing $FILE....." >> $logfile
232 PKG_FILE
=`find . \( -name "$FILE.pkg.tar.gz" -o -name "$FILE.pkg.tar.bz2" -o -name "$FILE.pkg.tar.xz" \)`
233 if [ -f $PKG_FILE ]; then
234 pkgadd
-r $ROOT $PKGARGS $PKG_FILE > $tmpfile 2>&1
236 echo "OK" >> $logfile
239 echo "ERROR" >> $logfile
241 cat $tmpfile >> $logfile
248 if [ ! -d $ROOT/usr
/src
/linux-
$KERNEL_VERSION ]; then
249 progressbar
"Installing `basename $KERNEL .tar.bz2`..."
250 echo -n "Installing `basename $KERNEL .tar.bz2`....." >> $logfile
253 tar -C $ROOT/usr
/src
-xjf $KERNEL
254 cp -f .
/kernel
/linux-
$KERNEL_VERSION.config
$ROOT/usr
/src
/linux-
$KERNEL_VERSION/.config
257 echo "OK" >> $logfile
260 echo "ERROR" >> $logfile
262 cat $tmpfile >> $logfile
266 echo "Directory $ROOT/usr/src/linux-$KERNEL_VERSION already exists." >> $logfile
267 echo "Assuming linux-$KERNEL_VERSION is already installed." >> $logfile
271 echo "----------------------------------------------------------" >> $logfile
272 echo "$ERRORS error(s) found" >> $logfile
274 cat $logfile > $tmpfile
277 if [ "$ERRORS" = "0" ]; then
278 echo "$ACTION COMPLETED SUCCESSFULLY!" >> $logfile
280 echo "$ACTION FAILED!" >> $logfile
284 cat $tmpfile >> $logfile
286 ) | do_dialog
--title " Please wait " --gauge "" 8 60 0
289 do_dialog
--exit-label "OK" --textbox $logfile 19 68
301 if [ "$ACTION" = "UPGRADE" ] && [ -f /usr
/bin
/setup-helper
]
303 (/usr
/bin
/setup-helper
$ROOT &> $helperlogfile) | do_dialog \
304 --title " Please wait [2.6 -> 2.7.1 check]" --gauge "" 8 60 0
307 cat $helperlogfile 2> /dev
/null
311 collfile
=/tmp
/collections.$$
312 pkgfile
=/tmp
/packages.$$
314 helperlogfile
=/tmp
/log-helper.$$
316 neededfile
=/tmp
/needed.$$
317 markedfile
=/tmp
/marked.$$
319 # Detailed selection of packages
323 trap "rm -f $tmpfile $pkgfile $collfile $neededfile $markedfile" 0 1 2 5 15
325 if [ "$1" != "" ]; then
329 depsfile
=$crux_dir/setup.dependencies
331 if [ -d $crux_dir ]; then
334 do_dialog
--aspect 50 --msgbox "Directory $crux_dir not found. Aborting." 0 0