2008-09-26 19:59:07 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2008-09-28 07:57:30 +00:00
|
|
|
# pkgfs - Builds source distribution files and stows/unstows them into
|
2008-09-28 08:36:43 +00:00
|
|
|
# a master directory, thanks to Xstow.
|
2008-09-26 22:19:02 +00:00
|
|
|
#
|
2008-09-26 21:23:41 +00:00
|
|
|
#-
|
|
|
|
# Copyright (c) 2008 Juan Romero Pardines.
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions
|
|
|
|
# are met:
|
|
|
|
# 1. Redistributions of source code must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer in the
|
|
|
|
# documentation and/or other materials provided with the distribution.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
#-
|
|
|
|
#
|
2008-09-26 19:59:07 +00:00
|
|
|
# TODO
|
2008-09-28 09:41:26 +00:00
|
|
|
# - Multiple distfiles in a package.
|
|
|
|
# - Multiple URLs to download source distribution files.
|
|
|
|
# - Support GNU/BSD-makefile style source distribution files.
|
|
|
|
# - Fix PKGFS_{C,CXX}FLAGS, aren't passed to the environment yet.
|
|
|
|
# - Support adding filters to templates to avoid creating useless links.
|
2008-09-26 19:59:07 +00:00
|
|
|
#
|
|
|
|
# Default path to configuration file, can be overriden
|
|
|
|
# via the environment or command line.
|
|
|
|
#
|
|
|
|
: ${PKGFS_CONFIG_FILE:=/usr/local/etc/pkgfs.conf}
|
2008-09-29 15:01:12 +00:00
|
|
|
: ${PKGFS_REGISTERED_PKG_DB:=.pkgfs-registered-pkgfs.db}
|
2008-09-26 19:59:07 +00:00
|
|
|
|
2008-09-27 01:17:12 +00:00
|
|
|
: ${progname:=$(basename $0)}
|
|
|
|
: ${topdir:=$(/bin/pwd -P 2>/dev/null)}
|
|
|
|
: ${fetch_cmd:=/usr/bin/ftp -a}
|
|
|
|
: ${cksum_cmd:=/usr/bin/cksum -a rmd160}
|
|
|
|
: ${awk_cmd:=/usr/bin/awk}
|
|
|
|
: ${mkdir_cmd:=/bin/mkdir -p}
|
|
|
|
: ${tar_cmd:=/usr/bin/tar}
|
|
|
|
: ${unzip_cmd:=/usr/pkg/bin/unzip}
|
|
|
|
: ${rm_cmd:=/bin/rm}
|
2008-09-28 05:12:07 +00:00
|
|
|
: ${mv_cmd:=/bin/mv}
|
|
|
|
: ${cp_cmd:=/bin/cp}
|
|
|
|
: ${sed_cmd=/usr/bin/sed}
|
|
|
|
: ${grep_cmd=/usr/bin/grep}
|
|
|
|
: ${gunzip_cmd:=/usr/bin/gunzip}
|
|
|
|
: ${bunzip2_cmd:=/usr/bin/bunzip2}
|
|
|
|
: ${patch_cmd:=/usr/bin/patch}
|
|
|
|
: ${find_cmd:=/usr/bin/find}
|
|
|
|
: ${file_cmd:=/usr/bin/file}
|
|
|
|
: ${ln_cmd:=/bin/ln}
|
|
|
|
: ${chmod_cmd:=/bin/chmod}
|
2008-09-29 15:01:12 +00:00
|
|
|
: ${db_cmd:=/usr/bin/db -q}
|
2008-10-01 23:38:12 +00:00
|
|
|
: ${chmod_cmd:=/bin/chmod}
|
2008-09-28 05:12:07 +00:00
|
|
|
|
|
|
|
: ${xstow_version:=xstow-0.6.1-unstable}
|
|
|
|
: ${xstow_args:=-ap}
|
2008-09-27 01:17:12 +00:00
|
|
|
|
2008-09-30 20:48:52 +00:00
|
|
|
set_defvars()
|
|
|
|
{
|
|
|
|
# Directories
|
|
|
|
: ${PKGFS_TEMPLATESDIR:=$PKGFS_DISTRIBUTIONDIR/templates}
|
|
|
|
: ${PKGFS_DEPSDIR:=$PKGFS_DISTRIBUTIONDIR/dependencies}
|
|
|
|
: ${PKGFS_TMPLHELPDIR:=$PKGFS_DISTRIBUTIONDIR/helper-templates}
|
|
|
|
|
|
|
|
local DDIRS="PKGFS_DEPSDIR PKGFS_TEMPLATESDIR PKGFS_TMPLHELPDIR"
|
|
|
|
for i in ${DDIRS}; do
|
|
|
|
if [ ! -d "$PKGFS_DEPSDIR" ]; then
|
|
|
|
echo "**** ERROR: cannot find $i, aborting ***"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2008-09-27 01:17:12 +00:00
|
|
|
usage()
|
|
|
|
{
|
2008-09-26 19:59:07 +00:00
|
|
|
cat << _EOF
|
2008-09-27 01:17:12 +00:00
|
|
|
$progname: [-bCef] [-c <config_file>] <target> <tmpl>
|
2008-09-26 19:59:07 +00:00
|
|
|
|
|
|
|
Targets
|
2008-09-27 01:17:12 +00:00
|
|
|
info Show information about <tmpl>.
|
2008-09-28 09:41:26 +00:00
|
|
|
install Build and install package from <tmpl>.
|
2008-09-29 22:45:25 +00:00
|
|
|
list Lists and prints short description about installed packages.
|
2008-09-28 09:41:26 +00:00
|
|
|
remove Remove package completely (unstow and remove from destdir)
|
2008-09-27 01:17:12 +00:00
|
|
|
stow Create symlinks from <tmpl> in master directory.
|
|
|
|
unstow Remove symlinks from <tmpl> in master directory.
|
2008-09-26 19:59:07 +00:00
|
|
|
|
|
|
|
Options
|
2008-09-27 01:17:12 +00:00
|
|
|
-b Only build the source distribution file(s).
|
2008-09-28 05:12:07 +00:00
|
|
|
-C Do not remove build directory after successful build.
|
2008-09-26 19:59:07 +00:00
|
|
|
-c Path to global configuration file.
|
|
|
|
If not specified /usr/local/etc/pkgfs.conf is used.
|
|
|
|
-e Only extract the source distribution file(s).
|
|
|
|
-f Only fetch the source distribution file(s).
|
|
|
|
|
|
|
|
_EOF
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
check_path()
|
|
|
|
{
|
2008-09-27 01:17:12 +00:00
|
|
|
eval local orig="$1"
|
2008-09-26 19:59:07 +00:00
|
|
|
|
|
|
|
case "$orig" in
|
|
|
|
/)
|
|
|
|
;;
|
|
|
|
/*)
|
|
|
|
orig="${orig%/}"
|
|
|
|
;;
|
|
|
|
*)
|
2008-09-27 01:17:12 +00:00
|
|
|
orig="$topdir/${orig%/}"
|
2008-09-26 19:59:07 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2008-09-27 01:17:12 +00:00
|
|
|
path_fixed="$orig"
|
2008-09-26 19:59:07 +00:00
|
|
|
}
|
|
|
|
|
2008-09-28 05:12:07 +00:00
|
|
|
run_file()
|
|
|
|
{
|
|
|
|
local file="$1"
|
|
|
|
|
|
|
|
check_path "$file"
|
|
|
|
. $path_fixed
|
|
|
|
}
|
|
|
|
|
2008-09-30 13:22:57 +00:00
|
|
|
#
|
|
|
|
# This function merges two GNU info dirs into one and puts the result
|
|
|
|
# into PKGFS_MASTERDIR/share/info/dir.
|
|
|
|
#
|
|
|
|
merge_infodir_tmpl()
|
|
|
|
{
|
|
|
|
local pkgname="$1"
|
|
|
|
local merge_info_cmd="$PKGFS_MASTERDIR/bin/merge-info"
|
|
|
|
|
|
|
|
[ -z "$pkgname" ] && return 1
|
|
|
|
[ ! -r "$PKGFS_MASTERDIR/share/info/dir" ] && return 1
|
|
|
|
[ ! -r "$PKGFS_DESTDIR/$pkgname/share/info/dir" ] && return 1
|
|
|
|
|
|
|
|
$merge_info_cmd -d $PKGFS_MASTERDIR/share/info/dir \
|
|
|
|
$PKGFS_DESTDIR/$pkgname/share/info/dir -o \
|
|
|
|
$PKGFS_MASTERDIR/share/info/dir.new
|
|
|
|
if [ "$?" -ne 0 ]; then
|
|
|
|
echo -n "*** WARNING: there was an error merging info dir from"
|
|
|
|
echo " $pkgname, aborting ***"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
$mv_cmd -f $PKGFS_MASTERDIR/share/info/dir.new \
|
|
|
|
$PKGFS_MASTERDIR/share/info/dir
|
|
|
|
}
|
|
|
|
|
2008-09-27 01:17:12 +00:00
|
|
|
info_tmpl()
|
2008-09-26 19:59:07 +00:00
|
|
|
{
|
2008-09-29 15:01:12 +00:00
|
|
|
local tmpl="$1"
|
2008-09-29 23:59:51 +00:00
|
|
|
if [ -z "$tmpl" -o ! -f "$PKGFS_TEMPLATESDIR/$tmpl.tmpl" ]; then
|
2008-09-30 04:14:17 +00:00
|
|
|
echo -n "*** ERROR: invalid template file \`$tmpl' ***"
|
2008-09-28 05:12:07 +00:00
|
|
|
echo ", aborting ***"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2008-09-29 23:59:51 +00:00
|
|
|
run_file ${PKGFS_TEMPLATESDIR}/${tmpl}.tmpl
|
2008-09-28 05:12:07 +00:00
|
|
|
|
2008-09-28 09:41:26 +00:00
|
|
|
echo " pkgfs template definitions:"
|
2008-09-26 19:59:07 +00:00
|
|
|
echo
|
|
|
|
echo " pkgname: $pkgname"
|
|
|
|
for i in "${distfiles}"; do
|
|
|
|
[ -n "$i" ] && echo " distfile: $i"
|
|
|
|
done
|
|
|
|
echo " URL: $url"
|
|
|
|
echo " maintainer: $maintainer"
|
2008-09-27 01:17:12 +00:00
|
|
|
[ -n $checksum ] && echo " checksum: $checksum"
|
2008-09-26 19:59:07 +00:00
|
|
|
echo " build_style: $build_style"
|
|
|
|
echo " short_desc: $short_desc"
|
|
|
|
echo "$long_desc"
|
2008-09-30 02:28:05 +00:00
|
|
|
echo
|
|
|
|
if [ -r "$PKGFS_DEPSDIR/$pkgname-deps.db" ]; then
|
|
|
|
pkgdepf="$PKGFS_DEPSDIR/$pkgname-deps.db"
|
|
|
|
list="$($db_cmd btree $pkgdepf deps)"
|
|
|
|
echo " This package requires the following dependencies to be built:"
|
|
|
|
for i in ${list}; do
|
|
|
|
[ "$i" = "deps" ] && continue
|
|
|
|
echo " $i"
|
|
|
|
done
|
|
|
|
fi
|
2008-09-27 01:17:12 +00:00
|
|
|
}
|
|
|
|
|
2008-09-28 05:12:07 +00:00
|
|
|
apply_tmpl_patches()
|
|
|
|
{
|
|
|
|
if [ -z "$PKGFS_TEMPLATESDIR" ]; then
|
|
|
|
echo -n "*** WARNING: PKGFS_TEMPLATESDIR is not set, "
|
|
|
|
echo "won't apply patches ***"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# If package needs some patches applied before building,
|
|
|
|
# apply them now.
|
|
|
|
#
|
|
|
|
if [ -n "$patch_files" ]; then
|
|
|
|
for i in ${patch_files}; do
|
|
|
|
patch="$PKGFS_TEMPLATESDIR/$i"
|
|
|
|
if [ ! -f "$patch" ]; then
|
|
|
|
echo "*** WARNING: unexistent patch '$i' ***"
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Try to guess if its a compressed patch.
|
|
|
|
if $(echo $patch|$grep_cmd -q .gz); then
|
|
|
|
$gunzip_cmd $patch
|
|
|
|
patch=${patch%%.gz}
|
|
|
|
elif $(echo $patch|$grep_cmd -q .bz2); then
|
|
|
|
$bunzip2_cmd $patch
|
|
|
|
patch=${patch%%.bz2}
|
|
|
|
elif $(echo $patch|$grep_cmd -q .diff); then
|
|
|
|
# nada
|
|
|
|
else
|
|
|
|
echo "*** WARNING: unknown patch type '$i' ***"
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2008-10-01 23:38:12 +00:00
|
|
|
cd $wrksrc && $patch_cmd < $patch 2>/dev/null
|
2008-09-28 05:12:07 +00:00
|
|
|
if [ "$?" -eq 0 ]; then
|
2008-09-30 20:48:52 +00:00
|
|
|
echo "=> Patch applied: \`$i'."
|
2008-09-28 05:12:07 +00:00
|
|
|
else
|
|
|
|
echo -n "*** ERROR: couldn't apply patch '$i'"
|
|
|
|
echo ", aborting ***"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2008-09-29 15:01:12 +00:00
|
|
|
check_config_vars()
|
2008-09-27 01:17:12 +00:00
|
|
|
{
|
2008-09-28 05:12:07 +00:00
|
|
|
run_file ${PKGFS_CONFIG_FILE}
|
2008-09-28 07:57:30 +00:00
|
|
|
PKGFS_CONFIG_FILE=$path_fixed
|
2008-09-28 05:12:07 +00:00
|
|
|
|
2008-09-28 07:57:30 +00:00
|
|
|
if [ ! -f "$PKGFS_CONFIG_FILE" ]; then
|
2008-09-27 16:20:46 +00:00
|
|
|
echo -n "*** ERROR: cannot find configuration file: "
|
2008-09-27 01:17:12 +00:00
|
|
|
echo "'$PKGFS_CONFIG_FILE' ***"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2008-09-27 16:20:46 +00:00
|
|
|
local PKGFS_VARS="PKGFS_MASTERDIR PKGFS_DESTDIR PKGFS_BUILDDIR \
|
2008-09-30 20:48:52 +00:00
|
|
|
PKGFS_SRCDISTDIR"
|
2008-09-27 01:17:12 +00:00
|
|
|
|
2008-09-27 16:20:46 +00:00
|
|
|
for f in ${PKGFS_VARS}; do
|
|
|
|
eval val="\$$f"
|
|
|
|
if [ -z "$val" ]; then
|
|
|
|
echo "**** ERROR: '$f' not set in configuration "
|
|
|
|
echo "file, aborting ***"
|
2008-09-27 01:17:12 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2008-09-29 15:01:12 +00:00
|
|
|
|
2008-09-27 16:20:46 +00:00
|
|
|
if [ ! -d "$f" ]; then
|
|
|
|
$mkdir_cmd "$val"
|
|
|
|
if [ "$?" -ne 0 ]; then
|
|
|
|
echo -n "*** ERROR: couldn't create '$f'"
|
|
|
|
echo "directory, aborting ***"
|
|
|
|
exit 1
|
|
|
|
fi
|
2008-09-27 01:17:12 +00:00
|
|
|
fi
|
2008-09-27 16:20:46 +00:00
|
|
|
done
|
2008-09-26 19:59:07 +00:00
|
|
|
}
|
|
|
|
|
2008-09-28 05:12:07 +00:00
|
|
|
reset_tmpl_vars()
|
|
|
|
{
|
|
|
|
local TMPL_VARS="pkgname extract_sufx distfiles url configure_args \
|
2008-09-28 09:41:26 +00:00
|
|
|
make_build_args make_install_args build_style \
|
|
|
|
short_desc maintainer long_desc checksum wrksrc \
|
2008-09-29 15:01:12 +00:00
|
|
|
patch_files configure_env make_cmd"
|
2008-09-28 05:12:07 +00:00
|
|
|
|
|
|
|
for i in ${TMPL_VARS}; do
|
2008-09-29 15:01:12 +00:00
|
|
|
eval unset "$i"
|
2008-09-28 05:12:07 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2008-09-27 16:20:46 +00:00
|
|
|
check_tmpl_vars()
|
2008-09-26 19:59:07 +00:00
|
|
|
{
|
2008-09-28 07:57:30 +00:00
|
|
|
local pkg="$1"
|
2008-09-27 01:17:12 +00:00
|
|
|
local dfile=""
|
2008-09-26 19:59:07 +00:00
|
|
|
|
2008-09-28 07:57:30 +00:00
|
|
|
[ -z "$pkg" ] && return 1
|
|
|
|
|
2008-09-27 01:17:12 +00:00
|
|
|
REQ_VARS="pkgname extract_sufx url build_style"
|
2008-09-26 19:59:07 +00:00
|
|
|
|
|
|
|
# Check if required vars weren't set.
|
2008-09-27 01:17:12 +00:00
|
|
|
for i in ${REQ_VARS}; do
|
|
|
|
eval val="\$$i"
|
|
|
|
if [ -z "$val" -o -z "$i" ]; then
|
|
|
|
echo -n "*** ERROR: $i not set (incomplete template"
|
|
|
|
echo " build file), aborting ***"
|
2008-09-26 19:59:07 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2008-09-28 05:12:07 +00:00
|
|
|
if [ -z "$distfiles" ]; then
|
|
|
|
dfile="$pkgname$extract_sufx"
|
|
|
|
elif [ -n "${distfiles}" ]; then
|
|
|
|
dfile="$distfiles$extract_sufx"
|
|
|
|
else
|
|
|
|
echo "*** ERROR unsupported fetch state ***"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2008-09-30 20:48:52 +00:00
|
|
|
dfile="$PKGFS_SRCDISTDIR/$dfile"
|
2008-09-28 05:12:07 +00:00
|
|
|
|
2008-09-26 19:59:07 +00:00
|
|
|
case "$extract_sufx" in
|
|
|
|
.tar.bz2|.tar.gz|.tgz|.tbz)
|
2008-09-28 05:12:07 +00:00
|
|
|
extract_cmd="$tar_cmd xfz $dfile -C $PKGFS_BUILDDIR"
|
2008-09-26 19:59:07 +00:00
|
|
|
;;
|
|
|
|
.tar)
|
2008-09-28 05:12:07 +00:00
|
|
|
extract_cmd="$tar_cmd xf $dfile -C $PKGFS_BUILDDIR"
|
2008-09-26 19:59:07 +00:00
|
|
|
;;
|
|
|
|
.zip)
|
2008-09-27 01:17:12 +00:00
|
|
|
extract_cmd="$unzip_cmd -x $dfile -C $PKGFS_BUILDDIR"
|
2008-09-26 19:59:07 +00:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo -n "*** ERROR: unknown 'extract_sufx' argument in build "
|
2008-09-26 21:39:29 +00:00
|
|
|
echo "file ***"
|
2008-09-26 19:59:07 +00:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
check_rmd160_cksum()
|
|
|
|
{
|
2008-09-28 07:57:30 +00:00
|
|
|
local file="$1"
|
|
|
|
|
|
|
|
[ -z "$file" ] && return 1
|
2008-09-26 19:59:07 +00:00
|
|
|
|
|
|
|
if [ -z "${distfiles}" ]; then
|
|
|
|
dfile="$pkgname$extract_sufx"
|
|
|
|
elif [ -n "${distfiles}" ]; then
|
|
|
|
dfile="$distfiles$extract_sufx"
|
|
|
|
else
|
2008-09-28 07:57:30 +00:00
|
|
|
dfile="$file$extract_sufx"
|
2008-09-26 19:59:07 +00:00
|
|
|
fi
|
|
|
|
|
2008-09-29 20:51:08 +00:00
|
|
|
if [ -z "$checksum" ]; then
|
2008-09-30 04:14:17 +00:00
|
|
|
echo "*** ERROR: checksum unset in template file for \`$pkgname' ***"
|
2008-09-29 20:51:08 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2008-09-26 19:59:07 +00:00
|
|
|
origsum="$checksum"
|
2008-09-30 20:48:52 +00:00
|
|
|
dfile="$PKGFS_SRCDISTDIR/$dfile"
|
2008-09-27 01:17:12 +00:00
|
|
|
filesum="$($cksum_cmd $dfile | $awk_cmd '{print $4}')"
|
2008-09-26 19:59:07 +00:00
|
|
|
if [ "$origsum" != "$filesum" ]; then
|
|
|
|
echo "*** WARNING: checksum doesn't match (rmd160) ***"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2008-09-27 01:17:12 +00:00
|
|
|
fetch_tmpl_sources()
|
2008-09-26 19:59:07 +00:00
|
|
|
{
|
2008-09-27 01:17:12 +00:00
|
|
|
local file=""
|
|
|
|
local file2=""
|
2008-09-26 19:59:07 +00:00
|
|
|
|
2008-09-29 15:01:12 +00:00
|
|
|
[ -z "$pkgname" ] && return 1
|
|
|
|
|
2008-09-26 19:59:07 +00:00
|
|
|
if [ -z "$distfiles" ]; then
|
|
|
|
file="$pkgname"
|
|
|
|
else
|
|
|
|
file="$distfiles"
|
|
|
|
fi
|
|
|
|
|
|
|
|
for f in "$file"; do
|
2008-09-27 01:17:12 +00:00
|
|
|
file2="$f$extract_sufx"
|
2008-09-30 20:48:52 +00:00
|
|
|
if [ -f "$PKGFS_SRCDISTDIR/$file2" ]; then
|
2008-09-26 19:59:07 +00:00
|
|
|
check_rmd160_cksum $f
|
|
|
|
if [ "$?" -eq 0 ]; then
|
2008-09-27 01:17:12 +00:00
|
|
|
if [ -n "$only_fetch" ]; then
|
|
|
|
echo "=> checksum ok"
|
2008-09-26 19:59:07 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
fi
|
2008-09-27 01:17:12 +00:00
|
|
|
|
2008-09-30 20:48:52 +00:00
|
|
|
echo "==> Fetching \`$file2' source tarball"
|
2008-09-27 01:17:12 +00:00
|
|
|
|
2008-09-30 20:48:52 +00:00
|
|
|
cd $PKGFS_SRCDISTDIR && $fetch_cmd $url/$file2
|
2008-09-26 19:59:07 +00:00
|
|
|
if [ "$?" -ne 0 ]; then
|
2008-09-30 20:48:52 +00:00
|
|
|
if [ ! -f $PKGFS_SRCDISTDIR/$file2 ]; then
|
2008-09-27 01:17:12 +00:00
|
|
|
echo -n "*** ERROR: couldn't fetch '$file2', "
|
|
|
|
echo "aborting ***"
|
|
|
|
else
|
|
|
|
echo -n "*** ERROR: there was an error "
|
|
|
|
echo "fetching '$file2', aborting ***"
|
|
|
|
fi
|
2008-09-26 19:59:07 +00:00
|
|
|
exit 1
|
|
|
|
else
|
2008-09-27 01:17:12 +00:00
|
|
|
if [ -n "$only_fetch" ]; then
|
2008-09-26 19:59:07 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2008-09-27 01:17:12 +00:00
|
|
|
extract_tmpl_sources()
|
2008-09-26 19:59:07 +00:00
|
|
|
{
|
2008-09-29 15:01:12 +00:00
|
|
|
[ -z "$pkgname" ] && return 1
|
|
|
|
|
2008-09-30 20:48:52 +00:00
|
|
|
echo "==> Extracting \`$pkgname' into $PKGFS_BUILDDIR."
|
2008-09-26 21:39:29 +00:00
|
|
|
|
2008-09-27 01:17:12 +00:00
|
|
|
$extract_cmd
|
2008-09-26 19:59:07 +00:00
|
|
|
if [ "$?" -ne 0 ]; then
|
|
|
|
echo -n "*** ERROR: there was an error extracting the "
|
|
|
|
echo "distfile, aborting *** "
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2008-09-29 15:01:12 +00:00
|
|
|
unset extract_cmd
|
2008-09-27 01:17:12 +00:00
|
|
|
[ -n "$only_extract" ] && exit 0
|
|
|
|
}
|
|
|
|
|
2008-09-28 05:12:07 +00:00
|
|
|
fixup_tmpl_libtool()
|
|
|
|
{
|
2008-10-01 23:38:12 +00:00
|
|
|
local lt_file="$wrksrc/libtool"
|
2008-09-28 05:12:07 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# If package has a libtool file replace it with ours, so that
|
|
|
|
# we use the master directory while relinking, all will be fine
|
|
|
|
# once the package is stowned.
|
|
|
|
#
|
|
|
|
if [ -f "$lt_file" -a -f "$PKGFS_MASTERDIR/bin/libtool" ]; then
|
2008-10-01 23:38:12 +00:00
|
|
|
$rm_cmd -f $wrksrc/libtool
|
|
|
|
$rm_cmd -f $wrksrc/ltmain.sh
|
2008-09-28 05:12:07 +00:00
|
|
|
$ln_cmd -s $PKGFS_MASTERDIR/bin/libtool $lt_file
|
|
|
|
$ln_cmd -s $PKGFS_MASTERDIR/share/libtool/config/ltmain.sh \
|
2008-10-01 23:38:12 +00:00
|
|
|
$wrksrc/ltmain.sh
|
2008-09-28 05:12:07 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2008-09-27 01:17:12 +00:00
|
|
|
build_tmpl_sources()
|
|
|
|
{
|
2008-10-01 23:38:12 +00:00
|
|
|
local wrksrc=""
|
2008-09-26 19:59:07 +00:00
|
|
|
|
2008-09-29 15:01:12 +00:00
|
|
|
[ -z "$pkgname" ] && return 1
|
|
|
|
|
2008-10-01 23:38:12 +00:00
|
|
|
if [ -n "$distfiles" ]; then
|
|
|
|
wrksrc=$PKGFS_BUILDDIR/$distfiles
|
2008-09-26 19:59:07 +00:00
|
|
|
else
|
2008-10-01 23:38:12 +00:00
|
|
|
wrksrc=$PKGFS_BUILDDIR/$pkgname
|
2008-09-26 19:59:07 +00:00
|
|
|
fi
|
2008-09-27 01:17:12 +00:00
|
|
|
|
2008-10-01 23:38:12 +00:00
|
|
|
if [ ! -d "$wrksrc" ]; then
|
2008-09-28 09:41:26 +00:00
|
|
|
echo "*** ERROR: unexistent build directory, aborting ***"
|
2008-09-27 01:17:12 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2008-10-01 23:38:12 +00:00
|
|
|
export PATH="/bin:/sbin:/usr/bin:/usr/sbin:$PKGFS_MASTERDIR/bin:$PKGFS_MASTERDIR/sbin"
|
|
|
|
|
2008-09-28 05:12:07 +00:00
|
|
|
# Apply patches if requested by template file
|
|
|
|
apply_tmpl_patches
|
|
|
|
|
2008-09-30 20:48:52 +00:00
|
|
|
echo "==> Building \`$pkgname' (be patient, may take a while)"
|
2008-09-27 01:17:12 +00:00
|
|
|
|
2008-09-28 08:36:43 +00:00
|
|
|
#
|
|
|
|
# For now, just set LDFLAGS.
|
|
|
|
#
|
2008-09-30 15:17:11 +00:00
|
|
|
export LDFLAGS="-L$PKGFS_MASTERDIR/lib -Wl,-R$PKGFS_MASTERDIR/lib $LDFLAGS"
|
|
|
|
export PKG_CONFIG="$PKGFS_MASTERDIR/bin/pkg-config"
|
2008-09-29 20:32:08 +00:00
|
|
|
|
2008-10-01 23:38:12 +00:00
|
|
|
# Run stuff before configure.
|
|
|
|
if [ "$run_stuff_before" = "configure" ]; then
|
|
|
|
[ -f $PKGFS_TEMPLATESDIR/$run_stuff_before_configure_file ] && \
|
|
|
|
. $PKGFS_TEMPLATESDIR/$run_stuff_before_configure_file
|
|
|
|
fi
|
|
|
|
|
2008-09-26 19:59:07 +00:00
|
|
|
#
|
|
|
|
# Packages using GNU autoconf
|
|
|
|
#
|
|
|
|
if [ "$build_style" = "gnu_configure" ]; then
|
2008-09-28 05:12:07 +00:00
|
|
|
for i in ${configure_env}; do
|
|
|
|
[ -n "$i" ] && export $i
|
2008-09-26 19:59:07 +00:00
|
|
|
done
|
2008-10-01 23:38:12 +00:00
|
|
|
cd $wrksrc
|
2008-09-30 13:22:57 +00:00
|
|
|
#
|
|
|
|
# Pass consistent arguments to not have unexpected
|
|
|
|
# surprises later.
|
|
|
|
#
|
2008-09-30 20:48:52 +00:00
|
|
|
./configure --prefix="$PKGFS_MASTERDIR" \
|
|
|
|
--mandir="$PKGFS_DESTDIR/$pkgname/man" \
|
2008-09-30 13:22:57 +00:00
|
|
|
--infodir="$PKGFS_DESTDIR/$pkgname/share/info" \
|
|
|
|
${configure_args}
|
2008-09-28 05:12:07 +00:00
|
|
|
|
2008-09-28 08:36:43 +00:00
|
|
|
#
|
|
|
|
# Packages using propietary configure scripts.
|
|
|
|
#
|
2008-09-28 05:12:07 +00:00
|
|
|
elif [ "$build_style" = "configure" ]; then
|
2008-10-01 23:38:12 +00:00
|
|
|
cd $wrksrc
|
2008-09-28 05:12:07 +00:00
|
|
|
if [ -n "$configure_script" ]; then
|
|
|
|
./$configure_script ${configure_args}
|
2008-09-26 19:59:07 +00:00
|
|
|
else
|
2008-09-28 05:12:07 +00:00
|
|
|
./configure ${configure_args}
|
2008-09-26 19:59:07 +00:00
|
|
|
fi
|
2008-10-01 23:38:12 +00:00
|
|
|
#
|
|
|
|
# Packages that are perl modules and use Makefile.PL files.
|
|
|
|
# They are all handled by the helper perl-module.sh.
|
|
|
|
#
|
|
|
|
elif [ "$build_style" = "perl_module" ]; then
|
|
|
|
. $PKGFS_TMPLHELPDIR/perl-module.sh
|
|
|
|
perl_module_build $pkgname
|
|
|
|
#
|
|
|
|
# Unknown build_style type won't work :-)
|
|
|
|
#
|
|
|
|
else
|
|
|
|
echo "*** ERROR unknown build_style $build_style, aborting ***"
|
|
|
|
exit 1
|
2008-09-28 05:12:07 +00:00
|
|
|
fi
|
2008-09-26 19:59:07 +00:00
|
|
|
|
2008-10-01 23:38:12 +00:00
|
|
|
if [ "$build_style" != "perl_module" -a "$?" -ne 0 ]; then
|
2008-09-30 04:14:17 +00:00
|
|
|
echo "*** ERROR building (configure state) \`$pkgname' ***"
|
2008-09-28 05:12:07 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2008-09-26 19:59:07 +00:00
|
|
|
|
2008-09-28 05:12:07 +00:00
|
|
|
if [ -z "$make_cmd" ]; then
|
|
|
|
MAKE_CMD="/usr/bin/make"
|
|
|
|
else
|
|
|
|
MAKE_CMD="$make_cmd"
|
|
|
|
fi
|
2008-09-26 19:59:07 +00:00
|
|
|
|
2008-09-28 05:12:07 +00:00
|
|
|
# Fixup libtool script if necessary
|
|
|
|
fixup_tmpl_libtool
|
2008-09-27 01:17:12 +00:00
|
|
|
|
2008-10-01 23:38:12 +00:00
|
|
|
#
|
|
|
|
# Run template stuff before building.
|
|
|
|
#
|
|
|
|
if [ "$run_stuff_before" = "build" ]; then
|
|
|
|
[ -f $PKGFS_TEMPLATESDIR/$run_stuff_before_build_file ] && \
|
|
|
|
. $PKGFS_TEMPLATESDIR/$run_stuff_before_build_file
|
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# Build package via make.
|
|
|
|
#
|
2008-09-28 05:12:07 +00:00
|
|
|
${MAKE_CMD} ${make_build_args}
|
|
|
|
if [ "$?" -ne 0 ]; then
|
2008-09-30 04:14:17 +00:00
|
|
|
echo "*** ERROR building (make stage) \`$pkgname' ***"
|
2008-09-28 05:12:07 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2008-09-27 01:17:12 +00:00
|
|
|
|
2008-10-01 23:38:12 +00:00
|
|
|
#
|
|
|
|
# Run template stuff before installing.
|
|
|
|
#
|
|
|
|
if [ "$run_stuff_before" = "install" ]; then
|
|
|
|
[ -f $PKGFS_TEMPLATESDIR/$run_stuff_before_install_file ] && \
|
|
|
|
. $PKGFS_TEMPLATESDIR/$run_stuff_before_install_file
|
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# Install package via make.
|
|
|
|
#
|
2008-09-28 05:12:07 +00:00
|
|
|
${MAKE_CMD} ${make_install_args} \
|
|
|
|
install prefix="$PKGFS_DESTDIR/$pkgname"
|
|
|
|
if [ "$?" -ne 0 ]; then
|
2008-09-30 04:14:17 +00:00
|
|
|
echo "*** ERROR instaling \`$pkgname' ***"
|
2008-09-28 05:12:07 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2008-10-01 23:38:12 +00:00
|
|
|
#
|
|
|
|
# Run template stuff after installing.
|
|
|
|
#
|
|
|
|
if [ "$run_stuff_after" = "install" ]; then
|
|
|
|
[ -f $PKGFS_TEMPLATESDIR/$run_stuff_after_install_file ] && \
|
|
|
|
. $PKGFS_TEMPLATESDIR/$run_stuff_after_install_file
|
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
2008-09-30 20:48:52 +00:00
|
|
|
# Transform pkg-config files if requested by template.
|
2008-10-01 23:38:12 +00:00
|
|
|
#
|
2008-09-30 20:48:52 +00:00
|
|
|
for i in ${pkgconfig_override}; do
|
|
|
|
local tmpf="$PKGFS_DESTDIR/$pkgname/lib/pkgconfig/$i"
|
2008-10-01 23:38:12 +00:00
|
|
|
[ -f "$tmpf" ] && \
|
|
|
|
[ -f $PKGFS_TMPLHELPDIR/pkg-config-transform.sh ] && \
|
|
|
|
. $PKGFS_TMPLHELPDIR/pkg-config-transform.sh
|
|
|
|
pkgconfig_transform_file $tmpf
|
2008-09-30 20:48:52 +00:00
|
|
|
done
|
|
|
|
|
2008-09-30 13:22:57 +00:00
|
|
|
unset LDFLAGS PKG_CONFIG
|
2008-09-28 08:36:43 +00:00
|
|
|
|
2008-09-30 20:48:52 +00:00
|
|
|
echo "==> Installed \`$pkgname' into $PKGFS_DESTDIR/$pkgname."
|
2008-09-28 05:12:07 +00:00
|
|
|
|
2008-10-01 23:38:12 +00:00
|
|
|
#
|
|
|
|
# Remove $wrksrc if -C not specified.
|
|
|
|
#
|
|
|
|
if [ -d "$wrksrc" -a -z "$dontrm_builddir" ]; then
|
|
|
|
$rm_cmd -rf $wrksrc
|
2008-09-28 09:41:26 +00:00
|
|
|
[ "$?" -eq 0 ] && \
|
2008-09-30 20:48:52 +00:00
|
|
|
echo "=> Removed \`$pkgname' build directory."
|
2008-09-28 05:12:07 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
cd $PKGFS_BUILDDIR
|
|
|
|
}
|
|
|
|
|
|
|
|
stow_tmpl()
|
|
|
|
{
|
|
|
|
local pkg="$1"
|
2008-09-30 13:22:57 +00:00
|
|
|
local infodir_pkg="share/info/dir"
|
|
|
|
local infodir_master="$PKGFS_MASTERDIR/share/info/dir"
|
2008-09-30 16:19:52 +00:00
|
|
|
local my_xstowargs=
|
|
|
|
local real_xstowargs="$xstow_args"
|
2008-09-28 05:12:07 +00:00
|
|
|
|
2008-09-28 07:57:30 +00:00
|
|
|
[ -z "$pkg" ] && return 2
|
|
|
|
|
2008-09-30 13:22:57 +00:00
|
|
|
if [ -r "$PKGFS_DESTDIR/$pkg/$infodir_pkg" ]; then
|
|
|
|
merge_infodir_tmpl ${pkg}
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -r "$PKGFS_DESTDIR/$pkg/$infodir_pkg" -a -r "$infodir_master" ]; then
|
|
|
|
xstow_args="$xstow_args -i-file-in-dir $infodir_pkg"
|
|
|
|
fi
|
|
|
|
|
2008-09-30 16:19:52 +00:00
|
|
|
$PKGFS_XSTOW_CMD ${xstow_args} -pd-targets $PKGFS_MASTERDIR \
|
|
|
|
-dir $PKGFS_DESTDIR -target $PKGFS_MASTERDIR \
|
2008-09-30 13:22:57 +00:00
|
|
|
$PKGFS_DESTDIR/$pkg
|
2008-09-28 05:12:07 +00:00
|
|
|
if [ "$?" -ne 0 ]; then
|
2008-09-28 09:41:26 +00:00
|
|
|
echo "*** ERROR: couldn't create symlinks for \`$pkg' ***"
|
2008-09-28 05:12:07 +00:00
|
|
|
exit 1
|
|
|
|
else
|
2008-09-30 20:48:52 +00:00
|
|
|
echo "==> Created \`$pkg' symlinks into master directory."
|
2008-09-28 05:12:07 +00:00
|
|
|
fi
|
|
|
|
|
2008-09-30 16:19:52 +00:00
|
|
|
xstow_args="$real_xstowargs"
|
|
|
|
|
2008-09-29 15:01:12 +00:00
|
|
|
installed_tmpl_handler register $pkg
|
2008-09-28 05:12:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unstow_tmpl()
|
|
|
|
{
|
|
|
|
local pkg="$1"
|
|
|
|
|
2008-09-28 07:57:30 +00:00
|
|
|
if [ -z "$pkg" ]; then
|
|
|
|
echo "*** ERROR: template wasn't specified? ***"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
local tmppkg="${pkg%-[0-9]*}"
|
|
|
|
if [ "$tmppkg" = "xstow" ]; then
|
2008-09-28 09:41:26 +00:00
|
|
|
echo "*** INFO: You aren't allowed to unstow \`$xstow_version'."
|
2008-09-28 07:57:30 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2008-09-28 05:12:07 +00:00
|
|
|
$PKGFS_XSTOW_CMD -dir $PKGFS_DESTDIR -target $PKGFS_MASTERDIR \
|
2008-09-30 16:38:09 +00:00
|
|
|
-D -i-file-in-dir share/info/dir $PKGFS_DESTDIR/$pkg
|
2008-09-28 05:12:07 +00:00
|
|
|
if [ "$?" -ne 0 ]; then
|
|
|
|
exit 1
|
|
|
|
else
|
2008-09-30 16:38:09 +00:00
|
|
|
$rm_cmd -f $PKGFS_DESTDIR/$pkg/share/info/dir
|
2008-09-30 20:48:52 +00:00
|
|
|
echo "==> Removed \`$pkg' symlinks from master directory."
|
2008-09-26 19:59:07 +00:00
|
|
|
fi
|
2008-09-29 15:01:12 +00:00
|
|
|
|
|
|
|
installed_tmpl_handler unregister $pkg
|
2008-09-26 19:59:07 +00:00
|
|
|
}
|
|
|
|
|
2008-09-29 15:01:12 +00:00
|
|
|
add_dependency_tolist()
|
2008-09-26 19:59:07 +00:00
|
|
|
{
|
2008-09-29 15:01:12 +00:00
|
|
|
local pkgdepf="$1"
|
|
|
|
local reg_pkgdb="${PKGFS_DESTDIR}/${PKGFS_REGISTERED_PKG_DB}"
|
|
|
|
|
|
|
|
[ -z "$pkgdepf" ] && return 1
|
|
|
|
[ -n "$prev_depf" ] && pkgdepf=${prev_depf}
|
|
|
|
|
|
|
|
for i in $($db_cmd btree $pkgdepf deps); do
|
|
|
|
#
|
|
|
|
# Skip key
|
|
|
|
#
|
|
|
|
[ "$i" = "deps" ] && continue
|
|
|
|
|
|
|
|
echo -n " $i: "
|
|
|
|
#
|
|
|
|
# Check if dep already installed.
|
|
|
|
#
|
|
|
|
if [ -r "$reg_pkgdb" ]; then
|
|
|
|
check_installed_tmpl $i
|
|
|
|
if [ "$?" -eq 0 ]; then
|
|
|
|
echo "already installed."
|
|
|
|
continue
|
|
|
|
fi
|
2008-09-30 04:14:17 +00:00
|
|
|
echo "not installed."
|
2008-09-29 15:01:12 +00:00
|
|
|
# Added dep into list
|
|
|
|
deps_list="$i $deps_list"
|
|
|
|
[ -n "$prev_depf" ] && unset prev_depf
|
|
|
|
#
|
|
|
|
# Check if dependency needs more deps.
|
|
|
|
#
|
|
|
|
depdbf="$PKGFS_DEPSDIR/$i-deps.db"
|
|
|
|
if [ -r "$PKGFS_DEPSDIR/$i-deps.db" ]; then
|
|
|
|
add_dependency_tolist ${depdbf}
|
|
|
|
prev_depf="$depdbf"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
install_dependency_tmpl()
|
|
|
|
{
|
|
|
|
local pkgdepf="$1"
|
|
|
|
local tmpdepf="$pkgdepf"
|
|
|
|
local tmppkgname=
|
|
|
|
deps_list=
|
|
|
|
|
|
|
|
[ -z "$pkgdepf" ] && return 1
|
|
|
|
|
|
|
|
doing_deps=true
|
|
|
|
|
|
|
|
tmp_pkgn=${pkgdepf%%-deps.db}
|
2008-09-30 20:48:52 +00:00
|
|
|
echo "==> Required dependencies for $(basename $tmp_pkgn):"
|
2008-09-29 15:01:12 +00:00
|
|
|
|
|
|
|
add_dependency_tolist $pkgdepf
|
|
|
|
|
|
|
|
for i in ${deps_list}; do
|
2008-09-29 20:32:08 +00:00
|
|
|
# skip dup deps
|
|
|
|
check_installed_tmpl $i
|
|
|
|
[ "$?" -eq 0 ] && continue
|
2008-09-30 20:48:52 +00:00
|
|
|
echo "=> Installing dependency: $i"
|
2008-09-29 23:59:51 +00:00
|
|
|
install_tmpl "${i%-deps.db}"
|
2008-09-29 15:01:12 +00:00
|
|
|
done
|
2008-09-29 20:32:08 +00:00
|
|
|
|
|
|
|
deps_list=
|
2008-09-29 15:01:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
install_xstow_tmpl()
|
|
|
|
{
|
|
|
|
[ -x "$PKGFS_XSTOW_CMD" ] && return 0
|
|
|
|
|
|
|
|
reset_tmpl_vars
|
|
|
|
run_file "$PKGFS_TEMPLATESDIR/$xstow_version.tmpl"
|
|
|
|
cur_tmpl=$path_fixed
|
|
|
|
check_tmpl_vars ${xstow_version}
|
|
|
|
fetch_tmpl_sources
|
|
|
|
extract_tmpl_sources
|
|
|
|
build_tmpl_sources
|
|
|
|
PKGFS_XSTOW_CMD="$PKGFS_DESTDIR/$xstow_version/bin/xstow"
|
|
|
|
stow_tmpl $xstow_version
|
|
|
|
$sed_cmd -e "s|PKGFS_XSTOW_.*|PKGFS_XSTOW_CMD=$PKGFS_MASTERDIR/bin/xstow|" \
|
|
|
|
$path_fixed > $path_fixed.in && \
|
|
|
|
$mv_cmd $path_fixed.in $path_fixed
|
|
|
|
#
|
|
|
|
# Continue with origin package that called us.
|
|
|
|
#
|
|
|
|
run_file ${origin_tmpl}
|
|
|
|
cur_tmpl=${path_fixed}
|
|
|
|
}
|
|
|
|
|
|
|
|
installed_tmpl_handler()
|
|
|
|
{
|
|
|
|
local action="$1"
|
|
|
|
local pkg="$2"
|
|
|
|
|
|
|
|
[ -z "$action" -o -z "$pkg" ] && return 1
|
|
|
|
#
|
|
|
|
# This function is called every time a package has been stowned
|
|
|
|
# or unstowned.
|
|
|
|
# There's a db(3) btree database file in
|
|
|
|
# PKGFS_DESTDIR/PKGFS_REGISTER_PKG_DB that stores which package
|
|
|
|
# is installed and stowned.
|
|
|
|
#
|
|
|
|
if [ "$action" = "register" ]; then
|
|
|
|
$db_cmd -w btree ${PKGFS_DESTDIR}/${PKGFS_REGISTERED_PKG_DB} \
|
|
|
|
$pkg stowned
|
|
|
|
if [ "$?" -ne 0 ]; then
|
|
|
|
echo -n "*** ERROR: couldn't register stowned \`$pkg'"
|
|
|
|
echo " in db file ***"
|
2008-09-28 07:57:30 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2008-09-29 15:01:12 +00:00
|
|
|
elif [ "$action" = "unregister" ]; then
|
|
|
|
$db_cmd -d btree ${PKGFS_DESTDIR}/${PKGFS_REGISTERED_PKG_DB} $pkg
|
|
|
|
if [ "$?" -ne 0 ]; then
|
|
|
|
echo -n "*** ERROR: \`$pkg' stowned not registered "
|
|
|
|
echo "in db file? ***"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
check_installed_tmpl()
|
|
|
|
{
|
|
|
|
local pkg="$1"
|
|
|
|
local db_file="${PKGFS_DESTDIR}/${PKGFS_REGISTERED_PKG_DB}"
|
|
|
|
|
|
|
|
[ -z "$pkg" ] && return 1
|
|
|
|
|
|
|
|
$db_cmd btree $db_file $pkg 2>&1 >/dev/null
|
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
|
|
|
install_tmpl()
|
|
|
|
{
|
2008-09-29 23:59:51 +00:00
|
|
|
cur_tmpl="$PKGFS_TEMPLATESDIR/$1.tmpl"
|
2008-09-29 15:01:12 +00:00
|
|
|
if [ -z "$cur_tmpl" -o ! -f "$cur_tmpl" ]; then
|
|
|
|
echo -n "*** ERROR: invalid template file '$cur_tmpl',"
|
|
|
|
echo " aborting ***"
|
|
|
|
exit 1
|
2008-09-28 05:12:07 +00:00
|
|
|
fi
|
2008-09-26 22:19:02 +00:00
|
|
|
|
2008-09-29 15:01:12 +00:00
|
|
|
reset_tmpl_vars
|
|
|
|
run_file ${cur_tmpl}
|
|
|
|
cur_tmpl=${path_fixed}
|
2008-09-28 07:57:30 +00:00
|
|
|
|
2008-09-29 15:01:12 +00:00
|
|
|
#
|
|
|
|
# If we are the originator package save the path this template in
|
|
|
|
# other var for future use.
|
|
|
|
#
|
|
|
|
if [ -z "$origin_tmpl" ]; then
|
|
|
|
origin_tmpl=${path_fixed}
|
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# Install xstow if it's not there.
|
|
|
|
#
|
|
|
|
install_xstow_tmpl
|
|
|
|
|
|
|
|
#
|
|
|
|
# Check vars for current template.
|
|
|
|
#
|
2008-09-28 07:57:30 +00:00
|
|
|
check_tmpl_vars ${pkgname}
|
2008-09-27 01:17:12 +00:00
|
|
|
|
2008-09-29 15:01:12 +00:00
|
|
|
#
|
2008-09-29 15:23:23 +00:00
|
|
|
# Handle required dependency for this template iff it
|
2008-09-29 15:01:12 +00:00
|
|
|
# is not installed and if we are being invoked by a dependency.
|
|
|
|
#
|
|
|
|
local pkgdepf="$PKGFS_DEPSDIR/$pkgname-deps.db"
|
|
|
|
if [ -r "$pkgdepf" -a -z "$doing_deps" ]; then
|
|
|
|
install_dependency_tmpl ${pkgdepf}
|
2008-09-29 15:23:23 +00:00
|
|
|
#
|
|
|
|
# At this point all required deps are installed, and
|
|
|
|
# only remaining is the origin template; install it.
|
|
|
|
#
|
2008-09-29 15:01:12 +00:00
|
|
|
doing_deps=
|
|
|
|
reset_tmpl_vars
|
|
|
|
run_file ${origin_tmpl}
|
2008-09-29 15:23:23 +00:00
|
|
|
check_tmpl_vars ${pkgname}
|
2008-09-29 15:01:12 +00:00
|
|
|
fi
|
|
|
|
|
2008-09-28 05:12:07 +00:00
|
|
|
if [ -n "$only_build" ]; then
|
2008-09-27 01:17:12 +00:00
|
|
|
build_tmpl_sources
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2008-09-29 15:01:12 +00:00
|
|
|
#
|
|
|
|
# Fetch, extract, stow and reset vars for a template.
|
|
|
|
#
|
2008-09-27 01:17:12 +00:00
|
|
|
fetch_tmpl_sources
|
|
|
|
extract_tmpl_sources
|
|
|
|
build_tmpl_sources
|
2008-09-29 15:01:12 +00:00
|
|
|
stow_tmpl ${pkgname}
|
2008-09-26 19:59:07 +00:00
|
|
|
}
|
|
|
|
|
2008-09-29 22:45:25 +00:00
|
|
|
list_tmpls()
|
|
|
|
{
|
|
|
|
local reg_pkgdb="$PKGFS_DESTDIR/$PKGFS_REGISTERED_PKG_DB"
|
|
|
|
|
|
|
|
if [ ! -r "$reg_pkgdb" ]; then
|
|
|
|
echo "*** ERROR: couldn't find the $reg_pkgdb, aborting ***"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
for i in $($db_cmd btree $reg_pkgdb); do
|
|
|
|
# Skip stowned value
|
|
|
|
[ "$i" = "stowned" ] && continue
|
|
|
|
# Run file to get short_desc and print something useful
|
|
|
|
run_file ${PKGFS_TEMPLATESDIR}/$i.tmpl
|
|
|
|
echo "$i $short_desc"
|
|
|
|
reset_tmpl_vars
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2008-09-28 09:41:26 +00:00
|
|
|
remove_tmpl()
|
|
|
|
{
|
|
|
|
local pkg="$1"
|
|
|
|
|
|
|
|
if [ -z "$pkg" ]; then
|
|
|
|
echo "*** ERROR: unexistent package, aborting ***"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d "$PKGFS_DESTDIR/$pkg" ]; then
|
|
|
|
echo "*** ERROR: cannot find package on $PKGFS_DESTDIR ***"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
unstow_tmpl ${pkg}
|
|
|
|
$rm_cmd -rf $PKGFS_DESTDIR/$pkg
|
2008-09-29 15:01:12 +00:00
|
|
|
return "$?"
|
2008-09-28 09:41:26 +00:00
|
|
|
}
|
|
|
|
|
2008-09-26 21:23:41 +00:00
|
|
|
#
|
|
|
|
# main()
|
|
|
|
#
|
2008-09-27 01:17:12 +00:00
|
|
|
args=$(getopt bCc:ef $*)
|
2008-09-26 19:59:07 +00:00
|
|
|
[ "$?" -ne 0 ] && usage
|
|
|
|
|
|
|
|
set -- $args
|
|
|
|
while [ "$#" -gt 0 ]; do
|
|
|
|
case "$1" in
|
2008-09-27 01:17:12 +00:00
|
|
|
-b)
|
|
|
|
only_build=yes
|
|
|
|
;;
|
|
|
|
-C)
|
2008-09-28 05:12:07 +00:00
|
|
|
dontrm_builddir=yes
|
2008-09-27 01:17:12 +00:00
|
|
|
;;
|
2008-09-26 19:59:07 +00:00
|
|
|
-c)
|
|
|
|
PKGFS_CONFIG_FILE="$2"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-e)
|
|
|
|
only_extract=yes
|
|
|
|
;;
|
|
|
|
-f)
|
|
|
|
only_fetch=yes
|
|
|
|
;;
|
|
|
|
--)
|
|
|
|
shift
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
[ "$#" -gt 2 ] && usage
|
|
|
|
|
2008-09-27 01:17:12 +00:00
|
|
|
target="$1"
|
|
|
|
if [ -z "$target" ]; then
|
2008-09-26 19:59:07 +00:00
|
|
|
echo "*** ERROR missing target ***"
|
|
|
|
usage
|
|
|
|
fi
|
|
|
|
|
2008-09-30 20:48:52 +00:00
|
|
|
#
|
|
|
|
# Check configuration vars before anyting else, and set defaults vars.
|
|
|
|
#
|
2008-09-29 15:01:12 +00:00
|
|
|
check_config_vars
|
2008-09-30 20:48:52 +00:00
|
|
|
set_defvars
|
2008-09-29 15:01:12 +00:00
|
|
|
|
2008-09-26 19:59:07 +00:00
|
|
|
# Main switch
|
2008-09-27 01:17:12 +00:00
|
|
|
case "$target" in
|
2008-09-26 19:59:07 +00:00
|
|
|
info)
|
2008-09-28 05:12:07 +00:00
|
|
|
info_tmpl "$2"
|
|
|
|
;;
|
2008-09-28 09:41:26 +00:00
|
|
|
install)
|
|
|
|
install_tmpl "$2"
|
|
|
|
;;
|
2008-09-29 22:45:25 +00:00
|
|
|
list)
|
|
|
|
list_tmpls
|
|
|
|
;;
|
2008-09-28 09:41:26 +00:00
|
|
|
remove)
|
|
|
|
remove_tmpl "$2"
|
|
|
|
;;
|
2008-09-28 05:12:07 +00:00
|
|
|
stow)
|
|
|
|
stow_tmpl "$2"
|
|
|
|
;;
|
|
|
|
unstow)
|
|
|
|
unstow_tmpl "$2"
|
2008-09-26 19:59:07 +00:00
|
|
|
;;
|
|
|
|
*)
|
2008-09-27 01:17:12 +00:00
|
|
|
echo "*** ERROR invalid target '$target' ***"
|
2008-09-26 19:59:07 +00:00
|
|
|
usage
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Agur
|
|
|
|
exit 0
|