Update of /cvsroot/leaf/src/bering-uclibc/apps/config
In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv16879
Modified Files:
apkg buildtool.cfg buildtool.mk lrcfg
Added Files:
build-modules lrcfg.backup with_storage
Removed Files:
lrcfg.back lrcfg.back.script mount.back
Log Message:
major rewrite of config scripts and addition of build-modules, by Paul Traina
--- NEW FILE: lrcfg.backup ---
#!/bin/sh
#
# Back up the configuration or modules database
#
# Linux Router Project - GPL v2
#
# Based on work by:
# Dave Cinege, Charles Steinkuehler, Eric Wolzak
#
WTMP=on
CWRT=on
. /etc/config.cfg
usage () {
cat <<-EOF
usage:
$(basename $0): <directory> { configdb | moddb }
EOF
exit 1
}
test $# -lt 2 && usage
MNT=$1; test -d $MNT || usage
PACKAGE=$2; test $PACKAGE != "configdb" -a $PACKAGE != "moddb" && usage
if [ "$WTMP" = "on" ] ; then
DIR="/tmp"
else
DIR="$MNT"
fi
if [ "$CWRT" = "on" ] && [ "$WTMP" = "off" ] ; then
echo
echo -n "Begin copy to device? (No space check!) "
read YN
if [ ! "$YN" = "y" ] ; then
echo "Exiting..."
sleep 2
exit 1
fi
fi
echo -n "Creating $PACKAGE.lrp Please wait: "
ticker &
cd /
if [ $PACKAGE = configdb ] ; then
/usr/sbin/apkg -o $DIR > /dev/null 2>&1
fi
if [ $PACKAGE = moddb ] ; then
/usr/sbin/apkg -d $DIR > /dev/null 2>&1
fi
killall ticker >/dev/null 2>&1
echo -n \
if [ "$WTMP" = "on" ]; then
if [ "$CWRT" = "on" ]; then
echo
echo "New Package:"
ls -l /tmp/$PACKAGE.lrp
echo "Old Package:"
ls -l $MNT/$PACKAGE.lrp
df $MNT
echo
echo -n "Enough freespace? (y/N) "
read YN
if [ ! "$YN" = "y" ]; then
echo "Exiting..."
rm /tmp/$PACKAGE.lrp
sleep 2
exit 1
fi
fi
echo -n "Copying $PACKAGE.lrp Please wait: "
ticker &
if ! cp /tmp/$PACKAGE.lrp $MNT/$PACKAGE.lrp >/dev/null 2>&1; then
echo "Could not move /tmp/$PACKAGE.lrp to $MNT/$PACKAGE.lrp"
sleep 2
killall ticker >/dev/null 2>&1
exit 1
fi
killall ticker >/dev/null 2>&1
echo -n \
rm /tmp/$PACKAGE.lrp
fi
exit 0
--- lrcfg.back DELETED ---
--- lrcfg.back.script DELETED ---
--- mount.back DELETED ---
Index: lrcfg
===================================================================
RCS file: /cvsroot/leaf/src/bering-uclibc/apps/config/lrcfg,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** lrcfg 6 Aug 2006 08:05:31 -0000 1.3
--- lrcfg 11 Sep 2006 21:05:17 -0000 1.4
***************
*** 1,54 ****
#!/bin/sh
#
! # lrmenu v0.0.1 (don't trust these version numbers)
#
! # Dave Cinege - GPL2
! # Linux Router Project
#
while [ 1 ]; do
! clear
! echo
! echo " LEAF configuration menu"
! echo
! echo
! echo " 1 ) Network configuration"
! echo
! echo " 2 ) System configuration"
! echo
! echo " 3 ) Packages configuration"
! echo
! echo " s) Save config"
! echo " m) Backup modules"
! echo
! echo " h) Help"
! echo " q) quit"
! echo "
----------------------------------------------------------------------------"
! echo -n " Selection: "
- read OPT
! case $OPT in
! q | Q) echo;echo "Exiting lrcfg";echo
! break ;;
! 1 ) lrcfg.conf ' Network configuration
menu' \
! 'conf' '$LRPKG/etc.net.conf' '' 'edit
$CONF1' ;;
! 2 ) lrcfg.conf ' System configuration
menu' \
! 'conf' '$LRPKG/etc.sys.conf' '' 'edit
$CONF1' ;;
! 3 ) lrcfg.conf ' Packages configuration
menu' \
! 'pack' '$LRPKG/packages' '-f
$LRPKG/$CONF.conf' \
! 'lrcfg.conf.packs "$CONF" "$LRPKG" '
! ;;
! s | S) lrcfg.back configdb ;;
! m | M) lrcfg.back moddb ;;
! h | H) lrcfg.conf ' Packages Help Menu' \
! 'pack' '$LRPKG/packages' '-f
$LRPKG/$CONF.help' \
! 'help $CONF;pauseme' ;;
! esac
!
! done
! exit 1
--- 1,56 ----
#!/bin/sh
#
! # Linux Router Project - GPL v2
#
! # Based on work by:
! # Dave Cinege
#
+ LRPKG="/var/lib/lrpkg"
+ MNT="$LRPKG/mnt"
while [ 1 ]; do
+ clear
+ cat <<EOF
! LEAF configuration menu
+ 1 ) Network configuration
! 2 ) System configuration
! 3 ) Packages configuration
! s) Save config
! m) Backup modules
!
! c) Configuration changed since last save
! d) Configuration changed from distribution
!
! h) Help
! q) quit
! ----------------------------------------------------------------------------
! EOF
!
! echo -n " Selection: "
! read OPT
! case $OPT in
! q | Q) exit 0 ;;
! 1 ) lrcfg.conf ' Network configuration menu' \
! 'conf' '$LRPKG/etc.net.conf' '' 'edit $CONF1' ;;
! 2 ) lrcfg.conf ' System configuration menu' \
! 'conf' '$LRPKG/etc.sys.conf' '' 'edit $CONF1' ;;
! 3 ) lrcfg.conf ' Packages configuration menu' \
! 'pack' '$LRPKG/packages' '-f $LRPKG/$CONF.conf' \
! 'lrcfg.conf.packs "$CONF" "$LRPKG" ' ;;
!
! s | S) with_storage $MNT lrcfg.backup $MNT configdb ;;
! m | M) with_storage $MNT lrcfg.backup $MNT moddb ;;
! c | C) with_storage $MNT apkg -r $MNT ; pauseme ;;
! d | D) with_storage $MNT apkg -R $MNT ; pauseme ;;
!
! h | H) lrcfg.conf ' Packages Help Menu' \
! 'pack' '$LRPKG/packages' '-f $LRPKG/$CONF.help' \
! 'help $CONF; pauseme' ;;
! esac
! done
Index: buildtool.mk
===================================================================
RCS file: /cvsroot/leaf/src/bering-uclibc/apps/config/buildtool.mk,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** buildtool.mk 13 Aug 2006 20:30:22 -0000 1.4
--- buildtool.mk 11 Sep 2006 21:05:17 -0000 1.5
***************
*** 20,33 ****
cp -a help $(CONFIG_TARGET_DIR)/usr/bin
cp -a pauseme $(CONFIG_TARGET_DIR)/usr/bin
! cp -a mount.back $(CONFIG_TARGET_DIR)/usr/sbin
cp -a apkg $(CONFIG_TARGET_DIR)/usr/sbin
cp -a apkg.merge $(CONFIG_TARGET_DIR)/usr/sbin
cp -a apkg.mergefile $(CONFIG_TARGET_DIR)/usr/sbin
! cp -a lrcfg.back.script $(CONFIG_TARGET_DIR)/usr/sbin
! cp -a lrcfg.back $(CONFIG_TARGET_DIR)/usr/sbin
cp -a config.cfg $(CONFIG_TARGET_DIR)/etc
cp -a lrcfg.conf $(CONFIG_TARGET_DIR)/usr/sbin
cp -a lrcfg.conf.packs $(CONFIG_TARGET_DIR)/usr/sbin
cp -a lrcfg $(CONFIG_TARGET_DIR)/usr/sbin
cp -a $(CONFIG_TARGET_DIR)/* $(BT_STAGING_DIR)
touch $(CONFIG_DIR)/.build
--- 20,33 ----
cp -a help $(CONFIG_TARGET_DIR)/usr/bin
cp -a pauseme $(CONFIG_TARGET_DIR)/usr/bin
! cp -a with_storage $(CONFIG_TARGET_DIR)/usr/sbin
cp -a apkg $(CONFIG_TARGET_DIR)/usr/sbin
cp -a apkg.merge $(CONFIG_TARGET_DIR)/usr/sbin
cp -a apkg.mergefile $(CONFIG_TARGET_DIR)/usr/sbin
! cp -a lrcfg.backup $(CONFIG_TARGET_DIR)/usr/sbin
cp -a config.cfg $(CONFIG_TARGET_DIR)/etc
cp -a lrcfg.conf $(CONFIG_TARGET_DIR)/usr/sbin
cp -a lrcfg.conf.packs $(CONFIG_TARGET_DIR)/usr/sbin
cp -a lrcfg $(CONFIG_TARGET_DIR)/usr/sbin
+ cp -a build-modules $(CONFIG_TARGET_DIR)/usr/sbin
cp -a $(CONFIG_TARGET_DIR)/* $(BT_STAGING_DIR)
touch $(CONFIG_DIR)/.build
Index: apkg
===================================================================
RCS file: /cvsroot/leaf/src/bering-uclibc/apps/config/apkg,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** apkg 25 Aug 2006 19:30:23 -0000 1.8
--- apkg 11 Sep 2006 21:05:17 -0000 1.9
***************
*** 5,8 ****
--- 5,9 ----
# Changed for modified backup by Eric Spakman
# Upgrade code by Cedric Schieli
+ # Rundiff code and various improvements by Paul Traina
#
# Licensed under the terms of the GPL-2
***************
*** 26,32 ****
TMP=${TMP:-"/tmp"}
PKGDB=${PKGDB:-"$PKGDIR/packages"}
! #SESSIONID=$( dd if=/dev/urandom bs=10 count=3 2>/dev/null | sha1sum -b | awk
'{print $1}' )
! SESSIONID=$( dd if=/dev/urandom bs=10 count=3 2>/dev/null | sha1sum | sed -e
's/ -//' )
# ---------------------------------------------------------
--- 27,35 ----
TMP=${TMP:-"/tmp"}
PKGDB=${PKGDB:-"$PKGDIR/packages"}
! SESSIONID=$(dd if=/dev/urandom bs=10 count=3 2>/dev/null | sha1sum | sed -e
's/ -//')
+ trap "rm -rf $TMP/$SESSIONID*" EXIT
+
+ . $PKGDIR/backup
# ---------------------------------------------------------
***************
*** 40,44 ****
}
-
# ---------------------------------------------------------
# Make FN - given a filename, make it a lrp name
--- 43,46 ----
***************
*** 69,73 ****
}
-
# ---------------------------------------------------------
# list_pkgs - list installed packages
--- 71,74 ----
***************
*** 93,97 ****
}
-
# ---------------------------------------------------------
# create_sha1 - given a package, create the sha1sum of it
--- 94,97 ----
***************
*** 116,120 ****
}
-
# ---------------------------------------------------------
# install - installs a package
--- 116,119 ----
***************
*** 151,154 ****
--- 150,180 ----
}
+ # ---------------------------------------------------------
+ # figure out which files have changed from this package
+
+ package_changed_files () {
+ local tmp
+ tmp=$TMP/$SESSIONID.sha1
+
+ (
+ cd $PKGROOT
+ echo > $tmp
+
+ for pkg in $@ ; do
+ if [ -f $PKGDIR/$pkg.local ]; then
+ for a in $(find $(cat $PKGDIR/$pkg.local) -type f
2>/dev/null); do
+ ! grep -h "/\?${a}\$" $PKGDIR/*.sha1 >>$tmp
2>/dev/null && \
+ echo "0000000000000000000000000000000000000000
${a}" >>$tmp
+ done
+ fi
+ done
+
+ sha1sum -c $tmp 2>/dev/null | grep FAILED | sed -e "s/: FAILED//" | \
+ sort | uniq
+ )
+
+ rm -f $tmp
+ return 0
+ }
# ---------------------------------------------------------
***************
*** 177,205 ****
# ok, its there, installed... let's upgrade it...
(
- cd $PKGROOT
if [ -f $PKGDIR/$pkg.local ]; then
! for a in $( find $( cat $PKGDIR/$pkg.local ) -type f
2>/dev/null ); do
! ! grep "/\?${a}\$" $PKGDIR/$pkg.sha1 >>
$TMP/$SESSIONID.tmp1 2>/dev/null && \
! echo "0000000000000000000000000000000000000000 ${a}"
>>$TMP/$SESSIONID.tmp1
! done
! sha1sum -c $TMP/$SESSIONID.tmp1 2>/dev/null | grep FAILED | sed
-e 's/: FAILED//' >$TMP/$SESSIONID.tmp2
mkdir $TMP/$SESSIONID.tmpdir
! cd $TMP/$SESSIONID.tmpdir
tar -zxpf $pth $LRPKG/$pkg.local
! tar -zxvpf $pth -T $LRPKG/$pkg.local >$PKGDIR/$pkg.list
2>/dev/null
! tar -zxvpf $pth -X $LRPKG/$pkg.local -C $PKGROOT
>>$PKGDIR/$pkg.list
! find $( cat $LRPKG/$pkg.local ) -type f | xargs sha1sum >
$LRPKG/$pkg.sha1
! rm -f $(sha1sum -c $TMP/$SESSIONID.tmp1 2>/dev/null | grep OK |
sed -e 's/: OK//' )
! cp $LRPKG/$pkg.sha1 $PKGDIR/$pkg.sha1
! [ -n "$(cat $TMP/$SESSIONID.tmp2)" ] && for x in $( find $( cat
$TMP/$SESSIONID.tmp2 ) -type f 2>/dev/null ); do
! apkg.merge $PKGROOT $TMP/$SESSIONID.tmpdir $x
! done
! [ -n "$(cat $LRPKG/$pkg.local)" ] && find $( cat
$LRPKG/$pkg.local ) -type f 2>/dev/null | while read x; do
! mv $x $PKGROOT/$x
! done
! cd $PKGROOT
! rm -rf $TMP/$SESSIONID.tmp*
else
! tar -zxvpf $pth > $PKGDIR/$pkg.list
create_sha1 $pkg
fi
--- 203,240 ----
# ok, its there, installed... let's upgrade it...
(
if [ -f $PKGDIR/$pkg.local ]; then
! package_changed_files $pkg >$TMP/$SESSIONID.changed
!
mkdir $TMP/$SESSIONID.tmpdir
! cd $TMP/$SESSIONID.tmpdir
!
tar -zxpf $pth $LRPKG/$pkg.local
!
! if [ -f $LRPKG/$pkg.local ] ; then
! tar -zxpf $pth -T $LRPKG/$pkg.local
! tar -ztf $pth >$LRPKG/$pkg.list
!
! find $(cat $LRPKG/$pkg.local) -type f | \
! xargs sha1sum > $LRPKG/$pkg.sha1
!
! # remove local files that have not changed from
! # the installed version of this package
! rm -f $(sha1sum -c $PKGDIR/$pkg.sha1 2>/dev/null | \
! grep OK | sed 's/: OK$//')
!
! for file in $(cat $TMP/$SESSIONID.changed); do
! test -f $file && apkg.merge $PKGROOT . $file
! test -f $file && mv $file $PKGROOT/$file
! done
!
! tar -zxpf $pth -X $TMP/$SESSIONID.changed -C $PKGROOT
! mv $LRPKG/$pkg.list $PKGDIR
! mv $LRPKG/$pkg.sha1 $PKGDIR
! else
! tar -zxvpf $pth -C $PKGROOT >$PKGDIR/$pkg.list
! create_sha1 $pkg
! fi
else
! tar -zxvpf $pth -C $PKGROOT >$PKGDIR/$pkg.list
create_sha1 $pkg
fi
***************
*** 209,223 ****
}
-
# ---------------------------------------------------------
# create_local - create a lrp from the local files list
create_local () {
! local pkg;
! pth=$( expandpath $2 )
! pkg=$( package_part $1 )
! if [ -z $2 ]; then
echo "You must enter a dest path."; return 1;
fi
--- 244,257 ----
}
# ---------------------------------------------------------
# create_local - create a lrp from the local files list
create_local () {
! local pkg pth
! pth=$( expandpath $1 )
! pkg=$( package_part $configdb )
! if [ -z $1 ]; then
echo "You must enter a dest path."; return 1;
fi
***************
*** 235,268 ****
echo "Creating package of local files for ${pkg} ($pth)..."
! (
! cd $PKGROOT
! cat $PKGDB | while read x; do
! if [ -f $PKGDIR/$x.local ]; then
! for a in $( find $( cat $PKGDIR/$x.local ) -type f 2>/dev/null
); do
! ! grep "/\?${a}\$" $PKGDIR/$x.sha1 >> $TMP/$SESSIONID.tmp1
2>/dev/null && \
! echo "0000000000000000000000000000000000000000 ${a}"
>>$TMP/$SESSIONID.tmp1
! done
! fi
! done
! sha1sum -c $TMP/$SESSIONID.tmp1 | grep FAILED | sed -e 's/: FAILED//'
>$TMP/$SESSIONID.tmp2
! tar -c $( sort $TMP/$SESSIONID.tmp2 | uniq ) | gzip -c - > $pth
! rm $TMP/$SESSIONID*
! return 0
!
! )
}
-
# ---------------------------------------------------------
# create_mod - creates a modules db
create_mod () {
! local pkg pth xlist excl i
! if [ -z "$2" ]; then
echo "You must enter a dest path."; return 1;
fi
! pth=$( expandpath $2 )
! pkg=$( package_part $1 )
if ! ( cd $pth ); then
--- 269,286 ----
echo "Creating package of local files for ${pkg} ($pth)..."
! tar -zcf $pth -C $PKGROOT $(package_changed_files $(cat $PKGDB))
}
# ---------------------------------------------------------
# create_mod - creates a modules db
create_mod () {
! local pkg pth
! if [ -z "$1" ]; then
echo "You must enter a dest path."; return 1;
fi
! pth=$( expandpath $1 )
! pkg=$( package_part $moddb )
if ! ( cd $pth ); then
***************
*** 283,292 ****
echo $modules/$kernel > $PKGDIR/$pkg.exclude.list
tar -czf ${pth} -X $PKGDIR/$pkg.exclude.list $modules
- return 0
-
)
}
-
# ---------------------------------------------------------
# contents - lists contents of a package
--- 301,308 ----
echo $modules/$kernel > $PKGDIR/$pkg.exclude.list
tar -czf ${pth} -X $PKGDIR/$pkg.exclude.list $modules
)
+ return 0
}
# ---------------------------------------------------------
# contents - lists contents of a package
***************
*** 311,318 ****
--- 327,385 ----
# ---------------------------------------------------------
+ # rundiff - take a diff between saved and running config
+ #
+
+ rundiff () {
+ local backup_path vs_saved saved changed interest
+ backup_path=$1
+ vs_saved=$2
+
+ if [ ! -f $backup_path/$configdb.lrp ] ; then
+ echo "$0: $backup_path/$configdb.lrp not found"
+ exit 1;
+ fi
+
+ mkdir -p $TMP/$SESSIONID/saved
+ mkdir -p $TMP/$SESSIONID/distribution
+ cd $TMP/$SESSIONID
+ ln -s $PKGROOT running
+
+ saved=$(tar xvzf $backup_path/$configdb.lrp -C saved)
+
+ if [ $vs_saved = "saved" ] ; then
+ interest=$saved
+ fi
+
+ for pkg in $(cat $PKGDB) ; do
+ changed=$(package_changed_files $pkg)
+ if [ -n "$changed" ] ; then
+ tar xzf $backup_path/$pkg.lrp -C distribution $changed \
+ 2>/dev/null
+ interest="$interest $changed"
+ fi
+ done
+
+ interest=$(for file in $interest ; do echo $file ; done | sort | uniq)
+
+ for file in $interest ; do
+ if [ ! -f running/$file ] ; then
+ echo "*** $file has been deleted"
+ elif [ -f $vs_saved/$file ] ; then
+ diff -u $vs_saved/$file running/$file
+ elif [ -f distribution/$file ] ; then
+ diff -u distribution/$file running/$file
+ else
+ diff -u /dev/null running/$file
+ fi
+ done
+ }
+
+ # ---------------------------------------------------------
# Syntax
usage () {
cat <<-EOF
+ usage:
+
$( basename $0 ) - A Package Manager
***************
*** 323,342 ****
-c [path]<package> list contents of package
-l [<package>] list installed packages;
! if <package> given, tell if
! it is installed
-h this help
! package is a package name, the ".lrp" extension is
! optional.
EOF
}
-
#-----------------------------------------
case $1 in
! "-d") create_mod $2 $3
exit $?
;;
--- 390,408 ----
-c [path]<package> list contents of package
-l [<package>] list installed packages;
! if <package> given, tell if it is installed
! -r <backup-path> list all changes to config files since the last
save
! -R <backup-path> list all changes to config files from
distribution
-h this help
! package is a package name, the ".lrp" extension is optional.
EOF
}
#-----------------------------------------
case $1 in
! "-d") create_mod $2
exit $?
;;
***************
*** 358,362 ****
;;
! "-o") create_local $2 $3
exit $?
;;
--- 424,428 ----
;;
! "-o") create_local $2
exit $?
;;
***************
*** 366,369 ****
--- 432,443 ----
;;
+ "-r") rundiff $2 saved
+ exit $?
+ ;;
+
+ "-R") rundiff $2 distribution
+ exit $?
+ ;;
+
*) echo "$1 is an unknown command. Try -h for help."
;;
Index: buildtool.cfg
===================================================================
RCS file: /cvsroot/leaf/src/bering-uclibc/apps/config/buildtool.cfg,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** buildtool.cfg 25 Aug 2006 19:31:25 -0000 1.9
--- buildtool.cfg 11 Sep 2006 21:05:17 -0000 1.10
***************
*** 17,21 ****
</File>
! <File mount.back>
Server = cvs-sourceforge
Revision = HEAD
--- 17,21 ----
</File>
! <File with_storage>
Server = cvs-sourceforge
Revision = HEAD
***************
*** 41,51 ****
</File>
! <File lrcfg.back.script>
! Server = cvs-sourceforge
! Revision = HEAD
! Directory = config
! </File>
!
! <File lrcfg.back>
Server = cvs-sourceforge
Revision = HEAD
--- 41,45 ----
</File>
! <File lrcfg.backup>
Server = cvs-sourceforge
Revision = HEAD
***************
*** 77,85 ****
</File>
<Package>
<config>
! Version = 0.5
! Revision = 4
Help <<EOF
Core config and backup system package
--- 71,84 ----
</File>
+ <File build-modules>
+ Server = cvs-sourceforge
+ Revision = HEAD
+ Directory = config
+ </File>
<Package>
<config>
! Version = 0.6
! Revision = 1
Help <<EOF
Core config and backup system package
***************
*** 111,116 ****
</File>
<File>
! Filename = usr/sbin/mount.back
! Source = usr/sbin/mount.back
Type = binary
Permissions = 755
--- 110,115 ----
</File>
<File>
! Filename = usr/sbin/with_storage
! Source = usr/sbin/with_storage
Type = binary
Permissions = 755
***************
*** 135,146 ****
</File>
<File>
! Filename = usr/sbin/lrcfg.back.script
! Source = usr/sbin/lrcfg.back.script
! Type = binary
! Permissions = 755
! </File>
! <File>
! Filename = usr/sbin/lrcfg.back
! Source = usr/sbin/lrcfg.back
Type = binary
Permissions = 755
--- 134,139 ----
</File>
<File>
! Filename = usr/sbin/lrcfg.backup
! Source = usr/sbin/lrcfg.backup
Type = binary
Permissions = 755
***************
*** 173,176 ****
--- 166,175 ----
Permissions = 755
</File>
+ <File>
+ Filename = usr/sbin/build-modules
+ Source = usr/sbin/build-modules
+ Type = binary
+ Permissions = 755
+ </File>
</Contents>
</config>
--- NEW FILE: build-modules ---
#!/bin/sh
#
# Build /lib/modules based upon the contents of /etc/modules and a
# defined modules repository.
#
# Copyright (c) Paul Traina 2006, GPL v2
#
MODLIST=/etc/modules
MODREPO=/mnt/modules.tgz
LIBMOD=/lib/modules
##########################################################################
progname=`basename $0`
usage() {
cat >&2 <<-EOF
Usage: $progname [ -m modules ] [ -f modules.tar.gz ] [ -l module-dir ]
Defaults:
-m $MODLIST
-f $MODREPO
-l $LIBMOD
Extract kernel modules from $MODREPO into $LIBMOD
based upon the contents of $MODLIST.
EOF
}
args=`getopt -a -o hm:f:l: -n "$progname" -- "$@"`
if [ $? != 0 ] ; then
usage
exit 1
fi
eval set -- "$args"
while true ; do
case "$1" in
-h) usage; exit 0 ;;
-m) MODLIST="$2"; shift 2 ;;
-f) MODREPO="$2"; shift 2 ;;
-l) LIBMOD="$2"; shift 2 ;;
--) shift; break ;;
*) echo >&2 "Internal error"; exit 1 ;;
esac
done
if [ ! -f $MODLIST ] ; then
echo >&2 "$progname: module list $MODLIST not found"
exit 1
fi
if [ ! -f $MODREPO ] ; then
echo >&2 "$progname: module repository $MODREPO not found"
exit 1
fi
if [ ! -d $LIBMOD ] ; then
echo >&2 "$progname: module directory $LIBMOD not found"
exit 1
fi
##########################################################################
MODLIST=/tmp/build-modules-list.$$
MODTEMP=/tmp/build-modules-extract.$$
for mod in $modules ; do
if [ ! -f $LIBMOD/${mod}.o ] ; then
missing="${mod}.o ${missing}"
fi
done
# Nothing missing...
if [ -z "$missing" ] ; then
exit 0
fi
echo "Missing kernel modules: ${missing}"
#
# get absolute path of all modules in tarfile first (sigh)
#
trap "rm -f $MODLIST" 0 1 2
tar tzf $MODREPO > $MODLIST
for mod in $missing ; do
findmod="`grep -F ${mod} $MODLIST` ${findmod}"
done
rm -f $MODLIST
trap '' 0 1 2
#
# Now do the actual module extraction to a temporary area and then
# move the modules to /lib/modules
#
trap "rm -rf $MODTEMP" 0 1 2
mkdir $MODTEMP
tar xzf $MODREPO -C $MODTEMP $findmod
echo
echo -n "Installing modules:"
for mod in $findmod ; do
echo -n " `basename $mod .o`"
mv $MODTEMP/$mod $LIBMOD/`basename $mod`
done
echo
rm -rf $MODTEMP
trap '' 0 1 2
exit 0
--- NEW FILE: with_storage ---
#!/bin/sh
#
# Mount the backup storage media, run a command, and then unmount everything
# Linux Embedded Applications Framework
# GPL v2
#
# Based upon work by:
# Dave Cinege, James Sturdevant, Charles Steinkuehler
#
diskfile=/var/lib/lrpkg/pkgpath.disks
progname=$(basename $0)
if [ $1 = "-r" ]; then
readonly=$1
shift
fi
if [ $# -lt 2 ]; then
echo "$progname: usage: with_backup [-r] <mount-point> <command>"
exit 1;
fi
mount_point=$1 ; shift
if [ ! -d $mount_point ] ; then
echo "$progname: mount point $mount_point not found"
exit 1;
fi
command="$@"
if [ ! -f $diskfile ] ; then
echo "$progname: $diskfile not found"
exit 1;
fi
cat $diskfile | if read dev fs; then
if ! mount -o noatime $readonly -t $fs $dev $mount_point ; then
echo "$progname: mounting storage media $dev:$fs on $mount_point failed"
exit 1
fi
fi
$command
success=$?
if [ -z "$readonly" ]; then
sync
sleep 2
fi
umount $mount_point || exit $?
exit $success
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
leaf-cvs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/leaf-cvs-commits