GIT_SERVER="git://github.com/draenog"
HEAD_DETACHED=""
DEPTH=""
+REMOTE_PLD="origin"
+NEW_REPO=""
RES_FILE=""
[ -f "$USER_CFG" ] && . "$USER_CFG"
+if [ -n "$GIT_LOGINNAME" ]; then
+ GIT_SERVER="git@github.com:${GIT_LOGINNAME}"
+fi
+
if [ "$SCHEDTOOL" = "auto" ]; then
if [ -x /usr/bin/schedtool ] && schedtool -B -e echo >/dev/null; then
SCHEDTOOL="schedtool -B -e"
-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
--date yyyy-mm-dd - build package using resources from specified date,
-r <tag>, --cvstag <ref>
- build package using resources from specified branch/tag,
--A - build package using CVS resources as any sticky tags/date/kopts being reset.
+-A - build package using master branch as any sticky tags/branch/date being reset.
-R, --fetch-build-requires
- fetch what is BuildRequired,
-RB, --remove-build-requires
exit 2 ;;
"err_no_spec_in_repo" )
remove_build_requires
- echo >&2 "Error: spec file not stored in CVS repo."
+ echo >&2 "Error: spec file not stored in PLD repo."
exit 3 ;;
"err_no_source_in_repo" )
remove_build_requires
- echo >&2 "Error: some source, patch or icon files not stored in CVS repo. ($2)"
+ echo >&2 "Error: some source, patch or icon files not stored in PLD repo. ($2)"
exit 4 ;;
"err_cvs_add_failed" )
- echo >&2 "Error: failed to add package to CVS repo."
+ echo >&2 "Error: failed to add package to PLD repo."
exit 4 ;;
"err_build_fail" )
remove_build_requires
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"
__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"
if [ "$NOCVSSPEC" != "yes" ]; then
if [ -z "$DEPTH" ]; then
if [ -d "$ASSUMED_NAME/.git" ]; then
- git fetch origin || Exit_error err_no_spec_in_repo
+ git fetch $REMOTE_PLD || Exit_error err_no_spec_in_repo
elif [ "$ADD_PACKAGE_CVS" = "yes" ]; then
if [ ! -r "$ASSUMED_NAME/$SPECFILE" ]; then
echo "ERROR: No package to add ($ASSUMED_NAME/$SPECFILE)" >&2
else
(
unset GIT_WORK_TREE
- git clone ${GIT_SERVER}/${ASSUMED_NAME}.git || {
- # softfail if new package, i.e not yet added to cvs
+ git clone -o $REMOTE_PLD ${GIT_SERVER}/${ASSUMED_NAME}.git || {
+ # softfail if new package, i.e not yet added to PLD rep
[ ! -f "$ASSUMED_NAME/$SPECFILE" ] && Exit_error err_no_spec_in_repo
echo "Warning: package not in CVS - assuming new package"
NOCVSSPEC="yes"
mkdir $ASSUMED_NAME
fi
git init
- git remote add origin ${GIT_SERVER}/${ASSUMED_NAME}.git
+ git remote add $REMOTE_PLD ${GIT_SERVER}/${ASSUMED_NAME}.git
+ CVSTAG=${CVSTAG:-"master"}
fi
- git fetch "$DEPTH" origin ${CVSTAG}:remotes/origin/${CVSTAG} || {
+ git fetch $DEPTH $REMOTE_PLD ${CVSTAG}:remotes/${REMOTE_PLD}/${CVSTAG} || {
echo >&2 "Error: branch $CVSTAG does not exist"
exit 3
}
cvsignore_df .gitignore
- # add default log format to .cvsignore if it is relative to package dir
+ # add default log format to .gitignore 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')
# 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
fi
if [ -n "$CVSTAG" ]; then
- git checkout "$CVSTAG" -- 2>/dev/null || git checkout -t "origin/$CVSTAG" > /dev/null || exit
+ git checkout "$CVSTAG" -- 2>/dev/null || git checkout -t "${REMOTE_PLD}/$CVSTAG" > /dev/null || exit
git symbolic-ref -q HEAD > /dev/null &&
git merge '@{u}'
if [ -n "$CVSDATE" ]; then
cd "$REPO_DIR"
local url="$1"
if [ ! -f "mirrors" ] ; then
- ln -s rpm-build-toos/mirrors .
+ ln -s rpm-build-tools/mirrors .
fi
IFS="|"
if [ "$TAG_VERSION" = "yes" ]; then
update_shell_title "tag sources: $TAGVER"
git $OPTIONS $TAGVER || exit
+ 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 || Exit_error err_remote_problem $REMOTE_PLD
fi
}
}
display_branches() {
- if [ "$NOCVSSPEC" != "yes" ]; then
- echo -n "Available branches: "
- git branch -r | grep '^ origin' | grep -v origin/HEAD | sed 's#^ *origin/##' | xargs
- fi
+ echo -n "Available branches: "
+ git branch -r | grep "^ ${REMOTE_PLD}" | grep -v ${REMOTE_PLD}/HEAD | sed "s#^ *${REMOTE_PLD}/##" | xargs
}
# checks a given list of packages/files/provides agains current rpmdb.
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
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
}
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')
if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
TAG_BRANCH="${TREE_PREFIX}-branch"
- TAG_STATUS=$(git branch -r | grep -i "origin/$TAG_BRANCH$" | sed 's# *origin/##')
- if [ -n "$TAG_STATUS" -a -z "$CVSTAG" ]; then
+ TAG_STATUS=$(git branch -r | grep -i "${REMOTE_PLD}/$TAG_BRANCH$" | sed "s# *${REMOTE_PLD}/##")
+ if [ -n "$TAG_STATUS" -a "$TAG_STATUS" != "$CVSTAG" ]; then
Exit_error err_branch_exists "$TAG_STATUS"
fi
fi
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