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\}-//' |
|
---|
12 | sed 's/^[0-9]\{1\}-//')
|
---|
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 | vim*|unzip*) local VERSION=$(echo $PCKGVRS | sed 's/^[^0-9]*\([0-9]\)\([0-9]\)/\1.\2/') ;;
|
---|
18 | tidy*) local VERSION=$(echo $PCKGVRS | sed 's/^[^0-9]*\([0-9]*\)/\1cvs/') ;;
|
---|
19 | docbook-xml) local VERSION=4.5 ;;
|
---|
20 | *) local VERSION=$(echo ${PCKGVRS} | sed 's/^.*[-_]\([0-9]\)/\1/');;
|
---|
21 | esac
|
---|
22 | local ARCHIVE_NAME=$(dirname ${PKGDIR})/${PACKAGE}_${VERSION}.deb
|
---|
23 | case $(uname -m) in
|
---|
24 | x86_64) local ARCH=amd64 ;;
|
---|
25 | *) local ARCH=i386 ;;
|
---|
26 | esac
|
---|
27 |
|
---|
28 | pushd $PKG_DEST
|
---|
29 | rm -fv ./usr/share/info/dir # recommended since this directory is already there
|
---|
30 | # on the system
|
---|
31 | # The next lines are specific to dpkg, but usually all pacakge managers
|
---|
32 | # need some information on the version and the package.
|
---|
33 | mkdir DEBIAN
|
---|
34 | cat > DEBIAN/control <<EOF
|
---|
35 | Package: $PACKAGE
|
---|
36 | Version: $VERSION
|
---|
37 | Maintainer: Pierre Labastie <lnimbus@club-internet.fr>
|
---|
38 | Description: $PACKAGE
|
---|
39 | Architecture: $ARCH
|
---|
40 | EOF
|
---|
41 | # Building the binary package
|
---|
42 | dpkg-deb -b . $ARCHIVE_NAME
|
---|
43 | # Installing it on LFS
|
---|
44 | dpkg -i $ARCHIVE_NAME
|
---|
45 | # Storing the package (recommended).
|
---|
46 | mv -v $ARCHIVE_NAME /var/lib/packages
|
---|
47 | popd # Since the $PKG_DEST directory is destroyed
|
---|
48 | # immediately after the return of the function,
|
---|
49 | # getting back to $PKGDIR is important...
|
---|
50 | }
|
---|