From c5d2652d1b76011116445acaef2c591bd4842b16 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 24 Apr 2017 16:50:33 -0400 Subject: [PATCH 1/4] add code to specifically handle a release, and package versions --- utils/do_debian_package.sh | 103 ++++++++++++++++++++++++++----------- 1 file changed, 72 insertions(+), 31 deletions(-) diff --git a/utils/do_debian_package.sh b/utils/do_debian_package.sh index bc836788f..194499af2 100755 --- a/utils/do_debian_package.sh +++ b/utils/do_debian_package.sh @@ -23,6 +23,10 @@ case $i in INTERACTIVE="${i#*=}" shift # past argument=value ;; + -r=*|--release=*) + RELEASE="${i#*=}" + shift + ;; -s=*|--snapshot=*) SNAPSHOT="${i#*=}" shift # past argument=value @@ -39,6 +43,10 @@ case $i in GITHUB_FORK="${i#*=}" shift # past argument=value ;; + -v=*|--version=*) + PACKAGE_VERSION="${i#*=}" + shift + ;; --default) DEFAULT=YES shift # past argument with no value @@ -54,25 +62,38 @@ if [ "$TYPE" == "" ]; then echo "Defaulting to source build" TYPE="source"; fi; -if [ "$GITHUB_FORK" == "" ]; then - echo "Defaulting to ZoneMinder upstream git" - GITHUB_FORK="ZoneMinder" -fi; -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; +# 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" else - if [ "$BRANCH" == "" ]; then - echo "Defaulting to master branch"; - BRANCH="master"; + if [ "$GITHUB_FORK" == "" ]; then + echo "Defaulting to ZoneMinder upstream git" + GITHUB_FORK="ZoneMinder" fi; -fi; -if [ "$URGENCY" = "" ]; then - URGENCY="medium" -fi; + 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 # Instead of cloning from github each time, if we have a fork lying around, update it and pull from there instead. @@ -80,6 +101,8 @@ 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" + echo "git pull..." + git pull echo "git checkout $BRANCH" git checkout $BRANCH echo "git pull..." @@ -97,37 +120,39 @@ else fi; cd "${GITHUB_FORK}_zoneminder_release" -git checkout $BRANCH +if [ $RELEASE ]; then + git checkout $RELEASE +else + git checkout $BRANCH +fi; cd ../ VERSION=`cat ${GITHUB_FORK}_zoneminder_release/version` + if [ $VERSION == "" ]; then exit 1; fi; -DIRECTORY="zoneminder_$VERSION-$DISTRO"; if [ "$SNAPSHOT" != "stable" ] && [ "$SNAPSHOT" != "" ]; then - DIRECTORY="$DIRECTORY-$SNAPSHOT"; + VERSION="$VERSION~$SNAPSHOT"; fi; + +DIRECTORY="zoneminder_$VERSION-$DISTRO${PACKAGE_VERSION}"; echo "Doing $TYPE release $DIRECTORY"; mv "${GITHUB_FORK}_zoneminder_release" "$DIRECTORY.orig"; cd "$DIRECTORY.orig"; git submodule init git submodule update --init --recursive -if [ $DISTRO == "trusty" ] || [ $DISTRO == "precise" ]; then +if [ "$DISTRO" == "trusty" ] || [ "$DISTRO" == "precise" ]; then ln -sf distros/ubuntu1204 debian else - if [ $DISTRO == "wheezy" ]; then + if [ "$DISTRO" == "wheezy" ]; then ln -sf distros/debian debian else ln -sf distros/ubuntu1604 debian fi; fi; -# Auto-install all ZoneMinder's depedencies using the Debian control file -sudo apt-get install devscripts equivs -sudo mk-build-deps -ir ./debian/control - if [ "$DEBEMAIL" != "" ] && [ "$DEBFULLNAME" != "" ]; then AUTHOR="$DEBFULLNAME <$DEBEMAIL>" else @@ -138,9 +163,13 @@ else fi fi +if [ "$URGENCY" = "" ]; then + URGENCY="medium" +fi; + if [ "$SNAPSHOT" == "stable" ]; then cat < debian/changelog -zoneminder ($VERSION-$DISTRO) $DISTRO; urgency=$URGENCY +zoneminder ($VERSION-$DISTRO${PACKAGE_VERSION}) $DISTRO; urgency=$URGENCY * Release $VERSION @@ -149,7 +178,7 @@ zoneminder ($VERSION-$DISTRO) $DISTRO; urgency=$URGENCY EOF else cat < debian/changelog -zoneminder ($VERSION-$DISTRO-$SNAPSHOT) $DISTRO; urgency=$URGENCY +zoneminder ($VERSION-$DISTRO${PACKAGE_VERSION}) $DISTRO; urgency=$URGENCY * @@ -157,6 +186,12 @@ zoneminder ($VERSION-$DISTRO-$SNAPSHOT) $DISTRO; urgency=$URGENCY EOF fi; + +# 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: $?" + #rm -rf .git #rm .gitignore #cd ../ @@ -175,6 +210,7 @@ if [ "$DEBSIGN_KEYID" != "" ]; then DEBUILD="$DEBUILD -k$DEBSIGN_KEYID" fi $DEBUILD +echo "Status: $?" cd ../ if [ "$INTERACTIVE" != "no" ]; then @@ -192,15 +228,20 @@ if [ $TYPE == "binary" ]; then if [ "$install" == "Y" ]; then sudo dpkg -i $DIRECTORY*.deb fi; + 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; fi; else - SC=""; + SC="zoneminder_${VERSION}-${DISTRO}${PACKAGE_VERSION}_source.changes"; PPA=""; - if [ "$SNAPSHOT" == "stable" ]; then + if [ "$RELEASE" != "" ]; then PPA="ppa:iconnor/zoneminder"; - SC="zoneminder_${VERSION}-${DISTRO}_source.changes"; else - SC="zoneminder_${VERSION}-${DISTRO}-${SNAPSHOT}_source.changes"; if [ "$BRANCH" == "" ]; then PPA="ppa:iconnor/zoneminder-master"; else From 4d851dc00f1f13fcde03db7c24e2ee4d87b5f5e0 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 24 Apr 2017 16:54:01 -0400 Subject: [PATCH 2/4] Add Distribution guessing --- utils/do_debian_package.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/utils/do_debian_package.sh b/utils/do_debian_package.sh index 194499af2..bc862a48f 100755 --- a/utils/do_debian_package.sh +++ b/utils/do_debian_package.sh @@ -63,6 +63,11 @@ if [ "$TYPE" == "" ]; then TYPE="source"; fi; +if [ "$DISTRO" == "" ]; then + DISTRO=`lsb_release -a 2>/dev/null | grep Codename | awk '{print $2}'`; + echo "Guessed distro as $DISTRO"; +fi; + # Release is a special mode... it uploads to the release ppa and cannot have a snapshot if [ "$RELEASE" != "" ]; then if [ "$SNAPSHOT" != "" ]; then From 998aa2199b82d0e6c97c9d943764f4a655b094f9 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 24 Apr 2017 16:55:08 -0400 Subject: [PATCH 3/4] fix message for consistency --- utils/do_debian_package.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/do_debian_package.sh b/utils/do_debian_package.sh index bc862a48f..acc412550 100755 --- a/utils/do_debian_package.sh +++ b/utils/do_debian_package.sh @@ -65,7 +65,7 @@ fi; if [ "$DISTRO" == "" ]; then DISTRO=`lsb_release -a 2>/dev/null | grep Codename | awk '{print $2}'`; - echo "Guessed distro as $DISTRO"; + echo "Defaulting to $DISTRO for distribution"; fi; # Release is a special mode... it uploads to the release ppa and cannot have a snapshot From 3dff8a5da5e55361a9558e2b8272f3f03d3b6ad3 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 24 Apr 2017 17:01:24 -0400 Subject: [PATCH 4/4] update doc references to do_debian_package.sh --- docs/installationguide/ubuntu.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/installationguide/ubuntu.rst b/docs/installationguide/ubuntu.rst index 6e7ac45e4..903bf79d4 100644 --- a/docs/installationguide/ubuntu.rst +++ b/docs/installationguide/ubuntu.rst @@ -287,19 +287,19 @@ To build the latest master snapshot: :: - ./do_debian_package.sh `lsb_release -a 2>/dev/null | grep Codename | awk '{print $2}'` `date +%Y%m%d`01 local master + ./do_debian_package.sh --snapshot=NOW --branch=master --type=local To build the latest stable release: :: - ./do_debian_package.sh `lsb_release -a 2>/dev/null | grep Codename | awk '{print $2}'` `date +%Y%m%d`01 local stable + ./do_debian_package.sh --snapshot=stable --type=local -Note that the ``lsb_release -a 2>/dev/null | grep Codename | awk '{print $2}'`` -part simply extracts your distribution name - like "vivid", "trusty" etc. You -can always replace it by your distro name if you know it. As far as the script +Note that the distribution will be guessed using ``lsb_release -a 2>/dev/null | grep Codename | awk '{print $2}'`` +which simply extracts your distribution name - like "vivid", "trusty" etc. You +can always specify it using --distro=your distro name if you know it. As far as the script goes, it checks if your distro is "trusty" in which case it pulls in pre-systemd release configurations and if its not "trusty" it assumes its based on systemd and pulls in systemd related config files. @@ -378,4 +378,4 @@ change the $default array to reflect your new details. Example: 'database' => 'zm', 'prefix' => '', //'encoding' => 'utf8', - ); \ No newline at end of file + );