diff options
author | Peter Palfrader <peter@palfrader.org> | 2012-07-05 08:21:30 +0000 |
---|---|---|
committer | weasel <weasel@bc3d92e2-beff-0310-a7cd-cc87d7ac0ede> | 2012-07-05 08:21:30 +0000 |
commit | b3c04c2c62164f1a89d94a34e62e5c54d60be276 (patch) | |
tree | 9759fd7f1ad6fd9df72d19276fe0fdb6bb6462f5 /build-tor-sources | |
parent | a3d5a066d3400628c34c336384c56967cf6e89a3 (diff) |
Move more logic into functions
git-svn-id: svn+ssh://asteria.noreply.org/svn/weaselutils/trunk@534 bc3d92e2-beff-0310-a7cd-cc87d7ac0ede
Diffstat (limited to 'build-tor-sources')
-rwxr-xr-x | build-tor-sources | 323 |
1 files changed, 170 insertions, 153 deletions
diff --git a/build-tor-sources b/build-tor-sources index b470d3e..33cc929 100755 --- a/build-tor-sources +++ b/build-tor-sources @@ -24,19 +24,8 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. set -e -set -x -# this is hardcoded to weasel's directory layout. sorry. -case "$(basename $0)" in - build-obfsproxy-sources) - GITDIR="$HOME/projects/debian/debian/obfsproxy/obfsproxy" - PKG="obfsproxy" - SKIP_HARDY=1 - ;; - *) - GITDIR="$HOME/projects/tor/tor" - PKG="tor" -esac +SKIP_HARDY=0 assert_files_dont_exist () { local debian_version="$1"; @@ -131,150 +120,178 @@ bp2() { rm -r $dir } +backport_all() { + local dir="$1"; shift + local origtar="$1"; shift + local sid_debian_version="$1"; shift + + # SID + ################################################# + # null + + # LENNY + ################################################# + bp1 $dir $sid_debian_version lenny + (cd $dir; hardening_backport 0) + (cd $dir; remove_apparmor) + bp2 $dir $origtar + + # SQUEEZE + ################################################# + bp1 $dir $sid_debian_version squeeze + (cd $dir; remove_apparmor) + bp2 $dir $origtar + + # WHEEZY + ################################################# + bp1 $dir $sid_debian_version wheezy + bp2 $dir $origtar + + # HARDY (EOL: April 2013) + ################################################# + if [ -z "${SKIP_HARDY:-}" ] || [ "${SKIP_HARDY:-}" -eq 0 ]; then + bp1 $dir $sid_debian_version hardy + (echo "/Conflicts:"; echo d; echo i; echo "Conflicts: libssl0.9.8 (<< 0.9.8g-4ubuntu3.1)"; echo . ; echo w) | ed "$dir/debian/control" + (cd $dir; dch "Conflict with libssl0.9.8 (<< 0.9.8g-4ubuntu3.1) on hardy") + # hardy's dpkg-parsechangelog cannot deal with dots in the distribution field, remove them. + (cd $dir; dch --force-distribution --distribution "$(dpkg-parsechangelog | grep-dctrl -n -s Distribution '' | tr -d .)" '') + (cd $dir; hardening_backport 0) + (cd $dir; remove_apparmor) + bp2 $dir $origtar + fi + + # LUCID (EOL: April 2015) + ################################################# + bp1 $dir $sid_debian_version lucid + (cd $dir; remove_apparmor) + bp2 $dir $origtar + + # NATTY (EOL: October 2012) + ################################################# + bp1 $dir $sid_debian_version natty + (cd $dir; remove_apparmor) + bp2 $dir $origtar + + # ONEIRIC (EOL: April 2013) + ################################################# + bp1 $dir $sid_debian_version oneiric + (cd $dir; remove_apparmor) + bp2 $dir $origtar + + # PRECISE (EOL: April 2017) + ################################################# + bp1 $dir $sid_debian_version precise + bp2 $dir $origtar + + + ################################################# + ## BPO + ################################################# + + # SQUEEZE-BPO + ################################################# + bp1 $dir $sid_debian_version squeeze-bpo + bp2 $dir $origtar + + mkdir bpo + mv *'~bpo'* bpo/ +} + +main() { + local origtar="$1"; shift + local gitdir="$1"; shift + local pkg="$1"; shift -[ -d local-build ] || mkdir local-build + [ -d local-build ] || mkdir local-build -ORIGTAR="$1" -if [ -z "$ORIGTAR" ] ; then - echo "Usage: $0 <orig.tar.gz> [version]" >&2 - exit 1; -fi -DEB_REVISION="${2:-1}" + if [ -z "$origtar" ] ; then + echo "Usage: $0 <orig.tar.gz> [version]" >&2 + exit 1; + fi + local deb_revision="${2:-1}" + + + if [ ! -e "$origtar" ] ; then + echo "$origtar does not exist." >&2 + exit 1; + fi + + if [ "${origtar#${pkg}-}" != $origtar ]; then + ver="$origtar" + ver=${ver#${pkg}-} + ver=${ver%.tar.gz} + neworig="${pkg}_$ver.orig.tar.gz" + if ! [ -e "$neworig" ]; then + ln -v "$origtar" "$neworig" + fi + echo "Using $neworig instead of $origtar" + origtar="$neworig" + fi + local dir + local dir_version + dir=`tar tzf $origtar 2>/dev/null | head -n1` + dir="${dir%%/}" + dir_version="${dir##${pkg}-}" + if [ -e "$dir" ] ; then + echo "$dir already exists." >&2 + exit 1; + fi + tar xzf $origtar + git clone -n -s "$gitdir" git-"$dir" + local tag="debian-${pkg}-$dir_version-$deb_revision" + (cd "git-$dir" && git checkout $tag) + if diff -qr "git-$dir" "$dir" --exclude .git | grep -v '^Only in ' | grep --color .; then + echo "Differenced detected." + exit 1 + fi + (cd "git-$dir" && echo "\"`git rev-parse --short=16 "$tag"`\"" > "debian/micro-revision.i") + cp -av "git-$dir/debian" "$dir" + rm -rf "git-$dir" -if [ ! -e "$ORIGTAR" ] ; then - echo "$ORIGTAR does not exist." >&2 - exit 1; -fi -if [ "${ORIGTAR#${PKG}-}" != $ORIGTAR ]; then - ver="$ORIGTAR" - ver=${ver#${PKG}-} - ver=${ver%.tar.gz} - neworig="${PKG}_$ver.orig.tar.gz" - if ! [ -e "$neworig" ]; then - ln -v "$ORIGTAR" "$neworig" + debian_upstream_version=$(get_debian_version $dir upstream) + if [ "$origtar" != "${pkg}_$debian_upstream_version.orig.tar.gz" ] ; then + echo "possible mismatch: $origtar but $debian_upstream_version in debian/changelog" >&2 + exit 1; fi - echo "Using $neworig instead of $ORIGTAR" - ORIGTAR="$neworig" -fi - -DIR=`tar tzf $ORIGTAR | head -n1` -DIR="${DIR%%/}" -DIR_VERSION="${DIR##${PKG}-}" -if [ -e "$DIR" ] ; then - echo "$DIR already exists." >&2 - exit 1; -fi -tar xzf $ORIGTAR -git clone -n -s "$GITDIR" git-"$DIR" -TAG="debian-${PKG}-$DIR_VERSION-$DEB_REVISION" -(cd "git-$DIR" && git checkout $TAG) -if diff -qr "git-$DIR" "$DIR" --exclude .git | grep -v '^Only in ' | grep --color .; then - echo "Differenced detected." - exit 1 -fi -(cd "git-$DIR" && echo "\"`git rev-parse --short=16 "$TAG"`\"" > "debian/micro-revision.i") -cp -av "git-$DIR/debian" "$DIR" -rm -rf "git-$DIR" - - -debian_upstream_version=$(get_debian_version $DIR upstream) -if [ "$ORIGTAR" != "${PKG}_$debian_upstream_version.orig.tar.gz" ] ; then - echo "possible mismatch: $ORIGTAR but $debian_upstream_version in debian/changelog" >&2 - exit 1; -fi - -debian_version=$(get_debian_version $DIR) -sid_debian_version="$debian_version" -assert_files_dont_exist $debian_version -dpkg-source -b $DIR $ORIGTAR -rm -r $DIR - - - -# local -################################################# -cd local-build -dpkg-source -x ../${PKG}_$debian_version.dsc -cd ${PKG}-$debian_upstream_version -remove_apparmor -debuild -j8 -rfakeroot -uc -us -cd ../.. - -# SID -################################################# -# null - -# LENNY -################################################# -bp1 $DIR $sid_debian_version lenny -(cd $DIR; hardening_backport 0) -(cd $DIR; remove_apparmor) -bp2 $DIR $ORIGTAR - -# SQUEEZE -################################################# -bp1 $DIR $sid_debian_version squeeze -(cd $DIR; remove_apparmor) -bp2 $DIR $ORIGTAR - -# WHEEZY -################################################# -bp1 $DIR $sid_debian_version wheezy -bp2 $DIR $ORIGTAR - - - - -# HARDY (EOL: April 2013) -################################################# -if [ -z "${SKIP_HARDY:-}" ] || [ "${SKIP_HARDY:-}" -eq 0 ]; then - bp1 $DIR $sid_debian_version hardy - (echo "/Conflicts:"; echo d; echo i; echo "Conflicts: libssl0.9.8 (<< 0.9.8g-4ubuntu3.1)"; echo . ; echo w) | ed "$DIR/debian/control" - (cd $DIR; dch "Conflict with libssl0.9.8 (<< 0.9.8g-4ubuntu3.1) on hardy") - # hardy's dpkg-parsechangelog cannot deal with dots in the distribution field, remove them. - (cd $DIR; dch --force-distribution --distribution "$(dpkg-parsechangelog | grep-dctrl -n -s Distribution '' | tr -d .)" '') - (cd $DIR; hardening_backport 0) - (cd $DIR; remove_apparmor) - bp2 $DIR $ORIGTAR -fi - -# LUCID (EOL: April 2015) -################################################# -bp1 $DIR $sid_debian_version lucid -(cd $DIR; remove_apparmor) -bp2 $DIR $ORIGTAR - -# NATTY (EOL: October 2012) -################################################# -bp1 $DIR $sid_debian_version natty -(cd $DIR; remove_apparmor) -bp2 $DIR $ORIGTAR - -# ONEIRIC (EOL: April 2013) -################################################# -bp1 $DIR $sid_debian_version oneiric -(cd $DIR; remove_apparmor) -bp2 $DIR $ORIGTAR - -# PRECISE (EOL: April 2017) -################################################# -bp1 $DIR $sid_debian_version precise -bp2 $DIR $ORIGTAR - - -################################################# -## BPO -################################################# - -# SQUEEZE-BPO -################################################# -bp1 $DIR $sid_debian_version squeeze-bpo -bp2 $DIR $ORIGTAR - -mkdir bpo -mv *'~bpo'* bpo/ - -echo -echo "All done" + + debian_version=$(get_debian_version $dir) + sid_debian_version="$debian_version" + assert_files_dont_exist $debian_version + dpkg-source -b $dir $origtar + rm -r $dir + + + + # local + ################################################# + cd local-build + dpkg-source -x ../${pkg}_$debian_version.dsc + cd ${pkg}-$debian_upstream_version + remove_apparmor + debuild -j8 -rfakeroot -uc -us + cd ../.. + + + backport_all "$dir" "$origtar" "$sid_debian_version" + + echo + echo "All done" +} + +# this is hardcoded to weasel's directory layout. sorry. +case "$(basename $0)" in + build-obfsproxy-sources) + set -x + GITDIR="$HOME/projects/debian/debian/obfsproxy/obfsproxy" + PKG="obfsproxy" + main "${1:-}" $GITDIR $PKG + ;; + build-tor-sources) + set -x + GITDIR="$HOME/projects/tor/tor" + PKG="tor" + main "${1:-}" $GITDIR $PKG + ;; +esac |