]> git.pld-linux.org Git - packages/rpm-build-tools.git/blobdiff - builder.sh
separater parameters and locals
[packages/rpm-build-tools.git] / builder.sh
index df16b001e04707e85086e06bbe6a486f376120d5..978412d0d85b8a19626d179794b9709be4fac4c2 100755 (executable)
@@ -38,7 +38,7 @@ APPDIR=$(d=$0; [ -L "$d" ] && d=$(readlink -f "$d"); dirname "$d")
 VERSION="v0.35"
 VERSIONSTRING="\
 Build package utility from PLD Linux Packages repository
-$VERSION (C) 1999-2015 Free Penguins".
+$VERSION (C) 1999-2016 Free Penguins".
 
 CLEAN_PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
 
@@ -447,7 +447,8 @@ Usage: builder [--all-branches] [-D|--debug] [-V|--version] [--short-version]  [
                       constructions. Set GROUP_BCONDS to yes to make use of it.
 --target <platform>, --target=<platform>
                     - build for platform <platform>.
---init-rpm-dir      - initialize ~/rpm directory structure
+--init-rpm-dir, --init
+                    - initialize ~/rpm directory structure
 "
 }
 
@@ -554,7 +555,7 @@ depspecname() {
 }
 
 update_shell_title() {
-       [ -t 1 ] || return
+       [ -t 2 ] || return
        local len=${COLUMNS:-80}
        local msg="$(echo "$*" | cut -c-$len)"
 
@@ -918,10 +919,17 @@ create_git_repo() {
        fi
        [ -d "$ASSUMED_NAME/.git" ] || NEW_REPO=yes
        ssh $GIT_PUSH create ${ASSUMED_NAME} || Exit_error err_cvs_add_failed
+       (
+       set -e
        git init
-       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
+       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}
+
+       git config --local push.default current
+       git config --local branch.master.remote $REMOTE_PLD
+       git config --local branch.master.merge refs/heads/master
+       )
+       test $? = 0 || Exit_error err_remote_problem $REMOTE_PLD
 }
 
 get_spec() {
@@ -954,7 +962,10 @@ get_spec() {
                                                echo "Warning: package not in CVS - assuming new package"
                                                NOCVSSPEC="yes"
                                        }
-                                       git config --local --add "remote.$REMOTE_PLD.fetch"  'refs/notes/*:refs/notes/*'
+                                       git config --local --add "remote.$REMOTE_PLD.fetch" 'refs/notes/*:refs/notes/*'
+                                       git config --local --add "remote.$REMOTE_PLD.push" 'refs/notes/*:refs/notes/*'
+                                       git config --local --add "remote.$REMOTE_PLD.push" HEAD
+                                       git config --local push.default current
                                        git remote set-url --push  $REMOTE_PLD ssh://${GIT_PUSH}/${PACKAGES_DIR}/${ASSUMED_NAME}
                                )
                        fi
@@ -965,7 +976,10 @@ get_spec() {
                                fi
                                git init
                                git remote add $REMOTE_PLD ${GIT_SERVER}/${PACKAGES_DIR}/${ASSUMED_NAME}.git
-                               git config --local --add "remote.$REMOTE_PLD.fetch"  'refs/notes/*:refs/notes/*'
+                               git config --local --add "remote.$REMOTE_PLD.fetch" 'refs/notes/*:refs/notes/*'
+                               git config --local --add "remote.$REMOTE_PLD.push" 'refs/heads/*:refs/remotes/origin/*'
+                               git config --local --add "remote.$REMOTE_PLD.push" HEAD
+                               git config --local push.default current
                                git remote set-url --push  $REMOTE_PLD ssh://${GIT_PUSH}/${PACKAGES_DIR}/${ASSUMED_NAME}
                                CVSTAG=${CVSTAG:-"master"}
                        fi
@@ -993,7 +1007,7 @@ get_spec() {
 
                # create symlinks for tools
                if [ "$SYMLINK_TOOLS" != "no" -a -d "$PACKAGE_DIR" ]; then
-                       for a in dropin md5 adapter builder {relup,compile,repackage,rsync,pearize}.sh pldnotify.awk; do
+                       for a in dropin md5 adapter builder {relup,compile,repackage,rsync,pearize}.sh; do
                                # skip tools that don't exist in top dir
                                [ -f $a ] || continue
                                # skip tools that already exist
@@ -1144,7 +1158,7 @@ cvsignore_df() {
        if [ "$CVSIGNORE_DF" != "yes" ]; then
                return
        fi
-       cvsignore=${PACKAGE_DIR}/.gitignore
+       local cvsignore=${PACKAGE_DIR}/.git/info/exclude
 
        # add only if not yet there
        if ! awk -vf="$1" -vc=1 '$0 == f { c = 0 } END { exit c }' $cvsignore 2>/dev/null; then
@@ -1565,12 +1579,12 @@ try_upgrade() {
                echo "Updating spec file to version $TNEWVER"
        else
                if [ -n "$FLOAT_VERSION" ]; then
-                       TNOTIFY=$($APPDIR/pldnotify.awk ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE -n) || exit 1
+                       TNOTIFY=$(pldnotify ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE -n) || exit 1
                else
-                       TNOTIFY=$($APPDIR/pldnotify.awk ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE) || exit 1
+                       TNOTIFY=$(pldnotify ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE) || exit 1
                fi
 
-               # pldnotify.awk does not set exit codes, but it has match for ERROR
+               # pldnotify does not set exit codes, but it has match for ERROR
                # in output which means so.
                if [[ "$TNOTIFY" = *ERROR* ]]; then
                        echo >&2 "$TNOTIFY"
@@ -1642,6 +1656,13 @@ build_package() {
                fi
        fi
 
+       # unset these, should not be exposed to builder shell!
+       unset GIT_WORK_TREE GIT_DIR
+       # these are set by jenkins
+       unset GIT_PREVIOUS_COMMIT GIT_URL GIT_PREVIOUS_SUCCESSFUL_COMMIT GIT_BRANCH GIT_COMMIT
+       # fail if something still set
+       env | grep ^GIT_ && Exit_error err_build_fail
+
        local specdir=$(insert_gitlog $SPECFILE)
        # FIXME: eval here is exactly why?
        PATH=$CLEAN_PATH eval teeboth "'$logfile'" ${TIME_COMMAND} ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $specdir/$SPECFILE
@@ -2296,7 +2317,7 @@ while [ $# -gt 0 ]; do
                -Upi | --update-poldek-indexes )
                        UPDATE_POLDEK_INDEXES="yes"
                        shift ;;
-               --init-rpm-dir)
+               --init-rpm-dir|--init)
                        COMMAND="init_rpm_dir"
                        shift ;;
                -u | --try-upgrade )
This page took 0.151938 seconds and 4 git commands to generate.