Changeset becab57


Ignore:
Timestamp:
09/24/09 15:20:05 (10 years ago)
Author:
Paweł Foremski <pjf@…>
Branches:
master
Children:
d70d2bd
Parents:
aefabac
Message:

new env var names

Files:
8 edited

Legend:

Unmodified
Added
Removed
  • fakebox

    raefabac rbecab57  
    33# Fakebox, a simple cross-compilation toolkit
    44#
    5 # Copyright (C) 2007-2008 by Pawel Foremski <pjf@asn.pl>
     5# Copyright (C) 2007-2009 ASN Sp. z o.o.
     6#
     7# Authors: Pawel Foremski <pjf@asn.pl>
     8#          Michal Wrobel <maw@asn.pl>
    69#
    710# This program is free software; you can redistribute it and/or modify it under
     
    2326
    2427config="${1:-./fakebox.conf}"
    25 [ "$2" = "-f" ] && register="1"
     28if [[ -d "$config" ]]; then
     29        config="$config/fakebox.conf"
     30        # FIXME: read all *.conf and export
     31fi
     32
     33if [[ ! -f "$config" ]]; then
     34        echo "Error: configuration file not found: $config" >&2
     35        exit 1
     36fi
     37
     38[[ "$2" = "-f" ]] && register="1"
    2639
    2740###
     
    2942###
    3043
    31 [ -d "$config" ] && config="$config/fakebox.conf"
    32 if [ ! -f "$config" ]; then
    33         echo "Error: configuration file not found: $config" >&2
    34         exit 1
    35 fi
     44FB_TOP="$PWD"
    3645
    3746# load config
     
    4150[ -f "$config.local" ] && source "$config.local"
    4251
     52# FIXME: export loaded vars
     53
    4354###
    4455### defaults
    4556###
    4657
    47 # paths to toolchain and virtual root, relative to $FB_TOP
    48 FB_TOOLCHAIN=${FB_TOOLCHAIN:-toolchain}
    49 FB_ROOTFS=${FB_ROOTFS:-rootfs}
    50 
    51 # absolute path to top dir, containing configs, toolchain, etc
    52 FB_TOP=${FB_TOP:-`pwd`}
     58# absolute paths to toolchain and virtual root
     59FB_TOOLCHAIN=${FB_TOOLCHAIN:-$FB_TOP/toolchain}
     60FB_ROOTFS=${FB_ROOTFS:-$FB_TOP/rootfs}
    5361
    5462# wrapper prefix
    5563FB_WRAP="${FB_WRAP:-$FB_TOP/$FB_TOOLCHAIN/bin/$FB_PREFIX}"
    5664
    57 # path to fakebox
     65# path to fakebox (FIXME)
    5866FB_PATH=${FB_PATH:-$FB_TOP/fakebox}
    5967
     
    6371export FB_TOOLCHAIN FB_ROOTFS FB_WRAP FB_TOP FB_PATH FB_NAME
    6472
    65 # local modifications
    66 [ -e "${config%.conf}-local.conf" ] && source "${config%.conf}-local.conf"
    67 
    68 # path
     73# path (FIXME?)
    6974if [ -z "$FB_LEAVE_PATH" ]; then
    7075        PATH="$FB_PATH/wrappers:$FB_PATH/pkgtools"
     
    8388export CPP="cpp"
    8489
    85 # shortcuts
    86 export FB_ROOTDIR=$FB_TOP/$FB_ROOTFS
    87 export FB_TOOLSDIR=$FB_TOP/$FB_TOOLCHAIN/bin
     90# for autotools?
     91export CARCH="$FB_QEMU"
     92export CHOST="$FB_PREFIX"
    8893
    8994# magic flag
  • fakebox.conf

    raefabac rbecab57  
    66#
    77
    8 echo "Setting up Fakebox environment..."
    9 
    10 # target CPU architecture
    11 export FB_ARCH=mips
    12 
    138# filename prefix before gcc and other tools in toolchain/bin/
    14 export FB_PREFIX=$FB_ARCH-linux-uclibc
     9FB_PREFIX=$FB_ARCH-linux-uclibc
    1510
    1611# output of uname -a
    17 export FB_UNAME="Linux OpenWrt 2.6.19.2 #1 Fri Mar 16 19:16:54 CET 2007 mips unknown"
     12FB_UNAME="Linux OpenWrt 2.6.19.2 #1 Fri Mar 16 19:16:54 CET 2007 mips unknown"
    1813
    1914# machine to emulate (remember to verify with qemu)
    20 export FB_QEMU=$FB_ARCH
     15FB_QEMU=mips
     16
     17# optional
     18#CFLAGS="-march=$CARCH -O2 -s -pipe"
     19#CXXFLAGS="-march=$CARCH -O2 -s -pipe"
     20#MAKEFLAGS="-j 2"
     21
     22
  • makepkg.conf

    raefabac rbecab57  
    66
    77# FTP/HTTP download utility that makepkg should use to acquire sources
    8 export FTPAGENT="wget --continue --passive-ftp --tries=3 --waitretry=3 --timeout=10"
     8FB_FTPAGENT="wget --continue --passive-ftp --tries=3 --waitretry=3 --timeout=10"
    99
    10 export CARCH="$FB_ARCH"
    11 export CHOST="$FB_PREFIX"
    12 #export CFLAGS="-march=$CARCH -O2 -s -pipe"
    13 #export CXXFLAGS="-march=$CARCH -O2 -s -pipe"
     10# directory where all packages will be placed
     11FB_PKGDEST=$FB_TOP/build
    1412
    15 # for multiprocessor/multicore systems
    16 #export MAKEFLAGS="-j 2"
    17 
    18 # specify a fixed directory where all packages will be placed
    19 export PKGDEST=$FB_TOP/build
    20 
    21 # global directory for downloaded files
    22 export PKGDW=$FB_TOP/src
     13# directory for downloaded files
     14FB_PKGDW=$FB_TOP/src
    2315
    2416# if you want your name to show up in the packages you build, set this
    25 #export PACKAGER=""
     17#FB_PACKAGER=""
  • pkgtools/genmd5

    raefabac rbecab57  
    8787# retrieve sources
    8888msg "Retrieving sources..."
    89 mkdir -p $PKGDW
    90 cd $PKGDW
     89mkdir -p $FB_PKGDW
     90cd $FB_PKGDW
    9191
    9292for netfile in ${source[@]}; do
     
    9696                msg "    Found $file in build dir"
    9797        else
    98                 [ -z "$FTPAGENT" ] && error "FTPAGENT is not configured."
    99                 ftpclient=`echo $FTPAGENT | awk {'print $1'}`
     98                [ -z "$FB_FTPAGENT" ] && error "FTPAGENT is not configured."
     99                ftpclient=`echo $FB_FTPAGENT | awk {'print $1'}`
    100100                [ -z "`which $ftpclient 2> /dev/null`" ] && error "ftpclient `basename $ftpclient` is not installed."
    101101
     
    105105
    106106                msg "    Downloading $file"
    107                 $FTPAGENT $netfile 2>&1
     107                $FB_FTPAGENT $netfile 2>&1
    108108                [ ! -f $file ] && error "Failed to download $file"
    109109        fi
  • pkgtools/makepkg

    raefabac rbecab57  
    44# stripped down, cleaned up and feature enhanced version for Lintrack
    55#
    6 # Copyright (C):
    7 #       2002-2004 by Judd Vinet <jvinet@zeroflux.org> (Arch Linux)
    8 #       2005 by Dawid Ciezarkiewicz <dpc@asn.pl> (Lintrack)
    9 #       2005-2007 by Pawel Foremski <pjf@asn.pl> (Lintrack)
    10 #       2008 by Michał Wróbel <maw@asn.pl> (Lintrack)
     6# Copyright (C) 2002-2004 Judd Vinet <jvinet@zeroflux.org>
     7# Copyright (C) 2005-2009 ASN Sp. z o.o.
     8#
     9# Authors: Pawel Foremski <pjf@asn.pl>
     10#          Michał Wróbel <maw@asn.pl>
    1111#
    1212# This program is free software; you can redistribute it and/or modify it under
     
    2727startdir="`pwd`"
    2828installcmd=${INSTALLCMD:-installpkg}
    29 PKGDEST=${PKGDEST:-$startdir}
     29FB_PKGDEST=${FB_PKGDEST:-$startdir}
    3030original_args="$@"
    3131
     
    5353                           Hint: you may use <fixrel>=2-big, etc., too
    5454          -p <buildscript> Use an alternate build script (instead of PKGBUILD)
    55           -w <destdir>     Write package to <destdir> (instead of PKGDEST)
     55          -w <destdir>     Write package to <destdir> (instead of FB_PKGDEST)
    5656          -i, --install    Install the package after a successful build
    5757          -D, --describe   Just print name and version of the package
     
    176176
    177177        msg "  Compressing..."
    178         pkgdst="$PKGDEST/$pkgname-$pkgver-$pkgrel-1${suffix}.pkg.tar"
     178        pkgdst="$FB_PKGDEST/$pkgname-$pkgver-$pkgrel-1${suffix}.pkg.tar"
    179179        files="* .PKGINFO .FILELIST"
    180180        [ -f .INSTALL ] && files="$files .INSTALL"
     
    245245                                        p) BUILDSCRIPT=$OPTARG ;;
    246246                                        P) JUSTPACK=1 ;;
    247                                         w) PKGDEST=$OPTARG ;;
     247                                        w) FB_PKGDEST=$OPTARG ;;
    248248                                        F) FIXREL=$OPTARG ;;
    249249                                        -) OPTIND=0; break ;;
     
    258258
    259259# convert a (possibly) relative path to absolute
    260 PKGDEST="`realpath $PKGDEST`"
    261 mkdir -p $PKGDEST
     260FB_PKGDEST="`realpath $FB_PKGDEST`"
     261mkdir -p $FB_PKGDEST
    262262
    263263# unset special variables
     
    390390        msg "  Compressing..."
    391391        tar -cP --owner 0 --group 0 $files | gzip -9 \
    392                 > "$PKGDEST/$pkgname-$pkgver-$pkgrel-$FIXREL.pkg.tar.gz"
     392                > "$FB_PKGDEST/$pkgname-$pkgver-$pkgrel-$FIXREL.pkg.tar.gz"
    393393
    394394        msg "Done"
     
    398398# retrieve sources
    399399msg "Retrieving sources..."
    400 mkdir -p $PKGDW
    401 cd $PKGDW
     400mkdir -p $FB_PKGDW
     401cd $FB_PKGDW
    402402
    403403for netfile in ${source[@]}; do
     
    407407                msg "    Found $file in sources dir"
    408408        else
    409                 [ -z "$FTPAGENT" ] && error "FTPAGENT is not configured."
    410                 ftpclient=`echo $FTPAGENT | awk {'print $1'}`
     409                [ -z "$FB_FTPAGENT" ] && error "FB_FTPAGENT is not configured."
     410                ftpclient=`echo $FB_FTPAGENT | awk {'print $1'}`
    411411                [ -z "`which $ftpclient 2> /dev/null`" ] && error "ftpclient `basename $ftpclient` is not installed."
    412412
     
    416416
    417417                msg "    Downloading $file"
    418                 $FTPAGENT $netfile 2>&1
     418                $FB_FTPAGENT $netfile 2>&1
    419419                [ ! -f $file ] && error "Failed to download $file"
    420420        fi
     
    467467                case $file in
    468468                        *.tar.gz|*.tar.Z|*.tgz)
    469                                 cmd="tar --use-compress-program=gzip -xf $PKGDW/$file" ;;
     469                                cmd="tar --use-compress-program=gzip -xf $FB_PKGDW/$file" ;;
    470470                        *.tar.bz2)
    471                                 cmd="tar --use-compress-program=bzip2 -xf $PKGDW/$file" ;;
    472                         *.tar)  cmd="tar -xf $PKGDW/$file" ;;
    473                         *.zip)  unziphack=1; cmd="unzip -qqo $PKGDW/$file" ;;
    474                         *.gz)   cmd="zcat $PKGDW/$file > ${file%.gz}" ;;
    475                         *.bz2)  cmd="bzcat $PKGDW/$file > ${file%.bz2}" ;;
    476                         *)      cmd="cp $PKGDW/$file ${file}" ;;
     471                                cmd="tar --use-compress-program=bzip2 -xf $FB_PKGDW/$file" ;;
     472                        *.tar)  cmd="tar -xf $FB_PKGDW/$file" ;;
     473                        *.zip)  unziphack=1; cmd="unzip -qqo $FB_PKGDW/$file" ;;
     474                        *.gz)   cmd="zcat $FB_PKGDW/$file > ${file%.gz}" ;;
     475                        *.bz2)  cmd="bzcat $FB_PKGDW/$file > ${file%.bz2}" ;;
     476                        *)      cmd="cp $FB_PKGDW/$file ${file}" ;;
    477477                esac
    478478
     
    597597if [ "$INSTALL" = "1" ]; then
    598598        msg "Installing: $pkgname"
    599         $installcmd "$PKGDEST/$pkgname-$pkgver-$pkgrel-1${suffix}-big.pkg.tar.gz"
     599        $installcmd "$FB_PKGDEST/$pkgname-$pkgver-$pkgrel-1${suffix}-big.pkg.tar.gz"
    600600fi
    601601
  • pkgtools/makepkg-0.2

    raefabac rbecab57  
    156156
    157157        msg "  Compressing..."
    158         pkgdst="$PKGDEST/$pkgname-$pkgver-$pkgrel${suffix}.pkg.tar"
     158        pkgdst="$FB_PKGDEST/$pkgname-$pkgver-$pkgrel${suffix}.pkg.tar"
    159159        files="* .PKGINFO .FILELIST"
    160160        [ -f .INSTALL ] && files="$files .INSTALL"
     
    237237
    238238# convert a (possibly) relative path to absolute
    239 PKGDEST="`realpath $PKGDEST`"
    240 mkdir -p $PKGDEST
     239PKGDEST="`realpath $FB_PKGDEST`"
     240mkdir -p $FB_PKGDEST
    241241
    242242# unset special variables
     
    263263# retrieve sources
    264264msg "Retrieving sources..."
    265 mkdir -p $PKGDW
    266 cd $PKGDW
     265mkdir -p $FB_PKGDW
     266cd $FB_PKGDW
    267267
    268268for netfile in ${source[@]}; do
     
    272272                msg "    Found $file in sources dir"
    273273        else
    274                 [ -z "$FTPAGENT" ] && error "FTPAGENT is not configured."
    275                 ftpclient=`echo $FTPAGENT | awk {'print $1'}`
     274                [ -z "$FB_FTPAGENT" ] && error "FTPAGENT is not configured."
     275                ftpclient=`echo $FB_FTPAGENT | awk {'print $1'}`
    276276                [ -z "`which $ftpclient 2> /dev/null`" ] && error "ftpclient `basename $ftpclient` is not installed."
    277277
     
    281281
    282282                msg "    Downloading $file"
    283                 $FTPAGENT $netfile 2>&1
     283                $FB_FTPAGENT $netfile 2>&1
    284284                [ ! -f $file ] && error "Failed to download $file"
    285285        fi
     
    332332                case $file in
    333333                        *.tar.gz|*.tar.Z|*.tgz)
    334                                 cmd="tar --use-compress-program=gzip -xf $PKGDW/$file" ;;
     334                                cmd="tar --use-compress-program=gzip -xf $FB_PKGDW/$file" ;;
    335335                        *.tar.bz2)
    336                                 cmd="tar --use-compress-program=bzip2 -xf $PKGDW/$file" ;;
    337                         *.tar)  cmd="tar -xf $PKGDW/$file" ;;
    338                         *.zip)  unziphack=1; cmd="unzip -qqo $PKGDW/$file" ;;
    339                         *.gz)   cmd="zcat $PKGDW/$file > ${file%.gz}" ;;
    340                         *.bz2)  cmd="bzcat $PKGDW/$file > ${file%.bz2}" ;;
    341                         *)      cmd="cp $PKGDW/$file ${file}" ;;
     336                                cmd="tar --use-compress-program=bzip2 -xf $FB_PKGDW/$file" ;;
     337                        *.tar)  cmd="tar -xf $FB_PKGDW/$file" ;;
     338                        *.zip)  unziphack=1; cmd="unzip -qqo $FB_PKGDW/$file" ;;
     339                        *.gz)   cmd="zcat $FB_PKGDW/$file > ${file%.gz}" ;;
     340                        *.bz2)  cmd="bzcat $FB_PKGDW/$file > ${file%.bz2}" ;;
     341                        *)      cmd="cp $FB_PKGDW/$file ${file}" ;;
    342342                esac
    343343
  • pkgtools/upgradepkg

    • Property mode changed from 120000 to 100755
    raefabac rbecab57  
    1 installpkg
     1#!/bin/sh
     2#
     3# installpkg
     4# Simple tool which installs and upgrades Lintrack packages
     5#
     6# This file is licensed under GNU GPL 2.
     7# Copyright (C) 2006-2007 Pawel Foremski <pjf@asn.pl>
     8# Copyright (C) 2006-2007 Michal Wrobel <xmxwx@asn.pl>
     9#
     10# TODO: check portability
     11#
     12
     13# paths
     14if [ "$FAKEBOX" = "1" ]; then
     15        ROOTDIR="$FB_TOP/$FB_ROOTFS"
     16        VARDIR="$ROOTDIR/var/pkg"
     17        # XXX: assumes cwd is the root dir
     18        shell() { sudo /usr/sbin/chroot . /bin/sh "$@"; }
     19        ldconfig() { sudo /usr/sbin/chroot . /sbin/ldconfig "$@"; }
     20        depmod() { sudo /usr/sbin/chroot . /sbin/depmod "$@"; }
     21else
     22        ROOTDIR=/
     23        VARDIR=/var/pkg
     24        shell() { /bin/sh "$@"; }
     25        ldconfig() { /sbin/ldconfig "$@"; }
     26        depmod() { /sbin/depmod "$@"; }
     27fi
     28
     29# variables
     30unset big filelist runpost exclude pkg_opt
     31
     32# remove temporary files that this script could have created
     33cleanup()
     34{
     35        rm -f $ROOTDIR/.* 2> /dev/null
     36}
     37
     38# check cl arguments
     39[ -z "$1" ] && { echo "Usage: $0 package.pkg.tar.gz [<rootdir>]" >&2; exit 1; }
     40[ -f "$1" ] || { echo "$1: no such file" >&2; exit 1; }
     41
     42if [ -n "$2" ]; then
     43        ROOTDIR="`readlink -f $2`"
     44        VARDIR="$ROOTDIR/var/pkg"
     45fi
     46
     47# get basic information about the package
     48cd `dirname $1` || exit 1
     49pkgdir=`pwd`
     50pkglname="`basename $1`"
     51pkg="$pkgdir/$pkglname"
     52
     53# switch operation mode
     54case "`basename $0`" in
     55        installpkg) mode="install"; title="Installing"; call="install";;
     56        upgradepkg) mode="upgrade"; title="Upgrading";  call="upgrade";;
     57        *) echo "Call me as installpkg/upgradepkg"; exit 1;;
     58esac
     59
     60# start
     61echo "${title}: $pkglname"
     62mkdir -p $ROOTDIR && cd $ROOTDIR || exit 1
     63
     64# extract package information from filename
     65set -- `echo "$pkglname" | sed -re 's/^(.*)-(.*)-([0-9]+)-([0-9]+).*/\1 \2 \3 \4/g'`
     66echo "$pkglname" | grep -q '\-big.pkg.tar.gz' && big="1"
     67
     68if { [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ] || [ -z "$4" ]; }; then
     69        echo "pkg: '$pkglname' is not a valid Lintrack 2.1+ package"
     70        cleanup; exit 1
     71fi >&2
     72
     73pkgname="$1"
     74fixrel="$4"
     75pkgver="$2-$3-$fixrel"
     76
     77# check if user is not dumb
     78if [ "$mode" = "upgrade" ]; then
     79        if [ ! -f "$VARDIR/$pkgname/installed" ]; then # check if package is already installed
     80                echo "pkg: package '$pkgname' is not installed: cannot upgrade"
     81                cleanup; exit 1
     82        elif [ $fixrel -gt 1 ]; then
     83                # check if installed "bigness" matches this from the fixrel package
     84                if [ -f "$VARDIR/$pkgname/big" ]; then
     85                        [ "$big" != "1" ] && { echo "pkg: you should use a -big fixrel package"; cleanup; exit 1; }
     86                else
     87                        [ "$big" = "1" ] && { echo "pkg: you should NOT use a -big fixrel package"; cleanup; exit 1; }
     88                fi
     89
     90                # check if all fixrels up to $fixrel have already been installed
     91                ifixrel="`cat $VARDIR/$pkgname/installed | egrep -o '[0-9]+$'`"
     92                if [ $((fixrel-1)) -ne $ifixrel ]; then
     93                        echo "pkg: you need to install the fixrel=$((fixrel-1)) version of '$pkgname' package first"
     94                        cleanup; exit 1
     95                fi
     96        fi
     97elif { [ "$mode" = "install" ] && [ $fixrel -gt 1 ]; }; then
     98        echo "pkg: '$pkglname' is a fixrel package for upgrades only: cannot install"
     99        cleanup; exit 1
     100fi >&2
     101
     102# run function preparing for operation to be carried
     103if { [ $fixrel -eq 1 ] && tar -xzf $pkg .INSTALL 2>/dev/null; }; then
     104        shell .INSTALL pre_$call $pkgver || {
     105                echo "pkg: running 'pre_$call $pkgver' failed"
     106                cleanup; exit 1
     107        } >&2
     108        runpost=1
     109fi
     110
     111# if upgrading, store current permissions of all files from the target package
     112if [ "$mode" = "upgrade" ]; then
     113        echo "Storing permissions"
     114
     115        if [ $fixrel -eq 1 ]; then
     116                filelist="tar -Oxzf $pkg .FILELIST"
     117        else
     118                filelist="cat $VARDIR/$pkgname/FILELIST"
     119        fi
     120
     121        $filelist 2>/dev/null | while read file; do
     122                [ -e "$file" ] && stat -c "%a %n" $file
     123        done > .PERMISSIONS
     124
     125        # and make sure that /etc/fc won't be bothered, except if it's a fixrel
     126        [ $fixrel -eq 1 ] && exclude='etc/fc\netc/fc/*'
     127        pkg_opt='--keepfc'
     128fi
     129
     130# if package is already installed, remove the old one first
     131if { [ -f "$VARDIR/$pkgname/installed" ] && [ $fixrel -eq 1 ]; }; then
     132        # pkg is supposed to be in the same dir as installpkg
     133        `dirname $0`/pkg remove $pkg_opt "$pkgname"
     134fi
     135
     136# unpack new files
     137echo "Untarring new package"
     138echo -e "$exclude" | tar -X - -xzf $pkg || {
     139        echo "pkg: couldn't extract package contents"
     140        cleanup; exit 1
     141} >&2
     142
     143# restore permissions, if needed
     144if [ "$mode" = "upgrade" ]; then
     145        echo "Restoring permissions"
     146        cat .PERMISSIONS | while read file; do
     147                set -- $file
     148                p="$1"; shift
     149                chmod "$p" "$*"
     150        done
     151fi
     152
     153if [ $fixrel -eq 1 ]; then
     154        filelist=".FILELIST"
     155else
     156        filelist="$VARDIR/$pkgname/FILELIST"
     157fi
     158
     159# check if ldconfig should be run
     160if egrep -v '^lib/modules' $filelist | egrep -q 'lib/.+'; then
     161        echo "Calling ldconfig"
     162        ldconfig ${FAKEBOX:+-r $FB_TOP/$FB_ROOTFS} 2>/dev/null || echo "pkg: WARNING: ldconfig failed" >&2
     163fi
     164
     165# check if we should update module dependencies
     166if egrep -q '^lib/modules' $filelist; then
     167        # fetch full kernel version string
     168        ver="`egrep -m1 '^lib/modules/[0-9]\.[0-9]\..*/$' $filelist | sed -re 's;.*/([^/]*)/$;\1;'`"
     169
     170        echo "Calling depmod $ver"
     171        depmod -a $ver || echo "pkg: WARNING: depmod failed!" >&2
     172fi
     173
     174if [ $fixrel -eq 1 ]; then
     175        # run post-function, if needed
     176        if [ "$runpost" = 1 ]; then
     177                shell .INSTALL post_$call $pkgver || {
     178                        echo "pkg: running 'post_$call $pkgver' failed"
     179                        echo "pkg: WARNING: igoring this error"
     180                } >&2
     181        fi
     182
     183        # register new package in database
     184        mkdir -p "$VARDIR/$pkgname"
     185        cd "$VARDIR/$pkgname" || { echo "pkg: couldn't register package in database"; cleanup; exit 1; }
     186
     187        echo "$pkgver" > installed
     188        if [ -n "$big" ]; then touch big; else rm -f big; fi
     189        mv -f $ROOTDIR/.PKGINFO PKGINFO
     190        mv -f $ROOTDIR/.FILELIST FILELIST
     191else
     192        # run .FIX
     193        if tar -xzf $pkg .FIX 2>/dev/null; then
     194                shell .FIX || { echo "pkg: running .FIX script failed"; cleanup; exit 1; }
     195        fi
     196
     197        # update version information in database
     198        cd "$VARDIR/$pkgname" || { echo "pkg: couldn't update package information"; cleanup; exit 1; }
     199        echo "$pkgver" > installed
     200fi
     201
     202cleanup
     203exit 0
     204
     205# vim: tw=120
  • pkgtools/upgradepkg-0.2

    • Property mode changed from 120000 to 100755
    raefabac rbecab57  
    1 installpkg-0.2
     1#!/bin/bash
     2#
     3# installpkglocal
     4# Simple tool which installs package locally
     5#
     6# This file is licensed under GNU GPL 2, for full license text see file
     7# called "COPYING" in main distribution directory
     8#
     9
     10readonly VARDIR=var/pkg
     11
     12[ "$1" = "nosu" ] && { NOSU=1; shift; }
     13
     14[ -z "$1" ] && { echo "Usage: $0 package.pkg.tar.gz [ root_dir ]" >&2; exit 1; }
     15[ -f "$1" ] || { echo "$1: no such file" >&2; exit 1; }
     16
     17[ -z "$NOSU" ] && [ "`id -u`" != 0 ] && {
     18        if [ -n "`which su 2>/dev/null`" ]; then
     19                echo "You must be root to do that. Using su..." >&2
     20                su -c "sh $0 $*"
     21                exit $?
     22        else
     23                echo -n "Warning: no 'su' found, but required. [Enter] to continue, [Ctrl+C] to stop..."
     24                read foo
     25                NOSU=1
     26        fi
     27}
     28
     29cd `dirname $1` || exit 1
     30pkgdir=`pwd`
     31pkgname=`basename $1`
     32pkg="$pkgdir/$pkgname"
     33
     34case "`basename $0`" in
     35        installpkg|installpkg-0.2)
     36                title="Installing"
     37                call="install"
     38                ;;
     39        upgradepkg|upgradepkg-0.2)
     40                title="Upgrading"
     41                call="upgrade"
     42        ;;
     43        *)
     44                echo "Call me as installpkg/upgradepkg"
     45                exit 1
     46        ;;
     47esac
     48
     49rootdir="${2:-$FB_ROOTDIR}"
     50
     51echo "Installing $pkgname in $rootdir"
     52cd $OLDPWD || exit 1
     53cd $rootdir || exit 1
     54
     55tar -xzf $pkg .PKGINFO 2> /dev/null && {
     56        echo -n "Fetching package information: "
     57        . .PKGINFO 2>/dev/null
     58        echo "$pkgname $pkgver (build $builddate)"
     59}
     60
     61tar -xzf $pkg .INSTALL 2> /dev/null && {
     62        if [ "$NOSU" = "1" ]; then
     63                echo "WARNING: be sure to run pre_$call() and post_$call() functions from following file:"
     64                echo "---------------------------------------------------------------------------------------"
     65                cat .INSTALL
     66                echo "---------------------------------------------------------------------------------------"
     67        else
     68                echo "Running pre_$call in chroot `pwd`"
     69                /usr/sbin/chroot . /bin/bash .INSTALL pre_$call $pkgver || { echo "Error - aborting" >&2; exit 1; }
     70                runpostinstall=1
     71        fi
     72}
     73
     74echo "Extracting..."
     75tar -xzf $pkg || { echo "Error - aborting" >&2; exit 1; }
     76
     77[ "$runpostinstall" = 1 ] && {
     78        echo "Running post_$call in chroot `pwd`"
     79        /usr/sbin/chroot . /bin/bash .INSTALL post_$call $pkgver || echo "WARNING: ERROR" >&2
     80}
     81
     82echo "Registering package in local pkg database"
     83mkdir -p "$VARDIR/$pkgname"
     84echo "$pkgver" > "$VARDIR/$pkgname/installed"
     85cp -f .PKGINFO "$VARDIR/$pkgname/PKGINFO"
     86cp -f .FILELIST "$VARDIR/$pkgname/FILELIST"
     87
     88echo "Cleanup"
     89rm -f ./.* 2> /dev/null
     90
     91echo "Done"
Note: See TracChangeset for help on using the changeset viewer.