]> git.pld-linux.org Git - packages/rpm-build-tools.git/blobdiff - builder.sh
Exit with error when cannot push tags
[packages/rpm-build-tools.git] / builder.sh
index 5a44ea3cd55cc14ad731e648d2c5249cb61cde58..fbdecf8f44ba827ef44f45c928b87b5a72f625d9 100755 (executable)
@@ -113,6 +113,7 @@ GIT_SERVER="git://github.com/draenog"
 HEAD_DETACHED=""
 DEPTH=""
 REMOTE_PLD="origin"
+NEW_REPO=""
 
 RES_FILE=""
 
@@ -266,7 +267,7 @@ Usage: builder [-D|--debug] [-V|--version] [--short-version]  [-a|--add_cvs] [-b
 -debug              - produce rpm debug package (same as --opts -debug)
 -V, --version       - output builder version string
 --short-version     - output builder short version
--a, --add_cvs       - try add new package to PLD repo.
+-a, --add_vcs       - try add new package to PLD repo.
 -b, -ba, --build    - get all files from PLD repo or HTTP/FTP and build package
                       from <package>.spec,
 -bb, --build-binary - get all files from PLD repo or HTTP/FTP and build binary
@@ -705,6 +706,10 @@ Exit_error() {
                        remove_build_requires
                        echo >&2 "Error: conditions reject building this spec (${2})."
                        exit 12 ;;
+               "err_remote_problem" )
+                       remove_build_requires
+                       echo >&2 "Error: problem with remote (${2})"
+                       exit 13 ;;
                "err_not_implemented" )
                        remove_build_requires
                        echo >&2 "Error: functionality not yet imlemented"
@@ -745,6 +750,26 @@ init_builder() {
        __PWD=$(pwd)
 }
 
