use a master socket so auth only once

master
Daniel Berteaud 12 years ago
parent f2546625d1
commit ddf94681c4
  1. 20
      submit

@ -3,6 +3,7 @@
PACKAGE=$(basename $(pwd)) PACKAGE=$(basename $(pwd))
VERSION=$(rpm -q --qf "%{version}" --specfile $PACKAGE.spec) VERSION=$(rpm -q --qf "%{version}" --specfile $PACKAGE.spec)
ME=$(whoami) ME=$(whoami)
SERVER=build.firewall-services.com
BRANCH=$(git branch | grep '*' | cut -d' ' -f2) BRANCH=$(git branch | grep '*' | cut -d' ' -f2)
DIST=$1 DIST=$1
@ -13,11 +14,15 @@ fi
TMPDIR=$(mktemp -d) TMPDIR=$(mktemp -d)
mkdir -p $TMPDIR/$PACKAGE-$VERSION/ mkdir -p $TMPDIR/$PACKAGE-$VERSION/
SOCKET=$(mktemp -u)
# Open master SSH socket
ssh -M -f -N -o ControlPath=$SOCKET -l $ME $SERVER
# Tag GIT using the version in the spec file # Tag GIT using the version in the spec file
git tag -f $VERSION 2>&1 > /dev/null git tag -f $VERSION 2>&1 > /dev/null
# Create needed dirs on the build box # Create needed dirs on the build box
ssh -l $ME build.firewall-services.com mkdir -p rpmbuild/{RPMS,SRPMS,SPECS,SOURCES} ssh -o ControlPath=$SOCKET -l $ME $SERVER mkdir -p rpmbuild/{RPMS,SRPMS,SPECS,SOURCES}
# Generate a tgz archive from the repo # Generate a tgz archive from the repo
git archive --format=tar --prefix=$PACKAGE-$VERSION/ $BRANCH | tar xf - -C $TMPDIR git archive --format=tar --prefix=$PACKAGE-$VERSION/ $BRANCH | tar xf - -C $TMPDIR
@ -25,13 +30,16 @@ git archive --format=tar --prefix=$PACKAGE-$VERSION/ $BRANCH | tar xf - -C $TMPD
git log --format=%H | git log --pretty --stdin --no-walk > $TMPDIR/$PACKAGE-$VERSION/CHANGELOG.git git log --format=%H | git log --pretty --stdin --no-walk > $TMPDIR/$PACKAGE-$VERSION/CHANGELOG.git
#tar cz -C $TMPDIR $PACKAGE-$VERSION | ssh -l $ME build.firewall-services.com "cat > rpmbuild/SOURCES/$PACKAGE-$VERSION.tar.gz" #tar cz -C $TMPDIR $PACKAGE-$VERSION | ssh -l $ME build.firewall-services.com "cat > rpmbuild/SOURCES/$PACKAGE-$VERSION.tar.gz"
tar czf $TMPDIR/$PACKAGE-$VERSION.tar.gz -C $TMPDIR $PACKAGE-$VERSION tar czf $TMPDIR/$PACKAGE-$VERSION.tar.gz -C $TMPDIR $PACKAGE-$VERSION
scp -C $TMPDIR/$PACKAGE-$VERSION.tar.gz $ME@build.firewall-services.com:rpmbuild/SOURCES/$PACKAGE-$VERSION.tar.gz scp -o ControlPath=$SOCKET -C $TMPDIR/$PACKAGE-$VERSION.tar.gz $ME@$SERVER:rpmbuild/SOURCES/$PACKAGE-$VERSION.tar.gz
# Upload the spec file # Upload the spec file
scp $PACKAGE.spec $ME@build.firewall-services.com:rpmbuild/SPECS/ scp -o ControlPath=$SOCKET $PACKAGE.spec $ME@$SERVER:rpmbuild/SPECS/
# And build # And build
ssh -l $ME build.firewall-services.com rpmbuild -bs --nodeps rpmbuild/SPECS/$PACKAGE.spec ssh -o ControlPath=$SOCKET -l $ME $SERVER rpmbuild -bs --nodeps rpmbuild/SPECS/$PACKAGE.spec
ssh -l $ME build.firewall-services.com buildrpm rpmbuild/SRPMS/$PACKAGE-$VERSION-*.src.rpm $DIST ssh -o ControlPath=$SOCKET -l $ME $SERVER buildrpm rpmbuild/SRPMS/$PACKAGE-$VERSION-*.src.rpm $DIST
ssh -l $ME build.firewall-services.com rm -f rpmbuild/SPECS/$PACKAGE.spec rpmbuild/SOURCES/$PACKAGE-$VERSION.tar.gz rpmbuild/SRPMS/$PACKAGE-$VERSION*.src.rpm ssh -o ControlPath=$SOCKET -l $ME $SERVER rm -f rpmbuild/SPECS/$PACKAGE.spec rpmbuild/SOURCES/$PACKAGE-$VERSION.tar.gz rpmbuild/SRPMS/$PACKAGE-$VERSION*.src.rpm
rm -rf $TMPDIR rm -rf $TMPDIR
# Close master SSH connexion
ssh -S $SOCKET -O exit -l $ME $SERVER

Loading…
Cancel
Save