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