Update of /cvsroot/leaf/src/The_UnNamed_One/apps/config
In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv15949/apps/config

Added Files:
        apkg apkg.merge apkg.mergefile build-modules buildtool.cfg 
        buildtool.mk config.cfg help lrcfg lrcfg.backup lrcfg.conf 
        lrcfg.conf.packs pauseme with_storage 
Log Message:
initial import


--- 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
#
CWRT=on

. /etc/config.cfg

usage () {
        cat <<-EOF
        usage:
        $(basename $0): { configdb | moddb } [directory]
EOF
        exit 1
}

test $# -lt 1 && usage

STORAGE_MEDIA=${2:-$STORAGE_MEDIA}
BACKUP_PATH=$(echo $STORAGE_MEDIA | sed -e 's/ .*//')
MNT=$BACKUP_PATH;       test -d $MNT || usage
PACKAGE=$1;             test $PACKAGE != "configdb" -a $PACKAGE != "moddb" && 
usage
DIR="/tmp"

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 [ "$CWRT" = "on" ]; then 
        echo
        echo "New Package:"
        ls -l $DIR/$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 $DIR/$PACKAGE.lrp
                sleep 2
                exit 1
        fi
fi
                
echo -n "Copying $PACKAGE.lrp Please wait: "
ticker & 
if ! cp $DIR/$PACKAGE.lrp $MNT/$PACKAGE.lrp >/dev/null 2>&1; then
        echo "Could not move $DIR/$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 $DIR/$PACKAGE.lrp

exit 0

--- NEW FILE: config.cfg ---
# Confirm writes (on/off)
CWRT=on

--- NEW FILE: help ---
#!/bin/sh

HF="$1"
[ $# -eq 0 ] && HF="root" 
more "/var/lib/lrpkg/$HF.help"

--- NEW FILE: apkg.mergefile ---
#!/bin/sh

OLD="-"
NEW="+"
OIFS="$IFS"

usage() {
        echo "Usage: $0 OLD NEW"
        exit 1
}

[ $# -eq 2 ] || usage
[ -f $1 ] || usage
[ -f $2 ] || usage

old_file=$1
new_file=$2

eof_old=
eof_new=
eof_diff=

line_old=
line_new=
line_diff=

pos_old=1
pos_new=1


read_old() {
        IFS=
        if read line_old <&3; then
                pos_old=$(($pos_old+1))
        else
                eof_old=y
        fi
        IFS="$OIFS"
}

read_new() {
        IFS=
        if read line_new <&4; then
                pos_new=$(($pos_new+1))
        else
                eof_new=y
        fi
        IFS="$OIFS"
}

read_diff() {
        IFS=
        read line_diff || eof_diff=y
        IFS="$OIFS"
}

read_diff_header() {
        IFS=' ,@+-'
        read pos_diff_old len_diff_old pos_diff_new len_diff_new junk || 
eof_diff=y
        IFS="$OIFS"
}

diff -u $old_file $new_file | (

# Ignore first two lines
read junk
read junk

read_diff_header
while [ -z "$eof_diff" ]; do

        while [ "$pos_old" -lt "$pos_diff_old" ]; do
                read_old
                read_new
                echo "$line_old"
        done
        
        while [ "$len_diff_old" -gt 0 -o "$len_diff_new" -gt 0 ]; do
                read_diff
                case "$line_diff" in
                -*)
                        read_old
                        echo "${OLD}$line_old"
                        len_diff_old=$(($len_diff_old-1))
                        ;;
                +*)
                        read_new
                        echo "${NEW}$line_new"
                        len_diff_new=$(($len_diff_new-1))
                        ;;
                *)
                        read_old
                        read_new
                        echo "$line_old"
                        len_diff_old=$(($len_diff_old-1))
                        len_diff_new=$(($len_diff_new-1))
                        ;;
                esac
        done

        read_diff_header
done

while [ -z "$eof_old" ]; do
        read_old
        echo "$line_old"
done

) 3<$old_file 4<$new_file

