aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorWilly Tarreau <willy@wtap.(none)>2006-07-26 10:46:55 +0200
committerWilly Tarreau <willy@wtap.(none)>2006-07-26 10:46:55 +0200
commitfcb250efba23ae522c4c8cb03c47dd40edcf9603 (patch)
tree3756bd1748842a3f1049d857e8412f148a8741b9 /scripts
parentInitial commit (diff)
downloadflxutils-fcb250efba23ae522c4c8cb03c47dd40edcf9603.tar.xz
[RELEASE] flxutils-0.1.4.2v0.1.4.2
Diffstat (limited to '')
-rwxr-xr-xscripts/flxadd350
-rwxr-xr-xscripts/flxfix85
-rwxr-xr-xscripts/noctrlaltdel20
-rwxr-xr-xscripts/pci-listall2
-rwxr-xr-xscripts/pcidev141
-rwxr-xr-xscripts/pkg505
-rwxr-xr-xscripts/reset3
7 files changed, 1106 insertions, 0 deletions
diff --git a/scripts/flxadd b/scripts/flxadd
new file mode 100755
index 0000000..4723957
--- /dev/null
+++ b/scripts/flxadd
@@ -0,0 +1,350 @@
+#!/bin/sh
+
+yesno () {
+ echo -n "$1 [$2] : "; read
+ if [ "$REPLY" = "" ]; then
+ REPLY=$2;
+ fi
+ if [[ ( "$REPLY" = "O" ) || ( "$REPLY" = "o" ) || \
+ ( "$REPLY" = "y" ) || ( "$REPLY" = "Y" ) ]]; then
+ REPLY="O"
+ return 0
+ fi
+ return 1
+}
+
+update_sig () {
+ file=$1
+}
+
+update_dep () {
+ file=$1
+}
+
+if [ -z "$PKGROOT" ] ; then PKGROOT=/var/install; fi
+T=/tmp/flx.inst.$$
+T1=$T/f1
+T2=$T/f2
+T3=$T/f3
+T4=$T/f4
+T5=$T/f5
+rm -rf $T ; mkdir $T ; touch $T3
+touch $T5
+
+if [ -f $PKGROOT/depend.lst ] ; then
+ . $PKGROOT/depend.lst
+fi
+
+force=0
+lookfordepend=1
+while [ $# -gt 0 ] ; do
+ case $1 in
+ -t) # install most recent
+ doitfor=time
+ ;;
+ -f) # force reinstall
+ force=1
+ ;;
+ -f*) # force n reinstall recursive level
+ force=${1#-f}
+ ;;
+ -s) # install most recent
+ doitfor=size
+ ;;
+ -nd) # no dependence
+ lookfordepend=0
+ ;;
+ -r) # change root dir
+ shift
+ ROOT=$1
+ ;;
+ -v) # view only
+ mode=view
+ ;;
+ -I) # read from input
+ cat >> $T1
+ ;;
+ *) echo $1 >> $T1 ;;
+ esac
+ shift
+done
+
+exec 3>&0
+# lire l'existant et s'en servir de base
+if [ -f $ROOT/etc/formilux/sig.dat ] ; then
+ grep -v ^d $ROOT/etc/formilux/sig.dat | awk '{ print $8 }' > $T3
+elif [ -f $ROOT/etc/formilux/depend.dat ] ; then
+ cat $ROOT/etc/formilux/depend.dat | cut -f1 -d' ' | cut -f1 -d'('> $T3
+# find . ! -type d > $T3
+fi
+# lecture des fichiers de dependance de manière infinie
+while [ -f $T1 ] ; do
+ # lecture sur la dernière liste non résolue
+while read ; do
+ if [ -z "$REPLY" -o "${REPLY// /}" = "" ] ; then continue; fi
+ if [ "${REPLY/*\$*/\$}" = '$' ] ; then
+ REPLY=`eval echo "$REPLY"`
+ for i in $REPLY ; do
+ echo $i >> $T2
+ done
+ continue
+ fi
+ set $REPLY
+ depend=${1##*\(}
+ depend=${depend%%\)}
+ if [ "$depend" = "$1" ] ; then depend="" ; fi
+ file=`echo "${1%\(*\)}" | sed -e 's/\./\\./g' -e 's/*/.*/g' -e 's/\[/\\\[/g' -e 's/^\///' `
+ # looking for existing
+ if [ "$force" -lt 0 ] && grep -q "^\(.*/\)\?$file$" $T3 ; then continue ; fi
+ # looking for already installed
+ if grep -q "^\(.*/\)\?$file$" $T5 ; then continue ; fi
+# if [ -e $ROOT/$file ] ; then
+# update_sig $file
+# update_dep $file
+# continue
+# fi
+ request=$1
+ echo -n "Looking for $request ... "
+ m="[^ ]\+ \+"
+ if [ "$depend" ] ; then
+ lfile=`find $PKGROOT/ -name "$depend.lst" | xargs grep -sH "^\($m\)\{7\}\([^ ]*/\)\?$file\( .*\)\?$" | tr -s ' ' :`
+ else
+ lfile=`find $PKGROOT/ -name "*.lst" | xargs grep -sH "^\($m\)\{7\}\([^ ]*/\)\?$file\( .*\)\?$" | tr -s ' ' :`
+ fi
+ n=1
+
+ if [ `echo $lfile | wc -w` -gt 1 ] ; then
+ if [ "$doitfor" = time ] ; then
+ n=1
+ oldtime=0
+ for i in $lfile ; do
+ set ${i//:/ }
+ Rtype=$2
+ if [ ${#Rtype} = 10 ] ; then
+ Rtime=$7
+ else
+ Rtime=$8
+ fi
+ if [ $Rtime -gt $oldtime ] ; then
+ oldtime=$Rtime
+ oldn=$n
+ fi
+ n=$[ n + 1 ]
+ done
+ n=$oldn
+ elif [ "$doitfor" = size ] ; then
+ n=1
+ oldsize=99999999
+ for i in $lfile ; do
+ set ${i//:/ }
+ Rtype=$2
+ if [ ${#Rtype} = 10 ] ; then
+ Rsize=$5
+ else
+ Rsize=$6
+ fi
+ if [ $Rsize -gt $oldsize ] ; then
+ oldsize=$Rsize
+ oldn=$n
+ fi
+ n=$[ n + 1 ]
+ done
+ n=$oldn
+ else
+ rep=n
+ all=""
+ echo
+ while [ "$rep" != O ] ; do
+ n=1
+ for i in $lfile ; do
+ if [ -n "$all" ] ; then
+ all="$all,$n"
+ else
+ all=$n
+ fi
+ set ${i//:/ }
+ Rsrc=$1
+ Rtype=$2
+ if [ ${#Rtype} = 10 ] ; then
+ Rlink=$9
+ Rtime=$7
+ Rsize=$5
+ Rfile=$8
+ else
+ Rlink=${10}
+ Rtime=$8
+ Rsize=$6
+ Rfile=$9
+ fi
+ if [ "$Rlink" ] ; then
+ echo "$n : $Rfile ($Rsize bytes,${Rtime}s,$Tlink) in $Rsrc"
+ else
+ echo "$n : $Rfile ($Rsize bytes,${Rtime}s) in $Rsrc"
+ fi
+ n=$[ n + 1 ]
+ done
+ echo -n "Which of these packages ? (separated by ',', 'a' for all) : "
+ read n <&3
+ if [ "$n" = "a" ] ; then n=$all ; fi
+ yesno "Selection [$n] is ok (y/n)? " y <&3
+ rep=$REPLY
+ done
+ echo -n " * Looking for $request ... "
+ fi
+ fi
+ if [ `echo $lfile | wc -w` -eq 0 -o "$n" = "" ] ; then
+ echo "missing."
+ echo "$file" >> $T4
+ else
+ for line in `echo $lfile | cut -f$n -d' '` ; do
+ set ${line//:/ }
+ Rsrc=$1
+ Rtype=$2
+ if [ ${#Rtype} = 10 ] ; then
+ Rfile=$8
+ Rlink=$9
+ else
+ Rfile=$9
+ Rlink=${10}
+ fi
+ grep -F "$Rfile" $1 >> $T/sig.dat
+ d=$T/`dirname $1`
+ if [ ! -d $d ] ; then mkdir -p $d ; fi
+ f1=`dirname $Rsrc`/`basename $Rsrc .lst`.dep
+ f2=`echo $Rsrc|sed 's/-[0-9].*\.lst//'`.dep
+ unset dep
+ if [ $lookfordepend = 1 ] ; then
+ if [ -f $f1 ] ; then
+ # grep "^$Rfile " $f1 | cut -f2- -d' ' | tr ' ' '\12' | tee -a $T2
+ dep="$dep `grep "^\(.*/\)\?$Rfile " $f1 | cut -f2- -d' '`"
+ fi
+ if [ -f $f2 ] ; then
+ # grep "^$file " $f2 | cut -f2- -d' ' | tr ' ' '\12' | tee -a $T2
+ dep="$dep `grep "^\(.*/\)\?$file " $f2 | cut -f2- -d' '`"
+ fi
+ if [ "$dep" ] ; then
+ dep="`echo "$dep" | tr ' ' '\012' | sort -u | tee -a $T2`"
+ fi
+ fi
+ # file=`eval echo "$file" | sed -e 's/\[/\\\[/g' `
+ pkg=`basename $Rsrc .lst`
+ echo "$Rfile" >> $T/$Rsrc # where to find file
+ file=$Rfile
+ if [ "`echo $file | cut -c1`" = '/' ] ; then
+ echo "skipping (file $file begins with '/')"
+ continue
+ #elif [ "`echo $file | cut -c1-2`" != './' ] ; then
+ # file="./$file"
+ fi
+ echo $file >> $T5 # files that are already scan
+ if [ "$Rlink" ] ; then # link dependency
+ echo
+ echo -n " - Link '$Rlink' to '$file' -> "
+ if [ "`echo $Rlink | cut -c1`" = / ] ; then
+ echo "$Rlink" >> $T2
+ echo "dependency link '$Rlink'"
+ else
+ d=`dirname $file`/$Rlink
+ d=`dirname $d`
+ d=`basename $d`
+ echo "$d/`basename $Rlink`" >> $T2
+ echo "dependency link '$d/`basename $Rlink`'"
+ fi
+ echo -n " * Looking for $request ... "
+ fi
+ done
+ echo "done."
+ echo "$file($pkg) `echo "$dep" | tr '\012' ' '`" >> $T/depend.dat
+ fi
+ done < $T1
+ force=$[ force - 1 ]
+ rm -f $T1
+ if [ -f $T2 ] ; then mv -f $T2 $T1 ; fi
+done
+
+echo "Files search done."
+# untar data defined from designed package file
+find $T -name "*.lst" | while read ; do
+ tgz=/`dirname $REPLY|cut -f4- -d/`/`basename $REPLY .lst`
+ pkg=`basename $REPLY .lst`
+ if [ "$mode" = view ] ; then
+ opt=Utv
+ else
+ opt=Uxv
+ fi
+ if [ -f $tgz.tgz ] ; then
+ (cd $ROOT/ ; tar z${opt}Uf $tgz.tgz -T $REPLY )
+ elif [ -f $tgz.tar.gz ] ; then
+ (cd $ROOT/ ; tar z${opt}Uf $tgz.tar.gz -T $REPLY )
+ elif [ -f $tgz.tar.bz2 ] ; then
+ (cd $ROOT/ tar j${opt}Uf $tgz.tar.bz2 -T $REPLY )
+ fi
+done
+
+if [ -e $T4 ] ; then
+ echo "Missing files are:"
+ cat $T4
+fi
+
+if [ ! -d $ROOT/etc/formilux ] ; then
+ mkdir -p -m 0755 $ROOT/etc/formilux
+fi
+
+function update_depend {
+ if [ -e $T/depend.dat ] ; then
+ if [ -e $ROOT/etc/formilux/depend.dat ] ; then
+ sort -u $ROOT/etc/formilux/depend.dat > $T4
+ while read ; do
+ set -- `echo "$REPLY" | sed 's/[() ]/ /'`
+ line="`grep "^$1[( )]" $T/depend.dat`"
+ if [ $? = 0 ] ; then
+ echo "$line" >> $T/newdepend.dat
+ else
+ echo "$REPLY" >> $T/newdepend.dat
+ fi
+ done < $T4
+ # sort -u $T/depend.dat $T/newdepend.dat | diff -u -0 $T4 -
+ sort -i $T/depend.dat $T/newdepend.dat > $ROOT/etc/formilux/depend.dat
+ else
+ sort $T/depend.dat > $ROOT/etc/formilux/depend.dat
+ fi
+ fi
+}
+
+function update_sig2 {
+ if [ -e $T/sig.dat ] ; then
+ if [ -e $ROOT/etc/formilux/sig.dat ] ; then
+ grep -v ^d $T/sig.dat | awk '{print $8}' | xargs signfs -f $ROOT/etc/formilux/sig.dat -c --ignore-date | \
+ grep "^\(-\|+\|>\)" | cut -c3- > $T4
+ cat $T4 > $ROOT/etc/formilux/sig.dat
+ else
+ sort +7 $T/sig.dat > $ROOT/etc/formilux/sig.dat
+ fi
+ fi
+}
+
+function update_sig {
+ if [ -e $T/sig.dat ] ; then
+ if [ -e $ROOT/etc/formilux/sig.dat ] ; then
+ sort +7 -u $ROOT/etc/formilux/sig.dat > $T4
+ while read ; do
+ set -- $REPLY
+ line="`grep " $8\([ ].\+\)\?$" $T/sig.dat`"
+ if [ $? = 0 ] ; then
+ echo "$line" >> $T/newsig.dat
+ else
+ echo "$REPLY" >> $T/newsig.dat
+ fi
+ done < $T4
+ # sort +7 -u $T/sig.dat $T/newsig.dat | diff -u -0 $T4 -
+ sort +7 -u $T/sig.dat $T/newsig.dat > $ROOT/etc/formilux/sig.dat
+ else
+ sort +7 $T/sig.dat > $ROOT/etc/formilux/sig.dat
+ fi
+ fi
+}
+
+update_sig2
+
+rm -rf $T
+
diff --git a/scripts/flxfix b/scripts/flxfix
new file mode 100755
index 0000000..ef09a90
--- /dev/null
+++ b/scripts/flxfix
@@ -0,0 +1,85 @@
+#!/bin/bash
+
+# flxfix - 2003/01/31 - Willy Tarreau <willy@ant-computing.com>
+# Generates a shell script from a difference between two trees so that the last
+# one becomes as close to the first one as possible.
+# usage:
+# flx check <reference> <tobefixed> | flxfix [ -R ] > fix.sh
+# Use -R to swap the two trees
+
+# usage : fixperms $perm $uid $gid $date $name
+function fixperms {
+ echo touch -t \"`date -d "Jan 1 00:00:$4 UTC 1970" +"%Y%m%d%H%M.%S" `\" $5
+ echo chown $2:$3 $5
+ echo chmod $1 $5
+}
+
+mustswap=0
+if [ "x$1" = "x-R" ]; then
+ mustswap=1
+fi
+
+while read chg type perm uid gid size sign date name link rest; do
+ if [ $mustswap = 1 ]; then
+ chg=`echo $chg | tr '<>+\-' '><\-+'`
+ fi
+
+ if [ "x$rest" != "x" -o "x$type" != "xl" -a "x$link" != "x" ]; then
+ echo "# Ignoring too long line : $REPLY"
+ continue
+ elif [ "x$name" = "x" -o "x$type" = "xl" -a "x$link" = "x" ]; then
+ echo "# Ignoring too short line : $REPLY"
+ continue
+ fi
+
+ if [ x$chg = x+ ]; then
+ # new entry which wasn't in <reference>, should be removed
+ if [ x$type = xd ]; then
+ # theorically, we should use rm -rf to suppress all children
+ echo rmdir $name
+ else
+ echo rm -f $name
+ fi
+ elif [ x$chg = x- ]; then
+ # missing entry, sometimes we can rebuild them
+ if [ x$type = xl ]; then
+ # we'll rebuild a symbolic link
+ echo ln -s $link $name
+ echo chown -h $uid:$gid $name
+ elif [ x$type = xd ]; then
+ # we'll rebuild a directory
+ echo mkdir -p $name
+ fixperms $perm $uid $gid $date $name
+ elif [ x$type = x- ]; then
+ if [ x$size = x0 ]; then
+ # we can also rebuild files, only if they are empty
+ fixperms $perm $uid $gid $date $name
+ else
+ echo "echo \"Cannot create missing file $name ($size bytes).\""
+ fi
+ elif [ x$type = xc -o x$type = xb -o x$type = xf ]; then
+ # we'll rebuild nodes
+ echo mknod $name ${type/f/p} ${size/,/ }
+ fixperms $perm $uid $gid $date $name
+ else
+ echo "echo \"Cannot fix $name, unsupported file type : $type\""
+ fi
+ elif [ x$chg = x\< ]; then
+ # entry has changed
+ if [ x$type = xl ]; then
+ # we'll destroy and rebuild a symbolic link
+ echo rm -f $name
+ echo ln -s $link $name
+ echo chown -h $uid:$gid $name
+ elif [ x$type = xc -o x$type = xb -o x$type = xf ]; then
+ # we'll destroy and rebuild nodes
+ echo rm -f $name
+ echo mknod $name ${type/f/p} ${size/,/ }
+ fixperms $perm $uid $gid $date $name
+ else
+ # in other cases, we only try to fix perms
+ fixperms $perm $uid $gid $date $name
+ fi
+ fi
+done
+
diff --git a/scripts/noctrlaltdel b/scripts/noctrlaltdel
new file mode 100755
index 0000000..82d31a1
--- /dev/null
+++ b/scripts/noctrlaltdel
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+basename=`basename $0`
+param=$*
+
+set a `pidof -x -o $$ -o %PPID $basename `
+shift
+
+if [ $# -ge 1 ] ; then
+ kill $*
+ exec /sbin/shutdown $param
+ exit 0
+fi
+echo "Reboot requested, ... hit a second time to confirm!" | tee /dev/console | wall
+
+( sleep 2 ; \
+echo "Time elapsed (2 seconds), reboot canceled!"| tee /dev/console | wall ) &
+
+exit 0
+
diff --git a/scripts/pci-listall b/scripts/pci-listall
new file mode 100755
index 0000000..70da3b4
--- /dev/null
+++ b/scripts/pci-listall
@@ -0,0 +1,2 @@
+#!/bin/sh
+pcidev /lib/modules/`uname -r`/modules.pcimap | grep '^##none## [^ ]\+ [^ ]\+ [^ ]\+ [^ ]\+ [^ ]\+ [^ ]\+ [^ ]\+ [^ ]\+'|sed -e 's/^[^ ]\+ [^ ]\+ [^ ]\+ [^ ]\+ [^ ]\+ [^ ]\+ [^ ]\+ [^ ]\+ //'
diff --git a/scripts/pcidev b/scripts/pcidev
new file mode 100755
index 0000000..b232b69
--- /dev/null
+++ b/scripts/pcidev
@@ -0,0 +1,141 @@
+#! /bin/sh
+#
+# The block between #B and #E will be used as help.
+#B
+# Formilux 0.1.5 - http://www.ant-computing.com/
+# PCIDEV - PCI device drivers scanner version 0.2
+# 2002/02/02 - Willy Tarreau - willy@ant-computing.com
+# May be redistributed under the terms of the GPL.
+#
+# usage :
+# pcidev [-vnm] [path to modules.pcimap]
+# example :
+# pcidev /lib/modules/`uname -r`/modules.pcimap
+#
+# This program lists all pci devices, displays their IDs
+# and the names of the driver attached to each device, when
+# available, or "##none##'. If an argument is passed, it will
+# be interpreted as the path to a modules.pcimap file. In this
+# case, the list of all possible modules for each device is
+# appended at the end of the line.
+# If the "-n" argument is given, only modules that seem not to
+# have already been loaded will be. If the "-m" argument is given,
+# those modules will be loaded through modprobe (verbosely if "-v"
+# is specified).
+#E
+MODPROBE=0
+ONLYNEW=0
+VERBOSE=0
+MAPFILE=
+PCIDEVDIR=/proc/bus/pci
+
+if [ ! -d "$PCIDEVDIR" ]; then
+ echo "No PCI support on this host. Aborting."
+ exit 1
+fi
+
+while [ $# -gt 0 ]; do
+ case $1 in
+ -v)
+ VERBOSE=1
+ ;;
+ -n)
+ ONLYNEW=1
+ ;;
+ -m)
+ MODPROBE=1
+ ONLYNEW=1
+ ;;
+ -*)
+ sed -e '/^#B/,/^#E/!d' --e 's/^#.\?//' < $0
+ exit 1
+ ;;
+ *)
+ break
+ ;;
+ esac
+ shift
+done
+
+if [ $ONLYNEW -gt 0 ]; then
+ MAPFILE=/lib/modules/`uname -r`/modules.pcimap
+fi
+
+if [ $# -gt 0 ]; then
+ MAPFILE=$*
+fi
+
+
+# let's collect a list of all PCI devices in the form bus/slot.func
+pcidev=$PCIDEVDIR/*/*
+
+if [ $ONLYNEW -eq 0 ]; then
+ echo "# module device(entry) class vid pid svid spid irq modules"
+fi
+
+for device in $pcidev; do
+ x=${device%??/??.?}
+ dev=${device#$x}
+ set -- `od -v -tx1 -An $device`
+
+ # at first it semt it was possible not to display bridges
+ # but cardbus bridges (at least) do have a driver.
+ #if [ "${12}" = "06" ]; then
+ # this is a bridge => no driver !!
+ #continue;
+ #fi
+ vid=$2$1; pid=$4$3; class=${12}${11}${10};
+ svid=${46}${45}; spid=${48}${47}
+
+ # now construct in <entry> a 16 bits entry for pci/devices from $dev
+ set -- `echo $dev|tr '/.' ' '`
+ bus=$1; slot=$[0x$2]; func=$[0x$3];
+ high=$[((($slot<<3)+$func)>>4)+1]; low=$[((($slot<<3)+$func)&15)+1]
+ set 0 1 2 3 4 5 6 7 8 9 a b c d e f
+ eval entry=${bus}\${$high}\${$low}
+
+ # look for a registered device in /proc/bus/pci/devices
+ set -- `grep "^$entry" $PCIDEVDIR/devices`
+ irq=$[0x$3]; driver=${18}
+
+ # look for modules supporting these devices
+ if [ ! -z "$MAPFILE" ]; then
+ list=""
+ while read; do
+ set -- $REPLY
+ if [ "$1" != "#" ]; then
+ res=$[($2 == 0x$vid || $2 == 0xffffffff) && \
+ ($3 == 0x$pid || $3 == 0xffffffff) && \
+ ($4 == 0x$svid || $4 == 0xffffffff) && \
+ ($5 == 0x$spid || $5 == 0xffffffff) && \
+ ((0x$class & $7) == $6) ]
+ if [ $res -gt 0 ]; then
+ list="$list$1 "
+ fi
+ fi
+ done < $MAPFILE
+ fi
+
+ if [ -z "$driver" ]; then
+ if [ $ONLYNEW -gt 0 ]; then
+ if [ "$list" ]; then
+ if [ $MODPROBE -gt 0 ]; then
+ for module in $list; do
+ if [ $VERBOSE -gt 0 ]; then
+ echo "modprobe $module"
+ fi
+ modprobe $module
+ done
+ else
+ echo $list
+ fi
+ fi
+ else
+ echo "##none## $dev($entry) $class $vid $pid $svid $spid $irq $list"
+ fi
+ else
+ if [ $ONLYNEW -eq 0 ]; then
+ echo "$driver $dev($entry) $class $vid $pid $svid $spid $irq $list"
+ fi
+ fi
+done
diff --git a/scripts/pkg b/scripts/pkg
new file mode 100755
index 0000000..fde9058
--- /dev/null
+++ b/scripts/pkg
@@ -0,0 +1,505 @@
+#!/bin/bash
+#
+# /usr/sbin/pkg - Formilux source package manager - version 0.1.13 - 2003-02-02
+#
+# Copyright (C) 2001-2003 Benoit Dolez & Willy Tarreau
+# mailto: benoit@ant-computing.com,willy@ant-computing.com
+#
+# This program is licenced under GPLv2 ( http://www.gnu.org/licenses/gpl.txt )
+
+# patch -p1 by default
+PATCH_LEVEL=1
+
+function logit {
+ echo "$*"
+ $*
+ return $?
+}
+
+function do_compile_only {
+ $FLXMAKE
+ return $?
+}
+
+function pre_prepack {
+ if [ "$UID" != "0" -a "$force" != "1" ]; then
+ echo "You must specify '--force' to install as non-root"
+ exit 1
+ fi
+ if [ -d `pwd`/.flxdisk ] ; then rm -rf `pwd`/.flxdisk ; fi
+}
+
+function post_prepack {
+ if [ -d $ROOTDIR/opt ] ; then
+ (cd $ROOTDIR/opt ; mkdir bin sbin lib )
+ (cd $ROOTDIR/opt ; find */bin -type f -perm +111 -exec ln -s ../{} bin \; -printf "ln -s ../%p $ROOTDIR/opt/bin\n" )
+ (cd $ROOTDIR/opt ; find */sbin -type f -perm +111 -exec ln -s ../{} sbin \; -printf "ln -s ../%p $ROOTDIR/opt/sbin\n" )
+ (cd $ROOTDIR/opt ; find */lib -type f -perm +111 -exec ln -s ../{} lib \; -printf "ln -s ../%p $ROOTDIR/opt/lib\n" )
+ fi
+}
+
+function do_compile {
+ do_config_only && do_compile_only
+}
+
+function do_build {
+ for i in clean compile prepack strip pack ; do
+ if declare -f pre_$i > /dev/null ; then ( pre_$i ) ; fi
+ if [ $? != 0 ] ; then break ; fi
+ if declare -f do_$i > /dev/null ; then ( do_$i ) ; fi
+ if [ $? != 0 ] ; then break ; fi
+ if declare -f post_$i > /dev/null ; then ( post_$i ) ; fi
+ if [ $? != 0 ] ; then break ; fi
+ done
+}
+
+function do_delpack {
+ if [ -d `pwd`/.flxdisk ] ; then rm -rf `pwd`/.flxdisk ; fi
+}
+
+function do_clean {
+ make distclean || make mrproper || make clean
+ ( do_delpack )
+}
+
+function do_edit {
+ echo "Editing $CFGFILE..."
+ vi $CFGFILE
+}
+
+function do_cat {
+ cat $CFGFILE
+}
+
+function do_patch {
+ find . -name '*.rej' -o -name '*~' | xargs rm -f
+
+ for i in $PATCH_LIST; do
+ patch -Np$PATCH_LEVEL < $PKGROOT/$i
+ done
+
+ if [ -z "`find . -name '*.rej'`" ]; then
+ find . -name '*~' | xargs rm -f
+ fi
+}
+
+function do_unpatch {
+ UNPATCH_LIST=""
+
+ find . -name '*.rej' -o -name '*~' | xargs rm -f
+
+ for i in $PATCH_LIST; do
+ UNPATCH_LIST="$i $UNPATCH_LIST"
+ done
+
+ for i in $UNPATCH_LIST; do
+ patch -RNp$PATCH_LEVEL < $PKGROOT/$i
+ done
+
+ if [ -z "`find . -name '*.rej'`" ]; then
+ find . -name '*~' | xargs rm -f
+ fi
+}
+
+function get_perl_depend {
+ filename=$1
+ DEP=`grep "^\(.*['{\"]\)*[ ]*\(require\|use\) \+['\"]*[a-zA-Z][a-z:/A-Z0-9-_]*[; '\"]" $filename | \
+ sed -e 's/.*\(require\|use\) \+["'\'']\?\([^'\''" };]\+\)["'\'']\?/§§\2§§/g' \
+ -e 's/§§\([^§]\+\)§§[^§]*/ \1/g' | \
+ sed 's@::@/@g'`
+ if [ "x$DEP" != "x" ] ; then
+ echo -n "$filename" >> $F
+ for dep in $DEP ; do
+ if [ "x${dep/*.*}" != "x" ] ; then
+ echo -n " $dep.pm" >> $F
+ else
+ echo -n " $dep" >> $F
+ fi
+ done
+ echo >> $F
+ fi
+}
+
+function do_pack {
+ # use the file list when available
+ if [ "$FILE_LIST" ]; then
+ do_pack_files
+ return $?
+ fi
+
+ if [ ! -d $ROOTDIR ] ; then export ROOTDIR=`pwd` ; fi
+ cd $ROOTDIR
+
+## ( find lib -type l -name "lib*.so*" | xargs rm -f ; \
+## find usr/lib -type l -name "lib*.so*" | xargs rm -f ; \
+## ldconfig -nr . ) > /dev/null 2>&1
+ ldconfig -nr . lib usr/lib > /dev/null 2>&1
+ find . ! -type l | xargs touch -m
+
+ F=$PKGROOT/$packver.dep
+
+ rm -rf $F
+ if [ -e $F.diff ] ; then cat $F.diff $F ; fi
+
+ echo -n "Creating $F ... "
+ touch $F
+ find . -type f -o -type l | while read ; do
+ case $REPLY in
+ *.pm|*.pl|*.ph)
+ get_perl_depend $REPLY
+ ;;
+ */man/man*/*.[0-9n])
+ if [ "${REPLY/*gz}" ] ; then
+ if [ -L $REPLY ] ; then
+ LINK=`readlink $REPLY`
+ rm $REPLY
+ ln -s $LINK.gz $REPLY.gz
+ else
+ gzip -f -9 $REPLY
+ chmod 644 $REPLY.gz
+ fi
+ fi
+ echo "$REPLY \$MAN" >> $F
+ ;;
+ */info/*.info|*/info/*.info-[0-9]*)
+ if [ "${REPLY/*gz}" ] ; then
+ gzip -f -9 $REPLY
+ chmod 644 $REPLY.gz
+ fi
+ echo "$REPLY \$INFO" >> $F
+ ;;
+ */sbin/*|*/bin/*|*/lib/*|*/libexec/*)
+ flr="`file $REPLY`"
+ case "$flr" in
+ *\ shell\ *)
+ echo "$REPLY `head -1 $REPLY| sed -e 's/^#\! *\([^ ]\+\).*/\1/'` \$SHELL">>$F
+ ;;
+ *perl\ commands*)
+ echo "$REPLY `head -1 $REPLY| sed -e 's/^#\! *\([^ ]\+\).*/\1/'` ">>$F
+ get_perl_depend $REPLY
+ ;;
+ *:\ symbolic\ link*)
+ echo "$REPLY `echo $flr | cut -f5 -d' '`" >> $F
+ ;;
+ *\ ELF\ 32-bit\ LSB*dynamically\ linked*)
+ echo "$REPLY `ldd $REPLY 2>/dev/null | grep -v 'statically linked' | awk '{print $1}' | tr '\012' ' '`" >> $F
+ ;;
+ *\ ELF\ 32-bit\ LSB*shared\ object*)
+ echo "$REPLY `ldd $REPLY 2>/dev/null | grep -v 'statically linked' | awk '{print $1}' | tr '\012' ' '`" >> $F
+ ;;
+ esac
+ ;;
+ esac
+ done
+ echo "done."
+
+ echo -n "Creating $PKGROOT/$packver.lst ... "
+ (find . ! -type d -o -empty | cut -c3-| xargs flx sign --ignore-dot --no-depth > $PKGROOT/$packver.lst) > /dev/null 2>&1
+ echo "done."
+
+ F=$PKGROOT/$packver.$PKGSUFF
+ echo -n "Creating $F ... "
+ # we want everything, and directories only if they're empty. All this without './'
+ # we shouldn't get an empty line since . should contain at least what we want to tar !
+ find . ! -type d -o -empty | cut -c3- | tar -T - -cf - | gzip -9 >$F 2>/dev/null
+ echo "done."
+
+ if [ -n "$CFGFILE" ]; then
+ F=$PKGROOT/$packver.$CFGSUFF
+ echo -n "Creating $F ... "
+ if [ "$F" != "$CFGFILE" ]; then cp -f "$CFGFILE" "$F"; echo "done." ; else echo "up to date."; fi
+ fi
+
+}
+
+function do_unpack {
+ mkdir -p $ROOTDIR
+ cd $ROOTDIR
+
+ F=$PKGROOT/$packver.$PKGSUFF
+ echo -n "Extracting $F into $ROOTDIR ... "
+ tar zUxpf $F >/dev/null 2>&1
+ echo "done."
+}
+
+# same as pack, except that it uses files in the current directory as the root
+# entries, and that no strip, link nor compression is performed.
+# Only entries listed in the file pointed to by variable FILE_LIST find their
+# way to the archive.
+function do_pack_files {
+## ( find lib -type l -name "lib*.so*" | xargs rm -f ; \
+## find usr/lib -type l -name "lib*.so*" | xargs rm -f ; \
+## ldconfig -nr . ) > /dev/null 2>&1
+ find . ! -type l | xargs touch -m
+
+ F=$PKGROOT/$packver.dep
+
+ # absurde ? : rm puis cat !
+ rm -rf $F
+ if [ -e $F.diff ] ; then cat $F.diff $F ; fi
+
+ echo -n "Creating $F ... "
+ touch $F
+ find . -type f -o -type l | while read ; do
+ case $REPLY in
+ *.pm|*.pl|*.ph)
+ get_perl_depend $REPLY
+ ;;
+ */man/man*/*.[0-9n])
+ echo "$REPLY \$MAN" >> $F
+ ;;
+ */info/*.info|*/info/*.info-[0-9]*)
+ echo "$REPLY \$INFO" >> $F
+ ;;
+ */sbin/*|*/bin/*|*/lib/*|*/libexec/*)
+ flr="`file $REPLY`"
+ case "$flr" in
+ *\ shell\ *)
+ echo "$REPLY `head -1 $REPLY| sed -e 's/^#\! *\([^ ]\+\).*/\1/'` \$SHELL">>$F
+ ;;
+ *perl\ commands*)
+ echo "$REPLY `head -1 $REPLY| sed -e 's/^#\! *\([^ ]\+\).*/\1/'` ">>$F
+ get_perl_depend $REPLY
+ ;;
+ *:\ symbolic\ link*)
+ echo "$REPLY `echo $flr | cut -f5 -d' '`" >> $F
+ ;;
+ *\ ELF\ 32-bit\ LSB*dynamically\ linked*)
+ echo "$REPLY `ldd $REPLY 2>/dev/null | grep -v 'statically linked' | awk '{print $1}' | tr '\012' ' '`" >> $F
+ ;;
+ *\ ELF\ 32-bit\ LSB*shared\ object*)
+ echo "$REPLY `ldd $REPLY 2>/dev/null | grep -v 'statically linked' | awk '{print $1}' | tr '\012' ' '`" >> $F
+ ;;
+ esac
+ ;;
+ esac
+ done
+ echo "done."
+
+ echo -n "Creating $PKGROOT/$packver.lst ... "
+ (flx sign --no-depth --ignore-dot `cut -f1 -d' ' $FILE_LIST` > $PKGROOT/$packver.lst) > /dev/null 2>&1
+ echo "done."
+
+ F=$PKGROOT/$packver.$PKGSUFF
+ echo -n "Creating $F ... "
+
+ # we want everything, and directories only if they're empty. All this without './'
+ # we shouldn't get an empty line since . should contain at least what we want to tar !
+ cut -f1 -d' ' $FILE_LIST | tar -T - -cf - | gzip -9 >$F 2>/dev/null
+ echo "done."
+
+ if [ -n "$CFGFILE" ]; then
+ F=$PKGROOT/$packver.$CFGSUFF
+ echo -n "Creating $F ... "
+ if [ "$F" != "$CFGFILE" ]; then cp -f "$CFGFILE" "$F"; echo "done." ; else echo "up to date."; fi
+ fi
+
+}
+
+function do_strip {
+ if [ ! -d $ROOTDIR ] ; then export ROOTDIR=`pwd` ; fi
+ #find $ROOTDIR/. -type f | xargs file | grep ":.*executable.*not stripped" | cut -f1 -d: | xargs strip -x --strip-unneeded -R .note -R .comment > /dev/null 2>&1
+ # allow executable and shared (.so), but not relocatable (.o), both stripped or not stripped
+ find $ROOTDIR/. -type f | xargs file | grep ":.*ELF.*\(executable\|\shared\).*stripped" | cut -f1 -d: | xargs strip -x --strip-unneeded -R .note -R .comment > /dev/null 2>&1
+}
+
+function pre_pack {
+ ( do_strip )
+}
+
+function usage {
+ echo "Usage: pkg <action>"
+ echo " action is one of :"
+ echo " help : display this help."
+ echo " info : get information on current package."
+ echo " newpkg : build a more recent .pkg script from an old one."
+ echo " cat : display last .pkg file."
+ echo " edit : edit last .pkg file."
+ echo " patch : apply a list of patches to the directory prior to compile."
+ echo " unpatch : revert a list of patches to the directory."
+ echo " compile : do_compile=do_config_only+do_compile_only in .pkg script ($CFGROOT)"
+ echo " prepack : execute do_prepack in .pkg script ($CFGROOT)"
+ echo " strip : strip binaries in temporary directory"
+ echo " pack : strip binaries, then package in $PKGROOT"
+ echo " delpack : remove temporary directory"
+ echo " clean : execute 'make clean' and remove temporary directory."
+ echo " build : execute clean compile prepack pack."
+ echo " unpack : extract package into temporary directory"
+ echo "Variables are :"
+ echo "CFGROOT : directory for .pkg, .diff, <$CFGROOT>"
+ echo "CFGFILE : force to use of a .pkg, <$CFGFILE>"
+ echo "PKGROOT : directory for .lst, .tgz and .dep, <$PKGROOT>"
+ echo "ROOTDIR : base directory for package (not source), <$ROOTDIR>"
+ echo "FLXARCH : architecture for package name, <$FLXARCH>"
+ echo "KERNDIR : base directory for package (not source), <$KERNDIR>"
+ echo "DISTVER : build version (flx.1)"
+ exit 1
+}
+
+function do_help {
+ usage
+}
+
+function pre_info {
+ echo "Information for package $pack: "
+
+ echo " Package version : $PKGVER (\$PKGVER)"
+ echo " Distrib version : $DISTVER (\$DISTVER)"
+ echo -n " Config. file : "
+ if [ -e $CFGFILE ]; then
+ echo "$CFGFILE"
+ else
+ echo "none found."
+ fi
+ echo " Package file : $PKGROOT/$packver.$PKGSUFF"
+ echo -n " Package size : "
+ if [ -e $PKGROOT/$packver.$PKGSUFF ]; then
+ echo "`du -b $PKGROOT/$packver.$PKGSUFF|cut -f1` bytes."
+ else
+ echo "does not exist yet."
+ fi
+ if [ "$PATCH_LIST" ]; then
+ echo " Patches list : $PATCH_LIST"
+ fi
+}
+
+function do_newpkg {
+ if [ -n "$CFGFILE" ]; then
+ F=$PKGROOT/$packver.$CFGSUFF
+ echo -n "Creating $F ... "
+ if [ "$F" != "$CFGFILE" ]; then cp -f "$CFGFILE" "$F"; echo "done." ; else echo "up to date."; fi
+ fi
+}
+
+# setting fixed vars
+if [ -z "$KERNDIR" ] ; then KERNDIR="/usr/src/linux" ; fi
+if [ -z "$CFGROOT" ] ; then CFGROOT="/var/install" ; fi
+if [ -z "$PKGROOT" ] ; then PKGROOT="/var/install" ; fi
+#if [ -z "$DISTVER" ] ; then DISTVER="flx.1" ; fi
+if [ "$FLXARCH" = "" ]; then FLXARCH=`uname -m` ; fi
+
+PKGSUFF="tgz"
+CFGSUFF="pkg"
+exe=`basename $0`
+
+# check for action type
+echo $exe | grep -q "^pkg"
+if [ $? = 0 -a "$exe" != "pkg" ] ; then
+ type=`echo $exe | cut -c4-`
+else
+ type=$1
+fi
+
+# look for parameters
+if [ "$type" = "$1" -a "${type##-*}" ] ; then shift ; fi
+case $1 in
+ --force ) force=1; shift ;;
+ --help ) usage ;;
+ --source) type=source_only ;;
+ -* ) shift ;;
+esac
+
+if [ "$type" = "" ] ; then
+ usage ;
+fi
+
+# execute action
+if [ "$type" = "find" ] ; then
+ for i in * ; do
+ pkgf=`grep "/$i\$" $CFGROOT/*.$CFGSUFF | cut -f1 -d: | tr '\012' ' '`
+ echo "$i: $pkgf"
+ done
+elif [ "$type" != "source_only" ] ; then
+ ARGV=$*
+
+ # look for package name from directory name
+ pack=`pwd`
+ pack=`basename $pack | sed -e 's/[-_][0-9].*$//'`
+
+ # for package
+ if [ -n "$pack" ] ; then
+
+ packver=`pwd`
+ packver=`basename $packver`
+
+ if [ -z "$DISTVER" ]; then
+ if echo $packver | grep -q -- "-flx\." ; then
+ DISTVER=`echo $packver|sed 's/\(.*-\)\(flx.[0-9]\+\)\(.*\)/\2/'`
+ fi
+ fi
+
+ # source configuration
+ if [ -z "$ROOTDIR" ] ; then ROOTDIR=`pwd`/.flxdisk ; fi
+ if [ -n "$CFGFILE" ]; then
+ . $CFGFILE
+ else
+ CFGFILE=`find $CFGROOT/ $PKGROOT/ -name "$pack[-_]*-${DISTVER:-*}-$FLXARCH.$CFGSUFF"|sed -e "s/\.$CFGSUFF\$//"|sort|tail -1`
+ CFGFILE=${CFGFILE:-`find $CFGROOT/ $PKGROOT/ -name "$pack[-_]*-${DISTVER:-*}-*.$CFGSUFF"|sed -e "s/\.$CFGSUFF\$//"|sort|tail -1`}
+ CFGFILE=${CFGFILE:-`find $CFGROOT/ $PKGROOT/ -name "$pack[-_]*.$CFGSUFF"|sed -e "s/\.$CFGSUFF\$//"|sort|tail -1`}
+ CFGFILE=${CFGFILE:-`find $CFGROOT/ $PKGROOT/ -name "$pack.$CFGSUFF"|sed -e "s/\.$CFGSUFF\$//"|sort|tail -1`}
+ if [ -n "$CFGFILE" ]; then
+ CFGFILE=$CFGFILE.$CFGSUFF
+ . $CFGFILE
+ fi
+ fi
+
+ if [ -z "$DISTVER" ]; then
+ if echo $CFGFILE | grep -q -- "-flx\." ; then
+ DISTVER=`echo $CFGFILE|sed 's/\(.*-\)\(flx.[0-9]\+\)\(.*\)/\2/'`
+ else
+ DISTVER='flx.1'
+ fi
+ fi
+
+ echo $packver | grep -q -- "-flx\."
+ if [ $? != 0 ] ; then
+ packver=$packver-$DISTVER
+ fi
+
+ echo $packver | grep -q -- "-$FLXARCH\$"
+ if [ $? != 0 ] ; then packver=$packver-$FLXARCH ; fi
+
+ prefix=${packver%%[._-][0-9]*}
+ suffix=${packver#$prefix[._-]}
+ PKGVER=${suffix%-flx*}
+ PKGRADIX=$prefix
+ #echo "packver=$packver suffix=$suffix PKGVER=$PKGVER"
+ if [ -z "$DISTVER" ]; then
+ DISTVER=${suffix#$PKGVER-}
+ if [ "$DISTVER" = "$PKGVER" ]; then
+ DISTVER="flx.1"
+ else
+ DISTVER=${DISTVER%-*}
+ fi
+ fi
+
+ case "$FLXARCH" in
+ i686) arch=i686 cpu=i686 ;;
+ i486) arch=i486 cpu=i486 ;;
+ i386) arch=i386 cpu=i386 ;;
+ *) arch=i586 cpu=i686 ;;
+ esac
+
+ if [ -z "$FLXMAKE" ]; then
+ FLXMAKE=make
+ fi
+
+
+ if [ -z "$PATCH_LIST" ]; then
+ PATCH_LIST=${CFGFILE%%.$CFGSUFF}.diff
+ if [ ! -e "$PATCH_LIST" ]; then
+ unset PATCH_LIST
+ fi
+ fi
+
+ export DISTVER PKGRADIX PKGVER FLXMAKE PATCH_LIST FILE_LIST
+
+ if declare -f pre_$type > /dev/null ; then ( pre_$type ) ; fi
+ if [ $? != 0 ] ; then exit ; fi
+ if declare -f do_$type > /dev/null ; then ( do_$type ) ; fi
+ if [ $? != 0 ] ; then exit ; fi
+ if declare -f post_$type > /dev/null ; then ( post_$type ) ; fi
+
+ fi
+ # done
+fi
diff --git a/scripts/reset b/scripts/reset
new file mode 100755
index 0000000..3882a4e
--- /dev/null
+++ b/scripts/reset
@@ -0,0 +1,3 @@
+#!/bin/sh
+echo -n 'c'
+exec stty sane