]> git.pld-linux.org Git - packages/rpm-build-tools.git/blobdiff - builder.sh
- up
[packages/rpm-build-tools.git] / builder.sh
index 45d5c7c7e5c1929e219a9be5f1a7b2a625356359..c3c6c71b095e4f5b4ef487c8e70d51faaa61d506 100644 (file)
@@ -363,6 +363,8 @@ Usage: builder [-D|--debug] [-V|--version] [--short-version] [-a|--as_anon] [-b|
 -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/
+--upgrade-version   - upgrade to specified version in try-upgrade
 --use-greed-sources
                     - try download source from tag head if don't find it in
                       current tag
@@ -505,6 +507,7 @@ minirpm() {
 %lua_remove_etc_shells() %{nil}
 %required_jdk %{nil}
 %buildrequires_jdk %{nil}
+%pear_package_print_optionalpackages %{nil}
 EOF
        if [ "$NOINIT" = "yes" ] ; then
                cat >> $BUILDER_MACROS <<'EOF'
@@ -722,24 +725,30 @@ get_spec() {
                # XXX: still needed?
                SPECFILE=$(basename $SPECFILE)
        fi
-       if [ "$NOCVSSPEC" != "yes" ]; then
 
+       if [ "$NOCVSSPEC" != "yes" ]; then
                if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
                        echo "Warning: No CVS access defined - using local .spec file"
                        NOCVSSPEC="yes"
                fi
 
-               if [ -d "$ASSUMED_NAME" ]; then
+               if [ -d "$ASSUMED_NAME" -a -s "$ASSUMED_NAME/CVS/Root" ]; then
                        cvsup "$ASSUMED_NAME/$SPECFILE" || Exit_error err_no_spec_in_repo
                else
-                       cvsup -c -d $ASSUMED_NAME "packages/$ASSUMED_NAME/$SPECFILE" || Exit_error err_no_spec_in_repo
+                       cvsup -c -d $ASSUMED_NAME "packages/$ASSUMED_NAME/$SPECFILE" || {
+                               # softfail if new package, i.e not yet added to cvs
+                               [ ! -f "$ASSUMED_NAME/$SPECFILE" ] && Exit_error err_no_spec_in_repo
+                               echo "Warning: package not in CVS - assuming new package"
+                               NOCVSSPEC="yes"
+                               NOCVS="yes"
+                       }
 
                        # remove Entries.Static -- so 'cvs up' would update all files in a repo
-                       rm "$ASSUMED_NAME/CVS/Entries.Static"
+                       rm -f "$ASSUMED_NAME/CVS/Entries.Static"
                        cvsignore_df .cvsignore
 
-                       # add default log format to .cvsignore if it is relative
-                       if [ "$LOGFILE" == $(basename "$LOGFILE") ]; then
+                       # add default log format to .cvsignore if it is relative to package dir
+                       if [ -n "$LOGFILE" -a "$LOGFILE" = "${LOGFILE##*/}" ]; then
                                # substitute known "macros" to glob
                                local logfile=$(echo "$LOGFILE" | sed -e 's,\$\(PACKAGE_NAME\|DATE\),*,g')
                                if [ "$logfile" ]; then
@@ -751,7 +760,7 @@ get_spec() {
                        if [ "$SYMLINK_TOOLS" != "no" ]; then
                                for a in dropin md5 adapter builder {relup,compile,repackage,rsync,pearize}.sh pldnotify.awk; do
                                        [ -f $a ] || continue
-                                       ln -s ../$a $ASSUMED_NAME
+                                       ln -sf ../$a $ASSUMED_NAME
                                        cvsignore_df $a
                                done
                        fi
@@ -1439,13 +1448,24 @@ try_upgrade() {
 
                cd "$PACKAGE_DIR"
                
-               if [ -n "$FLOAT_VERSION" ]; then
-                       TNOTIFY=$($APPDIR/pldnotify.awk ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE -n) || exit 1
+               if [ "$UPGRADE_VERSION" ]; then
+                       TNEWVER=$UPGRADE_VERSION
                else
-                       TNOTIFY=$($APPDIR/pldnotify.awk ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE) || exit 1
-               fi
+                       if [ -n "$FLOAT_VERSION" ]; then
+                               TNOTIFY=$($APPDIR/pldnotify.awk ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE -n) || exit 1
+                       else
+                               TNOTIFY=$($APPDIR/pldnotify.awk ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE) || exit 1
+                       fi
 
-               TNEWVER=$(echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }')
+                       # pldnotify.awk does not set exit codes, but it has match for ERROR
+                       # in output which means so.
+                       if [[ "$TNOTIFY" = *ERROR* ]]; then
+                               echo >&2 "$TNOTIFY"
+                               exit 1
+                       fi
+
+                       TNEWVER=$(echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }')
+               fi
 
                if [ -n "$TNEWVER" ]; then
                        TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
@@ -1457,6 +1477,10 @@ try_upgrade() {
                        set_release $SPECFILE $PACKAGE_RELEASE 1
                        set_version $SPECFILE $PACKAGE_VERSION $TNEWVER
                        parse_spec
+                       if [ "$PACKAGE_VERSION" != "$TNEWVER" ]; then
+                               echo >&2 "Upgrading version failed, you need to update spec yourself"
+                               exit 1
+                       fi
                        return 1
                fi
        fi
@@ -1607,7 +1631,7 @@ set_bconds_values() {
        AVAIL_BCONDS_WITHOUT=""
        AVAIL_BCONDS_WITH=""
 
-       if egrep -q '^# *_with' ${SPECFILE}; then
+       if grep -Eq '^# *_with' ${SPECFILE}; then
                echo >&2 "ERROR: This spec has old style bconds."
                exit 1
        fi
@@ -1694,15 +1718,15 @@ spawn_sub_builder() {
        update_shell_title "spawn_sub_builder $package_name"
 
        sub_builder_opts=''
-       if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
+       if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
                sub_builder_opts="${sub_builder_opts} -R"
        fi
-       if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
+       if [ "${REMOVE_BUILD_REQUIRES}" = "nice" ]; then
                sub_builder_opts="${sub_builder_opts} -RB"
-       elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
+       elif [ "${REMOVE_BUILD_REQUIRES}" = "force" ]; then
                sub_builder_opts="${sub_builder_opts} -FRB"
        fi
-       if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
+       if [ "${UPDATE_POLDEK_INDEXES}" = "yes" ]; then
                sub_builder_opts="${sub_builder_opts} -Upi"
        fi
 
@@ -1989,13 +2013,23 @@ fetch_build_requires()
 }
 
 init_rpm_dir() {
-       TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
-       CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
+       local CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
+       local TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
+       local rpmdir=$(eval $RPM $RPMOPTS --eval '%{_rpmdir}')
+       local buildir=$(eval $RPM $RPMOPTS --eval '%{_builddir}')
+       local srpmdir=$(eval $RPM $RPMOPTS --eval '%{_srcrpmdir}')
+       local tmp
 
        echo "Initializing rpm directories to $TOP_DIR from $CVSROOT"
-       mkdir -p $TOP_DIR/{RPMS,BUILD,SRPMS}
-       cd $TOP_DIR
-       $CVS_COMMAND -d $CVSROOT co packages/{.cvsignore,rpm.groups,dropin,mirrors,md5,adapter{,.awk},fetchsrc_request,builder,{relup,compile,repackage}.sh}
+       mkdir -p $TOP_DIR $rpmdir $buildir $srpmdir
+
+       # need to checkout to tmp dir or we can't name our topdir
+       tmp=$(TMPDIR= TEMPDIR= mktemp -p $TOP_DIR -d) || exit 1
+       cd $tmp
+       $CVS_COMMAND -d $CVSROOT co packages/{.cvsignore,rpm.groups,dropin,mirrors,md5,adapter{,.awk},fetchsrc_request,builder,{relup,compile,repackage}.sh,ci,civim}
+       cd -
+       mv $tmp/packages/* $TOP_DIR
+       rm -rf $tmp
 
        init_builder
 
@@ -2003,11 +2037,11 @@ init_rpm_dir() {
        echo "- run cvs co SPECS"
 
        echo "To checkout *all* packages:"
-       echo "- run cvs up -dP in $TOP_DIR/packages dir"
+       echo "- run cvs up -dP in $TOP_DIR dir"
 
        echo ""
        echo "To commit with your developer account:"
-       echo "- edit $TOP_DIR/packages/CVS/Root"
+       echo "- edit $TOP_DIR/CVS/Root"
 }
 
 get_greed_sources() {
@@ -2271,6 +2305,8 @@ while [ $# -gt 0 ]; do
                        shift;;
                -u | --try-upgrade )
                        TRY_UPGRADE="1"; shift ;;
+               --upgrade-version )
+                       shift; UPGRADE_VERSION="$1"; shift;;
                -un | --try-upgrade-with-float-version )
                        TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
                -v | --verbose )
This page took 0.031692 seconds and 4 git commands to generate.