--- NEW FILE: lrcfg ---
#!/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 configuration
                                m) Backup modules

                                c) Show configuration changes since last save
                                d) Show configuration changes from defaults

                                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 configdb ;;
        m | M)  with_storage $MNT lrcfg.backup moddb ;;
        c | C)  with_storage $MNT apkg -r | more ; pauseme ;;
        d | D)  with_storage $MNT apkg -R | more ; pauseme ;;

        h | H)  lrcfg.conf '                    Packages Help Menu' \
                        'pack' '$LRPKG/packages' '-f $LRPKG/$CONF.help' \
                        'help $CONF; pauseme'  ;;
    esac
done

--- NEW FILE: lrcfg.conf ---
#!/bin/sh
#
# lrcfg.conf v0.0.1 (don't trust these version numbers)
#
# Dave Cinege - GPL2
#
# Linux Router Project 

if [ $# -ne 5 ]; then
        echo "Bad call to $(basename $0)"
        exit 1
fi

LRPKG="/var/lib/lrpkg"

TITLE="$1"
TYPE="$2"
eval CONFF="$3"
IF="$4"
COMMAND="$5"

while [ 1 ]; do

        clear
echo
echo "$TITLE"
echo
x=0     
if [ "$TYPE" = "pack" ]; then 
        for CONF in `cat $CONFF`; do
                if eval [ "$IF" ]; then
                        x=$(($x + 1))
                        echo "  $x) $CONF"
                fi
        done
elif [ "$TYPE" = "conf" ]; then
        
        IFS='
'       
        for CONF in `sed 's/^.* //' $CONFF`; do
                x=$(($x + 1))
                echo "  $x) $CONF"
        done
        IFS=' '
fi

echo
echo "  q) quit"
echo "  
----------------------------------------------------------------------------"
echo -n "       Selection: "


        read OPT

        case $OPT in
                q | Q)  exit 0 ;;
                "")     ;;      
                * )     x=0
                        if [ "$TYPE" = "pack" ]; then 
                                for CONF in `cat $CONFF`; do
                                        if eval [ "$IF" ]; then
                                                x=$(($x + 1))
                                        fi
                                
                                        if [ $x -eq $OPT ]; then 
                                                eval $COMMAND 
                                                break
                                        fi
                                done
                        elif [ "$TYPE" = "conf" ]; then 
                                IFS='
'
                                for CONF1 in `sed 's/   .*$//' $CONFF`; do
                                        x=$(($x + 1))
                                        if [ $x -eq $OPT ]; then
                                                eval $COMMAND
                                                break
                                        fi
                                done
                                IFS=' '
                        fi  ;;
        esac

done

exit 1

--- NEW FILE: buildtool.mk ---
# makefile for config
include $(MASTERMAKEFILE)

CONFIG_DIR=.
CONFIG_TARGET_DIR:=$(BT_BUILD_DIR)/config

$(CONFIG_DIR)/.source:
        touch $(CONFIG_DIR)/.source

source: $(CONFIG_DIR)/.source
                        
$(CONFIG_DIR)/.configured: $(CONFIG_DIR)/.source
        touch $(CONFIG_DIR)/.configured
                                                                 
$(CONFIG_DIR)/.build: $(CONFIG_DIR)/.configured
        mkdir -p $(CONFIG_TARGET_DIR)
        mkdir -p $(CONFIG_TARGET_DIR)/usr/bin
        mkdir -p $(CONFIG_TARGET_DIR)/usr/sbin
        mkdir -p $(CONFIG_TARGET_DIR)/etc
        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

build: $(CONFIG_DIR)/.build
                                                                                
         
clean:
        rm -rf $(CONFIG_TARGET_DIR)
        rm -f $(CONFIG_DIR)/.build
        rm -f $(CONFIG_DIR)/.configured
                                                                                
                                 
srcclean: clean
        rm -f $(CONFIG_DIR)/.source

--- NEW FILE: apkg.merge ---
#!/bin/sh

TMP=${TMP:-"/tmp"}
SESSIONID=$( dd if=/dev/urandom bs=10 count=3 2>/dev/null | sha1sum | sed -e 
's/  -//' )

usage() {
        echo "Usage: $0 OLDDIR NEWDIR SUBPATH"
        exit 1
}

[ $# -eq 3 ] || usage
[ -d $1 ] || usage
[ -d $2 ] || usage
[ -f $3 ] || usage

while [ 1 ]; do

clear
cat <<EOF
Following file has been locally modified and a new version is to be installed :
$3

  K ) Keep old file
  R ) Replace old file with new one
  D ) Show differences between old and new file
  M ) Edit a merged version of the files

  -----------------------------------------------------------------------------
