# Notes (todo):
# - builder -u fetches current version first (well that's okay, how you compare versions if you have no old spec?)
# - when Icon: field is present, -5 and -a5 doesn't work
+# - builder -R skips installing BR if spec is not present before builder invocation (need to run builder twice)
VERSION="\
-Build package utility from PLD CVS repository
+Build package utility from PLD Linux CVS repository
V 0.13 (C) 1999-2005 Free Penguins".
PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
UPDATE5=""
ADD5=""
NO5=""
-ADAPTERIZE=""
ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"}
CVSROOT=""
[-Tvs|--tag-version-stable] [-Tvn|--tag-version-nest]
[-Ts|--tag-stable] [-Tn|--tag-nest] [-Tv|--tag-version]
[{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}]
-[-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>]
+[-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--show-bconds]
[--with/--without <feature>] [--define <macro> <value>] <package>[.spec]
-5, --update-md5 - update md5 comments in spec, implies -nd -ncs
---adapter[ize] - run adapter.awk on SPECFILE
-a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
-n5, --no-md5 - ignore md5 comments in spec
-D, --debug - enable builder script debugging mode,
from <package>.spec,
-bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
only package from <package>.spec,
+-bp, --build-prep - execute the %prep phase of <package>.spec,
+-bc - reserved (not implemented)
+-bi reserved (not implemented)
-bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
them into src.rpm,
--bp, --build-prep - execute the %prep phase of <package>.spec,
+--short-circuit - reserved (not implemented)
-B, --branch - add branch
-c, --clean - clean all temporarily created files (in BUILD, SOURCES,
SPECS and \$RPM_BUILD_ROOT),
-sp, --source-paths - list sources - filenames with full local paths (intended for
offline operations; does not work when Icon field is present
but icon file is absent),
+-su, --source-urls - list urls - urls to sources and patches
+ intended for copying urls with spec with lots of macros in urls
-T <cvstag> , --tag <cvstag>
- add cvs tag <cvstag> for files,
-Tvs, --tag-version-stable
-U, --update - refetch sources, don't use distfiles, and update md5 comments
-Upi, --update-poldek-indexes
- refresh or make poldek package index files.
+-np, --nopatch <patchnumber>
+ - don't apply <patchnumber>
+--show-bconds - show available conditional builds, which can be used
+ - with --with and/or --without switches.
--with/--without <feature>
- conditional build package depending on %_with_<feature>/
%_without_<feature> macro switch. You may now use
"
}
+update_shell_title() {
+ [ -t 1 ] || return
+ local len=${COLUMNS:-80}
+ local msg=$(echo "$*" | cut -c-$len)
+
+ msg="builder[$SPECFILE] $msg"
+ case "$TERM" in
+ cygwin|xterm*)
+ echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
+ ;;
+ screen*)
+ echo >&2 -ne "\033]0;$msg\007"
+ ;;
+ esac
+}
+
# set TARGET from BuildArch: from SPECFILE
set_spec_target() {
if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
parse_spec()
{
+ update_shell_title "parsing specfile"
if [ -n "$DEBUG" ]; then
set -x;
set -v;
get_spec()
{
+
+ update_shell_title "get_spec"
+
if [ -n "$DEBUG" ]; then
set -x;
set -v;
get_files()
{
GET_FILES="$@"
+ update_shell_title "fetching sources"
if [ -n "$DEBUG" ]; then
set -x;
url_attic=$(distfiles_attic_url "$i")
FROM_DISTFILES=1
if [ "`echo $url | grep -E '^(\.|/)'`" ]; then
+ update_shell_title "get_files: $url"
${GETLOCAL} $url $target
else
if [ -z "$NOMIRRORS" ]; then
url="`find_mirror "$url"`"
fi
+ update_shell_title "get_files: $url"
${GETURI} ${OUTFILEOPT} "$target" "$url" || \
if [ "`echo $url | grep -E 'ftp://'`" ]; then
+ update_shell_title "get_files: $url"
${GETURI2} ${OUTFILEOPT} "$target" "$url"
fi
fi
if ! test -s "$target"; then
rm -f "$target"
if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
+ update_shell_title "get_files: $url_attic"
${GETLOCAL} $url_attic $target
else
if [ -z "$NOMIRRORS" ]; then
url_attic="`find_mirror "$url_attic"`"
fi
+ update_shell_title "get_files: $url_attic"
${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
+ update_shell_title "get_files: $url_attic"
${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
fi
fi
else
im="$i"
fi
+ update_shell_title "get_files: $im"
${GETURI} "$im" || \
if [ "`echo $im | grep -E 'ftp://'`" ]; then
+ update_shell_title "get_files: $im"
${GETURI2} "$im"
fi
fi
echo "MD5 sum mismatch. Trying full fetch."
FROM_DISTFILES=2
rm -f $target
+ update_shell_title "get_files: $url"
${GETURI} ${OUTFILEOPT} "$target" "$url" || \
if [ "`echo $url | grep -E 'ftp://'`" ]; then
+ update_shell_title "get_files: $url"
${GETURI2} ${OUTFILEOPT} "$target" "$url"
fi
if ! test -s "$target"; then
rm -f "$target"
+ update_shell_title "get_files: $url_attic"
${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
+ update_shell_title "get_files: $url_attic"
${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
fi
fi
build_package()
{
+ update_shell_title "build_package"
if [ -n "$DEBUG" ]; then
set -x;
set -v;
cd "$SPECS_DIR"
if [ -n "$TRY_UPGRADE" ]; then
+ update_shell_title "build_package: try_upgrade"
if [ -n "$FLOAT_VERSION" ]; then
TNOTIFY=`./pldnotify.awk $SPECFILE -n` || exit 1
else
build-prep )
BUILD_SWITCH="-bp --nodeps" ;;
esac
+
+ update_shell_title "build_package: $COMMAND"
if [ -n "$LOGFILE" ]; then
LOG=`eval echo $LOGFILE`
if [ -d "$LOG" ]; then
echo "LASTLOG=$LOG" > $LASTLOG_FILE
fi
RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
- (time nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $TARGET_SWITCH $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
+ (time eval nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $TARGET_SWITCH $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
RETVAL=`cat $RES_FILE`
rm $RES_FILE
if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
set_bconds_values()
{
+ update_shell_title "set bcond values"
+
AVAIL_BCONDS_WITHOUT=""
AVAIL_BCONDS_WITH=""
if `grep -q ^%bcond ${SPECFILE}`; then
run_sub_builder()
{
package_name="${1}"
- echo -ne "Package installation failed:\t$package_name\n"
+ update_shell_title "run_sub_builder $package_name"
#
# No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
# pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
parent_spec_name=''
# Istnieje taki spec? ${package}.spec
- if [ -f "${SPECS_DIR}${package}.spec" ]; then
+ if [ -f "${SPECS_DIR}/${package}.spec" ]; then
parent_spec_name=${package}.spec
- elif [ -f "${SPECS_DIR}`echo ${package_name}|sed -e s,-devel.*,,g -e s,-static,,g`.spec" ]; then
- parent_spec_name="`echo ${package_name}|sed -e s,-devel.*,,g -e s,-static,,g`.spec"
+ elif [ -f "${SPECS_DIR}/`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec" ]; then
+ parent_spec_name="`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec"
else
for provides_line in `grep ^Provides:.*$package ${SPECS_DIR} -R`
do
fi
if [ "${parent_spec_name}" != "" ]; then
- sub_builder_opts=''
- if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
- sub_builder_opts="${sub_builder_opts} -R"
- fi
- if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
- sub_builder_opts="${sub_builder_opts} -RB"
- elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
- sub_builder_opts="${sub_builder_opts} -FRB"
- fi
- if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
- sub_builder_opts="${sub_builder_opts} -Upi"
- fi
- cd "${SPECS_DIR}"
- ./builder ${sub_builder_opts} ${parent_spec_name}
+ spawn_sub_builder $parent_spec_name
fi
NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
}
+spawn_sub_builder()
+{
+ package_name="${1}"
+ update_shell_title "spawn_sub_builder $package_name"
+
+ sub_builder_opts=''
+ if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
+ sub_builder_opts="${sub_builder_opts} -R"
+ fi
+ if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
+ sub_builder_opts="${sub_builder_opts} -RB"
+ elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
+ sub_builder_opts="${sub_builder_opts} -FRB"
+ fi
+ if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
+ sub_builder_opts="${sub_builder_opts} -Upi"
+ fi
+
+ cd "${SPECS_DIR}"
+ ./builder ${sub_builder_opts} "$@"
+}
+
remove_build_requires()
{
if [ "$INSTALLED_PACKAGES" != "" ]; then
fi
}
+display_branches()
+{
+ if [ "$NOCVSSPEC" != "yes" ]; then
+ echo -ne "Available branches: "
+ cvs status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
+ fi
+}
+
# checks a given list of packages/files/provides agains current rpmdb.
# outputs all dependencies whcih current rpmdb doesn't satisfy.
# input can be either STDIN or parameters
DEPS=$(rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
# packages
- echo "$DEPS" | awk '/^no package provides/ { print "@" $NF }'
+ echo "$DEPS" | awk '/^no package provides/ { print $NF }'
# other deps (files)
- echo "$DEPS" | awk -F: '/^error:.*No such file/{o=$2; gsub("^ file ", "", o); print "@" o}'
+ echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
}
# checks if given package/files/provides exists in rpmdb.
fetch_build_requires()
{
if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
+ update_shell_title "fetch build requires"
if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
- CONF=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
- DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
+ local CONF=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
+ local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
+ update_shell_title "poldek: update indexes"
if [ -n "$CONF" ] || [ -n "$DEPS" ]; then
- $SU_SUDO /usr/bin/poldek --update || $SU_SUDO /usr/bin/poldek --upa
+ $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
fi
if [ -n "$CONF" ]; then
+ update_shell_title "uninstall conflicting packages: $CONF"
echo "Trying to uninstall conflicting packages ($CONF):"
$SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CONF
fi
- if [ -n "$DEPS" ]; then
+
+ while [ "$DEPS" ]; do
+ update_shell_title "install deps: $DEPS"
echo "Trying to install dependencies ($DEPS):"
- $SU_SUDO /usr/bin/poldek --caplookup -uGv $DEPS
- fi
+ local log=.${SPECFILE}_poldek.log
+ $SU_SUDO /usr/bin/poldek --caplookup -uGq $DEPS | tee $log
+ failed=$(awk -F: '/^error:/{print $2}' $log)
+ rm -f $log
+ local ok
+ if [ -n "$failed" ]; then
+ for package in $failed; do
+ # FIXME: sanitise, deps could be not .spec files
+ spawn_sub_builder -bb $package && ok="$ok $package"
+ done
+ DEPS="$ok"
+ else
+ DEPS=""
+ fi
+ done
return
fi
;;
*)
echo "Attempting to run spawn sub - builder..."
+ echo -ne "Package installation failed:\t$package_name\n"
run_sub_builder $package_name
if [ $? -eq 0 ]; then
install_required_packages $package_name;
rm -f ".$package-req.txt"
else
echo "Attempting to run spawn sub - builder..."
+ echo -ne "Package installation failed:\t$package\n"
run_sub_builder $package
if [ $? -eq 0 ]; then
install_required_packages $package;
fi
}
-diffcol()
-{
- # vim like diff colourization, glen@pld-linux.org
- sed -e '
- s,\e,\e[44m^[\e[49m,g;
- s,\a,\e[44m^G\e[49m,g;
- s,^\(Index:\|diff\|---\|+++\) .*$,\e[32m&,;
- s,^@@ ,\e[33m&,g;
- s,^-,\e[35m&,;
- s,^+,\e[36m&,;
- s,\r,\e[44m^M\e[49m,g;
- s, , ,g;
- s,\([^[:space:]]\)\([[:space:]]\+\)$,\1\e[41m\2\e[49m,g;
- s,$,\e[0m,
- ' "$@"
-}
-
-adapterize()
-{
- cd "$SPECS_DIR"
- local tmpdir
- tmpdir=$(mktemp -d ${TMPDIR:-/tmp}/adapter-XXXXXX) || exit
- awk -f adapter.awk $SPECFILE > $tmpdir/$SPECFILE || exit
-
- if [ "`diff --brief $SPECFILE $tmpdir/$SPECFILE`" ] ; then
- diff -u $SPECFILE $tmpdir/$SPECFILE > $tmpdir/$SPECFILE.diff
- if [ -t 1 ]; then
- diffcol $tmpdir/$SPECFILE.diff | less -r
- while : ; do
- echo -n "Accept? [yn] "
- read ans
- case "$ans" in
- [yYoO]) # y0 mama
- mv -f $tmpdir/$SPECFILE $SPECFILE
- echo "Ok, adapterized."
- break
- ;;
- [nNsS])
- echo "Ok, exiting."
- break
- ;;
- esac
- done
- else
- cat $tmpdir/$SPECFILE.diff
- fi
- else
- echo "The SPEC is perfect ;)"
- fi
-
- rm -rf $tmpdir
-}
-
#---------------------------------------------
# main()
NOCVSSPEC="yes"
UPDATE5="yes"
shift ;;
- --adapter | --adapterize )
- COMMAND="adapterize";
- NODIST="yes"
- NOCVSSPEC="yes"
- ADAPTERIZE="yes"
- shift ;;
-a5 | --add-md5 )
COMMAND="get";
NODIST="yes"
shift;;
--opts )
shift; RPMOPTS="$RPM_OPTS ${1}"; shift ;;
+ --nopatch | -np )
+ shift; RPMOPTS="${RPMOPTS} --define \"patch${1} echo ignoring patch${1} \""; shift ;;
--with | --without )
case $GROUP_BCONDS in
"yes")
-sp | --sources-paths)
COMMAND="list-sources-local-paths"
shift ;;
+ -su | --sources-urls)
+ COMMAND="list-sources-urls"
+ shift ;;
-Tvs | --tag-version-stable )
COMMAND="tag";
TAG="STABLE"
shift 2
RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
;;
+ --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
+ SHOW_BCONDS="yes"
+ shift
+ ;;
--nodeps)
shift
RPMOPTS="${RPMOPTS} --nodeps"
esac
fi
+update_shell_title "$COMMAND"
case "$COMMAND" in
"build" | "build-binary" | "build-source" | "build-prep" )
init_builder;
get_spec;
set_bconds_values;
display_bconds;
+ display_branches;
+ [ X"$SHOW_BCONDS" = X"yes" ] && exit 0
fetch_build_requires;
parse_spec;
if [ "$INTEGER_RELEASE" = "yes" ]; then
echo $SAP | awk '{gsub(/.*\//,"") ; print}'
done
;;
+ "list-sources-urls" )
+ init_builder
+ NOCVSSPEC="yes"
+ DONT_PRINT_REVISION="yes"
+ get_spec
+ parse_spec
+ SAPS="$SOURCES $PATCHES"
+ for SAP in $SAPS ; do
+ echo $SAP
+ done
+ ;;
"list-sources-local-paths" )
init_builder
NOCVSSPEC="yes"
echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
done
;;
- "adapterize" )
- adapterize
- ;;
"usage" )
usage;;
"version" )