+create_git_repo() {
+       update_shell_title "add_package"
+
+       if [ -n "$DEBUG" ]; then
+               set -x
+               set -v
+       fi
+
+       cd "$REPO_DIR"
+       SPECFILE=$(basename $SPECFILE)
+       if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then
+               echo "ERROR: No package to add ($ASSUMED_NAME/$SPECFILE)" >&2
+               exit 101
+       fi
+       [ -d "$ASSUMED_NAME/.git" ] || NEW_REPO=yes
+       pldpkg.py add ${ASSUMED_NAME} || Exit_error err_cvs_add_failed
+       git init
+       git remote add $REMOTE_PLD ${GIT_SERVER}/${ASSUMED_NAME}.git || Exit_error err_remote_problem $REMOTE_PLD
+}
+
 get_spec() {
 
        update_shell_title "get_spec"
@@ -790,7 +815,7 @@ get_spec() {
                                git remote add $REMOTE_PLD ${GIT_SERVER}/${ASSUMED_NAME}.git
                                CVSTAG=${CVSTAG:-"master"}
                        fi
-                       git fetch "$DEPTH" $REMOTE_PLD ${CVSTAG}:remotes/${REMOTE_PLD}/${CVSTAG} || {
+                       git fetch $DEPTH $REMOTE_PLD ${CVSTAG}:remotes/${REMOTE_PLD}/${CVSTAG} || {
                                echo >&2 "Error: branch $CVSTAG does not exist"
                                exit 3
                        }
@@ -809,7 +834,7 @@ get_spec() {
 
                # create symlinks for tools
                if [ "$SYMLINK_TOOLS" != "no" ]; 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,pearize}.sh pldnotify.awk; do
                                [ -f $a ] || continue
                                ln -sf ../$a $ASSUMED_NAME
                                cvsignore_df $a
@@ -1272,12 +1297,12 @@ tag_files() {
        if [ "$TAG_VERSION" = "yes" ]; then
                update_shell_title "tag sources: $TAGVER"
                git $OPTIONS $TAGVER || exit
-               git push $CVS_FORCE $REMOTE_PLD tag $TAGVER
+               git push $CVS_FORCE $REMOTE_PLD tag $TAGVER || Exit_error err_remote_problem $REMOTE_PLD
        fi
        if [ -n "$TAG" ]; then
                update_shell_title "tag sources: $TAG"
                git $OPTIONS $TAG $chunk || exit
-               git push $CVS_FORCE $REMOTE_PLD tag $TAG
+               git push $CVS_FORCE $REMOTE_PLD tag $TAG || Exit_error err_remote_problem $REMOTE_PLD
        fi
 }
 
@@ -1920,8 +1945,9 @@ init_rpm_dir() {
        echo "Initializing rpm directories to $TOP_DIR from $GIT_SERVER"
        mkdir -p $TOP_DIR $rpmdir $buildir $srpmdir
 
-       GIT_WORK_TREE=${TOP_DIR}/rpm-build-tools git clone  ${GIT_SERVER}/rpm-build-tools.git || 
-       for a in dropin md5 adapter builder mirrors {relup,compile,repackage,rsync,pearize}.sh pldnotify.awk; do
+       cd "$TOP_DIR"
+       git clone  ${GIT_SERVER}/rpm-build-tools.git ${TOP_DIR}/rpm-build-tools
+       for a in dropin md5 adapter builder mirrors {relup,compile,repackage,pearize}.sh pldnotify.awk; do
                ln -s rpm-build-tools/$a .
        done
        init_builder
@@ -1931,13 +1957,10 @@ mr_proper() {
        init_builder
        NOCVSSPEC="yes"
        DONT_PRINT_REVISION="yes"
-       get_spec
-       parse_spec
 
        # remove spec and sources
-       $RPMBUILD --clean --rmsource --rmspec --nodeps --define "_specdir $PACKAGE_DIR" --define "_sourcedir $PACKAGE_DIR" $SPECFILE
+       $RPMBUILD --clean --rmsource --rmspec --nodeps --define "_specdir $PACKAGE_DIR" --define "_sourcedir $PACKAGE_DIR" $PACKAGE_DIR/$SPECFILE
        rm -rf $PACKAGE_DIR/.git .gitignore
-       cd $__PWD
        rmdir --ignore-fail-on-non-empty $PACKAGE_DIR
 }
 
@@ -2363,7 +2386,7 @@ case "$COMMAND" in
                        if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
                                TAG_BRANCH="${TREE_PREFIX}-branch"
                                TAG_STATUS=$(git branch -r | grep -i "${REMOTE_PLD}/$TAG_BRANCH$" | sed "s# *${REMOTE_PLD}/##")
-                               if [ "$TAG_STATUS" != "$CVSTAG" ]; then
+                               if [ -n "$TAG_STATUS" -a "$TAG_STATUS" != "$CVSTAG" ]; then
                                        Exit_error err_branch_exists "$TAG_STATUS"
                                fi
                        fi
@@ -2406,14 +2429,23 @@ case "$COMMAND" in
                        Exit_error err_no_spec_in_cmdl
                fi
 
-               ADD_PACKAGE_CVS=yes get_spec
-               parse_spec
-
-               if [ -n "$NOSOURCE0" ] ; then
-                       SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
+               create_git_repo
+               if [ -n "$NEW_REPO" ]; then
+                       parse_spec
+                       local file
+                       for file in $SOURCES $PATCHES; do
+                               if [ -z $(src_md5 "$file") ]; then
+                                       git add $file || Exit_error err_no_source_in_repo $file
+                               else
+                                       cvsignore_df `nourl $file`
+                               fi
+                       done
+                       git add $SPECFILE
+                       git commit -m 'Initial commit'
+                       git push --dry-run $REMOTE_PLD master || Exit_error err_cvs_add_failed
+               else
+                       echo "You had already git repository. Push chosen branches to remote: ${REMOTE_PLD}"
                fi
-               get_files $SOURCES $PATCHES
-               check_md5 $SOURCES
                ;;
        "get" )
                init_builder
This page took 0.098871 seconds and 4 git commands to generate.