EOF
echo -n "       Selection: "

read OPT
echo

case $OPT in
k|K)
        rm $2/$3
        break
        ;;
r|R)
        break
        ;;
d|D)
        clear
        diff -u $1/$3 $2/$3 | more
        pauseme
        ;;
m|M)
        tmp=$TMP/$SESSIONID.tmp
        apkg.mergefile $1/$3 $2/$3 > $tmp
        sha1=$(sha1sum $tmp)
        $EDITOR $tmp
        if echo "$sha1" | sha1sum -c >/dev/null 2>&1; then
                rm $tmp
        else
                mv $tmp $2/$3
                break
        fi
        ;;
esac

done

--- NEW FILE: lrcfg.conf.packs ---
#!/bin/sh

lrcfg.conf "                    $1 configuration files" \
                'conf' "$2/$1.conf" '' 'edit $CONF1'

--- NEW FILE: apkg ---
#!/bin/sh
# apkg - A Package manager for PC-R platform
# rewritten from apkg by David Douthitt's "oxygen" distro
# This code written by Nathan Angelacos and Natanael Copa
# 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


# ---------------------------------------------------------
# expandpath - given a path, expand it
# code from apkg by David Douthitt
expandpath () {
        local D=$(dirname $1)
        if `echo "$D" | grep -v "^/" > /dev/null`; then
            [ `dirname $1` = "." ] && D=$PWD || D=$PWD/$(dirname $1)
        fi
        echo $D/$(basename $1)
        }

# ---------------------------------------------------------

PKGROOT=`expandpath ${PKGROOT:-"/"}`
LRPKG=${LRPKG:-"var/lib/lrpkg"}
PKGDIR="$PKGROOT/$LRPKG"
TMP=${TMP:-"/tmp"}
PKGDB=${PKGDB:-"$PKGDIR/packages"}
SESSIONID=$(dd if=/dev/urandom bs=10 count=3 2>/dev/null | sha1sum | sed -e 's/ 
 -//')
STORAGE_MEDIA=${STORAGE_MEDIA:-"/mnt"}
BACKUP_PATH=$(echo $STORAGE_MEDIA | sed -e 's/ .*//')

trap "rm -rf $TMP/$SESSIONID*" EXIT

. $PKGDIR/backup

# ---------------------------------------------------------
# package_part - given a path, print just the basename,
# without the .lrp - code from apkg by David Douthitt

package_part () {
        local F=${1##*/}
        F=${F%%.lrp}
        echo $F
        }
                                                
# ---------------------------------------------------------
# Make FN - given a filename, make it a lrp name
# code from apkg by David Douthitt
makeFN () {
        F=$1
        if [ ! -f $F ]; then
                F=$F.lrp
                if [ ! -f $F ]; then
                        F="$(expandpath $F)"
                        #if [ ! -f $F ]; then
                        #        err "file ($F) does not exist!"
                        #        echo $1
                        #        return 1
                        #fi
                fi
        fi
        expandpath $F
        }


remsuffix () {
        echo ${1%.lrp}
        }

addsuffix () {
        echo $(remsuffix $1).lrp
        }

# ---------------------------------------------------------
# list_pkgs - list installed packages 
# if a package name is given, list it, or return 1
list_pkgs () {
        local m x
        if [ -n "$1" ]; then
            m=$( grep "^\(.*/\)\?$(package_part $1)$" $PKGDB )
            if [ -n "$m" ]; then
                x=$( basename $m )
                echo $m $( cat $PKGDIR/$x.version 2>/dev/null )
                return 0
            else
                echo "package $1 is not installed"
                return 1
            fi
        fi
        for x in $( cat $PKGDB  ); do
            m=$( basename $x )
            echo $x $( cat $PKGDIR/$m.version 2>/dev/null )
        done
        return 0
        }

# ---------------------------------------------------------
# create_sha1 - given a package, create the sha1sum of it
#   assumes the package exists...
create_sha1 () {
    ( cd $PKGROOT
        [ -f $PKGDIR/$1.local ] && \
            find $( cat $PKGDIR/$1.local ) -type f | xargs sha1sum > 
$PKGDIR/$1.sha1
    )
}

#----------------------------------------------------------
# prepkg - run a prepkg script if it exist
run_prepkg() {
    local pkg
    pkg=$( package_part $1 )    

    ( 
        cd $PKGROOT
        [ -f $PKGDIR/$pkg.prepkg ] && sh $PKGDIR/$pkg.prepkg
    )
}

# ---------------------------------------------------------
# install - installs a package

install () {
        local pkg pth

        if [ -z "$1" ]; then
            echo "No package name given." ; return 1
        fi
        
        pth=$( makeFN $1 )
        pkg=$( package_part $pth )

        if [ -z "$pkg" ]; then
            echo "No package name given."; return 1
        fi
        if list_pkgs "$pkg" >/dev/null; then
            echo "$pkg already installed."; return 1 
        fi
        if [ ! -f "$pth" ]; then
            echo "$pth not found."; return 1 
        fi
        
        # ok, its there, not installed... let's install it...
        ( 
        cd $PKGROOT
        tar -zxvpf $pth > $PKGDIR/$pkg.list
        )
        echo "$pkg" >> $PKGDB
        create_sha1 $pkg
        echo "$pkg installed"
        return 0
        }

# ---------------------------------------------------------
# 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
        }

# ---------------------------------------------------------
# upgrade - upgrades a package

upgrade () {
        local pkg pth

        if [ -z "$1" ]; then
            echo "No package name given." ; return 1
        fi
        
        pth=$( makeFN $1 )
        pkg=$( package_part $pth )

        if [ -z "$pkg" ]; then
            echo "No package name given."; return 1
        fi
        if ! list_pkgs "$pkg" >/dev/null; then
            echo "$pkg not installed."; return 1 
        fi
        if [ ! -f "$pth" ]; then
            echo "$pth not found."; return 1 
        fi
        
        # 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 $(cat $PKGDIR/$pkg.sha1 | sed '/  -/d' | \
                                sha1sum -c 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
        )
        echo "$pkg upgraded"
        return 0
        }

