X-Git-Url: http://git.pld-linux.org/?a=blobdiff_plain;f=builder.sh;h=5eacb84efd52e8875d2f062c1b1670222664dac2;hb=d1417da44e3cdd873c1861b558358aa12a00d9d4;hp=1c23aa58733412be676635dca75330113fc885f8;hpb=cc538c2438540c0de1c24b0bb4af8aba430c9680;p=packages%2Frpm-build-tools.git diff --git a/builder.sh b/builder.sh index 1c23aa5..5eacb84 100644 --- a/builder.sh +++ b/builder.sh @@ -16,13 +16,12 @@ # 100 - Unknown error (should not happen) # Notes (todo): -# - builder -u fetches current version first -# - tries to get new version from distfiles without new md5 -# - after fetching new version doesn't update md5 +# - 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" @@ -42,7 +41,6 @@ UPDATE="" UPDATE5="" ADD5="" NO5="" -ADAPTERIZE="" ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"} CVSROOT="" @@ -185,11 +183,10 @@ Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build] [-Tvs|--tag-version-stable] [-Tvn|--tag-version-nest] [-Ts|--tag-stable] [-Tn|--tag-nest] [-Tv|--tag-version] [{-Tp|--tag-prefix} ] [{-tt|--test-tag}] -[-nu|--no-urls] [-v|--verbose] [--opts ] +[-nu|--no-urls] [-v|--verbose] [--opts ] [--show-bconds] [--with/--without ] [--define ] [.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, @@ -200,9 +197,12 @@ Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build] from .spec, -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary only package from .spec, +-bp, --build-prep - execute the %prep phase of .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 .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), @@ -247,6 +247,8 @@ Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build] -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 , --tag - add cvs tag for files, -Tvs, --tag-version-stable @@ -272,6 +274,10 @@ Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build] -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 + - don't apply +--show-bconds - show available conditional builds, which can be used + - with --with and/or --without switches. --with/--without - conditional build package depending on %_with_/ %_without_ macro switch. You may now use @@ -282,6 +288,22 @@ Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build] " } +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 @@ -324,6 +346,7 @@ rpm_dump () { parse_spec() { + update_shell_title "parsing specfile" if [ -n "$DEBUG" ]; then set -x; set -v; @@ -434,6 +457,9 @@ init_builder() get_spec() { + + update_shell_title "get_spec" + if [ -n "$DEBUG" ]; then set -x; set -v; @@ -600,6 +626,7 @@ cvsignore_df () get_files() { GET_FILES="$@" + update_shell_title "fetching sources" if [ -n "$DEBUG" ]; then set -x; @@ -653,27 +680,33 @@ get_files() url=$(distfiles_url "$i") url_attic=$(distfiles_attic_url "$i") FROM_DISTFILES=1 - if [ `echo $url | grep -E '^(\.|/)'` ]; then + 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 + 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 + if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then + update_shell_title "get_files: $url_attic" ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic" fi fi @@ -704,14 +737,16 @@ get_files() done fi - if [ -z "$NOURLS" ] && [ ! -f "`nourl $i`" -o -n "$UPDATE" ] && [ `echo $i | grep -E 'ftp://|http://|https://'` ]; then + if [ -z "$NOURLS" ] && [ ! -f "`nourl $i`" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then if [ -z "$NOMIRRORS" ]; then im="`find_mirror "$i"`" else im="$i" fi + update_shell_title "get_files: $im" ${GETURI} "$im" || \ - if [ `echo $im | grep -E 'ftp://'` ]; then + if [ "`echo $im | grep -E 'ftp://'`" ]; then + update_shell_title "get_files: $im" ${GETURI2} "$im" fi fi @@ -743,14 +778,18 @@ get_files() 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 + 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 + if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then + update_shell_title "get_files: $url_attic" ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic" fi fi @@ -889,6 +928,7 @@ branch_files() build_package() { + update_shell_title "build_package" if [ -n "$DEBUG" ]; then set -x; set -v; @@ -897,6 +937,7 @@ build_package() 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 @@ -911,13 +952,13 @@ build_package() cp -f $SPECFILE $SPECFILE.bak chmod +w $SPECFILE eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE" - eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t1/' $SPECFILE" + eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE" parse_spec; if [ -n "$ICONS" ]; then get_files $ICONS; parse_spec; fi - get_files "$SOURCES $PATCHES"; + NODIST="yes" UPDATE5="yes" get_files "$SOURCES $PATCHES"; unset TOLDVER TNEWVER TNOTIFY fi fi @@ -933,6 +974,8 @@ build_package() 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 @@ -944,7 +987,7 @@ build_package() 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 @@ -981,6 +1024,8 @@ install_required_packages() set_bconds_values() { + update_shell_title "set bcond values" + AVAIL_BCONDS_WITHOUT="" AVAIL_BCONDS_WITH="" if `grep -q ^%bcond ${SPECFILE}`; then @@ -1003,6 +1048,7 @@ set_bconds_values() # This takes package name, first defined in spec. # so consider that when defining flags for package. PN=`$RPM -q --qf '%{NAME}\n' --specfile $SPECFILE | head -n 1` + SN=${SPECFILE%%\.spec} AVAIL=`$RPMBUILD --bcond $SPECFILE` BCONDRC=$HOME/.bcondrc @@ -1013,7 +1059,7 @@ set_bconds_values() [[ "$pkg" == \#* ]] && continue # any package or current package? - if [ "$pkg" = "*" ] || [ "$pkg" = "$PN" ]; then + if [ "$pkg" = "*" ] || [ "$pkg" = "$PN" ] || [ "$pkg" = "$SN" ]; then for flag in $flags; do opt=${flag#[+-]} @@ -1114,7 +1160,7 @@ set_bconds_values() 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 @@ -1130,10 +1176,10 @@ run_sub_builder() 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 @@ -1142,24 +1188,33 @@ run_sub_builder() 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 @@ -1193,6 +1248,14 @@ display_bconds() 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 @@ -1209,10 +1272,10 @@ _rpm_prov_check() 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. @@ -1234,21 +1297,39 @@ _rpm_cnfl_check() 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 @@ -1343,6 +1424,7 @@ fetch_build_requires() ;; *) 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; @@ -1362,6 +1444,7 @@ fetch_build_requires() 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; @@ -1394,59 +1477,6 @@ fetch_build_requires() fi } -diffcol() -{ - # vim like diff colourization, glen@pld-linux.org - sed -e ' - s,,^[,g; - s,,^G,g; - s,^\(Index:\|diff\|---\|+++\) .*$,&,; - s,^@@ ,&,g; - s,^-,&,; - s,^+,&,; - s, ,^M,g; - s, , ,g; - s,\([^[:space:]]\)\([[:space:]]\+\)$,\1\2,g; - s,$,, - ' "$@" -} - -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() @@ -1464,12 +1494,6 @@ do NOCVSSPEC="yes" UPDATE5="yes" shift ;; - --adapter | --adapterize ) - COMMAND="adapterize"; - NODIST="yes" - NOCVSSPEC="yes" - ADAPTERIZE="yes" - shift ;; -a5 | --add-md5 ) COMMAND="get"; NODIST="yes" @@ -1537,6 +1561,8 @@ do 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") @@ -1584,6 +1610,9 @@ do -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" @@ -1647,6 +1676,10 @@ do 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" @@ -1674,6 +1707,7 @@ if [ -n "$TARGET" ]; then esac fi +update_shell_title "$COMMAND" case "$COMMAND" in "build" | "build-binary" | "build-source" | "build-prep" ) init_builder; @@ -1681,6 +1715,8 @@ case "$COMMAND" in 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 @@ -1763,7 +1799,7 @@ case "$COMMAND" in ;; "tag" ) NOURLS=1 - NODIST=1 + NODIST="yes" init_builder; if [ -n "$SPECFILE" ]; then get_spec; @@ -1800,6 +1836,17 @@ case "$COMMAND" in 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" @@ -1811,9 +1858,6 @@ case "$COMMAND" in echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }') done ;; - "adapterize" ) - adapterize - ;; "usage" ) usage;; "version" )