2015-01-18 17:58:24 +01:00
|
|
|
# $Id$
|
|
|
|
# function for packing and installing a tree. We only have access
|
|
|
|
# to variables PKGDIR and PKG_DEST
|
|
|
|
# Other variables can be passed on the command line, or in the environment
|
|
|
|
|
|
|
|
packInstall() {
|
|
|
|
|
|
|
|
# A proposed implementation for versions and package names.
|
|
|
|
local PCKGVRS=$(basename $PKGDIR)
|
|
|
|
local TGTPKG=$(basename $PKG_DEST)
|
2020-07-06 07:38:54 +02:00
|
|
|
local PACKAGE=$(echo ${TGTPKG} | sed 's/^[0-9]\{3,4\}-//' |
|
|
|
|
sed 's/^[0-9]\{2\}-//')
|
2015-01-18 17:58:24 +01:00
|
|
|
# version is only accessible from PKGDIR name. Since the format of the
|
|
|
|
# name is not normalized, several hacks are necessary...
|
|
|
|
case $PCKGVRS in
|
|
|
|
expect*|tcl*) local VERSION=$(echo $PCKGVRS | sed 's/^[^0-9]*//') ;;
|
2020-07-06 07:20:06 +02:00
|
|
|
unzip*) local VERSION=$(echo $PCKGVRS | sed 's/^[^0-9]*\([0-9]\)\([0-9]\)/\1.\2/') ;;
|
2015-01-18 17:58:24 +01:00
|
|
|
docbook-xml) local VERSION=4.5 ;;
|
|
|
|
*) local VERSION=$(echo ${PCKGVRS} | sed 's/^.*[-_]\([0-9]\)/\1/' |
|
|
|
|
sed 's/_/./g');;
|
|
|
|
# the last sed above is because some package managers do not want a '_'
|
|
|
|
# in version.
|
|
|
|
esac
|
|
|
|
case $(uname -m) in
|
|
|
|
x86_64) local ARCH=x86_64 ;;
|
|
|
|
*) local ARCH=i686 ;;
|
|
|
|
esac
|
|
|
|
local ARCHIVE_NAME=${PACKAGE}-${VERSION}-1-${ARCH}.pkg.tar.gz
|
|
|
|
|
|
|
|
pushd $PKG_DEST
|
|
|
|
rm -fv ./usr/share/info/dir # recommended since this directory is already there
|
|
|
|
# on the system
|
|
|
|
# Right now, we have the files in the current directory. They should be moved
|
|
|
|
# to /sources/$PACKAGE/src.
|
|
|
|
mkdir -p ../$PACKAGE/src
|
2020-07-07 17:27:54 +02:00
|
|
|
# We'll build as user builder. We need this directory to be owned by that user.
|
|
|
|
chown -R builder ../$PACKAGE
|
2015-01-18 17:58:24 +01:00
|
|
|
mv * ../$PACKAGE/src
|
2020-07-07 17:27:54 +02:00
|
|
|
chown -R builder $PKG_DEST
|
2020-07-06 07:38:54 +02:00
|
|
|
chmod -R o+r ../$PACKAGE
|
2015-01-18 17:58:24 +01:00
|
|
|
|
|
|
|
cat > PKGBUILD <<EOF
|
|
|
|
pkgname=( '$PACKAGE' )
|
|
|
|
pkgver=$VERSION
|
|
|
|
pkgrel=1
|
|
|
|
pkgdesc=$PACKAGE
|
|
|
|
arch=( '$ARCH' )
|
|
|
|
|
|
|
|
package() {
|
2020-07-06 07:38:54 +02:00
|
|
|
cp -a * \$pkgdir
|
2015-01-18 17:58:24 +01:00
|
|
|
}
|
|
|
|
EOF
|
|
|
|
# Building the binary package
|
2020-07-07 17:27:54 +02:00
|
|
|
su builder -c"PATH=$PATH; makepkg -c --skipinteg" || true
|
2015-01-18 17:58:24 +01:00
|
|
|
# Installing it on LFS
|
2020-07-06 07:38:54 +02:00
|
|
|
if ! pacman -U --noconfirm /var/lib/packages/$ARCHIVE_NAME; then
|
|
|
|
pacman -U --noconfirm --overwrite '*' /var/lib/packages/$ARCHIVE_NAME
|
2015-01-18 17:58:24 +01:00
|
|
|
fi
|
|
|
|
popd # Since the $PKG_DEST directory is destroyed
|
|
|
|
# immediately after the return of the function,
|
|
|
|
# getting back to $PKGDIR is important...
|
|
|
|
}
|