# ---------------------------------------------------------
# create_local - create a lrp from the local files list

create_local () {
        local pkg pth

        pth=${1:-$BACKUP_PATH}
        pth=$( expandpath $pth )
        pkg=$( package_part $configdb )
        
        if [ -z $pth ]; then 
            echo "You must enter a dest path."; return 1; 
        fi
                 
        if ! ( cd $pth ); then
            echo "Dest path ($pth) not found."; return 1
        fi
        pth="${pth}/$pkg.lrp"
                                           
        # touch didn't work for us, so we try an echo instead.
        echo "" >$pth 2>/dev/null
        if [ $? -gt 0 ]; then
            echo "Unable to create the dest pkg (pth)"; return 1
        fi

        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

        pth=${1:-$BACKUP_PATH}
        pth=$( expandpath $pth )
        pkg=$( package_part $moddb )

        if [ -z "$pth" ]; then 
            echo "You must enter a dest path."; return 1; 
        fi

        if ! ( cd $pth ); then
            echo "Dest path ($pth) not found."; return 1 
        fi
        pth="${pth}/$pkg.lrp"
                 
        echo "" >$pth 2>/dev/null
        if [ $? -gt 0 ]; then
            return 1
        fi

        echo "Creating ${pkg} ($pth)..." 
        (
                cd $PKGROOT
                modules=lib/modules
                kernel=`uname -r`
                echo $modules/$kernel > $TMP/$SESSIONID.exclude
                tar -czf ${pth} -X $TMP/$SESSIONID.exclude $modules
        )
        return 0
        }

# ---------------------------------------------------------
# contents - lists contents of a package

contents () {
        local pkg pth

        if [ -z "$1" ]; then
            echo "No package name given." ; return 1
        fi

        pth=$( makeFN $1)
        pkg=$( package_part $pth )

        if [ -z "$pkg" ]; then
            echo "No package name given."; return 1
        fi
        if [ ! -f "$pth" ]; then
            echo "$pth not found."; return 1
        fi
        
        echo "Package $pth contents:"
        tar -tzvf $pth
        return 0
        }

# ---------------------------------------------------------
# rundiff - take a diff between saved and running config
#

