2015-08-21 08:35:01 +08:00
#!/bin/bash
2016-01-21 05:09:12 +08:00
if [ " $1 " = = "clean" ] ; then
read -p "Do you really want to delete existing packages? [y/N]"
[ [ $REPLY = = [ yY] ] ] && { rm -fr zoneminder*.build zoneminder*.changes zoneminder*.deb; echo "Existing package files deleted" ; } || { echo "Packages have NOT been deleted" ; }
exit;
fi
2017-01-16 01:18:51 +08:00
for i in " $@ "
do
case $i in
-b= *| --branch= *)
BRANCH = " ${ i #*= } "
shift # past argument=value
; ;
-d= *| --distro= *)
DISTRO = " ${ i #*= } "
shift # past argument=value
; ;
-i= *| --interactive= *)
INTERACTIVE = " ${ i #*= } "
shift # past argument=value
; ;
2017-04-25 04:50:33 +08:00
-r= *| --release= *)
RELEASE = " ${ i #*= } "
shift
; ;
2017-01-16 01:18:51 +08:00
-s= *| --snapshot= *)
SNAPSHOT = " ${ i #*= } "
shift # past argument=value
; ;
-t= *| --type= *)
TYPE = " ${ i #*= } "
shift # past argument=value
; ;
2017-01-17 10:13:56 +08:00
-u= *| --urgency= *)
URGENCY = " ${ i #*= } "
shift # past argument=value
; ;
2017-01-16 01:18:51 +08:00
-f= *| --fork= *)
GITHUB_FORK = " ${ i #*= } "
shift # past argument=value
; ;
2017-04-25 04:50:33 +08:00
-v= *| --version= *)
PACKAGE_VERSION = " ${ i #*= } "
shift
; ;
2017-01-16 01:18:51 +08:00
--default)
DEFAULT = YES
shift # past argument with no value
; ;
*)
# unknown option
; ;
esac
done
2016-01-21 05:09:12 +08:00
2015-08-21 08:35:01 +08:00
DATE = ` date -R`
if [ " $TYPE " = = "" ] ; then
2017-01-14 22:58:36 +08:00
echo "Defaulting to source build"
TYPE = "source" ;
2015-08-21 08:35:01 +08:00
fi ;
2017-04-25 04:50:33 +08:00
# Release is a special mode... it uploads to the release ppa and cannot have a snapshot
if [ " $RELEASE " != "" ] ; then
if [ " $SNAPSHOT " != "" ] ; then
echo "Releases cannot have a snapshot.... exiting."
exit 0;
fi
if [ " $GITHUB_FORK " != "" ] && [ " $GITHUB_FORK " != "ZoneMinder" ] ; then
echo " Releases cannot have a fork ( $GITHUB_FORK ).... exiting. "
exit 0;
fi
BRANCH = " release- $RELEASE "
2017-01-14 22:58:36 +08:00
else
2017-04-25 04:50:33 +08:00
if [ " $GITHUB_FORK " = = "" ] ; then
echo "Defaulting to ZoneMinder upstream git"
GITHUB_FORK = "ZoneMinder"
2017-01-14 22:58:36 +08:00
fi ;
2017-04-25 04:50:33 +08:00
if [ " $SNAPSHOT " = = "stable" ] ; then
if [ " $BRANCH " = = "" ] ; then
BRANCH = $( git describe --tags $( git rev-list --tags --max-count= 1) ) ;
echo " Latest stable branch is $BRANCH " ;
fi ;
else
if [ " $BRANCH " = = "" ] ; then
echo "Defaulting to master branch" ;
BRANCH = "master" ;
fi ;
if [ " $SNAPSHOT " = = "NOW" ] ; then
SNAPSHOT = ` date +%Y%m%d%H%M%S` ;
fi ;
fi ;
fi
2017-01-17 10:13:56 +08:00
2017-01-14 22:58:36 +08:00
# Instead of cloning from github each time, if we have a fork lying around, update it and pull from there instead.
if [ ! -d " ${ GITHUB_FORK } _zoneminder_release " ] ; then
if [ -d " ${ GITHUB_FORK } _ZoneMinder.git " ] ; then
echo " Using local clone ${ GITHUB_FORK } _ZoneMinder.git to pull from. "
cd " ${ GITHUB_FORK } _ZoneMinder.git "
2017-04-25 04:50:33 +08:00
echo "git pull..."
git pull
2017-01-14 22:58:36 +08:00
echo " git checkout $BRANCH "
git checkout $BRANCH
echo "git pull..."
git pull
cd ../
echo " git clone ${ GITHUB_FORK } _ZoneMinder.git ${ GITHUB_FORK } _zoneminder_release "
git clone " ${ GITHUB_FORK } _ZoneMinder.git " " ${ GITHUB_FORK } _zoneminder_release "
else
echo " git clone https://github.com/ $GITHUB_FORK /ZoneMinder.git ${ GITHUB_FORK } _zoneminder_release "
git clone " https://github.com/ $GITHUB_FORK /ZoneMinder.git " " ${ GITHUB_FORK } _zoneminder_release "
fi
else
echo "release dir already exists. Please remove it."
exit 0;
2015-08-21 08:35:01 +08:00
fi ;
2017-01-14 22:58:36 +08:00
cd " ${ GITHUB_FORK } _zoneminder_release "
2017-04-25 04:50:33 +08:00
if [ $RELEASE ] ; then
git checkout $RELEASE
else
git checkout $BRANCH
fi ;
2017-01-14 22:58:36 +08:00
cd ../
VERSION = ` cat ${ GITHUB_FORK } _zoneminder_release/version`
2017-04-25 04:50:33 +08:00
2015-08-21 08:35:01 +08:00
if [ $VERSION = = "" ] ; then
2016-01-05 22:04:04 +08:00
exit 1;
2015-08-21 08:35:01 +08:00
fi ;
2017-01-14 22:58:36 +08:00
if [ " $SNAPSHOT " != "stable" ] && [ " $SNAPSHOT " != "" ] ; then
2017-04-25 04:50:33 +08:00
VERSION = " $VERSION ~ $SNAPSHOT " ;
2017-01-14 22:58:36 +08:00
fi ;
2017-04-25 04:50:33 +08:00
DIRECTORY = " zoneminder_ $VERSION - $DISTRO ${ PACKAGE_VERSION } " ;
2017-01-14 22:58:36 +08:00
echo " Doing $TYPE release $DIRECTORY " ;
mv " ${ GITHUB_FORK } _zoneminder_release " " $DIRECTORY .orig " ;
cd " $DIRECTORY .orig " ;
2015-08-21 08:35:01 +08:00
git submodule init
git submodule update --init --recursive
2017-04-25 04:50:33 +08:00
if [ " $DISTRO " = = "trusty" ] || [ " $DISTRO " = = "precise" ] ; then
2017-01-14 22:58:36 +08:00
ln -sf distros/ubuntu1204 debian
else
2017-04-25 04:50:33 +08:00
if [ " $DISTRO " = = "wheezy" ] ; then
2017-01-14 22:58:36 +08:00
ln -sf distros/debian debian
else
ln -sf distros/ubuntu1604 debian
fi ;
2015-08-21 08:35:01 +08:00
fi ;
2017-01-14 23:53:05 +08:00
if [ " $DEBEMAIL " != "" ] && [ " $DEBFULLNAME " != "" ] ; then
AUTHOR = " $DEBFULLNAME < $DEBEMAIL > "
2016-01-19 22:05:40 +08:00
else
2017-01-14 23:53:05 +08:00
if [ -z ` hostname -d` ] ; then
AUTHOR = " `getent passwd $USER | cut -d ':' -f 5 | cut -d ',' -f 1` <`whoami`@`hostname`.local> "
else
AUTHOR = " `getent passwd $USER | cut -d ':' -f 5 | cut -d ',' -f 1` <`whoami`@`hostname`> "
fi
2016-01-19 22:05:40 +08:00
fi
2017-04-25 04:50:33 +08:00
if [ " $URGENCY " = "" ] ; then
URGENCY = "medium"
fi ;
2017-01-14 22:58:36 +08:00
if [ " $SNAPSHOT " = = "stable" ] ; then
cat <<EOF > debian/changelog
2017-04-25 04:50:33 +08:00
zoneminder ( $VERSION -$DISTRO ${ PACKAGE_VERSION } ) $DISTRO ; urgency = $URGENCY
2017-01-14 22:58:36 +08:00
* Release $VERSION
2017-01-14 23:01:55 +08:00
-- $AUTHOR $DATE
2017-01-14 22:58:36 +08:00
EOF
else
2015-08-21 08:35:01 +08:00
cat <<EOF > debian/changelog
2017-04-25 04:50:33 +08:00
zoneminder ( $VERSION -$DISTRO ${ PACKAGE_VERSION } ) $DISTRO ; urgency = $URGENCY
2015-08-21 08:35:01 +08:00
*
2017-01-14 23:01:55 +08:00
-- $AUTHOR $DATE
2015-08-21 08:35:01 +08:00
EOF
2017-01-14 22:58:36 +08:00
fi ;
2017-04-25 04:50:33 +08:00
# Auto-install all ZoneMinder's depedencies using the Debian control file
sudo apt-get install devscripts equivs
sudo mk-build-deps -ir ./debian/control
echo " Status: $? "
2016-01-05 22:04:04 +08:00
#rm -rf .git
#rm .gitignore
#cd ../
#tar zcf zoneminder_$VERSION-$DISTRO.orig.tar.gz zoneminder_$VERSION-$DISTRO-$SNAPSHOT.orig
#cd zoneminder_$VERSION-$DISTRO-$SNAPSHOT.orig
2015-08-21 08:35:01 +08:00
if [ $TYPE = = "binary" ] ; then
2017-01-14 23:53:05 +08:00
DEBUILD = debuild
2015-08-21 08:35:01 +08:00
else
2017-01-14 22:58:36 +08:00
if [ $TYPE = = "local" ] ; then
2017-01-14 23:53:05 +08:00
DEBUILD = "debuild -i -us -uc -b"
2017-01-14 22:58:36 +08:00
else
2017-01-14 23:53:05 +08:00
DEBUILD = "debuild -S -sa"
2017-01-14 22:58:36 +08:00
fi ;
2015-08-21 08:35:01 +08:00
fi ;
2017-01-14 23:53:05 +08:00
if [ " $DEBSIGN_KEYID " != "" ] ; then
DEBUILD = " $DEBUILD -k $DEBSIGN_KEYID "
fi
$DEBUILD
2017-04-25 04:50:33 +08:00
echo " Status: $? "
2016-01-05 22:04:04 +08:00
2015-08-21 08:35:01 +08:00
cd ../
2017-01-16 01:18:51 +08:00
if [ " $INTERACTIVE " != "no" ] ; then
read -p "Do you want to keep the checked out version of Zoneminder (incase you want to modify it later) [y/N]"
[ [ $REPLY = = [ yY] ] ] && { mv $DIRECTORY zoneminder_release; echo "The checked out copy is preserved in zoneminder_release" ; } || { rm -fr $DIRECTORY ; echo "The checked out copy has been deleted" ; }
echo "Done!"
else
rm -fr $DIRECTORY ; echo "The checked out copy has been deleted" ;
fi
2016-01-21 05:09:12 +08:00
2017-01-14 22:58:36 +08:00
if [ $TYPE = = "binary" ] ; then
2017-01-16 01:18:51 +08:00
if [ " $INTERACTIVE " != "no" ] ; then
echo "Not doing dput since it's a binary release. Do you want to install it? (Y/N)"
read install
if [ " $install " = = "Y" ] ; then
sudo dpkg -i $DIRECTORY *.deb
fi ;
2017-04-25 04:50:33 +08:00
if [ " $DISTRO " = = "jessie" ] ; then
echo "Do you want to upload this binary to zmrepo? (y/N)"
read install
if [ " $install " = = "Y" ] ; then
scp " zoneminder_*- ${ VERSION } - ${ DISTRO } * " " zmrepo@zmrepo.connortechnology.com:debian/ ${ BRANCH } /mini-dinstall/incoming/ "
fi ;
fi ;
2017-01-14 22:58:36 +08:00
fi ;
else
2017-04-25 04:50:33 +08:00
SC = " zoneminder_ ${ VERSION } - ${ DISTRO } ${ PACKAGE_VERSION } _source.changes " ;
2017-01-14 22:58:36 +08:00
PPA = "" ;
2017-04-25 04:50:33 +08:00
if [ " $RELEASE " != "" ] ; then
2017-01-14 22:58:36 +08:00
PPA = "ppa:iconnor/zoneminder" ;
else
if [ " $BRANCH " = = "" ] ; then
PPA = "ppa:iconnor/zoneminder-master" ;
else
PPA = " ppa:iconnor/zoneminder- $BRANCH " ;
fi ;
fi ;
2017-01-16 01:18:51 +08:00
dput = "Y" ;
if [ " $INTERACTIVE " != "no" ] ; then
echo " Ready to dput $SC to $PPA ? Y/N... " ;
read dput
fi
2017-01-14 22:58:36 +08:00
if [ " $dput " = = "Y" -o " $dput " = = "y" ] ; then
dput $PPA $SC
fi ;
fi ;
2016-01-21 05:09:12 +08:00
2016-01-05 22:04:04 +08:00