]> git.pld-linux.org Git - packages/rpm-build-tools.git/blobdiff - builder.sh
builder --no-init: reset all variables to current dir
[packages/rpm-build-tools.git] / builder.sh
index a29cc133e7302ecc7e83e590e60593919b058dd2..b997716e1d7ff7b4014f7c116fa0a089d945558b 100755 (executable)
@@ -581,10 +581,7 @@ set_spec_target() {
 
 # runs rpm with minimal macroset
 minirpm() {
-       # we reset macros not to contain macros.build as all the %() macros are
-       # executed here, while none of them are actually needed.
-       # at the time of this writing macros.build + macros contained 70 "%(...)" macros.
-       safe_macrofiles=$(rpm $TARGET_SWITCH --showrc | awk -F: '/^macrofiles/ { gsub(/^macrofiles[ \t]+:/, "", $0); gsub(/:.*macros.build:/, ":", $0); print $0 } ')
+       safe_macrofiles=$(rpm $TARGET_SWITCH --showrc | awk -F: '/^macrofiles/ { gsub(/^macrofiles[ \t]+:/, "", $0); print $0 } ')
 
        # TODO: move these to /usr/lib/rpm/macros
        cat > $BUILDER_MACROS <<'EOF'
@@ -851,8 +848,10 @@ init_builder() {
                        PACKAGE_DIR=$REPO_DIR/$ASSUMED_NAME
                fi
        else
-               REPO_DIR="."
-               PACKAGE_DIR="."
+               TOP_DIR=$(pwd)
+               PACKAGE_DIR=$TOP_DIR
+               REPO_DIR=$PACKAGE_DIR
+               RPMBUILDOPTS="$RPMBUILDOPTS --define '_topdir $TOP_DIR' --define '_builddir %_topdir' --define '_rpmdir %_topdir' --define '_srcrpmdir %_topdir'"
        fi
        export GIT_WORK_TREE=$PACKAGE_DIR
        export GIT_DIR=$PACKAGE_DIR/.git
@@ -1600,7 +1599,7 @@ build_package() {
 
        local specdir=$(insert_gitlog $SPECFILE)
        # FIXME: eval here is exactly why?
-       PATH=$CLEAN_PATH eval teeboth "'$logfile'" ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $specdir/$SPECFILE
+       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
        retval=$?
        rm -r $specdir
 
@@ -2081,23 +2080,36 @@ fetch_build_requires()
                fi
 }
 
+init_repository() {
+       local remoterepo=$1
+       local localrepo=$2
+
+       if [ ! -e $localrepo ]; then
+               git clone -o $REMOTE_PLD ${GIT_SERVER}/$remoterepo $localrepo
+               git --git-dir=$localrepo/.git remote set-url --push  $REMOTE_PLD ssh://${GIT_PUSH}/$remoterepo
+       fi
+}
+
 init_rpm_dir() {
        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 TEMPLATES=template-specs
        local tmp
 
        echo "Initializing rpm directories to $TOP_DIR from $GIT_SERVER"
        mkdir -p $TOP_DIR $rpmdir $buildir $srpmdir
 
        cd "$TOP_DIR"
-       if [ ! -e ../rpm-build-tools ]; then
-               git clone  ${GIT_SERVER}/${PACKAGES_DIR}/rpm-build-tools.git ../rpm-build-tools
-       fi
-       for a in adapter builder fetchsrc_request; do
+       init_repository ${PACKAGES_DIR}/rpm-build-tools.git ../rpm-build-tools
+       init_repository projects/$TEMPLATES ../$TEMPLATES
+       for a in adapter builder fetchsrc_request compile repackage; do
                ln -sf ../rpm-build-tools/${a}.sh $a
        done
+       for a in md5; do
+               ln -sf ../rpm-build-tools/${a} $a
+       done
        ln -sf ../rpm-build-tools/mirrors mirrors
        init_builder
 }
@@ -2108,7 +2120,7 @@ mr_proper() {
        DONT_PRINT_REVISION="yes"
 
        # remove spec and sources
-       PATH=$CLEAN_PATH $RPMBUILD --clean --rmsource --rmspec --nodeps --define "_specdir $PACKAGE_DIR" --define "_sourcedir $PACKAGE_DIR" --define "_builddir $builddir" $PACKAGE_DIR/$SPECFILE
+       PATH=$CLEAN_PATH $RPMBUILD --clean --rmsource --rmspec --nodeps --define "__urlgetfile() %nil" --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
 }
@@ -2451,6 +2463,9 @@ else
        NICE_COMMAND="nice -n ${DEF_NICE_LEVEL}"
 fi
 
+# see time(1) for output format that could be used
+TIME_COMMAND="time -p"
+
 update_shell_title "$COMMAND"
 case "$COMMAND" in
        "show_bconds")
This page took 0.028679 seconds and 4 git commands to generate.