rundiff () {
        local backup_path vs_saved saved changed interest lrp
        vs_saved=$1

        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
                interest="$interest $changed"
                for lrp in $STORAGE_MEDIA ; do
                    if [ -f $lrp/$pkg.lrp ] ; then
                        tar xzf $lrp/$pkg.lrp -C distribution $changed 
2>/dev/null
                        break
                    fi
                done
            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
        
        Commands are:
                
        -i [path]<package>      install package
        -u [path]<package>      upgrade package
        -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
                exit $?
                ;;

        "-h" | "") usage
                exit 1
                ;;
                
        "-c")   contents $2
                exit $?
                ;;

        "-l")   list_pkgs $2
                exit $?
                ;;

        "-i")   install $2
                exit $?
                ;;
                
        "-o")   create_local $2
                exit $?
                ;;
                
        "-u")   upgrade $2
                exit $?
                ;;

        "-r")   rundiff saved
                exit $?
                ;;

        "-R")   rundiff distribution
                exit $?
                ;;

        *)      echo "$1 is an unknown command.  Try -h for help."
                ;;
            
        esac

--- NEW FILE: buildtool.cfg ---
<File buildtool.mk>
  Server = cvs-sourceforge
  Revision = HEAD
  Directory = config
</File>

<File help>
  Server = cvs-sourceforge
  Revision = HEAD
  Directory = config
</File>

<File pauseme>
  Server = cvs-sourceforge
  Revision = HEAD
  Directory = config
</File>

<File with_storage>
  Server = cvs-sourceforge
  Revision = HEAD
  Directory = config
</File>

<File apkg>
  Server = cvs-sourceforge
  Revision = HEAD
  Directory = config
</File>

<File apkg.merge>
  Server = cvs-sourceforge
  Revision = HEAD
  Directory = config
</File>

<File apkg.mergefile>
  Server = cvs-sourceforge
  Revision = HEAD
  Directory = config
</File>

<File lrcfg.backup>
  Server = cvs-sourceforge
  Revision = HEAD
  Directory = config
</File>

<File config.cfg>
  Server = cvs-sourceforge
  Revision = HEAD
  Directory = config
</File>

<File lrcfg.conf>
  Server = cvs-sourceforge
  Revision = HEAD
  Directory = config
</File>

<File lrcfg.conf.packs>
  Server = cvs-sourceforge
  Revision = HEAD
  Directory = config
</File>

<File lrcfg>
  Server = cvs-sourceforge
  Revision = HEAD
  Directory = config
</File>

<File build-modules>
  Server = cvs-sourceforge
  Revision = HEAD
  Directory = config
</File>

<Package>
        <config>
                Version = 0.6 
                Revision = 8
                Help <<EOF
                Core config and backup system package
                LEAF package by __PACKAGER__, __BUILDDATE__
                EOF

                <Permissions>
                        Files = 644
                        Directories = 755
                </Permissions>
                
                <Owner>
                                Files = root:root
                                Directories = root:root
                </Owner>
                
                <Contents>
                        <File>
                                Filename        = usr/bin/help
                                Source          = usr/bin/help
                                Type            = binary
                                Permissions = 755                               
                        </File>
                        <File>
                                Filename        = usr/bin/pauseme
                                Source          = usr/bin/pauseme
                                Type            = binary
                                Permissions = 755                               
                        </File>
                        <File>
                                Filename        = usr/sbin/with_storage
                                Source          = usr/sbin/with_storage
                                Type            = binary
                                Permissions = 755
                        </File>
                        <File>
                                Filename        = usr/sbin/apkg
                                Source          = usr/sbin/apkg
                                Type            = binary
                                Permissions = 755                               
                        </File>
                        <File>
                                Filename        = usr/sbin/apkg.merge
                                Source          = usr/sbin/apkg.merge
                                Type            = binary
                                Permissions = 755                               
                        </File>
                        <File>
                                Filename        = usr/sbin/apkg.mergefile
                                Source          = usr/sbin/apkg.mergefile
                                Type            = binary
                                Permissions = 755                               
                        </File>
                        <File>
                                Filename        = usr/sbin/lrcfg.backup
                                Source          = usr/sbin/lrcfg.backup
                                Type            = binary
                                Permissions = 755       
                        </File>         
                        <File>
                                Filename        = etc/config.cfg
                                Source          = etc/config.cfg
                                Description     = Backup defaults
                                Type            = conf
                                Type            = local
                                Type            = binary
                        </File>         
                        <File>
                                Filename        = usr/sbin/lrcfg.conf
                                Source          = usr/sbin/lrcfg.conf
                                Type            = binary
                                Permissions = 755       
                        </File>         
                        <File>
                                Filename        = usr/sbin/lrcfg.conf.packs
                                Source          = usr/sbin/lrcfg.conf.packs
                                Type            = binary
                                Permissions = 755       
                        </File>
                        <File>
                                Filename        = usr/sbin/lrcfg
                                Source          = usr/sbin/lrcfg
                                Type            = binary
                                Permissions = 755       
                        </File>
                        <File>
                                Filename        = usr/sbin/build-modules
                                Source          = usr/sbin/build-modules
                                Type            = binary
                                Permissions = 755       
                        </File>
                </Contents>
        </config>
