From b72f89c54737bd975560080bdb4d1b48c404c1c2 Mon Sep 17 00:00:00 2001 From: Marcin Krol Date: Mon, 9 Jul 2012 12:54:17 +0000 Subject: [PATCH] - git version of PLD builder --- builder | 255 +++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 161 insertions(+), 94 deletions(-) diff --git a/builder b/builder index 00a7c99..f634e61 100755 --- a/builder +++ b/builder @@ -39,7 +39,7 @@ RCSID='$Id: builder,v 1.645 2011/02/13 17:54:10 glen Exp $' r=${RCSID#* * } rev= VERSION="v0.35/$rev" VERSIONSTRING="\ Build package utility from PLD Linux Packages repository -$VERSION (C) 1999-2011 Free Penguins". +$VERSION (C) 1999-2012 Free Penguins". PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin" @@ -74,6 +74,9 @@ USER_AGENT="PLD/Builder($VERSION)" # See LOGFILE example. DATE=`date +%Y-%m-%d_%H-%M-%S` +# target arch, can also be used for log file naming +TARGET=$(rpm -E %{_target}) + # Example: LOGFILE='../log.$PACKAGE_NAME' # Example: LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE' # Example: LOGFILE='$PACKAGE_NAME/$PACKAGE_NAME.$DATE.log' @@ -94,7 +97,7 @@ BCOND="" GROUP_BCONDS="no" # create symlinks for tools in PACKAGE_DIR, see get_spec() -SYMLINK_TOOLS="yes" +SYMLINK_TOOLS="no" PATCHES="" SOURCES="" @@ -104,12 +107,19 @@ PACKAGE_VERSION="" PACKAGE_NAME="" ASSUMED_NAME="" PROTOCOL="http" + +# use lftp by default when available +USE_LFTP= +lftp --version > /dev/null 2>&1 && USE_LFTP=yes +PARALLEL_DOWNLOADS=10 + WGET_RETRIES=${MAX_WGET_RETRIES:-0} CVS_FORCE="" CVSIGNORE_DF="yes" CVSTAG="" -GIT_SERVER="git@git.tld-linux.org" +GIT_SERVER="git://git.pld-linux.org" +GIT_PUSH="git@git.pld-linux.org" PACKAGES_DIR="packages" HEAD_DETACHED="" DEPTH="" @@ -119,7 +129,7 @@ NEW_REPO="" RES_FILE="" -DISTFILES_SERVER="://df.tld-linux.org" +DISTFILES_SERVER="://distfiles.pld-linux.org" ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org" DEF_NICE_LEVEL=19 @@ -146,6 +156,7 @@ else fi fi +UPDATE_POLDEK_INDEXES_OPTS="" # Here we load saved user environment used to # predefine options set above, or passed to builder @@ -159,6 +170,7 @@ fi # Example of ~/.builderrc: # #UPDATE_POLDEK_INDEXES="yes" +#UPDATE_POLDEK_INDEXES_OPTS="--mo=nodiff" #FETCH_BUILD_REQUIRES="yes" #REMOVE_BUILD_REQUIRES="force" #GROUP_BCONDS="yes" @@ -176,10 +188,6 @@ fi [ -f "$USER_CFG" ] && . "$USER_CFG" -if [ -n "$GIT_LOGINNAME" ]; then - GIT_SERVER="git@git.tld-linux.org" -fi - if [ "$SCHEDTOOL" = "auto" ]; then if [ -x /usr/bin/schedtool ] && schedtool -B -e echo >/dev/null; then SCHEDTOOL="schedtool -B -e" @@ -196,6 +204,10 @@ elif [ -n "$USE_AXEL" ]; then GETURI="axel -a $AXEL_OPTS" GETURI2="$GETURI" OUTFILEOPT="-o" +elif [ -n "$USE_LFTP" ]; then + GETURI=download_lftp + GETURI2=$GETURI + OUTFILEOPT="" else wget --help 2>&1 | grep -q -- ' --no-check-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate" wget --help 2>&1 | grep -q -- ' --inet ' && WGET_OPTS="$WGET_OPTS --inet" @@ -209,7 +221,7 @@ fi GETLOCAL="cp -a" -if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then +if rpm --version 2>&1 | grep -q '4.0.[0-2]'; then RPM="rpm" RPMBUILD="rpm" else @@ -248,6 +260,27 @@ run_poldek() { #--------------------------------------------- # functions +download_lftp() { + local outfile=$1 url=$2 retval tmpfile + # TODO: use mktemp + tmpfile=$outfile.tmp + lftp -c " + $([ "$DEBUG" = "yes" ] && echo "debug 5;") + set ssl:verify-certificate no; + set net:max-retries $WGET_RETRIES; + set http:user-agent \"$USER_AGENT\"; + pget -n $PARALLEL_DOWNLOADS -c \"$url\" -o \"$tmpfile\" + " + + retval=$? + if [ $retval -eq 0 ]; then + mv -f "$tmpfile" "$outfile" + else + rm -f "$tmpfile" + fi + return $retval +} + usage() { if [ -n "$DEBUG" ]; then set -xv; fi echo "\ @@ -262,9 +295,11 @@ Usage: builder [--all-branches] [-D|--debug] [-V|--version] [--short-version] [ [--show-bconds] [--with/--without ] [--define ] [.spec][:tag] +-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 ---all-branches - make shallow fetch of all branches; --depth required +--all-branches - make shallow fetch of all branches; --depth required -n5, --no-md5 - ignore md5 comments in spec -D, --debug - enable builder script debugging mode, -debug - produce rpm debug package (same as --opts -debug) @@ -278,7 +313,7 @@ Usage: builder [--all-branches] [-D|--debug] [-V|--version] [--short-version] [ -bp, --build-prep - execute the %prep phase of .spec, -bc - execute the %build phase of .spec, -bi - execute the %install phase of .spec --bl - execute the %files phase of .spec +-bl - execute the %files phase of .spec -bs, --build-source - get all files from PLD repo or HTTP/FTP and only pack them into src.rpm, --short-circuit - short-circuit build @@ -286,13 +321,11 @@ Usage: builder [--all-branches] [-D|--debug] [-V|--version] [--short-version] [ -c, --clean - clean all temporarily created files (in BUILD\$RPM_BUILD_ROOT) after rpmbuild commands. may be used with building process. -m, --mr-proper - clean all temporarily created files (in BUILD, SOURCES, - SPECS and \$RPM_BUILD_ROOT). Doesn't run - any rpm building. --cf, --cvs-force - use -f when tagging + SPECS and \$RPM_BUILD_ROOT). Doesn't run any rpm building. +-cf, --cvs-force - use -f when tagging --define - define a macro with value , ---depth - - make shallow fetch +--depth - make shallow fetch --alt_kernel - same as --define 'alt_kernel ' --nodeps - rpm won't check any dependences @@ -311,10 +344,13 @@ Usage: builder [--all-branches] [-D|--debug] [-V|--version] [--short-version] [ -ns, --no-srcs - don't download Sources/Patches -ns0, --no-source0 - don't download Source0 -nn, --no-net - don't download anything from the net --pm, --prefer-mirrors - prefer mirrors (if any) over distfiles for SOURCES +-pN, -p N - set PARALLEL_DOWNLOADS to N (default $PARALLEL_DOWNLOADS) +-pm, --prefer-mirrors + - prefer mirrors (if any) over distfiles for SOURCES --no-init - don't initialize builder paths (SPECS and SOURCES) -ske, ---skip-existing-files - skip existing files in get_files +--skip-existing-files + - skip existing files in get_files --opts - additional options for rpm -q, --quiet - be quiet, --date yyyy-mm-dd - build package using resources from specified date, @@ -329,18 +365,21 @@ Usage: builder [--all-branches] [-D|--debug] [-V|--version] [--short-version] [ -FRB, --force-remove-build-requires - remove all you fetched with -R or --fetch-build-requires remember, this option works without confirmation, --sd, --source-distfiles - list sources available from distfiles (intended for offline +-sd, --source-distfiles + - list sources available from distfiles (intended for offline operations; does not work when Icon field is present but icon file is absent), --sc, --source-cvs - list sources available from PLD repo --sdp, --source-distfiles-paths - list sources available from distfiles - +-sc, --source-cvs - list sources available from PLD repo +-sdp, --source-distfiles-paths + - list sources available from distfiles - paths relative to distfiles directory (intended for offline operations; does not work when Icon field is present but icon file is absent), -sf, --source-files - list sources - bare filenames (intended for offline operations; does not work when Icon field is present but icon file is absent), --lsp, --source-paths - list sources - filenames with full local paths (intended for +-lsp, --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 @@ -363,7 +402,7 @@ Usage: builder [--all-branches] [-D|--debug] [-V|--version] [--short-version] [ -u, --try-upgrade - check version, and try to upgrade package -un, --try-upgrade-with-float-version - as above, but allow float version - php-pear-Services_Digg/ + php-pear-Services_Digg/ --upgrade-version - upgrade to specified version in try-upgrade -U, --update - refetch sources, don't use distfiles, and update md5 comments -Upi, --update-poldek-indexes @@ -374,9 +413,8 @@ Usage: builder [--all-branches] [-D|--debug] [-V|--version] [--short-version] [ - abort instead of applying patch --show-bconds - show available conditional builds, which can be used - with --with and/or --without switches. ---show-bcond-args - show active bconds, from ~/.bcondrc. this is used by - ./repackage.sh script. in other words, the output is - parseable by scripts. +--show-bcond-args - show active bconds, from ~/.bcondrc. this is used by ./repackage.sh script. + In other words, the output is parseable by scripts. --show-avail-bconds - show available bconds --with/--without - conditional build package depending on %_with_/ @@ -384,8 +422,8 @@ Usage: builder [--all-branches] [-D|--debug] [-V|--version] [--short-version] [ --with feat1 feat2 feat3 --without feat4 feat5 --with feat6 constructions. Set GROUP_BCONDS to yes to make use of it. --target , --target= - - build for platform . ---init-rpm-dir - initialize ~/rpm directory structure + - build for platform . +--init-rpm-dir - initialize ~/rpm directory structure " } @@ -394,10 +432,14 @@ tempfile() { mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM.$$ } +tempdir() { + mktemp -d builder.XXXXXX +} + # inserts git log instead of %changelog # outputs name of modified file created by tempfile insert_gitlog() { - local SPECFILE=$1 specfile=$(tempfile) gitlog=$(tempfile) speclog=$(tempfile) + local SPECFILE=$1 specdir=$(tempdir) gitlog=$(tempfile) speclog=$(tempfile) # allow this being customized local log_entries=$(rpm -E '%{?_buildchangelogtruncate}') @@ -408,15 +450,19 @@ insert_gitlog() { # http://rpm.org/gitweb?p=rpm.git;a=blob;f=build/parseChangelog.c#l31 # NOTE: changelog date is always in UTC for rpmbuild # * 1265749244 +0000 Random Hacker 9370900 - git log -${log_entries:-20} --format=format:"* %ad %an <%ae> %h%n%s%n" --date=raw > $gitlog - gawk '/^\* /{printf("* %s %s\n", strftime("%a %b %d %Y", $2), substr($0, length($1)+length($2)+length($3)+4)); next}{print}' $gitlog > $speclog + git rev-list -${log_entries:-20} HEAD | while read sha1; do + local logfmt='%B%n' + git notes list $sha1 &> /dev/null && logfmt=%N + git log -n 1 $sha1 --format=format:"* %ad %an <%ae> %h%n${logfmt}%n" --date=raw | sed '/^$/q' + done > $gitlog + LC_ALL=C gawk '/^\* /{printf("* %s %s\n", strftime("%a %b %d %Y", $2), substr($0, length($1)+length($2)+length($3)+4)); next}{print}' $gitlog > $speclog sed '/^%changelog/,$d' $SPECFILE | sed -e "\${ a%changelog r $speclog } - " > $specfile + " > $specdir/$SPECFILE rm -f $gitlog $speclog - echo $specfile + echo $specdir } # change dependency to specname @@ -620,7 +666,7 @@ parse_spec() { cd $PACKAGE_DIR cache_rpm_dump - if (rpm_dump | grep -qEi ":.*nosource.*1"); then + if rpm_dump | grep -qEi ":.*nosource.*1"; then FAIL_IF_NO_SOURCES="no" fi @@ -783,9 +829,11 @@ create_git_repo() { exit 101 fi [ -d "$ASSUMED_NAME/.git" ] || NEW_REPO=yes - ssh $GIT_SERVER create ${ASSUMED_NAME} || Exit_error err_cvs_add_failed + # ssh $GIT_SERVER create ${ASSUMED_NAME} || Exit_error err_cvs_add_failed git init - git remote add $REMOTE_PLD ${GIT_SERVER}:${PACKAGES_DIR}/${ASSUMED_NAME}.git || Exit_error err_remote_problem $REMOTE_PLD + git remote add $REMOTE_PLD ${GIT_SERVER}/${PACKAGES_DIR}/${ASSUMED_NAME}.git && \ + git remote set-url --push $REMOTE_PLD ssh://${GIT_PUSH}/${PACKAGES_DIR}/${ASSUMED_NAME} \ + || Exit_error err_remote_problem $REMOTE_PLD } get_spec() { @@ -816,12 +864,13 @@ get_spec() { else ( unset GIT_WORK_TREE - git clone -o $REMOTE_PLD ${GIT_SERVER}:${PACKAGES_DIR}/${ASSUMED_NAME}.git "$REPO_DIR/${ASSUMED_NAME}" || { + git clone -o $REMOTE_PLD ${GIT_SERVER}/${PACKAGES_DIR}/${ASSUMED_NAME}.git || { # softfail if new package, i.e not yet added to PLD rep [ ! -f "$ASSUMED_NAME/$SPECFILE" ] && Exit_error err_no_spec_in_repo echo "Warning: package not in CVS - assuming new package" NOCVSSPEC="yes" } + git remote set-url --push $REMOTE_PLD ssh://${GIT_PUSH}/${PACKAGES_DIR}/${ASSUMED_NAME} ) fi else @@ -842,6 +891,7 @@ get_spec() { exit 3 } fi + git fetch $REMOTE_PLD 'refs/notes/*:refs/notes/*' cvsignore_df .gitignore @@ -857,8 +907,11 @@ get_spec() { # create symlinks for tools if [ "$SYMLINK_TOOLS" != "no" ]; then for a in dropin md5 adapter builder {relup,compile,repackage,pearize}.sh pldnotify.awk; do + # skip tools that don't exist in top dir [ -f $a ] || continue - ln -sf ../$a $ASSUMED_NAME + # skip tools that already exist + [ -f $ASSUMED_NAME/$a ] && continue + ln -s ../$a $ASSUMED_NAME cvsignore_df $a done fi @@ -890,7 +943,7 @@ find_mirror() { cd "$REPO_DIR" local url="$1" if [ ! -f "mirrors" ] ; then - ln -s scripts/mirrors . + ln -s rpm-build-tools/mirrors . fi IFS="|" @@ -913,11 +966,14 @@ find_mirror() { # 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() { @@ -942,7 +998,7 @@ src_md5() { fi fi - source_md5=`grep -i "^#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'` + source_md5=$(grep -iE "^#[ ]*(No)?$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://') if [ -n "$source_md5" ]; then echo $source_md5 else @@ -952,7 +1008,7 @@ src_md5() { 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 @@ -1026,10 +1082,10 @@ update_md5() { 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" @@ -1045,22 +1101,22 @@ update_md5() { 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" + tag="# No$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 @@ -1204,10 +1260,10 @@ get_files() { im="$i" fi update_shell_title "${GETURI%% *}: $im" - ${GETURI} "$im" ${OUTFILEOPT} "$target" || \ + ${GETURI} ${OUTFILEOPT} "$target" "$im" || \ if [ "`echo $im | grep -E 'ftp://'`" ]; then update_shell_title "${GETURI2%% *}: $im" - ${GETURI2} "$im" ${OUTFILEOPT} "$target" + ${GETURI2} ${OUTFILEOPT} "$target" "$im" fi test -s "$target" || rm -f "$target" fi @@ -1262,6 +1318,17 @@ get_files() { fi } +tag_exist() { + local _tag="$1" + echo "Searching for tag $_tag..." + if [ -n "$DEPTH" ]; then + local ref=`git ls-remote $REMOTE_PLD "refs/tags/$_tag"` + [ -n "$ref" ] && echo "$ref" && Exit_error err_tag_exists "$_tag" + else + git show-ref "refs/tags/$_tag" && Exit_error err_tag_exists "$_tag" + fi +} + make_tagver() { if [ -n "$DEBUG" ]; then set -x @@ -1274,16 +1341,16 @@ make_tagver() { fi # NOTE: CVS tags may must not contain the characters `$,.:;@' - TAGVER=$(echo $TAG_PREFIX$PACKAGE_NAME-$PACKAGE_VERSION-$PACKAGE_RELEASE | tr '[.@]' '[_#]') + TAGVER=$(echo $TAG_PREFIX$PACKAGE_NAME-$PACKAGE_VERSION-$PACKAGE_RELEASE) - # Remove #kernel.version_release from TAGVER because tagging sources + # Remove @kernel.version_release from TAGVER because tagging sources # could occur with different kernel-headers than kernel-headers used at build time. # besides, %{_kernel_ver_str} is not expanded. - # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1#%{_kernel_ver_str} + # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1@%{_kernel_ver_str} # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1 - TAGVER=${TAGVER%#*} + TAGVER=${TAGVER%@*} echo -n "$TAGVER" } @@ -1472,11 +1539,11 @@ build_package() { echo "LASTLOG=$LOG" > $LASTLOG_FILE fi RES_FILE=$(tempfile) - local specfile=$(insert_gitlog $SPECFILE) + local specdir=$(insert_gitlog $SPECFILE) - (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 + (time eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $specdir/$SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG RETVAL=`cat $RES_FILE` - rm $RES_FILE $specfile + rm -r $RES_FILE $specdir if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then if [ "$RETVAL" -eq "0" ]; then mv $LOG $LOGDIROK @@ -1485,9 +1552,10 @@ build_package() { fi fi else - BRLISTFILE=$(tempfile) - eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $SPECFILE + local specdir=$(insert_gitlog $SPECFILE) + eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $specdir/$SPECFILE RETVAL=$? + rm -r $specdir fi if [ "$RETVAL" -ne "0" ]; then if [ -n "$TRY_UPGRADE" ]; then @@ -1498,17 +1566,6 @@ build_package() { fi echo "" fi - # try to nicely show package list, to just copy&paste it to poldek or so... - #eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $SPECFILE 2>$BRLISTFILE - #BRLIST=$(awk 'BEGIN{ORS=" ";} NR>1 {print $1;}' $BRLISTFILE) - #echo - #echo "To install packages type:" - #echo "poldek -ivh $BRLIST" - #echo - #echo "In poldek, copy these command:" - #echo "install $BRLIST" - #echo - #rm $BRLISTFILE Exit_error err_build_fail fi unset BUILD_SWITCH @@ -1544,7 +1601,7 @@ process_bcondrc() { # w32codec-installer license_agreement # php +mysqli # --- - if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then + if [ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ]); then : else return @@ -1980,11 +2037,11 @@ init_rpm_dir() { mkdir -p $TOP_DIR $rpmdir $buildir $srpmdir cd "$TOP_DIR" - if [ ! -e ../scripts ]; then - git clone ${GIT_SERVER}:${PACKAGES_DIR}/scripts.git ../scripts + if [ ! -e ../rpm-build-tools ]; then + git clone ${GIT_SERVER}/${PACKAGES_DIR}/rpm-build-tools.git ../rpm-build-tools fi - for a in dropin md5 adapter builder mirrors {relup,compile,repackage,pearize}.sh pldnotify.awk; do - ln -s ../scripts/$a . + for a in adapter builder; do + ln -s ../rpm-build-tools/${a}.sh $a done init_builder } @@ -1995,8 +2052,8 @@ mr_proper() { DONT_PRINT_REVISION="yes" # remove spec and sources - $RPMBUILD --clean --rmsource --rmspec --nodeps --define "_specdir $PACKAGE_DIR" --define "_sourcedir $PACKAGE_DIR" $PACKAGE_DIR/$SPECFILE - rm -rf $PACKAGE_DIR/.git .gitignore + $RPMBUILD --clean --rmsource --rmspec --nodeps --define "_specdir $PACKAGE_DIR" --define "_sourcedir $PACKAGE_DIR" --define "_builddir $builddir" $PACKAGE_DIR/$SPECFILE + rm -rf $PACKAGE_DIR/{.git,.gitignore} rmdir --ignore-fail-on-non-empty $PACKAGE_DIR } @@ -2010,6 +2067,12 @@ fi 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" @@ -2076,6 +2139,14 @@ while [ $# -gt 0 ]; do RPMOPTS="${RPMOPTS} --define \"_smp_mflags $1\"" shift ;; + -p) + PARALLEL_DOWNLOADS=$2 + shift 2 + ;; + -p[0-9]) + PARALLEL_DOWNLOADS=${1#-p} + shift + ;; -l | --logtofile ) shift; LOGFILE="${1}"; shift ;; -ni| --nice ) @@ -2170,7 +2241,7 @@ while [ $# -gt 0 ]; do -FRB | --force-remove-build-requires) REMOVE_BUILD_REQUIRES="force" shift ;; - -sc | --sources-cvs) + -sc | --source-cvs) COMMAND="list-sources-cvs" shift ;; -sd | --source-distfiles) @@ -2406,15 +2477,11 @@ case "$COMMAND" in # ./builder -bs test.spec -r AC-branch -Tp auto-ac- -tt if [ -n "$TEST_TAG" ]; then local TAGVER=`make_tagver` - echo "Searching for tag $TAGVER..." - if [ -n "$DEPTH" ]; then - local ref=`git ls-remote $REMOTE_PLD "refs/tags/$TAGVER"` - [ -n "$ref" ] && echo "$ref" && Exit_error err_tag_exists "$TAGVER" - else - git show-ref "refs/tags/$TAGVER" && Exit_error err_tag_exists "$TAGVER" - fi + tag_exist $TAGVER + # check also tags created in CVS + tag_exist $(echo $TAGVER | tr '[.@]' '[_#]') # - do not allow to build from HEAD when XX-branch exists - TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g') + TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto/\([a-zA-Z]\+\)/.*#\1#g') if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then TAG_BRANCH="${TREE_PREFIX}-branch" if [ -n "$DEPTH" ]; then @@ -2443,12 +2510,12 @@ case "$COMMAND" in ;; *) NODIST="yes" get_files $SOURCES $PATCHES - update_md5 $SOURCES + update_md5 $SOURCES $PATCHES ;; esac build_package - if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then - run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz + if [ "$UPDATE_POLDEK_INDEXES" = "yes" ] && [ "$COMMAND" = "build" -o "$COMMAND" = "build-binary" ]; then + run_poldek --sdir="${POLDEK_INDEX_DIR}" ${UPDATE_POLDEK_INDEXES_OPTS} --mkidxz fi remove_build_requires ;; @@ -2513,7 +2580,7 @@ case "$COMMAND" in if [ -n "$NOSOURCE0" ] ; then SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'` fi - update_md5 $SOURCES + update_md5 $SOURCES $PATCHES ;; "tag" ) NOURLS=1 -- 2.44.0