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