</Package>

--- 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
#
MODULES=/etc/modules
MODREPO=/mnt/modules.tgz
LIBMOD=/lib/modules

MODLIST=/tmp/build-modules.$$.list
MODTEMP=/tmp/build-modules.$$.extract

trap "rm -rf $MODTEMP $MODLIST" EXIT

##########################################################################
progname=`basename $0`

usage() {
    cat >&2 <<-EOF
        Usage: $progname [-f] [ -m modules-file ] [ -r modules.tar.gz ] [ -l 
module-dir ]

        -f force
        -m modules textfile ($MODULES)
        -r modules tarfile ($MODREPO)
        -l modules directory ($LIBMOD)

        Extract kernel modules from $MODREPO into $LIBMOD
        based upon the contents of $MODULES.
EOF
}

force=no

while getopts hfm:r:l: option; do
    case $option in
        m) MODULES=$OPTARG      ;;
        r) MODREPO=$OPTARG      ;;
        l) LIBMOD=$OPTARG       ;;
        f) force=yes            ;;
        h) usage; exit 0        ;;
        ?) usage; exit 1        ;;
    esac
done
shift $((${OPTIND} - 1))

if [ ! -f $MODULES ] ; then
    echo >&2 "$progname: module list $MODULES 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

##########################################################################

for mod in `sed -e 's/[# ].*//' -e '/^$/d' $MODULES | sort` ; do
   if [ ! -f $LIBMOD/${mod}.o -o "$force" = "yes" ] ; then
       missing="${missing} ${mod}"
   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)
#
echo "Reading modules directory..."
tar tzf $MODREPO > $MODLIST
for mod in $missing ; do
    findmod="${findmod} `grep -F /${mod}.o $MODLIST`"
done    

#
# Now do the actual module extraction to a temporary area and then
# move the modules to /lib/modules
#
mkdir $MODTEMP
tar xzf $MODREPO -C $MODTEMP $findmod

echo -n "Copying modules:"
for mod in $findmod ; do
    echo -n " `basename $mod .o`"
    mv $MODTEMP/$mod $LIBMOD/`basename $mod`
done
echo

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 [ $# -lt 2 ]; then
    echo "$progname: usage: with_storage [-r] <mount-point> <command>"
    exit 1;
fi

if [ $1 = "-r" ]; then
   readonly=$1
   shift
fi

mount_root=$1 ; shift
if [ ! -d $mount_root ] ; then
   echo "$progname: mount point $mount_root not found"
   exit 1;
fi

command="$@"

if [ ! -f $diskfile ] ; then
   echo "$progname: $diskfile not found"
   exit 1;
fi

mount_points=""
subpoint=0

while read dev fs; do 
    mp=${mount_root}${subpoint}
    if test ! -d $mp && ! mkdir $mp; then
        echo "$progname: unable to create $mp"
        exit 1
    fi
    if ! mount -o noatime $readonly -t $fs $dev $mp ; then
        echo "$progname: mounting storage media $dev:$fs on $mount_root failed"
        exit 1
    fi
    mount_points="$mount_points $mp"
    subpoint="$(($subpoint+1))"
done < $diskfile

STORAGE_MEDIA="$mount_points" $command
success=$?

if [ -z "$readonly" ]; then
    sync
    sleep 2
fi

for mp in $mount_points ; do
    umount $mp || echo "$progname: unable to unmount $mp"
    rmdir $mp
done

exit $success

--- NEW FILE: pauseme ---
#!/bin/sh

echo -n "    Press return...";read n;echo


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
leaf-cvs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/leaf-cvs-commits

Reply via email to