Changeset d70d2bd


Ignore:
Timestamp:
09/24/09 16:31:30 (10 years ago)
Author:
Paweł Foremski <pjf@…>
Branches:
master
Children:
a9ed2b6
Parents:
becab57
Message:

general update, new env vars, etc.

Files:
10 edited

Legend:

Unmodified
Added
Removed
  • bashrc

    rbecab57 rd70d2bd  
    66
    77# notify user he's in fakebox mode
    8 export PS1="\[\033[01;31m\]\u@$FB_NAME\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ "
     8export PS1="\[\033[01;31m\]\u@$FB_TARGET\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ "
    99
    1010# make his life bit easier ;-)
  • fakebox

    rbecab57 rd70d2bd  
    2525#
    2626
    27 config="${1:-./fakebox.conf}"
    28 if [[ -d "$config" ]]; then
    29         config="$config/fakebox.conf"
    30         # FIXME: read all *.conf and export
    31 fi
     27export FB_TOP="$PWD"
    3228
    33 if [[ ! -f "$config" ]]; then
    34         echo "Error: configuration file not found: $config" >&2
     29[[ -z "$1" ]] && { cat <<-EOF
     30        Usage: fakebox <target> [-fr]
     31       
     32        Options:
     33                -f                  force binfmt_misc register, even if already done
     34                -r                  exit after registering binfmt_misc
     35        EOF
    3536        exit 1
    36 fi
     37} >&2
    3738
    38 [[ "$2" = "-f" ]] && register="1"
     39sudo_used=
     40function asroot()
     41{
     42        if [[ $UID -ne 0 ]]; then
     43                if [[ -z asroot_used ]]; then
     44                        cat <<-EOF
     45                        Warning: binfmt_misc not fully registered and you are not root
     46                                 I'll try to use sudo, but if this fails, run me as root with -r and then again as $USER
     47                        EOF
     48                        sudo_used=1
     49                fi >&2
    3950
    40 ###
    41 ### configuration
    42 ###
     51                sudo "$@"
     52                return $?
     53        else
     54                "$@"
     55                return $?
     56        fi
     57}
    4358
    44 FB_TOP="$PWD"
     59### CLI args
     60export FB_TARGET="`basename $1`"
     61shift
    4562
    46 # load config
    47 source $config
     63while [[ -n "$1" ]]; do
     64        case "$1" in
     65                "-f") register=1;;
     66                "-r") exit_after_register=1;;
     67                   *) echo "Invalid option: $1" >&2; exit 1;;
     68        esac
     69        shift
     70done
    4871
    49 # load local config changes
    50 [ -f "$config.local" ] && source "$config.local"
     72### target config
     73for i in $FB_TOP/$FB_TARGET/*.conf; do
     74        echo "Loading $FB_TARGET/`basename $i`"
     75        source $i
     76done
    5177
    52 # FIXME: export loaded vars
     78### our variables, defaults
     79FB_WRAP="${FB_WRAP:-$FB_TOOLCHAIN/bin/$FB_PREFIX}"
     80FB_DEBUG=${FB_DEBUG:-0}
     81FB_BINFMT_QEMUWRAP="${FB_BINFMT_QEMUWRAP:-$FB_TOP/fakebox/wrappers/qemuwrap}"
    5382
    54 ###
    55 ### defaults
    56 ###
    57 
    58 # absolute paths to toolchain and virtual root
    59 FB_TOOLCHAIN=${FB_TOOLCHAIN:-$FB_TOP/toolchain}
    60 FB_ROOTFS=${FB_ROOTFS:-$FB_TOP/rootfs}
    61 
    62 # wrapper prefix
    63 FB_WRAP="${FB_WRAP:-$FB_TOP/$FB_TOOLCHAIN/bin/$FB_PREFIX}"
    64 
    65 # path to fakebox (FIXME)
    66 FB_PATH=${FB_PATH:-$FB_TOP/fakebox}
    67 
    68 # id displayed in bash prompt
    69 FB_NAME=${FB_NAME:-fakebox}
    70 
    71 export FB_TOOLCHAIN FB_ROOTFS FB_WRAP FB_TOP FB_PATH FB_NAME
    72 
    73 # path (FIXME?)
    74 if [ -z "$FB_LEAVE_PATH" ]; then
    75         PATH="$FB_PATH/wrappers:$FB_PATH/pkgtools"
    76         PATH="$PATH:$FB_TOP/$FB_TOOLCHAIN/bin"
    77 #       PATH="$PATH:$FB_TOP/$FB_ROOTFS/bin:$FB_TOP/$FB_ROOTFS/usr/bin"
    78 #       PATH="$PATH:$FB_TOP/$FB_ROOTFS/sbin:$FB_TOP/$FB_ROOTFS/usr/sbin"
     83if [[ -z "$FB_LEAVE_PATH" ]]; then
     84        PATH="$FB_PATH:$FB_TOP/bin:$FB_TOP/fakebox/wrappers:$FB_TOP/fakebox/pkgtools"
     85        PATH="$PATH:$FB_TOOLCHAIN/bin"
     86#       PATH="$PATH:$FB_ROOTFS/bin:$FB_ROOTFS/usr/bin:$FB_ROOTFS/sbin:$FB_ROOTFS/usr/sbin"
    7987        PATH="$PATH:$HOME/bin:$HOME/local/bin:/usr/local/bin:/usr/local/sbin"
    8088        PATH="$PATH:/usr/bin:/usr/sbin:/bin:/sbin"
    81 
    82         [ -d "$FB_TOP/bin" ] && PATH="$PATH:$FB_TOP/bin"
    83 
    84         export PATH
    8589fi
    8690
    8791# hack for c preprocessor in some weird toolchains
    88 export CPP="cpp"
     92CPP="cpp"
    8993
    9094# for autotools?
    91 export CARCH="$FB_QEMU"
    92 export CHOST="$FB_PREFIX"
     95CARCH="$FB_QEMU"
     96CHOST="$FB_PREFIX"
    9397
    9498# magic flag
    95 export FAKEBOX=1
     99FAKEBOX=1
    96100
    97 ###
    98 ### pkg tools
    99 ###
    100 source ${FB_MAKEPKG_CONF:-makepkg.conf}
     101### Export VARIABLES
     102vars=( `set | sed -re '/^[A-Z][A-Z0-9_]*=/!d' -e 's;=.*;;g'` )
     103export "${vars[@]}"
    101104
    102 ###
    103 ### qemu
    104 ###
    105 
    106 if [ -n "$FB_QEMU" ]; then
     105### get binfmt_misc details
     106if [[ -n "$FB_QEMU" ]]; then
    107107        # 0x7f, ELF, \0, { 1 - LE, 2 - BE }, 12 x 0x00, 2-byte arch ID in given endianness
    108108        # XXX: below supports big-endians only
     
    124124fi
    125125
    126 if [ $notsupported -eq 0 ]; then
     126### try loading
     127if [[ $notsupported -eq 0 ]] ; then
    127128        # check if binfmt_misc is already loaded
    128         if [ ! -e /proc/sys/fs/binfmt_misc/register ]; then
    129                 echo "Using sudo to load and init binfmt_misc module"
    130                 sudo modprobe binfmt_misc || exit 1
    131                 sudo mount -t binfmt_misc none /proc/sys/fs/binfmt_misc || exit 1
     129        if [[ ! -e /proc/sys/fs/binfmt_misc/register ]] ; then
     130                asroot modprobe binfmt_misc || exit 1
     131                asroot mount -t binfmt_misc none /proc/sys/fs/binfmt_misc || exit 1
    132132        fi
    133133
    134134        # remove any existing registration with the same magic
    135135        for f in /proc/sys/fs/binfmt_misc/*; do
    136                 [ "`basename $f`" != "register" ] || continue
    137                 { [ "$register" = "1" ] || [ "`basename $f`" != "fakebox-$FB_QEMU" ]; } || continue
    138                 [ -e "$f" ] || exit 1
     136                [[ -e "$f" ]] || continue
     137                name="`basename $f`"
     138
     139                [[ "$name" = "register" ]] && continue
     140                { [[ "$register" != "1" ]]  && [[ "$name" = "fakebox-$FB_QEMU" ]]; } && continue
     141
    139142                grep -q "magic $MAGIC_PLAIN" $f || continue
    140143                grep -q "mask $MASK_PLAIN" $f || continue
    141                 echo -e "\nWarning: Removing existing binfmt_misc wrapper: `basename $f` (using sudo)"
    142                 echo "-1" | sudo dd of=$f status=noxfer || exit 1
     144
     145                echo -e "\nWarning: Removing existing binfmt_misc wrapper: $name"
     146                echo "-1" | asroot dd of=$f status=noxfer || exit 1
    143147        done
    144148
    145         if [ ! -f /proc/sys/fs/binfmt_misc/fakebox-$FB_QEMU ]; then
    146                 [ "`id -u`" != "0" ] && \
    147                         echo -e "\nWarning: Using sudo to register $FB_QEMU qemu wrapper"
     149        if [[ ! -f /proc/sys/fs/binfmt_misc/fakebox-$FB_QEMU ]] ; then
     150                # register us XXX: no 2>/dev/null for dd's crappy msgs in order to see errors
     151                echo "Registering fakebox-$FB_QEMU in binfmt_misc"
     152                echo ":fakebox-$FB_QEMU:M:0:$MAGIC:$MASK:$FB_BINFMT_QEMUWRAP:" \
     153                        | asroot dd of=/proc/sys/fs/binfmt_misc/register status=noxfer || exit 1
    148154
    149                 # register us
    150                 # XXX: no 2>/dev/null for dd's crappy msgs in order to see errors
    151                 echo "Registering fakebox-$FB_QEMU in binfmt_misc"
    152                 {
    153                         echo -n ":fakebox-$FB_QEMU:M:0:$MAGIC:$MASK:"
    154                         if [ -e "/usr/lib/fakebox-qemuwrap:" ]; then
    155                                 echo "/usr/lib/fakebox-qemuwrap:"
    156                         else
    157                                 echo "$FB_PATH/wrappers/qemuwrap:"
    158                         fi
    159                 } | sudo dd of=/proc/sys/fs/binfmt_misc/register status=noxfer || exit 1
    160 
    161                 if [ -e /proc/sys/vm/mmap_min_addr ]; then
     155                if [[ -e /proc/sys/vm/mmap_min_addr ]] ; then
    162156                        echo "Fixing mmap bug"
    163                         echo 4096 | sudo dd of=/proc/sys/vm/mmap_min_addr status=noxfer || exit 1
     157                        echo 4096 | asroot dd of=/proc/sys/vm/mmap_min_addr status=noxfer || exit 1
    164158                fi
    165159        fi
     160else
     161        echo "Warning: qemu emulation not loaded"
    166162fi
    167163
     
    170166###
    171167
    172 # run shell
    173 /bin/bash --noprofile --rcfile "${FB_BASHRC:-$FB_PATH/bashrc}"
     168if [[ "$exit_after_register" = "1" ]]; then
     169        echo "Registration done"
     170        exit 0
     171else
     172        /bin/bash --noprofile --rcfile "${FB_BASHRC:-$FB_TOP/fakebox/bashrc}"
     173fi
  • pkgtools/genmd5

    rbecab57 rd70d2bd  
    33# genmd5, part of Arch Linux's makepkg
    44#
    5 # Copyright (C):
    6 #       2002-2004 by Judd Vinet <jvinet@zeroflux.org> (Arch Linux)
    7 #       2005-2007 by Pawel Foremski <pjf@asn.pl> (Lintrack)
    8 #       2005 by Dawid Ciezarkiewicz <arael@asn.pl> (Lintrack)
     5# Copyright (C) 2002-2004 Judd Vinet <jvinet@zeroflux.org>
     6# Copyright (C) 2005-2009 ASN Sp. z o.o.
     7#
     8# Authors: Pawel Foremski <pjf@asn.pl>
     9#          Michał Wróbel <maw@asn.pl>
    910#
    1011# This program is free software; you can redistribute it and/or modify
  • pkgtools/genpkglist

    rbecab57 rd70d2bd  
    44# needed by Lintrack package repositories
    55#
    6 # Copyright (C) 2006-2007 by Pawel Foremski <pjf@asn.pl>
    7 # Copyright (C) 2006-2007 by Michal Wrobel <xmxwx@asn.pl>
     6# Copyright (C) 2006-2009 ASN Sp. z o.o.
     7#
     8# Authors: Pawel Foremski <pjf@asn.pl>
     9#          Michal Wrobel <xmxwx@asn.pl>
    810#
    911# This program is free software; you can redistribute it and/or modify it under
  • pkgtools/installpkg

    rbecab57 rd70d2bd  
    55#
    66# 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
     7# Copyright (C) 2006-2009 ASN Sp. z o.o.
     8#
     9# Authors: Pawel Foremski <pjf@asn.pl>
     10#          Michal Wrobel <xmxwx@asn.pl>
    1111#
    1212
  • pkgtools/pkg

    rbecab57 rd70d2bd  
    33# pkg - manages Lintrack packages
    44#
    5 # Copyright (C) 2006-2007 by Pawel Foremski <pjf@asn.pl>
    6 # Copyright (C) 2006-2007 by Michal Wrobel <xmxwx@asn.pl>
     5# Copyright (C) 2006-2009 ASN Sp. z o.o.
     6#
     7# Authors: Pawel Foremski <pjf@asn.pl>
     8#          Michał Wróbel <maw@asn.pl>
    79#
    810# This program is free software; you can redistribute it and/or modify it under
     
    2426
    2527if [ "$FAKEBOX" = "1" ]; then
    26         ROOTDIR=$FB_TOP/$FB_ROOTFS
     28        ROOTDIR=$FB_ROOTFS
    2729        SHELL="sudo /usr/sbin/chroot . /bin/sh"
    2830else
  • pkgtools/upgradepkg

    • Property mode changed from 100755 to 120000
    rbecab57 rd70d2bd  
    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
    14 if [ "$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 "$@"; }
    21 else
    22         ROOTDIR=/
    23         VARDIR=/var/pkg
    24         shell() { /bin/sh "$@"; }
    25         ldconfig() { /sbin/ldconfig "$@"; }
    26         depmod() { /sbin/depmod "$@"; }
    27 fi
    28 
    29 # variables
    30 unset big filelist runpost exclude pkg_opt
    31 
    32 # remove temporary files that this script could have created
    33 cleanup()
    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 
    42 if [ -n "$2" ]; then
    43         ROOTDIR="`readlink -f $2`"
    44         VARDIR="$ROOTDIR/var/pkg"
    45 fi
    46 
    47 # get basic information about the package
    48 cd `dirname $1` || exit 1
    49 pkgdir=`pwd`
    50 pkglname="`basename $1`"
    51 pkg="$pkgdir/$pkglname"
    52 
    53 # switch operation mode
    54 case "`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;;
    58 esac
    59 
    60 # start
    61 echo "${title}: $pkglname"
    62 mkdir -p $ROOTDIR && cd $ROOTDIR || exit 1
    63 
    64 # extract package information from filename
    65 set -- `echo "$pkglname" | sed -re 's/^(.*)-(.*)-([0-9]+)-([0-9]+).*/\1 \2 \3 \4/g'`
    66 echo "$pkglname" | grep -q '\-big.pkg.tar.gz' && big="1"
    67 
    68 if { [ -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
    71 fi >&2
    72 
    73 pkgname="$1"
    74 fixrel="$4"
    75 pkgver="$2-$3-$fixrel"
    76 
    77 # check if user is not dumb
    78 if [ "$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
    97 elif { [ "$mode" = "install" ] && [ $fixrel -gt 1 ]; }; then
    98         echo "pkg: '$pkglname' is a fixrel package for upgrades only: cannot install"
    99         cleanup; exit 1
    100 fi >&2
    101 
    102 # run function preparing for operation to be carried
    103 if { [ $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
    109 fi
    110 
    111 # if upgrading, store current permissions of all files from the target package
    112 if [ "$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'
    128 fi
    129 
    130 # if package is already installed, remove the old one first
    131 if { [ -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"
    134 fi
    135 
    136 # unpack new files
    137 echo "Untarring new package"
    138 echo -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
    144 if [ "$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
    151 fi
    152 
    153 if [ $fixrel -eq 1 ]; then
    154         filelist=".FILELIST"
    155 else
    156         filelist="$VARDIR/$pkgname/FILELIST"
    157 fi
    158 
    159 # check if ldconfig should be run
    160 if 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
    163 fi
    164 
    165 # check if we should update module dependencies
    166 if 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
    172 fi
    173 
    174 if [ $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
    191 else
    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
    200 fi
    201 
    202 cleanup
    203 exit 0
    204 
    205 # vim: tw=120
     1installpkg
  • pkgtools/upgradepkg-0.2

    • Property mode changed from 100755 to 120000
    rbecab57 rd70d2bd  
    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 
    10 readonly 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 
    29 cd `dirname $1` || exit 1
    30 pkgdir=`pwd`
    31 pkgname=`basename $1`
    32 pkg="$pkgdir/$pkgname"
    33 
    34 case "`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         ;;
    47 esac
    48 
    49 rootdir="${2:-$FB_ROOTDIR}"
    50 
    51 echo "Installing $pkgname in $rootdir"
    52 cd $OLDPWD || exit 1
    53 cd $rootdir || exit 1
    54 
    55 tar -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 
    61 tar -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 
    74 echo "Extracting..."
    75 tar -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 
    82 echo "Registering package in local pkg database"
    83 mkdir -p "$VARDIR/$pkgname"
    84 echo "$pkgver" > "$VARDIR/$pkgname/installed"
    85 cp -f .PKGINFO "$VARDIR/$pkgname/PKGINFO"
    86 cp -f .FILELIST "$VARDIR/$pkgname/FILELIST"
    87 
    88 echo "Cleanup"
    89 rm -f ./.* 2> /dev/null
    90 
    91 echo "Done"
     1installpkg-0.2
  • wrappers/qemuwrap

    rbecab57 rd70d2bd  
    55
    66[ "$FB_DEBUG" = "3" ] && echo " [FB] qemu: $@" >&2
    7 ${FB_QEMU_PATH:-qemu}-$FB_QEMU -L "$FB_TOP/$FB_ROOTFS" "$@"
     7${FB_QEMU_PATH:-qemu}-$FB_QEMU -L "$FB_ROOTFS" "$@"
  • wrappers/wrapper

    rbecab57 rd70d2bd  
    88ME="`basename $0`"
    99
    10 [ -n "$FB_DEBUG" ] || FB_DEBUG=0
    11 [ $FB_DEBUG -ge 1 ] && echo " [FB]  called: $ME $@" >&2
     10[[ $FB_DEBUG -ge 1 ]] && echo " [FB]  called: $ME $@" >&2
    1211
    1312# hacks
    14 [ "$FB_OFF" = "1" ] && exec "/usr/bin/$ME" "$@"
    15 [ "$ME" = "strip" ] && exec "$FB_WRAP-$ME" "$@"
    16 [ "$ME" = "cc" ] && ME=gcc
     13[[ "$FB_OFF" = "1" ]] && exec "/usr/bin/$ME" "$@"
     14[[ "$ME" = "strip" ]] && exec "$FB_WRAP-$ME" "$@"
     15[[ "$ME" = "cc" ]] && ME=gcc
    1716
    1817# prefix absolute /usr paths with $FB_TOP
     
    2423
    2524# handle special cases
    26 [ "$1" = "-V" ] || case "$ME" in
     25[[ "$1" = "-V" ]] || case "$ME" in
    2726        gcc|g++|ld|cpp|cc)
    28                 if [ "$FB_USE_SYSROOT_OPT" = "1" ]; then
    29                         args[${#args[@]}]="--sysroot=$FB_ROOTDIR"
     27                if [[ "$FB_USE_SYSROOT_OPT" = "1" ]]; then
     28                        args[${#args[@]}]="--sysroot=$FB_ROOTFS"
    3029                else
    31                         args[${#args[@]}]="-I$FB_ROOTDIR/usr/include"
    32                         args[${#args[@]}]="-L$FB_ROOTDIR/lib"
    33                         args[${#args[@]}]="-L$FB_ROOTDIR/usr/lib"
     30                        args[${#args[@]}]="-I$FB_ROOTFS/usr/include"
     31                        args[${#args[@]}]="-L$FB_ROOTFS/lib"
     32                        args[${#args[@]}]="-L$FB_ROOTFS/usr/lib"
    3433                        FB_WRAP_ADD="$FB_WRAP_ADD_GCC_LD"
    3534                fi
     
    3837
    3938# exec proper tool
    40 [ $FB_DEBUG -ge 2 ] && echo " [FB]  result: $FB_WRAP-$ME" "${args[@]}" $FB_WRAP_ADD >&2
     39[[ $FB_DEBUG -ge 2 ]] && echo " [FB]  result: $FB_WRAP-$ME" "${args[@]}" $FB_WRAP_ADD >&2
    4140exec "$FB_WRAP-$ME" "${args[@]}" $FB_WRAP_ADD
Note: See TracChangeset for help on using the changeset viewer.