Last active 6 months ago

Revision 37e4f5120f41046a92033441e696e08b17534153

git2release Raw
1#!/bin/bash
2#TMPDIR=/tmp/
3# creating temp dir
4TMPDIR=`mktemp -d`
5trap "rm -rf $TMPDIR" EXIT
6# defining some values
7DIR=$(pwd)
8# git clone git://git.debian.org/git/pkg-nagios/pkg-nagios-plugins.git /tmp/monitoring-plugins.git
9
10case "$1" in
11 --release-tarball)
12 URL=${2}
13 UTARBALL=$(basename ${URL})
14 PROJECT=$(basename ${UTARBALL} .tar.gz)
15 REPACKURL="https://raw.github.com/waja/pkg-nagios-plugins/master/debian/bin/repack.sh"
16
17 # grab tarball
18 wget ${URL} -O ${TMPDIR}/${UTARBALL}
19 # create a dir where we extract
20 mkdir -p ${TMPDIR}/${PROJECT}
21 # extract the tarball
22 tar -xzf ${TMPDIR}/${UTARBALL} -C ${TMPDIR}/${PROJECT}
23 EXTRACTDIR=$(ls -d ${TMPDIR}/${PROJECT}/*)
24 # move all one directory level higher
25 mv ${EXTRACTDIR}/* ${EXTRACTDIR}/.. && rm ${EXTRACTDIR}/.git* && rmdir ${EXTRACTDIR}
26 # install needed packages
27 sudo apt-get build-dep nagios-plugins
28 sudo aptitude install autoconf automake
29 # create release tarball
30 cd ${TMPDIR}/${PROJECT}
31 tools/setup && ./configure && make dist
32 RELEASETAR=$(ls ${TMPDIR}/${PROJECT}/*.tar.gz)
33 # download debian repack script
34 REPACK=$(basename ${REPACKURL})
35 wget ${REPACKURL} -O ${TMPDIR}/${REPACK}
36 # repack everything
37 chmod +x ${TMPDIR}/${REPACK}
38 ${TMPDIR}/${REPACK} ${RELEASETAR}
39 # copy everything in here
40 cp $(ls ${TMPDIR}/${PROJECT}/*.tar.gz) ${DIR}
41 ;;
42 --prepare-debian)
43 UTARBALL=${2}
44 PROJECT=$(basename $(tar tfz "${UTARBALL}" | head -1))
45 if [ -d "${PROJECT}" ] ; then
46 echo -n remove "${PROJECT}"? ${RTURN}
47 read RTURN
48 if [ "$RTURN" == "Y" ] || [ "$RTURN" == "y" ] ; then
49 rm -rf "${PROJECT}"
50 fi
51 fi
52 #DEBIANGITURL="git@github.com:waja/pkg-nagios-plugins.git"
53 DEBIANGITURL="git@github.com:waja/pkg-nagios-plugins.git -b m-p"
54 # extract the tarball
55 tar -xzf "${UTARBALL}"
56 # fetch latest debian packaging
57 git clone ${DEBIANGITURL} "${TMPDIR}"
58 # copy over the whole debian packaging
59 cp -a "${TMPDIR}"/debian "${PROJECT}"
60 # create a symlink to match debian conventions
61 # FIXME - the last part of this needs to be approved
62 ORIGTAR=$(echo "${UTARBALL}"|sed 's/\.tar\.gz/.orig.tar.gz/'|sed 's/plugins-/plugins_/')
63 [ -L "${ORIGTAR}" ] || ln -s "${UTARBALL}" "${ORIGTAR}"
64 # fetch build-deps
65 sudo apt-get build-dep nagios-plugins
66 # add changelog entry and start to build the package
67 cd "${PROJECT}" && dch -R && debuild -sa
68 ;;
69 *)
70 echo "Usage: ${0} [--release-tarball|--prepare-debian]" >&2
71 exit 3
72 ;;
73esac