RCSID='$Id$' r=${RCSID#* * } rev=${r%% *}
VERSION="v0.35/$rev"
VERSIONSTRING="\
-Build package utility from PLD Linux CVS repository
-$VERSION (C) 1999-2010 Free Penguins".
+Build package utility from PLD Linux Packages repository
+$VERSION (C) 1999-2011 Free Penguins".
PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
run_poldek() {
- RES_FILE=$(mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM)
+ RES_FILE=$(tempfile)
if [ -n "$LOGFILE" ]; then
LOG=`eval echo $LOGFILE`
if [ -n "$LASTLOG_FILE" ]; then
[--show-bconds] [--with/--without <feature>] [--define <macro> <value>]
<package>[.spec][:cvstag]
+-4 - force ipv4 when transferring files
-5, --update-md5 - update md5 comments in spec, implies -nd -ncs
+-6 - force ipv6 when transferring files
-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,
"
}
+# create tempfile. as secure as possible
+tempfile() {
+ mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM.$$
+}
+
# change dependency to specname
# common changes:
# - perl(Package::Name) -> perl-Package-Name
# Warning: unpredictable results if same URL used twice
src_no() {
+ local file="$1"
+ # escape some regexp characters if part of file name
+ file=$(echo "$file" | sed -e 's#\([\+\*\.]\)#\\\1#g')
cd $PACKAGE_DIR
rpm_dump | \
- grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
- sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
- head -n 1 | xargs
+ grep -E "(SOURCE|PATCH)URL[0-9]*[ ]*${file}""[ ]*$" | \
+ sed -e 's/.*\(SOURCE\|PATCH\)URL\([0-9][0-9]*\).*/\1\2/' | \
+ head -n 1 | tr OURCEATH ourceath | xargs
}
src_md5() {
fi
fi
- source_md5=`grep -i "^#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
+ source_md5=`grep -i "^#[ ]*$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
if [ -n "$source_md5" ]; then
echo $source_md5
else
else
# we have empty SourceX-md5, but it is still possible
# that we have NoSourceX-md5 AND NoSource: X
- nosource_md5=`grep -i "^#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
+ nosource_md5=`grep -i "^#[ ]*No$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
if [ -n "$nosource_md5" -a -n "`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" ] ; then
echo $nosource_md5
fi
local srcno=$(src_no "$i")
if [ -n "$ADD5" ]; then
[ "$fp" = "$i" ] && continue # FIXME what is this check doing?
- grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE && continue
+ grep -qiE '^#[ ]*'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE && continue
grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE && continue
else
- grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE || grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE || continue
+ grep -qiE '^#[ ]*'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE || grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE || continue
fi
if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
need_files="$need_files $i"
for i in "$@"; do
local fp=$(nourl "$i")
local srcno=$(src_no "$i")
- local md5=$(grep -iE '^#[ ]*(No)?Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE )
+ local md5=$(grep -iE '^#[ ]*(No)?'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE )
if [ -z "$md5" ]; then
md5=$(grep -iE '^[ ]*BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE )
fi
if [ -n "$ADD5" ] && is_url $i || [ -n "$md5" ]; then
- local tag="# Source$srcno-md5:\t"
+ local tag="# $srcno-md5:\t"
if [[ "$md5" == *NoSource* ]]; then
tag="# NoSource$srcno-md5:\t"
elif [ -n "$USEDIGEST" ]; then
tag="BuildRequires:\tdigest(%SOURCE$srcno) = "
fi
md5=$(md5sum "$fp" | cut -f1 -d' ')
- echo "Updating Source$srcno ($md5: $fp)."
+ echo "Updating $srcno ($md5: $fp)."
perl -i -ne '
- print unless (/^\s*#\s*(No)?Source'$srcno'-md5\s*:/i or /^\s*BuildRequires:\s*digest\(%SOURCE'$srcno'\)/i);
- print "'"$tag$md5"'\n" if /^Source'$srcno'\s*:\s+/;
+ print unless (/^\s*#\s*(No)?'$srcno'-md5\s*:/i or /^\s*BuildRequires:\s*digest\(%SOURCE'$srcno'\)/i);
+ print "'"$tag$md5"'\n" if /^'$srcno'\s*:\s+/i;
' \
$PACKAGE_DIR/$SPECFILE
fi
if [ -n "$LASTLOG_FILE" ]; then
echo "LASTLOG=$LOG" > $LASTLOG_FILE
fi
- RES_FILE=$(mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM)
+ RES_FILE=$(tempfile)
(time eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
RETVAL=`cat $RES_FILE`
cvs_entry_remove $PACKAGE_DIR $SPECFILE $SOURCES $PATCHES
# remove spec and sources
- $RPMBUILD --clean --rmsource --rmspec --nodeps --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $SPECFILE
+ $RPMBUILD --clean --rmsource --rmspec --nodeps --define "_specdir $PACKAGE_DIR" --define "_sourcedir $PACKAGE_DIR" $SPECFILE
}
#---------------------------------------------
while [ $# -gt 0 ]; do
case "${1}" in
+ -4|-6)
+ # NOTE: we should be fetcher specific, like fille WGET_OPTS, but
+ # unfortunately $GETURI is already formed
+ GETURI="$GETURI $1"
+ shift
+ ;;
-5 | --update-md5)
COMMAND="update_md5"
NODIST="yes"
-sc | --sources-cvs)
COMMAND="list-sources-cvs"
shift ;;
- -sd | --sources-distfiles)
+ -sd | --source-distfiles)
COMMAND="list-sources-distfiles"
shift ;;
- -sdp | --sources-distfiles-paths)
+ -sdp | --source-distfiles-paths)
COMMAND="list-sources-distfiles-paths"
shift ;;
- -sf | --sources-files)
+ -sf | --source-files)
COMMAND="list-sources-files"
shift ;;
- -lsp | --sources-paths)
+ -lsp | --source-paths)
COMMAND="list-sources-local-paths"
shift ;;
- -su | --sources-urls)
+ -su | --source-urls)
COMMAND="list-sources-urls"
shift ;;
-Tvs | --tag-version-stable )
;;
*)
NODIST="yes" get_files $SOURCES $PATCHES
- update_md5 $SOURCES
+ update_md5 $SOURCES $PATCHES
;;
esac
build_package
if [ -n "$NOSOURCE0" ] ; then
SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
fi
- update_md5 $SOURCES
+ update_md5 $SOURCES $PATCHES
;;
"tag" )
NOURLS=1