Commit 106eccea authored by Vitaly Lipatov's avatar Vitaly Lipatov

rpmgp: only clone with -g, add new -gm option for remote clone and clone

parent 8c92bf36
...@@ -152,7 +152,8 @@ phelp() ...@@ -152,7 +152,8 @@ phelp()
echog " -a search pkgname in all known repositories" echog " -a search pkgname in all known repositories"
echog " -c check if this package exists in the ALT Linux repository" echog " -c check if this package exists in the ALT Linux repository"
echog " -d download all matched packages" echog " -d download all matched packages"
echog " -g remote clone repo to USER/packages and clone it locally" echog " -g clone last built package repo"
echog " -gm remote clone repo to USER/packages and clone it locally"
echog " -m migrate to gear from spec/srpm" echog " -m migrate to gear from spec/srpm"
echog "Ext. options:" echog "Ext. options:"
echog " -b install packages needed for build (use sudo apt-get) (need spec not package name)" echog " -b install packages needed for build (use sudo apt-get) (need spec not package name)"
...@@ -225,27 +226,22 @@ if [ -n "$INSTALLBINARY" ] ; then ...@@ -225,27 +226,22 @@ if [ -n "$INSTALLBINARY" ] ; then
exec $SUDO $CMD $LISTPKG exec $SUDO $CMD $LISTPKG
fi fi
if [ -n "$MIGRATEGEAR" ] ; then # TODO: do gpull -a for get all branches?
for INFILE in $LISTNAMES ; do get_all_remote_branches()
# call for each file due generated BASENAME {
LISTNAMES=$INFILE pack_src_rpm $INFILE $LISTRPMARGS local CURRENTBRANCH=$(get_current_branch)
PKGNAME="$LISTBUILT" # create all branches
if [ -z "$BASENAME" ] ; then for i in $(git branch -a | grep -v "/HEAD" | grep "remotes/origin/") ; do
echo "Can't get basename for $PKGNAME, skipping" local BRANCHNAME=$(echo $i | sed -e "s|remotes.*/||g")
continue if is_exist_branch $BRANCHNAME ; then
git checkout $BRANCHNAME || fatal "can't checkout $BRANCHNAME"
git pull origin $BRANCHNAME
else
git checkout -b $(echo $i | sed -e "s|remotes.*/||g") $i
fi fi
echo "Create gear repo $BASENAME from $PKGNAME in $GITREPODIR"
GEARDIR=$GITREPODIR/$BASENAME
test -d "$GEARDIR" && fatal "repo $GEARDIR already exits"
mkdir -p "$GEARDIR" || fatal "can't create dir $GEARDIR"
cd $GEARDIR || fatal "can't cd to $GEARDIR"
git init-db || fatal "can't init db"
gear-srpmimport $PKGNAME || fatal "can't import srpm $PKGNAME"
# remove src.rpm only if it was generated from spec
[ -z ${INFILE/*rpm/} ] || rm -vf $PKGNAME
done done
exit 0 git checkout sisyphus || git checkout master || git checkout $CURRENTBRANCH
fi }
# clone remote git # clone remote git
if [ -n "$CLONEGIT" ] ; then if [ -n "$CLONEGIT" ] ; then
...@@ -253,6 +249,16 @@ if [ -n "$CLONEGIT" ] ; then ...@@ -253,6 +249,16 @@ if [ -n "$CLONEGIT" ] ; then
# http://git.altlinux.org/gears/N/NAME.git # http://git.altlinux.org/gears/N/NAME.git
RREPO="/gears/$REPOPATH" RREPO="/gears/$REPOPATH"
if [ -z "$MIGRATEGEAR" ] ; then
echo "Clone from $GIRARHOST:$RREPO ..."
if ! git clone $GIRARHOST:$RREPO ; then
# http://git.altlinux.org/srpms/N/NAME.git
RREPO="/srpms/$REPOPATH"
echo "Try clone from $RREPO ..."
git clone $GIRARHOST:$RREPO || fatal "Can't clone."
fi
else
echo "Remote clone from $RREPO ..." echo "Remote clone from $RREPO ..."
if ! ssh $GIRARHOST clone $RREPO packages/$PKGNAME.git ; then if ! ssh $GIRARHOST clone $RREPO packages/$PKGNAME.git ; then
# http://git.altlinux.org/srpms/N/NAME.git # http://git.altlinux.org/srpms/N/NAME.git
...@@ -262,20 +268,41 @@ if [ -n "$CLONEGIT" ] ; then ...@@ -262,20 +268,41 @@ if [ -n "$CLONEGIT" ] ; then
fi fi
git clone $GIRARHOST:packages/$PKGNAME.git git clone $GIRARHOST:packages/$PKGNAME.git
fi
# get or update all branches
if cd $PKGNAME ; then if cd $PKGNAME ; then
CURRENTBRANCH=$(get_current_branch) get_all_remote_branches
# create all branches
for i in $(git branch -a | grep -v "/HEAD" | grep "remotes/origin/") ; do
git checkout -b $(echo $i | sed -e "s|remotes.*/||g") $i
done
git checkout sisyphus || git checkout master || git checkout $CURRENTBRANCH
cd - >/dev/null cd - >/dev/null
fi fi
echo "See other repos at $GIRARHOST:" echo "See other repos at $GIRARHOST:"
list_git_package $PKGNAME list_git_package $PKGNAME
exit $? exit $?
fi fi
if [ -n "$MIGRATEGEAR" ] ; then
for INFILE in $LISTNAMES ; do
# call for each file due generated BASENAME
LISTNAMES=$INFILE pack_src_rpm $INFILE $LISTRPMARGS
PKGNAME="$LISTBUILT"
if [ -z "$BASENAME" ] ; then
echo "Can't get basename for $PKGNAME, skipping"
continue
fi
echo "Create gear repo $BASENAME from $PKGNAME in $GITREPODIR"
GEARDIR=$GITREPODIR/$BASENAME
test -d "$GEARDIR" && fatal "repo $GEARDIR already exits"
mkdir -p "$GEARDIR" || fatal "can't create dir $GEARDIR"
cd $GEARDIR || fatal "can't cd to $GEARDIR"
git init-db || fatal "can't init db"
gear-srpmimport $PKGNAME || fatal "can't import srpm $PKGNAME"
# remove src.rpm only if it was generated from spec
[ -z ${INFILE/*rpm/} ] || rm -vf $PKGNAME
done
exit 0
fi
# lists packages for build # lists packages for build
if [ -n "$LISTREQS" ] ; then if [ -n "$LISTREQS" ] ; then
print_target_buildreq $PKGNAME print_target_buildreq $PKGNAME
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment