aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorWilly Tarreau <w@1wt.eu>2006-07-16 14:53:18 +0200
committerWilly Tarreau <willy@wtap.(none)>2006-07-26 10:49:02 +0200
commite5312cb6d1399100999bde420cdda1ec1740f8fc (patch)
tree517d96af08dbc087ac4a74f80805fc2f6e522596 /scripts
parent[RELEASE] flxutils-0.1.10.1 (diff)
downloadflxutils-e5312cb6d1399100999bde420cdda1ec1740f8fc.tar.xz
[RELEASE] flxutils-0.1.11v0.1.11
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/flxextract9
-rwxr-xr-xscripts/flxrescan137
-rwxr-xr-xscripts/flxsearch12
-rwxr-xr-xscripts/mkinstall587
-rwxr-xr-xscripts/pkg20
5 files changed, 749 insertions, 16 deletions
diff --git a/scripts/flxextract b/scripts/flxextract
index bfecb25..dae9650 100755
--- a/scripts/flxextract
+++ b/scripts/flxextract
@@ -26,7 +26,7 @@ function main {
fi
if [ "x$1" = "xd" ]; then
# it's a directory
- rm -f $ROOTDIR/$8 # just in case it was something else
+ rm -f $ROOTDIR/$8 >/dev/null 2>&1 # just in case it was something else
mkdir -p $ROOTDIR/$8
touch -t `date -d "Jan 1 00:00:$7 UTC 1970" +"%Y%m%d%H%M.%S" ` $ROOTDIR/$8
chown $3:$4 $ROOTDIR/$8
@@ -47,9 +47,6 @@ function main {
echo "." >&2
}
-# repertoire contenant les .lst et les .tgz servant de source
-SEARCHPATH=$PKGROOT
-SEARCHPATH=${SEARCHPATH:-.}/.
# temporary file and directory
TMP=$(date +%y%m%d)-$RANDOM
@@ -92,6 +89,10 @@ while [ $# -gt 0 ] ; do
shift
done
+# repertoire contenant les .lst et les .tgz servant de source
+SEARCHPATH=${SEARCHPATH:-${PKGROOT:+$PKGROOT/.}}
+SEARCHPATH=${SEARCHPATH:-.}
+
if [ $PRINTUSAGE -gt 0 ]; then
# affiche les lignes du case ci-dessus
echo "Usage : $0 followed by these parameters :"
diff --git a/scripts/flxrescan b/scripts/flxrescan
new file mode 100755
index 0000000..f5bd0a1
--- /dev/null
+++ b/scripts/flxrescan
@@ -0,0 +1,137 @@
+#!/bin/bash
+
+function main {
+ local file packages pack pkgsrc
+ exec 3>&0
+ # cette boucle permet de rechercher le package à utiliser pour trouver
+ # le fichier si cela est possible
+ while read file packages; do
+ echo -n \# >&2
+ if [ -z "$packages" ] ; then
+ echo "##no package## $file" >> $LOGFILE
+ echo "$file" >> $TMPDIR/OUTPUT
+ continue
+ fi
+
+ for pack in ${packages//,/ }; do
+ pkgsrc=$(find $SEARCHPATH -name ${pack}'*'.lst | head -1)
+ [ "$pkgsrc" ] && break
+ done
+
+ if [ -z "$pkgsrc" ]; then
+ echo "##no package## $file $packages" >> $LOGFILE
+ echo "$file $packages" >> $TMPDIR/OUTPUT
+ continue
+ fi
+
+ set -- $( grep "$file" $pkgsrc | awk '{ if ($8=="'$file'") print $0; }' )
+ if [ -z "$*" ]; then
+ pkgsrc=$( basename $pkgsrc .lst )
+ echo "##not found## $file $pkgsrc,${pkgsrc%-*},${pkgsrc%-*-*},${pkgsrc%%[._-][0-9]*}" >> $LOGFILE
+ echo "$file $packages" >> $TMPDIR/OUTPUT
+ continue
+ fi
+
+ pkgsrc=$( basename $pkgsrc .lst )
+ echo $file $pkgsrc,${pkgsrc%-*},${pkgsrc%-*-*},${pkgsrc%%[._-][0-9]*} >> $TMPDIR/OUTPUT
+ echo $file $pkgsrc,${pkgsrc%-*},${pkgsrc%-*-*},${pkgsrc%%[._-][0-9]*} >> $LOGFILE
+ done < $LFILES
+ echo "." >&2
+}
+
+
+# temporary file and directory
+TMP=$(date +%y%m%d)-$RANDOM
+while [ -e /tmp/pg-$TMP ] ; do TMP=$(date +%y%m%d)-$RANDOM ; done
+TMPDIR=/tmp/pg-$TMP
+PRINTUSAGE=0
+
+# traitement des parametres
+if [ $# -eq 0 ]; then
+ PRINTUSAGE=1
+fi
+
+while [ $# -gt 0 ] ; do
+ case "$1" in
+ -i) # <infile> fichierssources des autres fichiers
+ [ "$2" ] || PRINTUSAGE=1
+ INPUT=( $INPUT $2 )
+ shift;
+ ;;
+ -u) # update first source file with results
+ UPDATE=1
+ ;;
+ -o) # <outfile> fichier destination remis a jour
+ [ "$2" ] || PRINTUSAGE=1
+ OUTPUT=$2
+ shift;
+ ;;
+ -l) # <logfile> fichier de reference pour les associations fichier/package
+ [ "$2" ] || PRINTUSAGE=1
+ LOGFILE="$2"
+ shift
+ ;;
+ -p) # <pkgdir> repertoire de recherche pour les packages
+ [ "$2" ] || PRINTUSAGE=1
+ SEARCHPATH="$SEARCHPATH $2/."
+ shift
+ ;;
+ -h) # affiche l'aide sur les paramètres
+ PRINTUSAGE=1
+ shift
+ ;;
+ esac
+ shift
+done
+
+# repertoire contenant les .lst et les .tgz servant de source
+SEARCHPATH=${SEARCHPATH:-${PKGROOT:+$PKGROOT/.}}
+SEARCHPATH=${SEARCHPATH:-.}
+
+if [ $PRINTUSAGE -gt 0 ]; then
+ # affiche les lignes du case ci-dessus
+ echo "Usage : $0 followed by these parameters :"
+ grep '^[ ]\+-.) #.*' $0
+ echo
+ exit 1
+fi
+
+DATE=$(date +%Y%m%d-%H%M%S)
+
+LOGFILE=${LOGFILE:-/tmp/package-$DATE.log}
+if [ -e $LOGFILE ] ; then
+ echo "Error : log file $LOGFILE exists."
+ exit 0
+fi
+
+# fabrication des fichiers temporaires
+mkdir -p -m 700 $TMPDIR
+# fichier contenant l'ensemble des fichiers requis
+LFILES=$TMPDIR/lfiles ; touch $LFILES
+# fichier contenant la correspondance non du package source du package
+SFILES=$TMPDIR/sfiles ; touch $SFILES
+
+# fabrication d'un fichier contenant la liste de tous les fichiers recherchés
+# le fichier source peut contenir lui-même des informations de packages de provenance
+cat $INPUT > $LFILES
+sort -u $LFILES > $LFILES.new ; rm $LFILES ; mv $LFILES.new $LFILES
+
+main
+
+
+if [ -e $TMPDIR/OUTPUT ] ; then
+ if [ "$UPDATE" == 1 -a "$INPUT" ] ; then
+ set -- $INPUT
+ rm -f $1 ; mv $TMPDIR/OUTPUT $1
+ echo "Le résultat est dans $1, et les opérations sont dans $LOGFILE"
+ elif [ "$OUTPUT" ] ; then
+ mv $TMPDIR/OUTPUT $OUTPUT
+ echo "Le résultat est dans $OUTPUT, et les opérations sont dans $LOGFILE"
+ else
+ cat $TMPDIR/OUTPUT
+ fi
+else
+ echo "Aucun résultat produit. Consulter les opérations dans $LOGFILE"
+fi
+
+rm -rf $TMPDIR
diff --git a/scripts/flxsearch b/scripts/flxsearch
index 1820020..44eac13 100755
--- a/scripts/flxsearch
+++ b/scripts/flxsearch
@@ -112,7 +112,7 @@ function main {
packages=""
fi
fi
- if [ "$packages" ] ; then # des packages potenties de source ont été donnés
+ if [ "$packages" ] ; then # des packages potentiels de source ont été donnés
echo -n \# >&2
REPLY=""
elif [ $SILENT = 0 -a ${#sources[*]} = 0 ] ; then # le fichier n'a été trouvé dans aucun package
@@ -132,7 +132,7 @@ function main {
fi
if [ "$REPLY" ] ; then
pkgname=$( basename $REPLY .lst )
- matchlist=$pkgname,${pkgname%-*},${pkgname%-*-*},${pkgname%%-*}
+ matchlist=$pkgname,${pkgname%-*},${pkgname%-*-*},${pkgname%%[._-][0-9]*}
echo $file $matchlist >> $TMPDIR/OUTPUT
else
echo $file $packages >> $TMPDIR/OUTPUT
@@ -140,10 +140,6 @@ function main {
done < $LFILES
}
-# repertoire contenant les .lst et les .tgz servant de source
-SEARCHPATH=$PKGROOT
-SEARCHPATH=${SEARCHPATH:-.}
-
# temporary file and directory
TMP=$(date +%y%m%d)-$RANDOM
while [ -e /tmp/pg-$TMP ] ; do TMP=$(date +%y%m%d)-$RANDOM ; done
@@ -212,6 +208,10 @@ while [ $# -gt 0 ] ; do
shift
done
+# repertoire contenant les .lst et les .tgz servant de source
+SEARCHPATH=${SEARCHPATH:-${PKGROOT:+$PKGROOT/.}}
+SEARCHPATH=${SEARCHPATH:-.}
+
if [ $PRINTUSAGE -gt 0 ]; then
# affiche les lignes du case ci-dessus
echo "Usage : $0 followed by these parameters :"
diff --git a/scripts/mkinstall b/scripts/mkinstall
new file mode 100755
index 0000000..f1e2d1d
--- /dev/null
+++ b/scripts/mkinstall
@@ -0,0 +1,587 @@
+#!/bin/sh
+
+# This function collects some information in /proc and other places.
+# It should be called ASAP.
+
+function init {
+ #umount /mnt/cdrom >/dev/null 2>&1 # to avoid stupid recursive copying !
+ CDROMS=$(grep -i '^drive name:' /proc/sys/dev/cdrom/info |cut -f2- -d:)
+}
+
+# user interface functions
+function ask {
+ echo -n "$1 [$2] : "; read
+ if [ "$REPLY" = "" ]; then REPLY=$2; fi
+}
+
+function yesno {
+ echo -n "$1 [$2] : "; read ; REPLY=`echo $REPLY | cut -c1`
+ if [ "$REPLY" = "" ]; then REPLY=$2; fi
+ if [ "$REPLY" = o -o "$REPLY" = y -o "$REPLY" = Y ]; then
+ REPLY="y"
+ fi
+}
+
+#
+function check_directories {
+ if [ ! -d $ROOTDIR/etc/. ] ; then
+ if [ -d $ROOTDIR/boot/etc/. ] ; then
+ ln -s boot/etc $ROOTDIR/etc
+ else
+ echo "Can't find 'etc' directory neither in '/' nor in '/boot'"
+ return 1
+ fi
+ fi
+ if [ ! -d $ROOTDIR/var/. ] ; then
+ mkdir $ROOTDIR/var ; fi
+ if [ ! -d $ROOTDIR/var/tmp ] ; then
+ mkdir $ROOTDIR/var/tmp ; chmod 1777 $ROOTDIR/var/tmp ; fi
+ if [ ! -d $ROOTDIR/var/run ] ; then
+ mkdir $ROOTDIR/var/run ; fi
+ if [ ! -d $ROOTDIR/var/spool ] ; then
+ mkdir $ROOTDIR/var/spool ; fi
+ if [ ! -d $ROOTDIR/var/log ] ; then
+ mkdir $ROOTDIR/var/log ; fi
+ if [ ! -d $ROOTDIR/var/cache ] ; then
+ mkdir $ROOTDIR/var/cache ; fi
+ if [ ! -d $ROOTDIR/var/adm/. ] ; then
+ ln -s log $ROOTDIR/var/adm ; fi
+
+ return 0
+}
+
+# this function lists all hard drives found, but hides CDROMs
+function list_disks {
+ for i in `tail +3 /proc/partitions | awk '{print $4}' | grep '\([a-zA-Z]$\)\|\(c[0-9]*d[0-9]*$\)'`; do
+ if ! echo $CDROMS | grep -qw $i; then
+ echo $i
+ fi
+ done
+}
+
+function setup_part {
+
+ if [ -e /tmp/devmap -a -e /tmp/fstab ]; then
+ echo "Filesystems are currently configured this way :"
+ for i in `cut -f1 -d' ' /tmp/devmap`; do grep "^$i[ ]" /tmp/fstab | awk '{print $1 " => " $2 }'; done
+ echo "-- end of list --"
+ yesno "Do you want to change something (y/n) ?" "n"
+ if [ "$REPLY" != "y" ]; then return 0; fi
+ cp /tmp/fstab /tmp/fstab-
+ cp /tmp/devmap /tmp/devmap-
+ else
+ touch /tmp/fstab- /tmp/devmap-
+ fi
+
+ # clean temporary files
+ rm -rf /tmp/temp.$$ /tmp/fstab /tmp/devmap
+
+ # unmount previously mounted file-systems
+ for part in $(grep " $ROOTDIR" /proc/mounts|awk '{print $2}'|sort -r); do
+ umount $part;
+ done
+
+ echo "/proc /proc proc defaults 0 0" >> /tmp/fstab
+ echo "/dev /dev tmpfs size=0,nr_inodes=4096,,remount 0 0" >> /tmp/fstab
+ echo "/dev/pts /dev/pts devpts defaults 0 0" >> /tmp/fstab
+ echo "/dev/cdrom /mnt/cdrom iso9660 defaults,noauto,ro,user 0 0" >> /tmp/fstab
+
+ echo "/dev/$(readlink /dev/cdrom) /dev/cdrom" >> /tmp/devmap
+
+ # scan all disk
+ for disk in $(list_disks); do
+ # look for all detected partitions
+ for spart in `sfdisk -l /dev/$disk 2>/dev/null | grep "^/" |tr '*' ' '| cut -f3- -d'/' | awk '{print $1 ":" $6 }'` ; do
+ # partition name
+ part=`echo $spart|cut -f1 -d:`
+ set -- `echo $spart | tr ':' ' '`
+ set -- $* `fdisk -s /dev/$1` `sfdisk -l /dev/$disk 2>/dev/null | grep "/dev/$1 " | cut -c15-`
+
+ # hide mounted partitions
+ part=/dev/$part
+ if grep -q "$part " /proc/mounts > /dev/null ; then continue ; fi
+
+ # hide empty or extended partitions
+ if [ $2 = 0 -o $2 = 5 ] ; then continue ; fi
+
+ # partition size in Mega Bytes
+ size=$[ $3 / 1024]
+ # partition type in human readable form
+ type=$2
+ shift 8
+ htype=$*
+
+ # redo while not a good value
+ askagain=y
+ unset mountpoint
+ while [ "$askagain" = "y" ] ; do
+ askagain=n
+ echo
+ echo "Partition : $part ($htype, ${size} MB)"
+
+ # non linux partition
+ if [ $type != 82 -a $type != 83 -a $type != 8e -a $type != fd ] ; then
+ yesno "$part isn't a standard linux partition, would you like an entry in /etc/fstab (y/n)?" "n"
+ if [ "$REPLY" = "n" ] ; then continue ; fi
+ fstype=noauto
+ else
+ fstype=auto
+ fi
+
+ # getting mount point
+ if [ $type = 82 ] ; then
+ mountpoint=swap
+ else
+ mountpoint=$(grep "^$part[ ]" /tmp/fstab- | awk '{print $2 }')
+ fi
+ ask " Choose a mount point (swap,/,/boot,/var,...) or [Enter] for none" "$mountpoint"
+ # remove useless leading and trailing slashes
+ mountpoint=$(echo $REPLY|sed 's@^\([/]*\)\(/.*\)$@\2@'|sed 's@^\(.*[^/]\)\([/]*\)$@\1@')
+ if [ -z "$mountpoint" ] ; then break ; fi
+
+ case "$mountpoint" in
+ /) echo "$part /dev/root" >> /tmp/devmap ;;
+ /boot) echo "$part /dev/boot" >> /tmp/devmap ;;
+ swap) echo "$part /dev/swap" >> /tmp/devmap ; echo "$part swap swap defaults 0 0" >> /tmp/fstab;;
+ *) echo "$part /dev/fs/$(echo ${mountpoint#/} |tr '/' '.')" >> /tmp/devmap ;;
+ esac
+
+ formatcmd=''
+ # format linux partitions
+ if [ $type = 82 -o $type = 83 -o $type = 8e -o $type = fd ] ; then
+ # tell how to format
+ echo " 0: -- DO NOT format this partition (default) --" ; ch=0
+ if [ "$mountpoint" = "swap" ] ; then
+ ch1="mkswap $part" ; echo " >1: $ch1"
+ ch2="mkswap -c $part" ; echo " 2: $ch2 (with check)"
+ elif [ "`echo $mountpoint|cut -c1`" = "/" ] ; then
+ ch1="mke2fs -b 1024 -m 1 -s 1 $part"
+ if [ "$size" -lt 64 ]; then
+ echo " >1: $ch1 (small ext2)"
+ else
+ echo " 1: $ch1 (small ext2)"
+ fi
+ ch2="mke2fs -b 4096 -s 1 $part" ; echo " 2: $ch2 (large ext2)"
+ ch3="mke2fs -b 4096 -s 1 -j $part"
+ if [ "$size" -ge 64 ]; then
+ echo " >3: $ch3 (ext3)"
+ else
+ echo " 3: $ch3 (ext3)"
+ fi
+ ch4="mkreiserfs -h r5 $part" ; echo " 4: $ch4 (reiserfs)"
+ fi
+ ask " Select a format method or enter the complete command" "$ch"
+ case $REPLY in
+ 0) formatcmd='' ;;
+ [1-9]) formatcmd=`eval echo '\$ch'$REPLY` ;;
+ *) formatcmd=$REPLY ;;
+ esac
+ fi
+ done
+
+ # execute format
+ if [ "$formatcmd" ] ; then
+ echo -n "Doing: '$formatcmd': "
+ eval "echo y | $formatcmd" > /tmp/error.$$ 2>&1
+ if [ "$?" = "0" ] ; then
+ echo "done."
+ else
+ echo "failed."
+ echo "--------------------------------------------------------"
+ echo "$formatcmd said:"
+ sed -e "s/^/>> /" /tmp/error.$$
+ echo "----------- Filesystem will not be mounted -------------"
+ mountpoint=""
+ fi
+ fi
+ if [ "`echo $mountpoint|cut -c1`" = "/" ] ; then
+ echo "$mountpoint -t $fstype $part" >> /tmp/temp.$$
+ fi
+ done
+ done
+
+ # now we will mount all the filesystems we have just created, and add them to fstab
+ sort /tmp/temp.$$ | while read ; do
+ set -- $REPLY
+ mp=$1 ; shift
+ if [ ! -d $ROOTDIR$mp ] ; then mkdir -p $ROOTDIR$mp ; echo "Creating directory $mp" ; fi
+ if [ $2 != noauto ] ; then
+ echo -n "Mounting $mp ($3): "
+ mount -n $* $ROOTDIR$mp > /dev/null 2>&1
+ if [ "$?" = "0" ] ; then echo "done." ; else
+ echo "failed."
+ echo "##failed## $3 $mp $2 defaults 1 1" >> /tmp/fstab
+ fi
+ else
+ echo "#$3 $1 auto defaults 0 0" >> /tmp/fstab
+ fi
+ done
+ mount | grep '^[ ]*/' | grep "$ROOTDIR[/ ]" | sed "s@$ROOTDIR[/]*@/@" | \
+ awk '{ printf "%s\t%s\t%s\tdefaults%s\t1 %s\n",$1,$3,$5,($3=="/" || $3=="/boot")?",ro":"",($3=="/")?"1":"2" }' >> /tmp/fstab
+ #grep '^/' /proc/swaps | awk '{ print $1 "\tswap \tswap \tdefault 0 0"}' >> /tmp/fstab
+
+ mkdir -p -m 0755 $ROOTDIR/dev $ROOTDIR/proc $ROOTDIR/etc $ROOTDIR/mnt/cdrom
+ mount -t proc proc $ROOTDIR/proc # may be needed for compressed files
+
+### sed -e "s,^#L.*cdrom\$,ln ` readlink /dev/cdrom` /dev/cdrom," < /.preinit > $ROOTDIR/.preinit
+
+ rm -f /tmp/temp.$$
+ return 0
+}
+
+function setup_keyboard {
+ sed -n '/^service keyboard/,/^ *$/p' < /etc/config.rc
+}
+
+function setup_mouse {
+ sed -n '/^service mouse/,/^ *$/p' < /etc/config.rc
+}
+
+function setup_network {
+ echo "# hostname formilux"
+ echo "# interface eth0"
+ echo "# ip address 10.101.20.4/16"
+ echo "# ip dhcp"
+ echo "# service network"
+}
+
+# (re)build config.rc, startup.rc, fstab, devmap, lilo.conf
+function setup_config {
+ local MNT="$1"
+ local MPWD=$PWD
+ local TMP=/tmp/newconf
+
+ if [ ! -w /tmp ] ; then
+ echo "Directory /tmp not writable"; exit 1
+ fi
+
+ mkdir -p $TMP >/dev/null 2>&1
+
+ if [ "$MNT" = "" ] ; then MNT="$ROOTDIR"; fi
+
+# copy startup.rc and config.rc
+ rm -f $TMP/config.rc $TMP/startup.rc
+ if [ "$UPDATE_ONLY" != "y" -o ! -e $MNT/etc/config.rc ]; then
+ echo >> $TMP/config.rc
+ echo "# service syslogd" >> $TMP/config.rc
+ echo >> $TMP/config.rc
+ setup_network >> $TMP/config.rc
+ echo >> $TMP/config.rc
+ setup_keyboard >> $TMP/config.rc
+ setup_mouse >> $TMP/config.rc
+ chmod 644 $TMP/config.rc
+ fi
+
+ if [ "$UPDATE_ONLY" != "y" -o ! -e $MNT/etc/startup.rc ]; then
+ echo "#!/bin/sh" >> $TMP/startup.rc
+ echo "echo -n \"Default configuration ... \" " >> $TMP/startup.rc
+ echo "/sbin/init.d/sysprofiles /etc/config.rc" >> $TMP/startup.rc
+ chmod 755 $TMP/startup.rc
+ fi
+
+# copy fstab
+ cp /tmp/fstab $TMP/fstab
+
+# copy devmap
+ BOOTDEV=${BOOTDEV:-`echo $ROOTDEV | sed 's/[0-9]\+$//'`}
+ ask "Choose device on which LILO will be installed " $BOOTDEV
+ BOOTDEV=$REPLY
+ grep -v '/dev/mbr$' /tmp/devmap > $TMP/devmap
+ echo "$BOOTDEV /dev/mbr" >> $TMP/devmap
+
+# build a new lilo.conf
+ cd $MNT
+
+ KERNVER=`ls boot/*/bzImage | tail -1 | cut -f2 -d/`
+ KERNLBL=`echo $KERNVER | tr -d '.-'`
+ cat > $TMP/lilo.conf <<EOF
+serial = 0,9600n8
+boot = $BOOTDEV
+default = l$KERNLBL
+EOF
+
+ for bootimg in `ls boot/*/bzImage` ; do
+ echo "image = /$bootimg" >> $TMP/lilo.conf
+ echo " label = l`echo $bootimg | cut -f2 -d/ | tr -d '.-'`" >> $TMP/lilo.conf
+ echo " append = \"root=$ROOTDEV\"" >> $TMP/lilo.conf
+ echo " read-only" >> $TMP/lilo.conf
+ done
+
+ if [ `grep "label =" $TMP/lilo.conf | wc -l` = 0 ]; then
+ echo
+ echo "WARNING!!! no kernel was found in $MNT/boot !!!"
+ echo "You must install a kernel and edit $TMP/lilo.conf or your system will never boot."
+ echo
+ sleep 1
+ fi
+
+# copy /.preinit
+ if [ -e $MNT/.preinit -a "$UPDATE_ONLY" = "y" ]; then
+ cp $MNT/.preinit $TMP/.preinit
+ else
+ cp /.preinit $TMP/.preinit
+ fi
+
+ # 1st complicated part : merge old and new fstab.
+ # Method:
+ # - mount points only in old fstab are kept as-is
+ # - mount points in both with same types only have their dev updated
+ # - mount points in both with diff types are fully updated
+ # - mount points only in new fstab are merged
+ if [ "$UPDATE_ONLY" = "y" -a -e $MNT/etc/fstab ]; then
+ rm -f $TMP/fstab
+ while read; do
+ set -- $REPLY
+ if ! grep -q "^[^ ]\+[ ]\+${2}[ ]" /tmp/fstab; then
+ # not found
+ echo "$REPLY" >> $TMP/fstab
+ elif ! grep -q "^[^ ]\+[ ]\+${2}[ ]\+${3}[ ]" /tmp/fstab; then
+ # not found with the same type
+ echo "##old##$REPLY" >> $TMP/fstab
+ grep "^[^ ]\+[ ]\+${2}[ ]" /tmp/fstab >> $TMP/fstab
+ else
+ # found with the same type. We may have to update the device
+ dev=`grep "^[^# ]\+[ ]\+${2}[ ]" /tmp/fstab|head -1|awk '{print $1}'`
+ if [ "$dev" -a "$dev" != "$1" ]; then
+ echo "##old##$REPLY" >> $TMP/fstab
+ echo "$dev $2 $3 $4 $5 $6" >> $TMP/fstab # keep options
+ else
+ echo "$REPLY" >> $TMP/fstab # was commented or the same
+ fi
+ fi
+ done < $MNT/etc/fstab
+
+ # add new entries
+ while read; do
+ set -- $REPLY
+ if ! grep -q "^[^ ]\+[ ]\+${2}[ ]" $TMP/fstab; then
+ echo "$REPLY" >> $TMP/fstab
+ fi
+ done < /tmp/fstab
+ fi
+
+ # try to update lilo.conf
+
+ if [ -e $MNT/etc/lilo.conf -a "$UPDATE_ONLY" = "y" ]; then
+ rm -f $TMP/lilo.conf
+ if grep -q "^image.*$KERNVER" $MNT/etc/lilo.conf; then
+ # the latest kernel is referenced. We can use this conf.
+ (echo "boot = $BOOTDEV" ; grep -v "^boot[ ]*=[ ]*$BOOTDEV" $MNT/etc/lilo.conf | sed 's/^\(boot[ ]*=\)/##old##\1/') > $TMP/lilo.conf
+ else
+ # the latest kernel is missing from lilo.conf.
+ (echo "boot = $BOOTDEV" ; grep -v "^boot[ ]*=[ ]*$BOOTDEV" $MNT/etc/lilo.conf | sed 's/^\(boot[ ]*=\)/##old##\1/') | sed -e 's:^\(image.*=[^/]*/boot/\)\([^/]*\)\(/.*\)$:\1'$KERNVER'\3:' > $TMP/lilo.conf
+ fi
+ fi
+
+ # now, we may have to update .preinit to create aliased entries.
+ # we remove all references to devices that have been updated
+
+ grep -v "^[#]*\(ln\|L\).*[ ]\+\($(echo `cut -f2 -d' ' $TMP/devmap`|sed 's@ @\\|@g')\)" $TMP/.preinit > $TMP/.preinit-
+ grep -v ' /dev/fs/' $TMP/devmap | sed 's@^/dev/@ln @' >> $TMP/.preinit-
+ if grep -q ' /dev/fs' $TMP/devmap; then
+ if ! grep -q "^\(md\|M\)[ ]\+/dev/fs" $TMP/.preinit-; then
+ echo "md /dev/fs 755" >> $TMP/.preinit-
+ fi
+ grep ' /dev/fs/' $TMP/devmap | sed 's@^/dev@ln ..@' >> $TMP/.preinit-
+ fi
+ mv $TMP/.preinit- $TMP/.preinit ; chmod 711 $TMP/.preinit
+
+ rm -f $TMP/passwd
+ if [ "$UPDATE_ONLY" != "y" -o ! -e $MNT/etc/passwd ]; then
+ sed -e 's@/home/admin@/root@' < /etc/passwd |grep -v '^\(squid:\|pdnsd:\|flx:\|install:\)' > $TMP/passwd
+ chmod 644 $TMP/passwd
+ fi
+
+ # if /var is on its own filesystem, /tmp must be a true filesystem too.
+ if grep -q ' \(/dev/fs/var\|/dev/fs/var\.tmp\)$' $TMP/devmap; then
+ if ! grep -q "^[^ ]\+[ ]\+/tmp[ ]" $TMP/fstab; then
+ echo "/tmp /tmp tmpfs defaults 0 0" >> $TMP/fstab
+ fi
+ fi
+
+ cd $MPWD
+ return 0
+}
+
+function apply_config {
+ local MNT=$1
+ local TMP=/tmp/newconf
+
+ [ -e $TMP/.preinit ] && (rm -f $MNT/.preinit ; cp -p $TMP/.preinit $MNT)
+ [ -e $TMP/passwd ] && (rm -f $MNT/etc/passwd ; cp -p $TMP/passwd $MNT/etc)
+ [ -e $TMP/lilo.conf ] && (rm -f $MNT/etc/lilo.conf ; cp -p $TMP/lilo.conf $MNT/etc)
+ [ -e $TMP/fstab ] && (rm -f $MNT/etc/fstab ; cp -p $TMP/fstab $MNT/etc)
+ [ -e $TMP/config.rc ] && (rm -f $MNT/etc/config.rc ; cp -p $TMP/config.rc $MNT/etc)
+ [ -e $TMP/startup.rc ] && (rm -f $MNT/etc/startup.rc ; cp -p $TMP/startup.rc $MNT/etc)
+
+ # replace /tmp with a directory if needed
+ if grep -q "^[^ ]\+[ ]\+/tmp[ ]" $TMP/fstab; then
+ if [ -L $MNT/tmp ]; then rm -f $MNT/tmp && mkdir -m 1777 $MNT/tmp >/dev/null 2>&1; fi
+ fi
+ return 0
+}
+
+function do_lilo {
+ if [ -e $ROOTDIR/dev -a -e $ROOTDIR/.preinit -a -e $ROOTDIR/etc/lilo.conf ]; then
+ chroot $ROOTDIR /.preinit rebuild
+ chroot $ROOTDIR /sbin/lilo || lilo -r $ROOTDIR
+ umount $ROOTDIR/dev # remove what .preinit has installed
+ else
+ echo "LILO has NOT been run because it needs /dev, /.preinit, and /etc/lilo.conf"
+ fi
+ return 0
+}
+
+
+
+# main
+
+init
+
+if [ $0 = "mkdisk" ] ; then setup_part && exit 0 ; exit 1 ;
+elif [ $0 = "mkconfig" ] ; then setup_config $1 && exit 0 ; exit 1 ;
+elif [ $0 = "doconfig" ] ; then apply_config $1 && exit 0 ; exit 1 ;
+fi
+
+end=0
+while [ $# -ge 1 -a "$end" -ne 1 ] ; do
+ case $1 in
+ --disk) setup_part;;
+ --config) setup_config $2; shift;;
+ --apply) apply_config $2; shift;;
+ --) end=1;;
+ *) end=1;;
+ esac
+ if [ "$end" -eq 1 ] ; then break ; fi
+ shift
+done
+
+ROOTDIR=/mnt/disk
+PKGDIR=/home/pkg
+SHELLDIR=/
+
+action=1
+while [ "$action" != "q" -a "$action" != "Q" ] ; do
+
+ ROOTDEV=`mount | grep " on $ROOTDIR " | cut -f1 -d' '`
+
+ echo
+ echo "Possible actions are :"
+ echo "1: Run fdisk"
+ echo "2: Setup filesystems"
+ echo "3: Install packages"
+ echo "4: Build running config"
+ echo "5: Save built config for next reboot"
+ echo "6: Run lilo"
+ echo "7: Unmount all"
+ echo "s: Shell"
+ echo "q: Quit"
+
+ ask "Select an action (1..7/s/q)" "$action"
+
+ if [ "$REPLY" = "q" -o "$REPLY" = "Q" ] ; then break; fi
+ if [ "$REPLY" = "s" -o "$REPLY" = "S" ] ; then (cd $SHELLDIR; pwd; sh -i); REPLY=$action; continue; fi
+
+ action=`expr $REPLY + 1`
+ if [ "$action" = 8 ] ; then action=q ; fi
+ echo
+ case $REPLY in
+ 1)
+ # unmount previously mounted file-systems
+ for part in $(grep " $ROOTDIR" /proc/mounts|awk '{print $2}'|sort -r); do umount $part; done
+
+ for disk in $(list_disks); do
+ sfdisk -l /dev/$disk
+ yesno "Clear partition table for '/dev/$disk' (y/n)?" "n"
+ if [ "$REPLY" = "y" ] ; then
+ dd if=/dev/zero of=/dev/$disk bs=1024 count=1 > /dev/null 2>&1
+ (echo o ; echo w ) | fdisk /dev/$disk > /dev/null 2>&1
+ fi
+ yesno "Run 'fdisk' for '/dev/$disk' (y/n)" "y"
+ if [ "$REPLY" = "y" ] ; then
+ fdisk /dev/$disk
+ fi
+ done
+ SHELLDIR=/
+ ;;
+ 2)
+ setup_part
+ SHELLDIR=/
+ ;;
+ 3)
+ cd /
+ if [ "$ROOTDEV" != "" ] ; then
+ ask "Packages directory, or files pattern ($PKGDIR, $PKGDIR/*.lst, *.prf, *.tgz)"$'\n'" " $PKGDIR ; PKGDIR="$REPLY"
+ if [ -d "$PKGDIR" ]; then
+ list=`cd $PKGDIR && ls *.prf *.lst *.tgz 2>/dev/null`
+ else
+ list=`basename "$PKGDIR"`
+ PKGDIR=`dirname "$PKGDIR"`
+ list=$(cd $PKGDIR && echo $list)
+ fi
+ echo "Package list :"; (cd $PKGDIR && ls $list); echo
+ for pack in $list ; do
+ ask "Install package '$pack' (y/n/./<other dest>) ?" "y"
+ INSTDIR=/
+ if [ "`echo $REPLY | cut -c1`" = "/" ] ; then INSTDIR=$REPLY ; fi
+ if [ "$REPLY" = "." ]; then break; fi
+ if [ "$REPLY" != "n" -a "$REPLY" != "N" ] ; then
+ case "$pack" in
+ *lst) cat $PKGDIR/$pack | xargs cp --target-directory=$ROOTDIR$INSTDIR -p --parents -d -R -x ;;
+ *tgz) mkdir -p -m 0755 $ROOTDIR$INSTDIR && tar zpxf $PKGDIR/$pack -C $ROOTDIR$INSTDIR ;;
+ *prf) flxextract -R $ROOTDIR$INSTDIR -i $PKGDIR/$pack ;;
+ esac
+ fi
+ done
+ check_directories || exit 1
+ fi
+ SHELLDIR=/
+ ;;
+ 4)
+ check_directories || exit 1
+ if [ "$UPDATE_ONLY" != "n" -a "$UPDATE_ONLY" != "y" ]; then
+ echo "Existing files can be REPLACED or UPDATED."
+ yesno "Do you prefer to UPDATE existing files (y/n) ?" "y"
+ UPDATE_ONLY="$REPLY"
+ fi
+ setup_config $ROOTDIR
+ echo "done."
+ echo "New files have been written to /tmp/newconf/"
+ echo "You can check them now by starting a shell."
+ SHELLDIR=/tmp/newconf
+ (cd $SHELLDIR ; ls -lart)
+ ;;
+ 5)
+ echo "Saving config (.preinit, startup.rc, config.rc, fstab, lilo.conf, passwd)"
+ apply_config $ROOTDIR
+ echo "Saving config ... done."
+ echo "Updating dynamic files (/etc/formilux/sig.dat, /etc/ld.so.cache) ... "
+ ldconfig -r $ROOTDIR > /dev/null 2>&1
+
+ for SYSTEMMAP in `echo $ROOTDIR/boot/System.map-*`; do
+ KERNVER=${SYSTEMMAP#$ROOTDIR/boot/System.map-}
+ chroot $ROOTDIR depmod -a -F /boot/System.map-$KERNVER $KERNVER
+ done
+
+ echo "Signing the filesystem... (this may take a while)"
+ cd $ROOTDIR ; signfs -x `mount|grep -v ' type \(tmpfs\|ramfs\)'|grep "^/.* $ROOTDIR "| \
+ sed "s@^.*$ROOTDIR\([^ ]*\) .*@.\1@"` > /etc/formilux/sig.dat
+ echo "Updating dynamic files ... done."
+ SHELLDIR=/
+ ;;
+ 6)
+ do_lilo
+ SHELLDIR=/
+ ;;
+ 7)
+ cd /
+ for mp in `grep "$ROOTDIR" /proc/mounts | cut -f2 -d' ' | sort -r` ; do
+ umount -n $mp
+ done
+ SHELLDIR=/
+ ;;
+ *)
+ ;;
+ esac
+done
+
diff --git a/scripts/pkg b/scripts/pkg
index 4d564ee..c9f111c 100755
--- a/scripts/pkg
+++ b/scripts/pkg
@@ -1,6 +1,6 @@
#!/bin/bash
#
-# /usr/sbin/pkg - Formilux source package manager - version 0.2.2 - 2003-02-14
+# /usr/sbin/pkg - Formilux source package manager - version 0.2.3 - 2003-03-20
#
# Copyright (C) 2001-2003 Benoit Dolez & Willy Tarreau
# mailto: benoit@ant-computing.com,willy@ant-computing.com
@@ -281,7 +281,15 @@ function do_pack_files {
echo "done."
echo -n "Creating $PKGROOT/$packver.lst ... "
- (flx sign --no-depth --ignore-dot `cut -f1 -d' ' $FILE_LIST|sed -e 's,/$,,'` > $PKGROOT/$packver.lst) > /dev/null 2>&1
+ # we try the special case of the '.' entry which is needed to set the root permissions.
+ # this entry must be set as "." in FILE_LIST.
+ if grep -q '^.[ ]' $FILE_LIST; then
+ set -- $(grep '^.[ ]' $FILE_LIST)
+ owner=${2%%:*}
+ group=${2##*:}
+ echo "d $3 $owner $group 0 -------------------------------- 0 ."
+ fi > $PKGROOT/$packver.lst
+ (flx sign --no-depth --ignore-dot `cut -f1 -d' ' $FILE_LIST|sed -e 's,/$,,'` >> $PKGROOT/$packver.lst) > /dev/null 2>&1
echo "done."
F=$PKGROOT/$packver.$PKGSUFF
@@ -523,10 +531,10 @@ elif [ "$type" != "source_only" ] ; then
fi
case "$FLXARCH" in
- i686) arch=i686 cpu=i686 ;;
- i486) arch=i486 cpu=i486 ;;
- i386) arch=i386 cpu=i386 ;;
- *) arch=i586 cpu=i686 ;;
+ i686) arch=i686 cpu=i686 basearch=i386 ;;
+ i486) arch=i486 cpu=i486 basearch=i386 ;;
+ i386) arch=i386 cpu=i386 basearch=i386 ;;
+ *) arch=i586 cpu=i686 basearch=i386 ;;
esac
if [ -z "$FLXMAKE" ]; then