[bd00951] | 1 | # function for packing and installing a tree. We only have access
|
---|
| 2 | # to variables PKGDIR and PKG_DEST
|
---|
| 3 | # Other variables can be passed on the command line, or in the environment
|
---|
| 4 |
|
---|
| 5 | packInstall() {
|
---|
| 6 |
|
---|
| 7 | # A proposed implementation for versions and package names.
|
---|
| 8 | local PCKGVRS=$(basename $PKGDIR)
|
---|
| 9 | local TGTPKG=$(basename $PKG_DEST)
|
---|
[3ac3ae1] | 10 | local PACKAGE=$(echo ${TGTPKG} | sed 's/^[0-9]\{3,4\}-//' |
|
---|
| 11 | sed 's/^[0-9]\{2\}-//')
|
---|
[bd00951] | 12 | # version is only accessible from PKGDIR name. Since the format of the
|
---|
| 13 | # name is not normalized, several hacks are necessary...
|
---|
| 14 | case $PCKGVRS in
|
---|
| 15 | expect*|tcl*) local VERSION=$(echo $PCKGVRS | sed 's/^[^0-9]*//') ;;
|
---|
[9593197] | 16 | unzip*) local VERSION=$(echo $PCKGVRS | sed 's/^[^0-9]*\([0-9]\)\([0-9]\)/\1.\2/') ;;
|
---|
[bd00951] | 17 | docbook-xml) local VERSION=4.5 ;;
|
---|
| 18 | *) local VERSION=$(echo ${PCKGVRS} | sed 's/^.*[-_]\([0-9]\)/\1/' |
|
---|
| 19 | sed 's/_/./g');;
|
---|
| 20 | # the last sed above is because some package managers do not want a '_'
|
---|
| 21 | # in version.
|
---|
| 22 | esac
|
---|
| 23 | case $(uname -m) in
|
---|
| 24 | x86_64) local ARCH=x86_64 ;;
|
---|
| 25 | *) local ARCH=i686 ;;
|
---|
| 26 | esac
|
---|
| 27 | local ARCHIVE_NAME=${PACKAGE}-${VERSION}-1-${ARCH}.pkg.tar.gz
|
---|
| 28 |
|
---|
| 29 | pushd $PKG_DEST
|
---|
| 30 | rm -fv ./usr/share/info/dir # recommended since this directory is already there
|
---|
| 31 | # on the system
|
---|
| 32 | # Right now, we have the files in the current directory. They should be moved
|
---|
[55e82d2] | 33 | # to /sources/$PACKAGE/src. Also, in case there was a failure before, clean
|
---|
| 34 | # /sources/$PACKAGE
|
---|
| 35 | rm -rf /sources/$PACKAGE
|
---|
| 36 | mkdir -p /sources/$PACKAGE/src
|
---|
| 37 |
|
---|
[3484658] | 38 | # We'll build as user builder. We need this directory to be owned by that user.
|
---|
[55e82d2] | 39 | chown -R builder /sources/$PACKAGE
|
---|
| 40 | mv * /sources/$PACKAGE/src
|
---|
[3484658] | 41 | chown -R builder $PKG_DEST
|
---|
[55e82d2] | 42 | chmod -R o+r /sources/$PACKAGE
|
---|
[bd00951] | 43 |
|
---|
| 44 | cat > PKGBUILD <<EOF
|
---|
| 45 | pkgname=( '$PACKAGE' )
|
---|
| 46 | pkgver=$VERSION
|
---|
| 47 | pkgrel=1
|
---|
| 48 | pkgdesc=$PACKAGE
|
---|
| 49 | arch=( '$ARCH' )
|
---|
| 50 |
|
---|
| 51 | package() {
|
---|
[3ac3ae1] | 52 | cp -a * \$pkgdir
|
---|
[bd00951] | 53 | }
|
---|
| 54 | EOF
|
---|
| 55 | # Building the binary package
|
---|
[3484658] | 56 | su builder -c"PATH=$PATH; makepkg -c --skipinteg" || true
|
---|
[bd00951] | 57 | # Installing it on LFS
|
---|
[3ac3ae1] | 58 | if ! pacman -U --noconfirm /var/lib/packages/$ARCHIVE_NAME; then
|
---|
| 59 | pacman -U --noconfirm --overwrite '*' /var/lib/packages/$ARCHIVE_NAME
|
---|
[bd00951] | 60 | fi
|
---|
| 61 | popd # Since the $PKG_DEST directory is destroyed
|
---|
| 62 | # immediately after the return of the function,
|
---|
| 63 | # getting back to $PKGDIR is important...
|
---|
| 64 | }
|
---|