Some changes to build
This commit is contained in:
Executable
+70
@@ -0,0 +1,70 @@
|
||||
#!/bin/bash
|
||||
|
||||
#Update schemata
|
||||
cd /home/prod/Smallwebs/Activizr-repo/schemas
|
||||
echo "Checking for updates to schema..."
|
||||
svn update
|
||||
|
||||
cd /home/packager/swarmops
|
||||
|
||||
#Update all files, including this one. Runpos will remain same in possible new version
|
||||
echo "Checking for updates to packaging process..."
|
||||
svn update
|
||||
|
||||
# Check parameters
|
||||
|
||||
if [ "$1" == "release" ]; then
|
||||
DROPFOLDER=release
|
||||
BUILDNUMLEN=6
|
||||
echo "Packaging FINISHED RELEASE for super-stable deployments."
|
||||
elif [ "$1" == "sprint" ]; then
|
||||
DROPFOLDER=sprint
|
||||
BUILDNUMLEN=6
|
||||
echo "Packaging END-OF-SPRINT for normal deployments."
|
||||
elif [ "$1" == "" ]; then
|
||||
DROPFOLDER=internal
|
||||
BUILDNUMLEN=8
|
||||
echo "internal" > ../lastbuild/swarmops/internal/frontend/SprintName.txt
|
||||
echo "Packaging internal test build."
|
||||
else
|
||||
echo "Syntax: repackage-build [sprint|release]"
|
||||
echo "(No parameter will trigger a build of the internal branch.)"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
BUILDID=$(cat ../lastbuild/swarmops/$DROPFOLDER/BuildIdentity.txt | tr -d ' \r')
|
||||
COMMITID=$(cat ../lastbuild/swarmops/$DROPFOLDER/CommitIdentity.txt | tr -d ' \r')
|
||||
|
||||
BUILDID=$(echo $BUILDID | cut -c 1-$BUILDNUMLEN)$(echo $COMMITID | cut -c 1-7)
|
||||
|
||||
echo ""
|
||||
echo "Packaging Swarmops, branch '$DROPFOLDER', build $BUILDID."
|
||||
echo "----------------------------------------------------------------------"
|
||||
echo ""
|
||||
|
||||
scripts/repackage-one frontend $1
|
||||
scripts/repackage-one backend $1
|
||||
scripts/repackage-one common $1
|
||||
|
||||
if [ "$DROPFOLDER" != "internal" ]; then
|
||||
# packaging extscripts should go here; copy from do-sprint
|
||||
fi
|
||||
|
||||
echo "Notifying developers that new build has packaged for test/deployment..."
|
||||
|
||||
if [ "$DROPFOLDER" == "internal" ]; then
|
||||
PACKAGELABEL="internal"
|
||||
echo "$(cat ../lastbuild/swarmops/internal/CommitMessage.txt)" > deploymsg.txt
|
||||
echo "" >> deploymsg.txt
|
||||
echo "The packages (swarmops-frontend-internal, swarmops-backend-internal) are available from repositories now, and can be tested at http://dev.swarmops.com/ as usual. Last 3 commits listed above." >> deploymsg.txt
|
||||
else
|
||||
PACKAGELABEL="$DROPFOLDER $(cat ../lastbuild/swarmops/$DROPFOLDER/frontend/SprintName.txt | tr -d '\n')"
|
||||
echo "NOTE: this is a $DROPFOLDER package bundle. It will deploy automatically to live systems via apt-get upgrade. Yay, we made another sprint!" > deploymsg.txt
|
||||
fi
|
||||
|
||||
# TODO: Add build messages to deploy message, at least for internal build
|
||||
|
||||
mail -a "From: Swarmops Builder <builds@swarmops.com>" -s "Swarmops $BUILDID ($PACKAGELABEL) packaged." "swarmops.developers@groups.facebook.com" < deploymsg.txt
|
||||
|
||||
rm deploymsg.txt
|
||||
|
||||
Executable
+178
@@ -0,0 +1,178 @@
|
||||
#!/bin/bash
|
||||
|
||||
DEPLOYDIR=usr/share/swarmops
|
||||
|
||||
# Check parameters
|
||||
|
||||
if [ "$2" == "release" ]; then
|
||||
CONTROLSUFFIX=-release
|
||||
DROPFOLDER=release
|
||||
BUILDNUMLEN=6
|
||||
echo "Packaging FINISHED RELEASE for super-stable deployments."
|
||||
elif [ "$2" == "sprint" ]; then
|
||||
CONTROLSUFFIX=-sprint
|
||||
DROPFOLDER=sprint
|
||||
BUILDNUMLEN=6
|
||||
echo "Packaging END-OF-SPRINT for normal deployments."
|
||||
else
|
||||
CONTROLSUFFIX=-internal
|
||||
DROPFOLDER=internal
|
||||
BUILDNUMLEN=8
|
||||
if [ "$1" == "extscripts" ]; then
|
||||
echo "Error: Cannot package external scripts for internal build. Use 'sprint' or 'release'."
|
||||
exit 1;
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$1" == "frontend" ]; then
|
||||
echo "Packaging frontend...";
|
||||
SOURCEDIR=/home/packager/lastbuild/swarmops/$DROPFOLDER/frontend
|
||||
TARGETDIR=frontend
|
||||
PACKAGE=frontend
|
||||
INCLUDEDB=no
|
||||
COPYFILES=yes
|
||||
elif [ "$1" == "backend" ]; then
|
||||
echo "Packaging backend..."
|
||||
SOURCEDIR=/home/packager/lastbuild/swarmops/$DROPFOLDER/backend
|
||||
TARGETDIR=backend
|
||||
PACKAGE=backend
|
||||
INCLUDEDB=no
|
||||
COPYFILES=yes
|
||||
elif [ "$1" == "extscripts" ]; then
|
||||
echo "Packaging external scripts..."
|
||||
SOURCEDIR=/home/prod/Smallwebs/HostedScripts
|
||||
TARGETDIR=frontend/Scripts/ExternalScripts
|
||||
PACKAGE=external-scripts
|
||||
COPYFILES=yes
|
||||
elif [ "$1" == "common" ]; then
|
||||
echo "Packaging common (the config file)..."
|
||||
COPYFILES=no
|
||||
INCLUDEDB=yes
|
||||
PACKAGE=common
|
||||
else
|
||||
echo "Syntax:"
|
||||
echo "repackage {frontend|backend|extscripts|common} [sprint|release]"
|
||||
echo
|
||||
echo "If 'sprint' or 'release' is not given, -internal will be added to the package name."
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
PACKAGENAME=$PACKAGE$CONTROLSUFFIX
|
||||
|
||||
cp ../lastbuild/swarmops/$DROPFOLDER/BuildIdentity.txt ./BuildIdentity.txt
|
||||
cp ../lastbuild/swarmops/$DROPFOLDER/CommitIdentity.txt ./CommitIdentity.txt
|
||||
|
||||
BUILDID=$(cat BuildIdentity.txt | tr -d ' \r')
|
||||
COMMITID=$(cat CommitIdentity.txt | tr -d ' \r')
|
||||
|
||||
BUILDID=$(echo $BUILDID | cut -c 1-$BUILDNUMLEN)$(echo $COMMITID | cut -c 1-7)
|
||||
|
||||
echo ""
|
||||
echo "Building package $PACKAGENAME $BUILDID."
|
||||
echo "----------------------------------------------------------------------"
|
||||
echo ""
|
||||
|
||||
# Delete flag that indicates a new drop is available
|
||||
#rm /home/packaging/lastbuild/BuildDropped.txt
|
||||
|
||||
# Remove previous package files, if any
|
||||
if [ -d debian ]; then
|
||||
rm -rf debian
|
||||
fi
|
||||
|
||||
# Init build
|
||||
mkdir debian
|
||||
mkdir debian/DEBIAN
|
||||
cd debian
|
||||
|
||||
|
||||
if [ "$COPYFILES" == "yes" ]; then
|
||||
echo "Copying payload files into repo..."
|
||||
mkdir -p $DEPLOYDIR/$TARGETDIR
|
||||
cp -R $SOURCEDIR/* $DEPLOYDIR/$TARGETDIR/.
|
||||
|
||||
#Special case: remove staging sandbox from scripts before packaging
|
||||
if [ "$1" == "extscripts" ]; then
|
||||
rm -rf $DEPLOYDIR/$TARGETDIR/staging
|
||||
fi
|
||||
|
||||
if [ -d $SOURCEDIR/etcinitd ]; then
|
||||
echo "Adding /etc/init.d files..."
|
||||
mkdir -p etc/init.d
|
||||
cp $SOURCEDIR/etcinitd/* etc/init.d/.
|
||||
fi
|
||||
|
||||
if [ "$1" == "frontend" ]; then
|
||||
echo "Moving user-configurable files to /etc/swarmops/..."
|
||||
mkdir -p etc/swarmops
|
||||
mv $DEPLOYDIR/$TARGETDIR/machineKey.config etc/swarmops/.
|
||||
sed -i 's/\"machineKey.config\"/\"..\/..\/..\/..\/etc\/swarmops\/machineKey.config\"/g' $DEPLOYDIR/$TARGETDIR/web.config
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Copying template files into repo..."
|
||||
if [ "$INCLUDEDB" == "yes" ]; then
|
||||
mkdir -p etc/swarmops
|
||||
cp ../templates/database.config.template etc/swarmops/database.config
|
||||
fi
|
||||
cp ../templates/control-$PACKAGENAME.template DEBIAN/control
|
||||
cp ../templates/conffiles-$PACKAGE.template DEBIAN/conffiles
|
||||
|
||||
if [ -e "../templates/prerm-$PACKAGE.template" ]; then
|
||||
echo "Adding $PACKAGE prerm script..."
|
||||
cp ../templates/prerm-$PACKAGE.template DEBIAN/prerm
|
||||
chmod +x DEBIAN/prerm
|
||||
else
|
||||
if [ -e "DEBIAN/prerm" ]; then
|
||||
echo "Deleting old prerm script..."
|
||||
rm DEBIAN/prerm
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -e "../templates/postinst-$PACKAGE.template" ]; then
|
||||
echo "Adding $PACKAGE postinst script..."
|
||||
cp ../templates/postinst-$PACKAGE.template DEBIAN/postinst
|
||||
chmod +x DEBIAN/postinst
|
||||
else
|
||||
if [ -e "DEBIAN/postinst" ]; then
|
||||
echo "Deleting old postinst script..."
|
||||
rm DEBIAN/postinst
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Converting CRLF line endings in scripts to LF-only..."
|
||||
dos2unix -q DEBIAN/*
|
||||
dos2unix -q etc/init.d/*
|
||||
|
||||
echo "Setting build number $BUILDID..."
|
||||
sed -i "s/--BuildNumber--/$BUILDID/" DEBIAN/control
|
||||
echo $BUILDID > $DEPLOYDIR/$TARGETDIR/BuildIdentity.txt
|
||||
|
||||
# Calculating new checksums
|
||||
echo "Creating MD5 checksum file..."
|
||||
../scripts/create-md5
|
||||
|
||||
echo "Creating package 'swarmops-$PACKAGENAME-latest.deb'..."
|
||||
cd ..
|
||||
if [ -e swarmops-$PACKAGENAME-latest.deb ]; then
|
||||
rm swarmops-$PACKAGENAME-latest.deb
|
||||
fi
|
||||
fakeroot dpkg-deb --build debian
|
||||
mv debian.deb swarmops-$PACKAGENAME-latest.deb
|
||||
cp swarmops-$PACKAGENAME-latest.deb /home/prod/Smallwebs/Activizr-repo
|
||||
|
||||
echo "Updating repositories..."
|
||||
scripts/update-repos swarmops-$PACKAGENAME-latest.deb
|
||||
|
||||
if [ "$2" == "" ]; then
|
||||
echo "Installing INTERNAL BUILD on swarmops-dev for testing..."
|
||||
sudo dpkg -i --force-confdef swarmops-$PACKAGENAME-latest.deb
|
||||
fi
|
||||
|
||||
echo "Cleaning up..."
|
||||
|
||||
rm swarmops-$PACKAGENAME-latest.deb
|
||||
rm -rf debian
|
||||
rm BuildIdentity.txt
|
||||
rm CommitIdentity.txt
|
||||
|
||||
Reference in New Issue
Block a user