2008-09-26 21:59:07 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2008-09-28 09:57:30 +02:00
|
|
|
# pkgfs - Builds source distribution files and stows/unstows them into
|
2008-09-28 10:36:43 +02:00
|
|
|
# a master directory, thanks to Xstow.
|
2008-09-27 00:19:02 +02:00
|
|
|
#
|
2008-09-26 23:23:41 +02: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 21:59:07 +02:00
|
|
|
# TODO
|
2008-10-05 21:23:39 +02:00
|
|
|
# - Implement a routine that checks if installed version is sufficient
|
|
|
|
# to satisfy the required dependency... right now it's very prone
|
|
|
|
# to errors and slow.
|
2008-09-28 11:41:26 +02:00
|
|
|
# - Multiple distfiles in a package.
|
|
|
|
# - Multiple URLs to download source distribution files.
|
2008-09-26 21:59:07 +02: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-27 03:17:12 +02: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}
|
|
|
|
: ${rm_cmd:=/bin/rm}
|
2008-09-28 07:12:07 +02: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 17:01:12 +02:00
|
|
|
: ${db_cmd:=/usr/bin/db -q}
|
2008-10-02 01:38:12 +02:00
|
|
|
: ${chmod_cmd:=/bin/chmod}
|
2008-09-28 07:12:07 +02:00
|
|
|
|
|
|
|
: ${xstow_args:=-ap}
|
2008-10-02 02:53:09 +02:00
|
|
|
: ${xstow_ignore_files:=perllocal.pod} # XXX For now ignore them.
|
2008-09-27 03:17:12 +02:00
|
|
|
|
2008-09-30 22:48:52 +02:00
|
|
|
set_defvars()
|
|
|
|
{
|
|
|
|
# Directories
|
|
|
|
: ${PKGFS_TEMPLATESDIR:=$PKGFS_DISTRIBUTIONDIR/templates}
|
|
|
|
: ${PKGFS_DEPSDIR:=$PKGFS_DISTRIBUTIONDIR/dependencies}
|
2008-10-04 06:29:49 +02:00
|
|
|
: ${PKGFS_BUILD_DEPS_DB:=$PKGFS_DEPSDIR/build-depends.db}
|
2008-09-30 22:48:52 +02:00
|
|
|
: ${PKGFS_TMPLHELPDIR:=$PKGFS_DISTRIBUTIONDIR/helper-templates}
|
2008-10-05 21:23:39 +02:00
|
|
|
: ${PKGFS_REGPKG_DB:=$PKGFS_DESTDIR/.pkgfs-registered-pkgs.db}
|
2008-09-30 22:48:52 +02:00
|
|
|
|
|
|
|
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 03:17:12 +02:00
|
|
|
usage()
|
|
|
|
{
|
2008-09-26 21:59:07 +02:00
|
|
|
cat << _EOF
|
2008-10-02 03:52:21 +02:00
|
|
|
$progname: [-bCefi] [-c <config_file>] <target> <tmplname>
|
2008-09-26 21:59:07 +02:00
|
|
|
|
|
|
|
Targets
|
2008-10-02 03:52:21 +02:00
|
|
|
info Show information about <tmplname>.
|
|
|
|
install Build and install package from <tmplname>.
|
2008-09-30 00:45:25 +02:00
|
|
|
list Lists and prints short description about installed packages.
|
2008-09-28 11:41:26 +02:00
|
|
|
remove Remove package completely (unstow and remove from destdir)
|
2008-10-02 03:52:21 +02:00
|
|
|
stow Create symlinks from <tmplname> in master directory.
|
|
|
|
unstow Remove symlinks from <tmplname> in master directory.
|
2008-09-26 21:59:07 +02:00
|
|
|
|
|
|
|
Options
|
2008-10-02 03:52:21 +02:00
|
|
|
-b Only build the source distribution file(s), without
|
|
|
|
extracting or fetching before.
|
2008-09-28 07:12:07 +02:00
|
|
|
-C Do not remove build directory after successful build.
|
2008-09-26 21:59:07 +02: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).
|
2008-10-02 03:52:21 +02:00
|
|
|
-i Only build and install the binary distribution file(s)
|
|
|
|
into the destdir directory, without stowning.
|
2008-09-26 21:59:07 +02:00
|
|
|
_EOF
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
check_path()
|
|
|
|
{
|
2008-09-27 03:17:12 +02:00
|
|
|
eval local orig="$1"
|
2008-09-26 21:59:07 +02:00
|
|
|
|
|
|
|
case "$orig" in
|
|
|
|
/)
|
|
|
|
;;
|
|
|
|
/*)
|
|
|
|
orig="${orig%/}"
|
|
|
|
;;
|
|
|
|
*)
|
2008-09-27 03:17:12 +02:00
|
|
|
orig="$topdir/${orig%/}"
|
2008-09-26 21:59:07 +02:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2008-09-27 03:17:12 +02:00
|
|
|
path_fixed="$orig"
|
2008-09-26 21:59:07 +02:00
|
|
|
}
|
|
|
|
|
2008-09-28 07:12:07 +02:00
|
|
|
run_file()
|
|
|
|
{
|
|
|
|
local file="$1"
|
|
|
|
|
|
|
|
check_path "$file"
|
|
|
|
. $path_fixed
|
|
|
|
}
|
|
|
|
|
2008-09-30 15:22:57 +02: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-10-04 06:29:49 +02:00
|
|
|
#
|
|
|
|
# Shows info about a template.
|
|
|
|
#
|
2008-09-27 03:17:12 +02:00
|
|
|
info_tmpl()
|
2008-09-26 21:59:07 +02:00
|
|
|
{
|
2008-09-29 17:01:12 +02:00
|
|
|
local tmpl="$1"
|
2008-09-30 01:59:51 +02:00
|
|
|
if [ -z "$tmpl" -o ! -f "$PKGFS_TEMPLATESDIR/$tmpl.tmpl" ]; then
|
2008-09-30 06:14:17 +02:00
|
|
|
echo -n "*** ERROR: invalid template file \`$tmpl' ***"
|
2008-09-28 07:12:07 +02:00
|
|
|
echo ", aborting ***"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2008-10-04 06:29:49 +02:00
|
|
|
run_file $PKGFS_TEMPLATESDIR/$tmpl.tmpl
|
2008-09-28 07:12:07 +02:00
|
|
|
|
2008-10-04 14:02:39 +02:00
|
|
|
echo "pkgname: $pkgname"
|
|
|
|
echo "version: $version"
|
2008-09-26 21:59:07 +02:00
|
|
|
for i in "${distfiles}"; do
|
2008-10-04 14:02:39 +02:00
|
|
|
[ -n "$i" ] && echo "distfile: $i"
|
2008-09-26 21:59:07 +02:00
|
|
|
done
|
2008-10-04 14:02:39 +02:00
|
|
|
echo "URL: $url"
|
|
|
|
echo "maintainer: $maintainer"
|
|
|
|
[ -n $checksum ] && echo "checksum: $checksum"
|
|
|
|
echo "build_style: $build_style"
|
|
|
|
echo "short_desc: $short_desc"
|
2008-09-26 21:59:07 +02:00
|
|
|
echo "$long_desc"
|
2008-09-30 04:28:05 +02:00
|
|
|
echo
|
2008-10-07 01:39:32 +02:00
|
|
|
check_build_depends_tmpl $pkg-$version
|
2008-10-04 06:29:49 +02:00
|
|
|
if [ "$?" -eq 0 ]; then
|
|
|
|
local list="$($db_cmd -V btree $PKGFS_BUILD_DEPS_DB $pkgname)"
|
2008-10-04 14:02:39 +02:00
|
|
|
echo "This package requires the following dependencies to be built:"
|
2008-09-30 04:28:05 +02:00
|
|
|
for i in ${list}; do
|
2008-10-04 14:02:39 +02:00
|
|
|
echo " $i"
|
2008-09-30 04:28:05 +02:00
|
|
|
done
|
|
|
|
fi
|
2008-09-27 03:17:12 +02:00
|
|
|
}
|
|
|
|
|
2008-10-04 06:29:49 +02:00
|
|
|
#
|
|
|
|
# Applies to the build directory the patches specified by a template.
|
|
|
|
#
|
2008-09-28 07:12:07 +02: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-02 01:38:12 +02:00
|
|
|
cd $wrksrc && $patch_cmd < $patch 2>/dev/null
|
2008-09-28 07:12:07 +02:00
|
|
|
if [ "$?" -eq 0 ]; then
|
2008-09-30 22:48:52 +02:00
|
|
|
echo "=> Patch applied: \`$i'."
|
2008-09-28 07:12:07 +02:00
|
|
|
else
|
|
|
|
echo -n "*** ERROR: couldn't apply patch '$i'"
|
|
|
|
echo ", aborting ***"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2008-10-04 06:29:49 +02:00
|
|
|
#
|
|
|
|
# Checks that all required variables specified in the configuration
|
|
|
|
# file are properly working.
|
|
|
|
#
|
2008-09-29 17:01:12 +02:00
|
|
|
check_config_vars()
|
2008-09-27 03:17:12 +02:00
|
|
|
{
|
2008-10-03 18:53:58 +02:00
|
|
|
local cffound=
|
|
|
|
|
|
|
|
if [ -z "$config_file_specified" ]; then
|
|
|
|
config_file_paths="$PKGFS_CONFIG_FILE ./pkgfs.conf"
|
|
|
|
for f in $config_file_paths; do
|
|
|
|
[ -f $f ] && PKGFS_CONFIG_FILE=$f && cffound=yes
|
|
|
|
done
|
|
|
|
if [ -z "$cffound" ]; then
|
|
|
|
echo -n "*** ERROR: config file not specified "
|
|
|
|
echo "and not in default location or current dir ***"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2008-09-28 07:12:07 +02:00
|
|
|
run_file ${PKGFS_CONFIG_FILE}
|
2008-09-28 09:57:30 +02:00
|
|
|
PKGFS_CONFIG_FILE=$path_fixed
|
2008-09-28 07:12:07 +02:00
|
|
|
|
2008-09-28 09:57:30 +02:00
|
|
|
if [ ! -f "$PKGFS_CONFIG_FILE" ]; then
|
2008-09-27 18:20:46 +02:00
|
|
|
echo -n "*** ERROR: cannot find configuration file: "
|
2008-09-27 03:17:12 +02:00
|
|
|
echo "'$PKGFS_CONFIG_FILE' ***"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2008-09-27 18:20:46 +02:00
|
|
|
local PKGFS_VARS="PKGFS_MASTERDIR PKGFS_DESTDIR PKGFS_BUILDDIR \
|
2008-10-03 15:41:26 +02:00
|
|
|
PKGFS_SRCDISTDIR PKGFS_SYSCONFDIR"
|
2008-09-27 03:17:12 +02:00
|
|
|
|
2008-09-27 18:20:46 +02:00
|
|
|
for f in ${PKGFS_VARS}; do
|
|
|
|
eval val="\$$f"
|
|
|
|
if [ -z "$val" ]; then
|
2008-10-03 15:41:26 +02:00
|
|
|
echo -n "**** ERROR: '$f' not set in configuration "
|
2008-09-27 18:20:46 +02:00
|
|
|
echo "file, aborting ***"
|
2008-09-27 03:17:12 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
2008-09-29 17:01:12 +02:00
|
|
|
|
2008-09-27 18:20:46 +02: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 03:17:12 +02:00
|
|
|
fi
|
2008-09-27 18:20:46 +02:00
|
|
|
done
|
2008-09-26 21:59:07 +02:00
|
|
|
}
|
|
|
|
|
2008-10-04 06:29:49 +02:00
|
|
|
#
|
|
|
|
# Resets all vars used by a template.
|
|
|
|
#
|
2008-09-28 07:12:07 +02:00
|
|
|
reset_tmpl_vars()
|
|
|
|
{
|
|
|
|
local TMPL_VARS="pkgname extract_sufx distfiles url configure_args \
|
2008-09-28 11:41:26 +02:00
|
|
|
make_build_args make_install_args build_style \
|
|
|
|
short_desc maintainer long_desc checksum wrksrc \
|
2008-10-02 03:00:32 +02:00
|
|
|
patch_files configure_env make_cmd pkgconfig_override \
|
|
|
|
run_stuff_before run_stuff_after \
|
|
|
|
run_stuff_before_configure_file run_stuff_before_build_file \
|
2008-10-02 22:56:00 +02:00
|
|
|
run_stuff_before_install_file run_stuff_after_install \
|
2008-10-06 16:57:36 +02:00
|
|
|
run_stuff_after_install_file make_build_target \
|
|
|
|
run_stuff_before_configure_cmd run_stuff_before_build_cmd \
|
|
|
|
run_stuff_before_install_cmd run_stuff_after_install_cmd \
|
|
|
|
make_install_target postinstall_helpers version \
|
|
|
|
ignore_files"
|
2008-09-28 07:12:07 +02:00
|
|
|
|
|
|
|
for i in ${TMPL_VARS}; do
|
2008-09-29 17:01:12 +02:00
|
|
|
eval unset "$i"
|
2008-09-28 07:12:07 +02:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2008-10-04 06:29:49 +02:00
|
|
|
#
|
|
|
|
# Checks some vars used in templates and sets $extract_cmd.
|
|
|
|
#
|
2008-09-27 18:20:46 +02:00
|
|
|
check_tmpl_vars()
|
2008-09-26 21:59:07 +02:00
|
|
|
{
|
2008-09-28 09:57:30 +02:00
|
|
|
local pkg="$1"
|
2008-09-27 03:17:12 +02:00
|
|
|
local dfile=""
|
2008-09-26 21:59:07 +02:00
|
|
|
|
2008-09-28 09:57:30 +02:00
|
|
|
[ -z "$pkg" ] && return 1
|
2008-10-07 02:55:37 +02:00
|
|
|
#
|
|
|
|
# There's nothing of interest if we are a meta template.
|
|
|
|
#
|
|
|
|
[ "$build_style" = "meta-template" ] && return 0
|
2008-09-28 09:57:30 +02:00
|
|
|
|
2008-10-04 06:29:49 +02:00
|
|
|
REQ_VARS="pkgname version extract_sufx url build_style"
|
2008-09-26 21:59:07 +02:00
|
|
|
|
|
|
|
# Check if required vars weren't set.
|
2008-09-27 03:17:12 +02: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 21:59:07 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2008-09-28 07:12:07 +02:00
|
|
|
if [ -z "$distfiles" ]; then
|
2008-10-04 06:29:49 +02:00
|
|
|
dfile="$pkgname-$version$extract_sufx"
|
2008-09-28 07:12:07 +02:00
|
|
|
elif [ -n "${distfiles}" ]; then
|
|
|
|
dfile="$distfiles$extract_sufx"
|
|
|
|
else
|
|
|
|
echo "*** ERROR unsupported fetch state ***"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2008-09-30 22:48:52 +02:00
|
|
|
dfile="$PKGFS_SRCDISTDIR/$dfile"
|
2008-09-28 07:12:07 +02:00
|
|
|
|
2008-09-26 21:59:07 +02:00
|
|
|
case "$extract_sufx" in
|
|
|
|
.tar.bz2|.tar.gz|.tgz|.tbz)
|
2008-09-28 07:12:07 +02:00
|
|
|
extract_cmd="$tar_cmd xfz $dfile -C $PKGFS_BUILDDIR"
|
2008-09-26 21:59:07 +02:00
|
|
|
;;
|
|
|
|
.tar)
|
2008-09-28 07:12:07 +02:00
|
|
|
extract_cmd="$tar_cmd xf $dfile -C $PKGFS_BUILDDIR"
|
2008-09-26 21:59:07 +02:00
|
|
|
;;
|
|
|
|
.zip)
|
2008-10-03 00:44:43 +02:00
|
|
|
if [ -f "$PKGFS_TMPLHELPDIR/unzip-extraction.sh" ]; then
|
|
|
|
. $PKGFS_TMPLHELPDIR/unzip-extraction.sh
|
|
|
|
fi
|
2008-10-03 17:19:37 +02:00
|
|
|
# $extract_cmd set by the helper
|
2008-09-26 21:59:07 +02:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo -n "*** ERROR: unknown 'extract_sufx' argument in build "
|
2008-09-26 23:39:29 +02:00
|
|
|
echo "file ***"
|
2008-09-26 21:59:07 +02:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2008-10-04 06:29:49 +02:00
|
|
|
#
|
|
|
|
# Verifies that a checksum of a distfile is correct.
|
|
|
|
#
|
2008-09-26 21:59:07 +02:00
|
|
|
check_rmd160_cksum()
|
|
|
|
{
|
2008-09-28 09:57:30 +02:00
|
|
|
local file="$1"
|
2008-10-03 14:32:26 +02:00
|
|
|
local dfile=
|
2008-09-28 09:57:30 +02:00
|
|
|
|
|
|
|
[ -z "$file" ] && return 1
|
2008-09-26 21:59:07 +02:00
|
|
|
|
|
|
|
if [ -z "${distfiles}" ]; then
|
2008-10-04 06:29:49 +02:00
|
|
|
dfile="$pkgname-$version$extract_sufx"
|
2008-09-26 21:59:07 +02:00
|
|
|
elif [ -n "${distfiles}" ]; then
|
|
|
|
dfile="$distfiles$extract_sufx"
|
|
|
|
else
|
2008-09-28 09:57:30 +02:00
|
|
|
dfile="$file$extract_sufx"
|
2008-09-26 21:59:07 +02:00
|
|
|
fi
|
|
|
|
|
2008-09-29 22:51:08 +02:00
|
|
|
if [ -z "$checksum" ]; then
|
2008-09-30 06:14:17 +02:00
|
|
|
echo "*** ERROR: checksum unset in template file for \`$pkgname' ***"
|
2008-09-29 22:51:08 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2008-09-26 21:59:07 +02:00
|
|
|
origsum="$checksum"
|
2008-09-30 22:48:52 +02:00
|
|
|
dfile="$PKGFS_SRCDISTDIR/$dfile"
|
2008-09-27 03:17:12 +02:00
|
|
|
filesum="$($cksum_cmd $dfile | $awk_cmd '{print $4}')"
|
2008-09-26 21:59:07 +02:00
|
|
|
if [ "$origsum" != "$filesum" ]; then
|
|
|
|
echo "*** WARNING: checksum doesn't match (rmd160) ***"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2008-10-04 06:29:49 +02:00
|
|
|
#
|
|
|
|
# Downloads the distfiles for a template from $url.
|
|
|
|
#
|
2008-09-27 03:17:12 +02:00
|
|
|
fetch_tmpl_sources()
|
2008-09-26 21:59:07 +02:00
|
|
|
{
|
2008-09-27 03:17:12 +02:00
|
|
|
local file=""
|
|
|
|
local file2=""
|
2008-09-26 21:59:07 +02:00
|
|
|
|
2008-09-29 17:01:12 +02:00
|
|
|
[ -z "$pkgname" ] && return 1
|
2008-10-07 02:55:37 +02:00
|
|
|
#
|
|
|
|
# There's nothing of interest if we are a meta template.
|
|
|
|
#
|
|
|
|
[ "$build_style" = "meta-template" ] && return 0
|
2008-09-29 17:01:12 +02:00
|
|
|
|
2008-09-26 21:59:07 +02:00
|
|
|
if [ -z "$distfiles" ]; then
|
2008-10-04 06:29:49 +02:00
|
|
|
file="$pkgname-$version"
|
2008-09-26 21:59:07 +02:00
|
|
|
else
|
|
|
|
file="$distfiles"
|
|
|
|
fi
|
|
|
|
|
|
|
|
for f in "$file"; do
|
2008-09-27 03:17:12 +02:00
|
|
|
file2="$f$extract_sufx"
|
2008-09-30 22:48:52 +02:00
|
|
|
if [ -f "$PKGFS_SRCDISTDIR/$file2" ]; then
|
2008-09-26 21:59:07 +02:00
|
|
|
check_rmd160_cksum $f
|
|
|
|
if [ "$?" -eq 0 ]; then
|
2008-09-27 03:17:12 +02:00
|
|
|
if [ -n "$only_fetch" ]; then
|
|
|
|
echo "=> checksum ok"
|
2008-09-26 21:59:07 +02:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
fi
|
2008-09-27 03:17:12 +02:00
|
|
|
|
2008-09-30 22:48:52 +02:00
|
|
|
echo "==> Fetching \`$file2' source tarball"
|
2008-09-27 03:17:12 +02:00
|
|
|
|
2008-09-30 22:48:52 +02:00
|
|
|
cd $PKGFS_SRCDISTDIR && $fetch_cmd $url/$file2
|
2008-09-26 21:59:07 +02:00
|
|
|
if [ "$?" -ne 0 ]; then
|
2008-09-30 22:48:52 +02:00
|
|
|
if [ ! -f $PKGFS_SRCDISTDIR/$file2 ]; then
|
2008-09-27 03:17:12 +02: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 21:59:07 +02:00
|
|
|
exit 1
|
|
|
|
else
|
2008-09-27 03:17:12 +02:00
|
|
|
if [ -n "$only_fetch" ]; then
|
2008-09-26 21:59:07 +02:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2008-10-04 06:29:49 +02:00
|
|
|
#
|
|
|
|
# Extracts contents of a distfile specified in a template into
|
|
|
|
# the build directory.
|
|
|
|
#
|
2008-09-27 03:17:12 +02:00
|
|
|
extract_tmpl_sources()
|
2008-09-26 21:59:07 +02:00
|
|
|
{
|
2008-09-29 17:01:12 +02:00
|
|
|
[ -z "$pkgname" ] && return 1
|
|
|
|
|
2008-10-07 02:55:37 +02:00
|
|
|
#
|
|
|
|
# There's nothing of interest if we are a meta template.
|
|
|
|
#
|
|
|
|
[ "$build_style" = "meta-template" ] && return 0
|
|
|
|
|
2008-10-04 06:29:49 +02:00
|
|
|
echo "==> Extracting \`$pkgname-$version' into $PKGFS_BUILDDIR."
|
2008-09-26 23:39:29 +02:00
|
|
|
|
2008-09-27 03:17:12 +02:00
|
|
|
$extract_cmd
|
2008-09-26 21:59:07 +02:00
|
|
|
if [ "$?" -ne 0 ]; then
|
|
|
|
echo -n "*** ERROR: there was an error extracting the "
|
|
|
|
echo "distfile, aborting *** "
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2008-09-29 17:01:12 +02:00
|
|
|
unset extract_cmd
|
2008-09-27 03:17:12 +02:00
|
|
|
[ -n "$only_extract" ] && exit 0
|
|
|
|
}
|
|
|
|
|
2008-09-28 07:12:07 +02:00
|
|
|
fixup_tmpl_libtool()
|
|
|
|
{
|
2008-10-02 01:38:12 +02:00
|
|
|
local lt_file="$wrksrc/libtool"
|
2008-09-28 07:12:07 +02: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-02 01:38:12 +02:00
|
|
|
$rm_cmd -f $wrksrc/libtool
|
|
|
|
$rm_cmd -f $wrksrc/ltmain.sh
|
2008-09-28 07:12:07 +02:00
|
|
|
$ln_cmd -s $PKGFS_MASTERDIR/bin/libtool $lt_file
|
|
|
|
$ln_cmd -s $PKGFS_MASTERDIR/share/libtool/config/ltmain.sh \
|
2008-10-02 01:38:12 +02:00
|
|
|
$wrksrc/ltmain.sh
|
2008-10-02 18:39:26 +02:00
|
|
|
elif [ -f "$PKGFS_MASTERDIR/bin/libtool" ]; then
|
|
|
|
$ln_cmd -s $PKGFS_MASTERDIR/bin/libtool $lt_file
|
2008-09-28 07:12:07 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2008-10-04 06:29:49 +02:00
|
|
|
#
|
|
|
|
# Configures, builds and installs a package into the destination
|
|
|
|
# directory.
|
|
|
|
#
|
2008-09-27 03:17:12 +02:00
|
|
|
build_tmpl_sources()
|
|
|
|
{
|
2008-10-04 06:29:49 +02:00
|
|
|
local pkg="$pkgname-$version"
|
|
|
|
|
|
|
|
[ -z "$pkgname" -o -z "$version" ] && return 1
|
2008-10-07 02:55:37 +02:00
|
|
|
#
|
|
|
|
# There's nothing of interest if we are a meta template.
|
|
|
|
#
|
|
|
|
[ "$build_style" = "meta-template" ] && return 0
|
2008-09-29 17:01:12 +02:00
|
|
|
|
2008-10-02 18:39:26 +02:00
|
|
|
if [ -n "$distfiles" -a -z "$wrksrc" ]; then
|
2008-10-02 01:38:12 +02:00
|
|
|
wrksrc=$PKGFS_BUILDDIR/$distfiles
|
2008-10-02 01:48:48 +02:00
|
|
|
elif [ -z "$wrksrc" ]; then
|
2008-10-04 06:29:49 +02:00
|
|
|
wrksrc=$PKGFS_BUILDDIR/$pkg
|
2008-10-02 01:48:48 +02:00
|
|
|
else
|
|
|
|
wrksrc=$PKGFS_BUILDDIR/$wrksrc
|
2008-09-26 21:59:07 +02:00
|
|
|
fi
|
2008-09-27 03:17:12 +02:00
|
|
|
|
2008-10-02 01:38:12 +02:00
|
|
|
if [ ! -d "$wrksrc" ]; then
|
2008-09-28 11:41:26 +02:00
|
|
|
echo "*** ERROR: unexistent build directory, aborting ***"
|
2008-09-27 03:17:12 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2008-10-02 01:38:12 +02:00
|
|
|
export PATH="/bin:/sbin:/usr/bin:/usr/sbin:$PKGFS_MASTERDIR/bin:$PKGFS_MASTERDIR/sbin"
|
|
|
|
|
2008-09-28 07:12:07 +02:00
|
|
|
# Apply patches if requested by template file
|
|
|
|
apply_tmpl_patches
|
|
|
|
|
2008-10-04 06:29:49 +02:00
|
|
|
echo "==> Building \`$pkg' (be patient, may take a while)"
|
2008-09-27 03:17:12 +02:00
|
|
|
|
2008-09-28 10:36:43 +02:00
|
|
|
#
|
2008-10-03 14:32:26 +02:00
|
|
|
# For now, just set them through the environment.
|
2008-09-28 10:36:43 +02:00
|
|
|
#
|
2008-10-03 14:32:26 +02:00
|
|
|
LDFLAGS="-L$PKGFS_MASTERDIR/lib -Wl,-R$PKGFS_MASTERDIR/lib $LDFLAGS"
|
2008-10-04 06:29:49 +02:00
|
|
|
export LDFLAGS="-L$PKGFS_DESTDIR/$pkg/lib $LDFLAGS"
|
2008-10-03 14:32:26 +02:00
|
|
|
export CFLAGS="$CFLAGS $PKGFS_CFLAGS"
|
|
|
|
export CXXFLAGS="$CXXFLAGS $PKGFS_CXXFLAGS"
|
|
|
|
export CPPFLAGS="-I$PKGFS_MASTERDIR/include $CPPFLAGS"
|
2008-09-30 17:17:11 +02:00
|
|
|
export PKG_CONFIG="$PKGFS_MASTERDIR/bin/pkg-config"
|
2008-09-29 22:32:08 +02:00
|
|
|
|
2008-10-02 01:38:12 +02:00
|
|
|
# Run stuff before configure.
|
2008-10-02 03:19:27 +02:00
|
|
|
for i in "$run_stuff_before"; do
|
|
|
|
if [ "$i" = "configure" ]; then
|
2008-10-06 16:57:36 +02:00
|
|
|
[ -f $run_stuff_before_configure_file ] && \
|
|
|
|
. $run_stuff_before_configure_file
|
|
|
|
[ -n "$run_stuff_before_configure_cmd" ] && \
|
|
|
|
${run_stuff_before_configure_cmd}
|
2008-10-02 03:19:27 +02:00
|
|
|
fi
|
|
|
|
done
|
2008-10-02 01:38:12 +02:00
|
|
|
|
2008-09-26 21:59:07 +02:00
|
|
|
#
|
|
|
|
# Packages using GNU autoconf
|
|
|
|
#
|
|
|
|
if [ "$build_style" = "gnu_configure" ]; then
|
2008-09-28 07:12:07 +02:00
|
|
|
for i in ${configure_env}; do
|
|
|
|
[ -n "$i" ] && export $i
|
2008-09-26 21:59:07 +02:00
|
|
|
done
|
2008-10-02 01:38:12 +02:00
|
|
|
cd $wrksrc
|
2008-09-30 15:22:57 +02:00
|
|
|
#
|
|
|
|
# Pass consistent arguments to not have unexpected
|
|
|
|
# surprises later.
|
|
|
|
#
|
2008-09-30 22:48:52 +02:00
|
|
|
./configure --prefix="$PKGFS_MASTERDIR" \
|
2008-10-04 06:29:49 +02:00
|
|
|
--mandir="$PKGFS_DESTDIR/$pkg/man" \
|
|
|
|
--infodir="$PKGFS_DESTDIR/$pkg/share/info" \
|
2008-10-03 15:41:26 +02:00
|
|
|
--sysconfdir="$PKGFS_SYSCONFDIR" \
|
2008-09-30 15:22:57 +02:00
|
|
|
${configure_args}
|
2008-09-28 07:12:07 +02:00
|
|
|
|
2008-09-28 10:36:43 +02:00
|
|
|
#
|
|
|
|
# Packages using propietary configure scripts.
|
|
|
|
#
|
2008-09-28 07:12:07 +02:00
|
|
|
elif [ "$build_style" = "configure" ]; then
|
2008-10-02 01:38:12 +02:00
|
|
|
cd $wrksrc
|
2008-09-28 07:12:07 +02:00
|
|
|
if [ -n "$configure_script" ]; then
|
|
|
|
./$configure_script ${configure_args}
|
2008-09-26 21:59:07 +02:00
|
|
|
else
|
2008-09-28 07:12:07 +02:00
|
|
|
./configure ${configure_args}
|
2008-09-26 21:59:07 +02:00
|
|
|
fi
|
2008-10-02 01:38:12 +02: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
|
2008-10-03 00:44:43 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Packages with BSD or GNU Makefiles are easy, just skip
|
|
|
|
# the configure stage and proceed.
|
|
|
|
#
|
|
|
|
elif [ "$build_style" = "bsd_makefile" -o \
|
|
|
|
"$build_style" = "gnu_makefile" ]; then
|
|
|
|
|
|
|
|
cd $wrksrc
|
2008-10-02 01:38:12 +02:00
|
|
|
#
|
|
|
|
# Unknown build_style type won't work :-)
|
|
|
|
#
|
|
|
|
else
|
|
|
|
echo "*** ERROR unknown build_style $build_style, aborting ***"
|
|
|
|
exit 1
|
2008-09-28 07:12:07 +02:00
|
|
|
fi
|
2008-09-26 21:59:07 +02:00
|
|
|
|
2008-10-02 01:38:12 +02:00
|
|
|
if [ "$build_style" != "perl_module" -a "$?" -ne 0 ]; then
|
2008-10-04 06:29:49 +02:00
|
|
|
echo "*** ERROR building (configure state) \`$pkg' ***"
|
2008-09-28 07:12:07 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
2008-09-26 21:59:07 +02:00
|
|
|
|
2008-10-03 00:44:43 +02:00
|
|
|
#
|
|
|
|
# Assume BSD make if make_cmd not set in template.
|
|
|
|
#
|
2008-09-28 07:12:07 +02:00
|
|
|
if [ -z "$make_cmd" ]; then
|
2008-10-03 00:44:43 +02:00
|
|
|
make_cmd="/usr/bin/make"
|
2008-09-28 07:12:07 +02:00
|
|
|
fi
|
2008-09-26 21:59:07 +02:00
|
|
|
|
2008-09-28 07:12:07 +02:00
|
|
|
# Fixup libtool script if necessary
|
|
|
|
fixup_tmpl_libtool
|
2008-09-27 03:17:12 +02:00
|
|
|
|
2008-10-02 01:38:12 +02:00
|
|
|
#
|
|
|
|
# Run template stuff before building.
|
|
|
|
#
|
2008-10-02 03:19:27 +02:00
|
|
|
for i in ${run_stuff_before}; do
|
|
|
|
if [ "$i" = "build" ]; then
|
2008-10-06 16:57:36 +02:00
|
|
|
[ -f $run_stuff_before_build_file ] && \
|
|
|
|
. $run_stuff_before_build_file
|
|
|
|
[ -n "$run_stuff_before_build_cmd" ] && \
|
|
|
|
${run_stuff_before_build_cmd}
|
2008-10-02 03:19:27 +02:00
|
|
|
fi
|
|
|
|
done
|
2008-10-02 01:38:12 +02:00
|
|
|
|
2008-10-02 18:39:26 +02:00
|
|
|
[ -z "$make_build_target" ] && make_build_target=
|
2008-10-07 00:10:13 +02:00
|
|
|
[ -n "$PKGFS_MAKEJOBS" ] && PKGFS_MAKEJOBS="-j$PKGFS_MAKEJOBS"
|
2008-10-02 01:38:12 +02:00
|
|
|
#
|
|
|
|
# Build package via make.
|
|
|
|
#
|
2008-10-07 00:10:13 +02:00
|
|
|
${make_cmd} ${PKGFS_MAKEJOBS} ${make_build_args} ${make_build_target}
|
2008-09-28 07:12:07 +02:00
|
|
|
if [ "$?" -ne 0 ]; then
|
2008-10-04 06:29:49 +02:00
|
|
|
echo "*** ERROR building (make stage) \`$pkg' ***"
|
2008-09-28 07:12:07 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
2008-09-27 03:17:12 +02:00
|
|
|
|
2008-10-02 01:38:12 +02:00
|
|
|
#
|
|
|
|
# Run template stuff before installing.
|
|
|
|
#
|
2008-10-02 03:19:27 +02:00
|
|
|
for i in ${run_stuff_before}; do
|
|
|
|
if [ "$i" = "install" ]; then
|
2008-10-06 16:57:36 +02:00
|
|
|
[ -f $run_stuff_before_install_file ] && \
|
|
|
|
. $run_stuff_before_install_file
|
|
|
|
[ -n "$run_stuff_before_install_cmd" ] && \
|
|
|
|
${run_stuff_before_install_cmd}
|
2008-10-02 03:19:27 +02:00
|
|
|
fi
|
|
|
|
done
|
2008-10-02 01:38:12 +02:00
|
|
|
|
2008-10-02 18:39:26 +02:00
|
|
|
[ -z "$make_install_target" ] && make_install_target=install
|
|
|
|
|
2008-10-02 01:38:12 +02:00
|
|
|
#
|
|
|
|
# Install package via make.
|
|
|
|
#
|
2008-10-03 00:44:43 +02:00
|
|
|
${make_cmd} ${make_install_args} ${make_install_target} \
|
2008-10-04 06:29:49 +02:00
|
|
|
prefix="$PKGFS_DESTDIR/$pkg"
|
2008-09-28 07:12:07 +02:00
|
|
|
if [ "$?" -ne 0 ]; then
|
2008-10-04 06:29:49 +02:00
|
|
|
echo "*** ERROR instaling \`$pkg' ***"
|
2008-09-28 07:12:07 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2008-10-02 01:38:12 +02:00
|
|
|
#
|
|
|
|
# Run template stuff after installing.
|
|
|
|
#
|
2008-10-02 03:19:27 +02:00
|
|
|
for i in ${run_stuff_after}; do
|
|
|
|
if [ "$i" = "install" ]; then
|
2008-10-06 16:57:36 +02:00
|
|
|
[ -f $run_stuff_after_install_file ] && \
|
|
|
|
. $run_stuff_after_install_file
|
|
|
|
[ -n "$run_stuff_after_install_cmd" ] && \
|
|
|
|
${run_stuff_after_install_cmd}
|
2008-10-02 03:19:27 +02:00
|
|
|
fi
|
|
|
|
done
|
2008-10-02 01:38:12 +02:00
|
|
|
|
|
|
|
#
|
2008-09-30 22:48:52 +02:00
|
|
|
# Transform pkg-config files if requested by template.
|
2008-10-02 01:38:12 +02:00
|
|
|
#
|
2008-09-30 22:48:52 +02:00
|
|
|
for i in ${pkgconfig_override}; do
|
2008-10-04 06:29:49 +02:00
|
|
|
local tmpf="$PKGFS_DESTDIR/$pkg/lib/pkgconfig/$i"
|
2008-10-02 01:38:12 +02:00
|
|
|
[ -f "$tmpf" ] && \
|
|
|
|
[ -f $PKGFS_TMPLHELPDIR/pkg-config-transform.sh ] && \
|
2008-10-04 16:27:27 +02:00
|
|
|
. $PKGFS_TMPLHELPDIR/pkg-config-transform.sh && \
|
|
|
|
pkgconfig_transform_file $tmpf
|
2008-09-30 22:48:52 +02:00
|
|
|
done
|
|
|
|
|
2008-09-28 10:36:43 +02:00
|
|
|
|
2008-10-04 06:29:49 +02:00
|
|
|
echo "==> Installed \`$pkg' into $PKGFS_DESTDIR/$pkg."
|
2008-09-28 07:12:07 +02:00
|
|
|
|
2008-10-03 17:19:37 +02:00
|
|
|
#
|
|
|
|
# Once all work has been done, unset compilation vars.
|
|
|
|
#
|
|
|
|
unset LDFLAGS CFLAGS CXXFLAGS CPPFLAGS PKG_CONFIG
|
|
|
|
|
2008-10-02 01:38:12 +02:00
|
|
|
#
|
|
|
|
# Remove $wrksrc if -C not specified.
|
|
|
|
#
|
|
|
|
if [ -d "$wrksrc" -a -z "$dontrm_builddir" ]; then
|
|
|
|
$rm_cmd -rf $wrksrc
|
2008-09-28 11:41:26 +02:00
|
|
|
[ "$?" -eq 0 ] && \
|
2008-10-04 06:29:49 +02:00
|
|
|
echo "=> Removed \`$pkg' build directory."
|
2008-09-28 07:12:07 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
cd $PKGFS_BUILDDIR
|
|
|
|
}
|
|
|
|
|
2008-10-04 06:29:49 +02:00
|
|
|
#
|
|
|
|
# Stows a currently installed package, i.e creates the links
|
|
|
|
# on the master directory.
|
|
|
|
#
|
2008-09-28 07:12:07 +02:00
|
|
|
stow_tmpl()
|
|
|
|
{
|
|
|
|
local pkg="$1"
|
2008-09-30 15:22:57 +02:00
|
|
|
local infodir_pkg="share/info/dir"
|
|
|
|
local infodir_master="$PKGFS_MASTERDIR/share/info/dir"
|
2008-09-30 18:19:52 +02:00
|
|
|
local real_xstowargs="$xstow_args"
|
2008-10-06 16:57:36 +02:00
|
|
|
local real_xstow_ignore="$xstow_ignore_files"
|
2008-09-28 07:12:07 +02:00
|
|
|
|
2008-09-28 09:57:30 +02:00
|
|
|
[ -z "$pkg" ] && return 2
|
|
|
|
|
2008-10-04 06:29:49 +02:00
|
|
|
if [ -n "$stow_flag" ]; then
|
|
|
|
pkg=$PKGFS_TEMPLATESDIR/$pkg.tmpl
|
|
|
|
run_file $pkg
|
|
|
|
pkg=$pkgname-$version
|
2008-10-07 02:55:37 +02:00
|
|
|
#
|
|
|
|
# You cannot stow a meta-template.
|
|
|
|
#
|
|
|
|
[ "$build_style" = "meta-template" ] && return 0
|
2008-10-04 06:29:49 +02:00
|
|
|
fi
|
|
|
|
|
2008-09-30 15:22:57 +02:00
|
|
|
if [ -r "$PKGFS_DESTDIR/$pkg/$infodir_pkg" ]; then
|
2008-10-04 06:29:49 +02:00
|
|
|
merge_infodir_tmpl $pkg
|
2008-09-30 15:22:57 +02:00
|
|
|
fi
|
|
|
|
|
2008-10-04 06:29:49 +02:00
|
|
|
if [ -r "$PKGFS_DESTDIR/$pkg/$infodir_pkg" \
|
|
|
|
-a -r "$infodir_master" ]; then
|
2008-09-30 15:22:57 +02:00
|
|
|
xstow_args="$xstow_args -i-file-in-dir $infodir_pkg"
|
|
|
|
fi
|
|
|
|
|
2008-10-06 16:57:36 +02:00
|
|
|
if [ -n "$ignore_files" ]; then
|
|
|
|
xstow_ignore_files="$xstow_ignore_files $ignore_files"
|
|
|
|
fi
|
|
|
|
|
|
|
|
$PKGFS_XSTOW_CMD -ignore "${xstow_ignore_files}" ${xstow_args} \
|
2008-10-02 02:53:09 +02:00
|
|
|
-pd-targets $PKGFS_MASTERDIR \
|
2008-09-30 18:19:52 +02:00
|
|
|
-dir $PKGFS_DESTDIR -target $PKGFS_MASTERDIR \
|
2008-09-30 15:22:57 +02:00
|
|
|
$PKGFS_DESTDIR/$pkg
|
2008-09-28 07:12:07 +02:00
|
|
|
if [ "$?" -ne 0 ]; then
|
2008-09-28 11:41:26 +02:00
|
|
|
echo "*** ERROR: couldn't create symlinks for \`$pkg' ***"
|
2008-09-28 07:12:07 +02:00
|
|
|
exit 1
|
|
|
|
else
|
2008-09-30 22:48:52 +02:00
|
|
|
echo "==> Created \`$pkg' symlinks into master directory."
|
2008-09-28 07:12:07 +02:00
|
|
|
fi
|
|
|
|
|
2008-10-05 21:23:39 +02:00
|
|
|
installed_tmpl_handler register $pkgname $version
|
2008-10-03 17:19:37 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Run template postinstall helpers if requested.
|
|
|
|
#
|
2008-10-04 06:29:49 +02:00
|
|
|
if [ "$pkgname" != "${pkg%%-$version}" ]; then
|
|
|
|
run_file $PKGFS_TEMPLATESDIR/${pkg%%-$version}.tmpl
|
2008-10-03 17:19:37 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
for i in ${postinstall_helpers}; do
|
|
|
|
local pihf="$PKGFS_TMPLHELPDIR/$i"
|
|
|
|
[ -f "$pihf" ] && . $pihf
|
|
|
|
done
|
2008-10-06 16:57:36 +02:00
|
|
|
|
|
|
|
xstow_ignore_files="$real_xstow_ignore"
|
|
|
|
xstow_args="$real_xstowargs"
|
2008-09-28 07:12:07 +02:00
|
|
|
}
|
|
|
|
|
2008-10-04 06:29:49 +02:00
|
|
|
#
|
|
|
|
# Unstows a currently stowned package, i.e removes its links
|
|
|
|
# from the master directory.
|
|
|
|
#
|
2008-09-28 07:12:07 +02:00
|
|
|
unstow_tmpl()
|
|
|
|
{
|
|
|
|
local pkg="$1"
|
2008-10-06 16:57:36 +02:00
|
|
|
local real_xstow_ignore="$xstow_ignore_files"
|
2008-09-28 07:12:07 +02:00
|
|
|
|
2008-09-28 09:57:30 +02:00
|
|
|
if [ -z "$pkg" ]; then
|
|
|
|
echo "*** ERROR: template wasn't specified? ***"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2008-10-04 06:29:49 +02:00
|
|
|
if [ "$pkg" = "xstow" ]; then
|
|
|
|
echo "*** INFO: You aren't allowed to unstow \`$pkg'."
|
2008-09-28 09:57:30 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2008-10-04 06:29:49 +02:00
|
|
|
run_file $PKGFS_TEMPLATESDIR/$pkg.tmpl
|
|
|
|
|
2008-10-07 02:55:37 +02:00
|
|
|
#
|
|
|
|
# You cannot unstow a meta-template.
|
|
|
|
#
|
|
|
|
[ "$build_style" = "meta-template" ] && return 0
|
|
|
|
|
2008-10-06 16:57:36 +02:00
|
|
|
if [ -n "$ignore_files" ]; then
|
|
|
|
xstow_ignore_files="$xstow_ignore_files $ignore_files"
|
|
|
|
fi
|
|
|
|
|
2008-09-28 07:12:07 +02:00
|
|
|
$PKGFS_XSTOW_CMD -dir $PKGFS_DESTDIR -target $PKGFS_MASTERDIR \
|
2008-10-06 16:57:36 +02:00
|
|
|
-D -i-file-in-dir share/info/dir -ignore \
|
|
|
|
"${xstow_ignore_files}" $PKGFS_DESTDIR/$pkgname-$version
|
2008-09-28 07:12:07 +02:00
|
|
|
if [ "$?" -ne 0 ]; then
|
|
|
|
exit 1
|
|
|
|
else
|
2008-10-04 06:29:49 +02:00
|
|
|
$rm_cmd -f $PKGFS_DESTDIR/$pkgname-$version/share/info/dir
|
2008-09-30 22:48:52 +02:00
|
|
|
echo "==> Removed \`$pkg' symlinks from master directory."
|
2008-09-26 21:59:07 +02:00
|
|
|
fi
|
2008-09-29 17:01:12 +02:00
|
|
|
|
2008-10-05 21:23:39 +02:00
|
|
|
installed_tmpl_handler unregister $pkgname $version
|
2008-10-06 16:57:36 +02:00
|
|
|
|
|
|
|
xstow_ignore_files="$real_xstow_ignore"
|
2008-09-26 21:59:07 +02:00
|
|
|
}
|
|
|
|
|
2008-10-04 06:29:49 +02:00
|
|
|
#
|
|
|
|
# Recursive function that founds dependencies in all required
|
|
|
|
# packages.
|
|
|
|
#
|
2008-09-29 17:01:12 +02:00
|
|
|
add_dependency_tolist()
|
2008-09-26 21:59:07 +02:00
|
|
|
{
|
2008-10-04 06:29:49 +02:00
|
|
|
local curpkg="$1"
|
2008-09-29 17:01:12 +02:00
|
|
|
|
2008-10-04 06:29:49 +02:00
|
|
|
[ -z "$curpkg" ] && return 1
|
|
|
|
[ -n "$prev_pkg" ] && curpkg=$prev_pkg
|
2008-09-29 17:01:12 +02:00
|
|
|
|
2008-10-07 01:39:32 +02:00
|
|
|
for i in $($db_cmd -V btree $PKGFS_BUILD_DEPS_DB ${curpkg%-[0-9].*}); do
|
2008-10-03 14:32:26 +02:00
|
|
|
#
|
2008-09-29 17:01:12 +02:00
|
|
|
# Check if dep already installed.
|
|
|
|
#
|
2008-10-05 21:23:39 +02:00
|
|
|
if [ -r "$PKGFS_REGPKG_DB" ]; then
|
|
|
|
check_installed_tmpl $i ${i##[aA-zZ]*-}
|
2008-10-04 20:44:56 +02:00
|
|
|
#
|
|
|
|
# If dep is already installed, put it on the
|
|
|
|
# installed deps list and continue.
|
|
|
|
#
|
2008-09-29 17:01:12 +02:00
|
|
|
if [ "$?" -eq 0 ]; then
|
2008-10-04 20:44:56 +02:00
|
|
|
installed_deps_list="$i $installed_deps_list"
|
2008-09-29 17:01:12 +02:00
|
|
|
continue
|
|
|
|
fi
|
2008-10-03 14:32:26 +02:00
|
|
|
|
2008-09-29 17:01:12 +02:00
|
|
|
deps_list="$i $deps_list"
|
2008-10-04 06:29:49 +02:00
|
|
|
[ -n "$prev_pkg" ] && unset prev_pkg
|
2008-09-29 17:01:12 +02:00
|
|
|
#
|
|
|
|
# Check if dependency needs more deps.
|
|
|
|
#
|
2008-10-04 06:29:49 +02:00
|
|
|
check_build_depends_tmpl $i
|
|
|
|
if [ "$?" -eq 0 ]; then
|
|
|
|
add_dependency_tolist $i
|
|
|
|
prev_pkg="$i"
|
2008-09-29 17:01:12 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2008-10-04 20:44:56 +02:00
|
|
|
#
|
|
|
|
# Removes duplicate deps in the installed or not installed list.
|
|
|
|
#
|
|
|
|
find_dupdeps_inlist()
|
|
|
|
{
|
|
|
|
local action="$1"
|
|
|
|
local tmp_list=
|
|
|
|
local dup=
|
|
|
|
|
|
|
|
[ -z "$action" ] && return 1
|
|
|
|
|
|
|
|
case "$action" in
|
|
|
|
installed)
|
|
|
|
list=$installed_deps_list
|
|
|
|
;;
|
|
|
|
notinstalled)
|
|
|
|
list=$deps_list
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
return 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
for f in $list; do
|
|
|
|
if [ -z "$tmp_list" ]; then
|
|
|
|
tmp_list="$f"
|
|
|
|
else
|
|
|
|
for i in $tmp_list; do
|
|
|
|
[ "$f" = "$i" ] && dup=yes
|
|
|
|
done
|
|
|
|
|
|
|
|
[ -z "$dup" ] && tmp_list="$tmp_list $f"
|
|
|
|
unset dup
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
case "$action" in
|
|
|
|
installed)
|
|
|
|
installed_deps_list="$tmp_list"
|
|
|
|
;;
|
|
|
|
notinstalled)
|
|
|
|
deps_list="$tmp_list"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
return 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2008-10-04 06:29:49 +02:00
|
|
|
#
|
|
|
|
# Installs all dependencies required by a package.
|
|
|
|
#
|
2008-09-29 17:01:12 +02:00
|
|
|
install_dependency_tmpl()
|
|
|
|
{
|
2008-10-04 06:29:49 +02:00
|
|
|
local pkg="$1"
|
2008-09-29 17:01:12 +02:00
|
|
|
deps_list=
|
2008-10-04 20:44:56 +02:00
|
|
|
installed_deps_list=
|
2008-09-29 17:01:12 +02:00
|
|
|
|
2008-10-04 06:29:49 +02:00
|
|
|
[ -z "$pkg" ] && return 1
|
2008-09-29 17:01:12 +02:00
|
|
|
|
|
|
|
doing_deps=true
|
|
|
|
|
2008-10-04 20:44:56 +02:00
|
|
|
add_dependency_tolist $pkg
|
|
|
|
find_dupdeps_inlist installed
|
|
|
|
find_dupdeps_inlist notinstalled
|
|
|
|
|
2008-10-04 06:29:49 +02:00
|
|
|
echo "==> Required dependencies for $(basename $pkg):"
|
2008-10-04 20:44:56 +02:00
|
|
|
for i in ${installed_deps_list}; do
|
2008-10-07 01:39:32 +02:00
|
|
|
fpkg="$($db_cmd -O '-' btree $PKGFS_REGPKG_DB ${i%-[0-9].*})"
|
2008-10-05 21:23:39 +02:00
|
|
|
echo " $i: found $fpkg."
|
2008-10-04 20:44:56 +02:00
|
|
|
done
|
2008-09-29 17:01:12 +02:00
|
|
|
|
2008-10-04 20:44:56 +02:00
|
|
|
for i in ${deps_list}; do
|
|
|
|
echo " $i: not installed."
|
|
|
|
done
|
2008-09-29 17:01:12 +02:00
|
|
|
|
|
|
|
for i in ${deps_list}; do
|
2008-09-29 22:32:08 +02:00
|
|
|
# skip dup deps
|
2008-09-30 22:48:52 +02:00
|
|
|
echo "=> Installing dependency: $i"
|
2008-10-07 01:39:32 +02:00
|
|
|
install_tmpl ${i%-[0-9].*}
|
2008-09-29 17:01:12 +02:00
|
|
|
done
|
2008-09-29 22:32:08 +02:00
|
|
|
|
2008-10-04 20:44:56 +02:00
|
|
|
unset installed_deps_list
|
2008-10-03 14:32:26 +02:00
|
|
|
unset deps_list
|
2008-09-29 17:01:12 +02:00
|
|
|
}
|
|
|
|
|
2008-10-04 06:29:49 +02:00
|
|
|
#
|
|
|
|
# Installs and stows the "xstow" package.
|
|
|
|
#
|
2008-09-29 17:01:12 +02:00
|
|
|
install_xstow_tmpl()
|
|
|
|
{
|
|
|
|
[ -x "$PKGFS_XSTOW_CMD" ] && return 0
|
|
|
|
|
|
|
|
reset_tmpl_vars
|
2008-10-04 06:29:49 +02:00
|
|
|
run_file "$PKGFS_TEMPLATESDIR/xstow.tmpl"
|
|
|
|
check_tmpl_vars $pkgname-$version
|
2008-09-29 17:01:12 +02:00
|
|
|
fetch_tmpl_sources
|
|
|
|
extract_tmpl_sources
|
|
|
|
build_tmpl_sources
|
2008-10-04 06:29:49 +02:00
|
|
|
PKGFS_XSTOW_CMD="$PKGFS_DESTDIR/$pkgname-$version/bin/xstow"
|
|
|
|
stow_tmpl $pkgname-$version
|
2008-09-29 17:01:12 +02:00
|
|
|
#
|
|
|
|
# Continue with origin package that called us.
|
|
|
|
#
|
2008-10-04 06:29:49 +02:00
|
|
|
run_file $origin_tmpl
|
2008-09-29 17:01:12 +02:00
|
|
|
}
|
|
|
|
|
2008-10-04 06:29:49 +02:00
|
|
|
#
|
|
|
|
# Registers or unregisters a package from the db file.
|
|
|
|
#
|
2008-09-29 17:01:12 +02:00
|
|
|
installed_tmpl_handler()
|
|
|
|
{
|
|
|
|
local action="$1"
|
|
|
|
local pkg="$2"
|
2008-10-05 21:23:39 +02:00
|
|
|
local version="$3"
|
2008-09-29 17:01:12 +02:00
|
|
|
|
2008-10-05 21:23:39 +02:00
|
|
|
[ -z "$action" -o -z "$pkg" -o -z "$version" ] && return 1
|
2008-09-29 17:01:12 +02:00
|
|
|
if [ "$action" = "register" ]; then
|
2008-10-07 02:55:37 +02:00
|
|
|
$db_cmd -w btree $PKGFS_REGPKG_DB $pkg $version 2>&1 >/dev/null
|
2008-09-29 17:01:12 +02:00
|
|
|
if [ "$?" -ne 0 ]; then
|
2008-10-07 02:55:37 +02:00
|
|
|
echo -n "*** ERROR: couldn't register \`$pkg'"
|
2008-09-29 17:01:12 +02:00
|
|
|
echo " in db file ***"
|
2008-09-28 09:57:30 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
2008-09-29 17:01:12 +02:00
|
|
|
elif [ "$action" = "unregister" ]; then
|
2008-10-07 02:55:37 +02:00
|
|
|
$db_cmd -d btree $PKGFS_REGPKG_DB $pkg 2>&1 >/dev/null
|
2008-09-29 17:01:12 +02:00
|
|
|
if [ "$?" -ne 0 ]; then
|
2008-10-07 02:55:37 +02:00
|
|
|
echo -n "*** ERROR: \`$pkg' not registered "
|
2008-09-29 17:01:12 +02:00
|
|
|
echo "in db file? ***"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2008-10-04 06:29:49 +02:00
|
|
|
#
|
2008-10-05 21:23:39 +02:00
|
|
|
# Checks the registered pkgs db file and returns 0 if a pkg that satisfies
|
|
|
|
# the minimal required version if there, or 1 otherwise.
|
2008-10-04 06:29:49 +02:00
|
|
|
#
|
2008-09-29 17:01:12 +02:00
|
|
|
check_installed_tmpl()
|
|
|
|
{
|
|
|
|
local pkg="$1"
|
2008-10-05 21:23:39 +02:00
|
|
|
local reqver="$2"
|
|
|
|
local iver=
|
2008-09-29 17:01:12 +02:00
|
|
|
|
2008-10-05 21:23:39 +02:00
|
|
|
[ -z "$pkg" -o -z "$reqver" ] && return 1
|
2008-09-29 17:01:12 +02:00
|
|
|
|
2008-10-07 01:39:32 +02:00
|
|
|
run_file $PKGFS_TEMPLATESDIR/${pkg%-[0-9].*}.tmpl
|
2008-10-05 21:23:39 +02:00
|
|
|
|
|
|
|
reqver="$(echo $reqver | $sed_cmd 's|\.||g;s|[aA-zZ]||g')"
|
|
|
|
|
|
|
|
$db_cmd -K btree $PKGFS_REGPKG_DB $pkgname 2>&1 >/dev/null
|
|
|
|
if [ "$?" -eq 0 ]; then
|
|
|
|
#
|
|
|
|
# Package is installed, let's check the version.
|
|
|
|
#
|
|
|
|
iver="$($db_cmd -V btree $PKGFS_REGPKG_DB $pkgname)"
|
|
|
|
if [ -n "$iver" ]; then
|
|
|
|
#
|
|
|
|
# As shell only supports decimal arith expressions,
|
|
|
|
# we simply remove anything except the numbers.
|
|
|
|
# It's not optimal and may fail, but it is enough
|
|
|
|
# for now.
|
|
|
|
#
|
|
|
|
iver="$(echo $iver | $sed_cmd 's|\.||g;s|[aA-zZ]||g')"
|
|
|
|
if [ "$iver" -eq "$reqver" \
|
|
|
|
-o "$iver" -gt "$reqver" ]; then
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
return 1
|
2008-09-29 17:01:12 +02:00
|
|
|
}
|
|
|
|
|
2008-10-04 06:29:49 +02:00
|
|
|
#
|
|
|
|
# Checks the build depends db file and returns 0 if pkg has dependencies,
|
|
|
|
# otherwise returns 1.
|
|
|
|
#
|
|
|
|
check_build_depends_tmpl()
|
|
|
|
{
|
|
|
|
local pkg="$1"
|
|
|
|
|
|
|
|
[ -z $pkg ] && return 1
|
|
|
|
[ ! -r $PKGFS_BUILD_DEPS_DB ] && return 1
|
|
|
|
|
2008-10-07 01:39:32 +02:00
|
|
|
$db_cmd -V btree $PKGFS_BUILD_DEPS_DB ${pkg%-[0-9].*} 2>&1 >/dev/null
|
2008-10-04 06:29:49 +02:00
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Installs a pkg by reading its build template file.
|
|
|
|
#
|
2008-09-29 17:01:12 +02:00
|
|
|
install_tmpl()
|
|
|
|
{
|
2008-10-04 06:29:49 +02:00
|
|
|
local pkg=
|
2008-09-30 01:59:51 +02:00
|
|
|
cur_tmpl="$PKGFS_TEMPLATESDIR/$1.tmpl"
|
2008-09-29 17:01:12 +02: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 07:12:07 +02:00
|
|
|
fi
|
2008-09-27 00:19:02 +02:00
|
|
|
|
2008-09-29 17:01:12 +02:00
|
|
|
reset_tmpl_vars
|
2008-10-04 06:29:49 +02:00
|
|
|
run_file $cur_tmpl
|
|
|
|
pkg="$1-$version"
|
2008-09-28 09:57:30 +02:00
|
|
|
|
2008-09-29 17:01:12 +02:00
|
|
|
#
|
|
|
|
# If we are the originator package save the path this template in
|
|
|
|
# other var for future use.
|
|
|
|
#
|
|
|
|
if [ -z "$origin_tmpl" ]; then
|
2008-10-04 06:29:49 +02:00
|
|
|
origin_tmpl=$path_fixed
|
2008-09-29 17:01:12 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# Install xstow if it's not there.
|
|
|
|
#
|
|
|
|
install_xstow_tmpl
|
|
|
|
|
|
|
|
#
|
|
|
|
# Check vars for current template.
|
|
|
|
#
|
2008-10-04 06:29:49 +02:00
|
|
|
check_tmpl_vars $pkg
|
2008-09-27 03:17:12 +02:00
|
|
|
|
2008-09-29 17:01:12 +02:00
|
|
|
#
|
2008-10-04 06:29:49 +02:00
|
|
|
# Install dependencies required by this package.
|
2008-09-29 17:01:12 +02:00
|
|
|
#
|
2008-10-04 06:29:49 +02:00
|
|
|
check_build_depends_tmpl $pkg
|
|
|
|
if [ "$?" -eq 0 -a -z "$doing_deps" ]; then
|
|
|
|
install_dependency_tmpl $pkg
|
2008-09-29 17:23:23 +02:00
|
|
|
#
|
|
|
|
# At this point all required deps are installed, and
|
|
|
|
# only remaining is the origin template; install it.
|
|
|
|
#
|
2008-10-03 15:41:26 +02:00
|
|
|
unset doing_deps
|
2008-09-29 17:01:12 +02:00
|
|
|
reset_tmpl_vars
|
2008-10-04 06:29:49 +02:00
|
|
|
run_file $origin_tmpl
|
|
|
|
check_tmpl_vars $pkgname-$version
|
2008-09-29 17:01:12 +02:00
|
|
|
fi
|
|
|
|
|
2008-09-28 07:12:07 +02:00
|
|
|
if [ -n "$only_build" ]; then
|
2008-09-27 03:17:12 +02:00
|
|
|
build_tmpl_sources
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2008-09-29 17:01:12 +02:00
|
|
|
#
|
|
|
|
# Fetch, extract, stow and reset vars for a template.
|
|
|
|
#
|
2008-09-27 03:17:12 +02:00
|
|
|
fetch_tmpl_sources
|
|
|
|
extract_tmpl_sources
|
|
|
|
build_tmpl_sources
|
2008-10-02 03:52:21 +02:00
|
|
|
|
2008-10-07 02:55:37 +02:00
|
|
|
#
|
|
|
|
# Just announce that meta-template is installed and exit.
|
|
|
|
#
|
|
|
|
if [ "$build_style" = "meta-template" ]; then
|
|
|
|
installed_tmpl_handler register $pkgname $version
|
|
|
|
echo "==> Installed meta-template \`$pkg'."
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
2008-10-02 03:52:21 +02:00
|
|
|
#
|
|
|
|
# Do not stow the pkg if requested.
|
|
|
|
#
|
2008-10-04 06:29:49 +02:00
|
|
|
[ -z "$only_install" ] && stow_tmpl $pkg
|
2008-09-26 21:59:07 +02:00
|
|
|
}
|
|
|
|
|
2008-10-04 06:29:49 +02:00
|
|
|
#
|
|
|
|
# Lists all currently installed packages.
|
|
|
|
#
|
2008-09-30 00:45:25 +02:00
|
|
|
list_tmpls()
|
|
|
|
{
|
2008-10-05 21:23:39 +02:00
|
|
|
if [ ! -r "$PKGFS_REGPKG_DB" ]; then
|
2008-10-03 18:53:58 +02:00
|
|
|
echo "=> No packages registered or missing register db file."
|
|
|
|
exit 0
|
2008-09-30 00:45:25 +02:00
|
|
|
fi
|
|
|
|
|
2008-10-05 21:23:39 +02:00
|
|
|
for i in $($db_cmd -K btree $PKGFS_REGPKG_DB); do
|
2008-09-30 00:45:25 +02:00
|
|
|
# Run file to get short_desc and print something useful
|
2008-10-05 21:23:39 +02:00
|
|
|
run_file ${PKGFS_TEMPLATESDIR}/$i.tmpl
|
|
|
|
echo "$i-$version $short_desc"
|
2008-09-30 00:45:25 +02:00
|
|
|
reset_tmpl_vars
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2008-10-04 06:29:49 +02:00
|
|
|
#
|
|
|
|
# Removes a currently installed package (unstow + removed from destdir).
|
|
|
|
#
|
2008-09-28 11:41:26 +02:00
|
|
|
remove_tmpl()
|
|
|
|
{
|
|
|
|
local pkg="$1"
|
|
|
|
|
|
|
|
if [ -z "$pkg" ]; then
|
|
|
|
echo "*** ERROR: unexistent package, aborting ***"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2008-10-04 06:29:49 +02:00
|
|
|
if [ ! -f "$PKGFS_TEMPLATESDIR/$pkg.tmpl" ]; then
|
|
|
|
echo "*** ERROR: cannot find template file ***"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
run_file $PKGFS_TEMPLATESDIR/$pkg.tmpl
|
|
|
|
|
2008-10-07 02:55:37 +02:00
|
|
|
#
|
|
|
|
# If it's a meta-template, just unregister it from the db.
|
|
|
|
#
|
|
|
|
if [ "$build_style" = "meta-template" ]; then
|
|
|
|
installed_tmpl_handler unregister $pkgname $version
|
|
|
|
[ "$?" -eq 0 ] && \
|
|
|
|
echo "=> Removed meta-template \`$pkg'."
|
|
|
|
return $?
|
|
|
|
fi
|
|
|
|
|
2008-10-04 06:29:49 +02:00
|
|
|
if [ ! -d "$PKGFS_DESTDIR/$pkg-$version" ]; then
|
2008-09-28 11:41:26 +02:00
|
|
|
echo "*** ERROR: cannot find package on $PKGFS_DESTDIR ***"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2008-10-04 14:02:39 +02:00
|
|
|
unstow_tmpl $pkg
|
2008-10-04 06:29:49 +02:00
|
|
|
$rm_cmd -rf $PKGFS_DESTDIR/$pkg-$version
|
2008-09-29 17:01:12 +02:00
|
|
|
return "$?"
|
2008-09-28 11:41:26 +02:00
|
|
|
}
|
|
|
|
|
2008-09-26 23:23:41 +02:00
|
|
|
#
|
|
|
|
# main()
|
|
|
|
#
|
2008-10-02 03:52:21 +02:00
|
|
|
args=$(getopt bCc:efi $*)
|
2008-09-26 21:59:07 +02:00
|
|
|
[ "$?" -ne 0 ] && usage
|
|
|
|
|
|
|
|
set -- $args
|
|
|
|
while [ "$#" -gt 0 ]; do
|
|
|
|
case "$1" in
|
2008-09-27 03:17:12 +02:00
|
|
|
-b)
|
|
|
|
only_build=yes
|
|
|
|
;;
|
|
|
|
-C)
|
2008-09-28 07:12:07 +02:00
|
|
|
dontrm_builddir=yes
|
2008-09-27 03:17:12 +02:00
|
|
|
;;
|
2008-09-26 21:59:07 +02:00
|
|
|
-c)
|
2008-10-03 18:53:58 +02:00
|
|
|
config_file_specified=yes
|
2008-09-26 21:59:07 +02:00
|
|
|
PKGFS_CONFIG_FILE="$2"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-e)
|
|
|
|
only_extract=yes
|
|
|
|
;;
|
|
|
|
-f)
|
|
|
|
only_fetch=yes
|
|
|
|
;;
|
2008-10-02 03:52:21 +02:00
|
|
|
-i)
|
|
|
|
only_install=yes
|
|
|
|
;;
|
2008-09-26 21:59:07 +02:00
|
|
|
--)
|
|
|
|
shift
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
[ "$#" -gt 2 ] && usage
|
|
|
|
|
2008-09-27 03:17:12 +02:00
|
|
|
target="$1"
|
|
|
|
if [ -z "$target" ]; then
|
2008-09-26 21:59:07 +02:00
|
|
|
echo "*** ERROR missing target ***"
|
|
|
|
usage
|
|
|
|
fi
|
|
|
|
|
2008-09-30 22:48:52 +02:00
|
|
|
#
|
|
|
|
# Check configuration vars before anyting else, and set defaults vars.
|
|
|
|
#
|
2008-09-29 17:01:12 +02:00
|
|
|
check_config_vars
|
2008-09-30 22:48:52 +02:00
|
|
|
set_defvars
|
2008-09-29 17:01:12 +02:00
|
|
|
|
2008-09-26 21:59:07 +02:00
|
|
|
# Main switch
|
2008-09-27 03:17:12 +02:00
|
|
|
case "$target" in
|
2008-09-26 21:59:07 +02:00
|
|
|
info)
|
2008-09-28 07:12:07 +02:00
|
|
|
info_tmpl "$2"
|
|
|
|
;;
|
2008-09-28 11:41:26 +02:00
|
|
|
install)
|
|
|
|
install_tmpl "$2"
|
|
|
|
;;
|
2008-09-30 00:45:25 +02:00
|
|
|
list)
|
|
|
|
list_tmpls
|
|
|
|
;;
|
2008-09-28 11:41:26 +02:00
|
|
|
remove)
|
|
|
|
remove_tmpl "$2"
|
|
|
|
;;
|
2008-09-28 07:12:07 +02:00
|
|
|
stow)
|
2008-10-04 06:29:49 +02:00
|
|
|
stow_flag=yes
|
2008-09-28 07:12:07 +02:00
|
|
|
stow_tmpl "$2"
|
|
|
|
;;
|
|
|
|
unstow)
|
|
|
|
unstow_tmpl "$2"
|
2008-09-26 21:59:07 +02:00
|
|
|
;;
|
|
|
|
*)
|
2008-09-27 03:17:12 +02:00
|
|
|
echo "*** ERROR invalid target '$target' ***"
|
2008-09-26 21:59:07 +02:00
|
|
|
usage
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Agur
|
|
|
|
exit 0
|