]> git.pld-linux.org Git - packages/rpm-build-tools.git/blobdiff - builder.sh
- BuildConflicts after BuildRequires
[packages/rpm-build-tools.git] / builder.sh
index 55dce254ea7366dc77c8c8ac7c07c56b1322e80c..5eacb84efd52e8875d2f062c1b1670222664dac2 100644 (file)
@@ -41,7 +41,6 @@ UPDATE=""
 UPDATE5=""
 ADD5=""
 NO5=""
-ADAPTERIZE=""
 ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"}
 CVSROOT=""
 
@@ -188,7 +187,6 @@ Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
 [--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,
@@ -199,9 +197,12 @@ Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
                       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),
@@ -246,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 <cvstag> , --tag <cvstag>
                     - add cvs tag <cvstag> for files,
 -Tvs, --tag-version-stable
@@ -286,12 +289,17 @@ 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 -ne "\033]1;builder: $*\007\033]2;builder: $*\007"
+               echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
        ;;
                screen*)
-               echo -ne "\033]0;builder: $*\007"
+               echo >&2 -ne "\033]0;$msg\007"
        ;;
        esac
 }
@@ -338,7 +346,7 @@ rpm_dump () {
 
 parse_spec()
 {
-       update_shell_title "parse_spec: $SPECFILE"
+       update_shell_title "parsing specfile"
        if [ -n "$DEBUG" ]; then
                set -x;
                set -v;
@@ -450,7 +458,7 @@ init_builder()
 get_spec()
 {
 
-       update_shell_title "get_spec: $SPECFILE"
+       update_shell_title "get_spec"
 
        if [ -n "$DEBUG" ]; then
                set -x;
@@ -618,7 +626,7 @@ cvsignore_df ()
 get_files()
 {
        GET_FILES="$@"
-       update_shell_title "get_files"
+       update_shell_title "fetching sources"
 
        if [ -n "$DEBUG" ]; then
                set -x;
@@ -673,26 +681,32 @@ get_files()
                                        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
@@ -729,8 +743,10 @@ get_files()
                                        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
@@ -762,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
+                                        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
@@ -908,7 +928,7 @@ branch_files()
 
 build_package()
 {
-       update_shell_title "build_package: $SPECFILE"
+       update_shell_title "build_package"
        if [ -n "$DEBUG" ]; then
                set -x;
                set -v;
@@ -917,7 +937,7 @@ build_package()
        cd "$SPECS_DIR"
 
        if [ -n "$TRY_UPGRADE" ]; then
-                 update_shell_title "build_package: try_upgrade: $SPECFILE"
+                 update_shell_title "build_package: try_upgrade"
                if [ -n "$FLOAT_VERSION" ]; then
                        TNOTIFY=`./pldnotify.awk $SPECFILE -n` || exit 1
                else
@@ -955,7 +975,7 @@ build_package()
                        BUILD_SWITCH="-bp --nodeps" ;;
        esac
 
-       update_shell_title "build_package: $COMMAND: $SPECFILE"
+       update_shell_title "build_package: $COMMAND"
        if [ -n "$LOGFILE" ]; then
                LOG=`eval echo $LOGFILE`
                if [ -d "$LOG" ]; then
@@ -1004,7 +1024,7 @@ install_required_packages()
 
 set_bconds_values()
 {
-       update_shell_title "set_bconds_values: $SPECFILE"
+       update_shell_title "set bcond values"
 
        AVAIL_BCONDS_WITHOUT=""
        AVAIL_BCONDS_WITH=""
@@ -1140,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
@@ -1156,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
@@ -1168,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
@@ -1268,22 +1297,39 @@ _rpm_cnfl_check()
 fetch_build_requires()
 {
        if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
-               update_shell_title "fetc_build_requires: $SPECFILE"
+               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
 
@@ -1378,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;
@@ -1397,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;
@@ -1429,59 +1477,6 @@ fetch_build_requires()
        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()
 
@@ -1499,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"
@@ -1621,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"
@@ -1844,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"
@@ -1855,9 +1858,6 @@ case "$COMMAND" in
                         echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
                done
                ;;
-       "adapterize" )
-               adapterize
-               ;;
        "usage" )
                usage;;
        "version" )
This page took 0.06832 seconds and 4 git commands to generate.