Changeset b25fc75


Ignore:
Timestamp:
09/29/09 15:29:50 (11 years ago)
Author:
Paweł Foremski <pjf@…>
Branches:
master
Children:
aa9e3a2
Parents:
2385f7e
Message:

various minor improvements

Location:
pkgtools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pkgtools/installpkg

    r2385f7e rb25fc75  
    4242}
    4343
     44usage()
     45{
     46        cat <<- EOF
     47        Usage: ${CALL}pkg [OPTIONS] [<package file>]
     48       
     49        $TITLE given package file.
     50       
     51        Options:
     52                --rootdir <dir>       use <dir> as /
     53                --nolibs              dont run ldconfig nor depmod
     54                --ldconfig            run ldconfig and exit
     55                --depmod              run depmod and exit
     56                --verbose             show extracted files
     57        EOF
     58}
     59
    4460# switch operation mode
    4561case "`basename $0`" in
    46         installpkg) mode="install"; title="Installing"; call="install";;
    47         upgradepkg) mode="upgrade"; title="Upgrading";  call="upgrade";;
     62        installpkg) MODE="install"; TITLE="Installing"; CALL="install";;
     63        upgradepkg) MODE="upgrade"; TITLE="Upgrading";  CALL="upgrade";;
    4864        *) echo "Call me as installpkg/upgradepkg"; exit 1;;
    4965esac
     
    5571                --ldconfig)    OPT_JUSTLD=1;;
    5672                --depmod)      OPT_JUSTDEPMOD=1;;
     73                --verbose)     OPT_VERBOSE=1;;
    5774                --rootdir)
    5875                        ROOTDIR="`readlink -f $2`"
     
    7289PKG="$1"
    7390if [ -z "$PKG" ]; then
    74         cat <<- EOF
    75         Usage: $0 [OPTIONS] [<package file>]
    76        
    77         $title given package file.
    78        
    79         Options:
    80                 --rootdir <dir>       use <dir> as /
    81                 --nolibs              dont run ldconfig nor depmod
    82                 --ldconfig            run ldconfig and exit
    83                 --depmod              run depmod and exit
    84         EOF
     91        usage
    8592        exit 0
    8693elif [ ! -f "$PKG" ]; then
     
    96103
    97104# start
    98 echo "$title: $pkglname"
     105echo "$TITLE: $pkglname"
    99106mkdir -p $ROOTDIR && cd $ROOTDIR || exit 1
    100107
    101108# extract package information from filename
    102 set -- `echo "$pkglname" | sed -re 's/^(.*)-(.*)-([0-9]+)-([0-9]+).*/\1 \2 \3 \4/g'`
     109set -- `echo "$pkglname" | sed -re 's/^(.*)-(.*)-(.*)-([0-9]+).*/\1 \2 \3 \4/g'`
    103110echo "$pkglname" | grep -q '\-big.pkg.tar.gz' && big="1"
    104111
     
    114121
    115122# check if user is not dumb
    116 if [ "$mode" = "upgrade" ]; then
     123if [ "$MODE" = "upgrade" ]; then
    117124        if [ ! -f "$VARDIR/$pkgname/installed" ]; then # check if package is already installed
    118125                echo "pkg: package '$pkgname' is not installed: cannot upgrade"
     
    135142                fi
    136143        fi
    137 elif { [ "$mode" = "install" ] && [ $fixrel -gt 1 ]; }; then
     144elif { [ "$MODE" = "install" ] && [ $fixrel -gt 1 ]; }; then
    138145        echo "pkg: '$pkglname' is a fixrel package for upgrades only: cannot install"
    139146        cleanup
     
    143150# run function preparing for operation to be carried
    144151if { [ $fixrel -eq 1 ] && tar -xzf $pkg .INSTALL 2>/dev/null; }; then
    145         sh .INSTALL pre_$call $pkgver || {
    146                 echo "pkg: running 'pre_$call $pkgver' failed"
     152        sh .INSTALL pre_$CALL $pkgver || {
     153                echo "pkg: running 'pre_$CALL $pkgver' failed"
    147154                cleanup; exit 1
    148155        } >&2
     
    151158
    152159# if upgrading, store current permissions of all files from the target package
    153 if [ "$mode" = "upgrade" ]; then
     160if [ "$MODE" = "upgrade" ]; then
    154161        echo "Storing permissions"
    155162
     
    176183
    177184# unpack new files
    178 echo "Untarring new package"
    179 echo -e "$exclude" | tar -X - -xzf $pkg || {
     185echo -e "$exclude" | tar -X - -x${OPT_VERBOSE:+v}zf $pkg || {
    180186        echo "pkg: couldn't extract package contents"
    181187        cleanup
     
    184190
    185191# restore permissions, if needed
    186 if [ "$mode" = "upgrade" ]; then
     192if [ "$MODE" = "upgrade" ]; then
    187193        echo "Restoring permissions"
    188194        cat .PERMISSIONS | while read file; do
     
    207213        # run post-function, if needed
    208214        if [ "$runpost" = 1 ]; then
    209                 sh .INSTALL post_$call $pkgver || {
    210                         echo "pkg: running 'post_$call $pkgver' failed"
     215                sh .INSTALL post_$CALL $pkgver || {
     216                        echo "pkg: running 'post_$CALL $pkgver' failed"
    211217                        echo "pkg: WARNING: igoring this error"
    212218                } >&2
  • pkgtools/makepkg

    r2385f7e rb25fc75  
    212212NOEXTRACT=0
    213213NOBUILD=0
    214 DEBUG=
    215214JUSTPACK=0
    216215FIXREL=1
     
    219218while [ "$#" -ne "0" ]; do
    220219        case $1 in
    221                 --debug)     DEBUG=1 ;;
     220                --debug)     export DEBUG=1 ;;
    222221                --noextract) NOEXTRACT=1 ;;
    223222                --nobuild)   NOBUILD=1 ;;
     
    230229                        while getopts "dDehoP:w:vF:-" opt; do
    231230                                case $opt in
    232                                         d) DEBUG=1 ;;
     231                                        d) export DEBUG=1 ;;
    233232                                        D) DESCRIBE=1 ;;
    234233                                        e) NOEXTRACT=1 ;;
     
    249248done
    250249
    251 export DEBUG
    252 
    253250# convert a (possibly) relative path to absolute
    254251FB_PKGDEST="`realpath $FB_PKGDEST`"
     
    277274fi
    278275source $BUILDSCRIPT
    279 
    280 if [ "$root_required" = "yes" ] && [ "`id -u`" != 0 ]; then
    281         fakeroot=`which fakeroot`
    282         [ -x "$fakeroot" ] || error "run me as root or install fakeroot"
    283         exec fakeroot -u -- $0 "$original_args"
    284 fi
    285276
    286277if [ -n "$gitpaths" ]; then
     
    343334                lastmod=`echo "$dirty" | xargs ls -lRL --full-time 2>/dev/null \
    344335                        | awk '{if (NF>=9) {print $6" "$7" "$8}}' | sort | tail -n1`
    345                 pkgver=${pkgver}_`date +%Y.%m.%d_%H:%M:%S -d "$lastmod"`
     336                pkgver=${pkgver}_`date +%Y.%m.%d_%H.%M.%S -d "$lastmod"`
    346337
    347338                # $dirty probably has a lot of duplicates, so let's get rid of them
     
    365356fi
    366357
    367 msg "Making package: $pkgname (`date`)"
     358msg "Making package: $pkgname-$pkgver-$pkgrel-$FIXREL (`date`)"
    368359cd $startdir
    369360
Note: See TracChangeset for help on using the changeset viewer.