]> git.pld-linux.org Git - packages/rpm-build-tools.git/blobdiff - builder.sh
Merge branch 'fix_test_tag'
[packages/rpm-build-tools.git] / builder.sh
index 14c19f5f09fb9357e96335455be4bbe1caf7b482..8a9db7e1d781188aa5a2ef87c93bce1359652259 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
@@ -843,7 +868,7 @@ find_mirror() {
        cd "$REPO_DIR"
        local url="$1"
        if [ ! -f "mirrors"  ] ; then
-               ln -s rpm-build-toos/mirrors .
+               ln -s rpm-build-tools/mirrors .
        fi
 
        IFS="|"
@@ -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
 }
 
@@ -2356,7 +2379,7 @@ case "$COMMAND" in
                if [ -n "$TEST_TAG" ]; then
                        local TAGVER=`make_tagver`
                        echo "Searching for tag $TAGVER..."
-                       git show-ref --quiet --verify "refs/tags/$TAGVER" && Exit_error err_tag_exists "$TAGVER" "$TAGREL"
+                       git show-ref --quiet --verify "refs/tags/$TAGVER" && Exit_error err_tag_exists "$TAGVER"
 
                        # - do not allow to build from HEAD when XX-branch exists
                        TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
@@ -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.045849 seconds and 4 git commands to generate.