Permalink
Browse files

Allow packaging of github repositories alternatively

  • Loading branch information...
1 parent dc1647c commit 23ed75a8e1a804c8c46307e563aff127284e96c7 @toddlipcon committed Oct 21, 2009
Showing with 97 additions and 45 deletions.
  1. +1 −1 debian/changelog
  2. +3 −3 debian/control
  3. +1 −1 debian/copyright
  4. +4 −4 debian/rules
  5. +84 −32 run.sh
  6. +4 −4 template.spec
View
@@ -1,4 +1,4 @@
-hadoop-gpl-compression (0.2.0svn46~unbuilt-1) UNRELEASED; urgency=low
+@PACKAGE_NAME@ (0.0-unbuilt) UNRELEASED; urgency=low
* Initial release
View
@@ -1,12 +1,12 @@
-Source: hadoop-gpl-compression
+Source: @PACKAGE_NAME@
Section: devel
Priority: extra
Maintainer: Todd Lipcon <todd@cloudera.com>
Build-Depends: debhelper (>= 5), sun-java6-jdk, liblzo2-dev, ant
Standards-Version: 3.8.0
-Homepage: http://code.google.com/p/hadoop-gpl-compression/
+Homepage: @PACKAGE_HOMEPAGE@
-Package: hadoop-gpl-compression
+Package: @PACKAGE_NAME@
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: GPL compression libraries for Hadoop
View
@@ -1,7 +1,7 @@
This package was debianized by Todd Lipcon <todd@cloudera.com> on
Tue, 20 Oct 2009 19:17:38 -0700.
-It was checked out of SVN from http://code.google.com/p/hadoop-gpl-compression/
+It was checked out from @PACKAGE_HOMEPAGE@
License:
View
@@ -10,9 +10,9 @@
#export DH_VERBOSE=1
VERSION=$(shell dpkg-parsechangelog | grep Version | head -1 | awk '{print $$2}')
-
-DESTDIR=$(CURDIR)/debian/hadoop-gpl-compression
-NAME_VER=hadoop-gpl-compression-$(VERSION)
+NAME=@PACKAGE_NAME@
+DESTDIR=$(CURDIR)/debian/$(NAME)
+NAME_VER=$(NAME)-$(VERSION)
HADOOP_HOME=/usr/lib/hadoop
configure: configure-stamp
@@ -27,7 +27,7 @@ build: build-stamp
build-stamp: configure-stamp
dh_testdir
- JAVA_HOME=/usr/lib/jvm/java-6-sun ant -Dversion=$(VERSION) compile-native package
+ JAVA_HOME=/usr/lib/jvm/java-6-sun ant -Dname=$(NAME) -Dversion=$(VERSION) compile-native package
touch $@
View
116 run.sh
@@ -1,13 +1,14 @@
#!/bin/bash -e
set -x
+
##############################
# Begin configurables
##############################
-SVNURL=${SVNURL:-http://hadoop-gpl-compression.googlecode.com/svn/trunk/}
-if [ -z "$SVN_REV" ]; then
- SVN_REV=$(svn info $SVNURL | grep Revision | awk '{print $2}')
-fi
-VERSION=${VERSION:-0.2.0svn$SVN_REV}
+# Which project to build.
+# github - builds the github fork hadoop-lzo project
+# googlecode - builds the original google code repo
+SRC_PROJECT=${SRC_PROJECT:-github}
+
RELEASE=${RELEASE:-1}
# Some metadata fields for the packages (used only by rpms)
@@ -21,29 +22,82 @@ HADOOP_HOME=${HADOOP_HOME:-/usr/lib/hadoop-0.20}
##############################
# End configurables
##############################
-
BINDIR=$(readlink -f $(dirname $0))
+mkdir -p build
+
+setup_googlecode() {
+ SVNURL=${SVNURL:-http://hadoop-gpl-compression.googlecode.com/svn/trunk/}
+ PACKAGE_HOMEPAGE=http://code.google.com/p/hadoop-gpl-compression/
+ if [ -z "$SVN_REV" ]; then
+ SVN_REV=$(svn info $SVNURL | grep Revision | awk '{print $2}')
+ [[ $SVN_REV == [0-9]+ ]]
+ echo "SVN Revision: $SVN_REV"
+ fi
+ VERSION=${VERSION:-0.2.0svn$SVN_REV}
+ NAME=hadoop-gpl-compression
+}
+
+checkout_googlecode() {
+ if [ ! -d $CHECKOUT ]; then
+ svn export -r $SVN_REV $SVNURL $CHECKOUT
+ fi
+ CHECKOUT_TAR=$BINDIR/build/${NAME}-$VERSION.tar.gz
+}
+
+setup_github() {
+ GITHUB_ACCOUNT=${GITHUB_ACCOUNT:-toddlipcon}
+ GITHUB_BRANCH=${GITHUB_BRANCH:-master}
+ PACKAGE_HOMEPAGE=http://github.com/$GITHUB_ACCOUNT/hadoop-lzo
+ TARURL=http://github.com/$GITHUB_ACCOUNT/hadoop-lzo/tarball/$GITHUB_BRANCH
+ if [ -z "$(ls $BINDIR/build/$GITHUB_ACCOUNT-hadoop*tar.gz)" ]; then
+ wget -P $BINDIR/build/ $TARURL
+ fi
+ ORIG_TAR=$(ls -1 $BINDIR/build/$GITHUB_ACCOUNT-hadoop*tar.gz | head -1)
+ GIT_HASH=$(expr match $ORIG_TAR ".*hadoop-lzo-\(.*\).tar.gz")
+ echo "Git hash: $GIT_HASH"
+ NAME=$GITHUB_ACCOUNT-hadoop-lzo
+ VERSION=$(date +"%Y%m%d%H%M%S").$GIT_HASH
+
+ pushd $BINDIR/build/ > /dev/null
+ mkdir $NAME-$VERSION/
+ tar -C $NAME-$VERSION/ --strip-components=1 -xzf $ORIG_TAR
+ tar czf $NAME-$VERSION.tar.gz $NAME-$VERSION/
+ popd > /dev/null
+
+ CHECKOUT_TAR=$BINDIR/build/$NAME-$VERSION.tar.gz
+}
+
+checkout_github() {
+ echo -n
+}
+
+do_substs() {
+sed "
+ s,@PACKAGE_NAME@,$NAME,g;
+ s,@PACKAGE_HOMEPAGE@,$PACKAGE_HOMEPAGE,g;
+ s,@VERSION@,$VERSION,g;
+ s,@RELEASE@,$RELEASE,g;
+ s,@PACKAGER@,$PACKAGER,g;
+ s,@PACKAGER_EMAIL@,$PACKAGER_EMAIL,g;
+ s,@HADOOP_HOME@,$HADOOP_HOME,g;
+"
+}
+
+setup_$SRC_PROJECT
+
TOPDIR=$BINDIR/build/topdir
-SVNCO=$BINDIR/hadoop-gpl-compression-$VERSION
-SVNTAR=$BINDIR/build/hadoop-gpl-compression-$VERSION.tar.gz
-mkdir -p build
-if [ ! -d $SVNCO ]; then
- svn export -r $SVN_REV $SVNURL $SVNCO
-fi
+CHECKOUT=$BINDIR/${NAME}-$VERSION
+checkout_$SRC_PROJECT
+
-if [ ! -e $SVNTAR ]; then
- pushd $SVNCO
+if [ ! -e $CHECKOUT_TAR ]; then
+ pushd $CHECKOUT
cd ..
- tar czf $SVNTAR $(basename $SVNCO)
+ tar czf $CHECKOUT_TAR $(basename $CHECKOUT)
popd
fi
-
-[[ $SVN_REV == [0-9]+ ]]
-
-echo "SVN Revision: $SVN_REV"
-
##############################
# RPM
##############################
@@ -53,21 +107,15 @@ mkdir -p $TOPDIR
(cd $TOPDIR/ && mkdir SOURCES BUILD SPECS SRPMS RPMS BUILDROOT)
-cat $BINDIR/template.spec | sed "
- s,@VERSION@,$VERSION,g;
- s,@RELEASE@,$RELEASE,g;
- s,@PACKAGER@,$PACKAGER,g;
- s,@PACKAGER_EMAIL@,$PACKAGER_EMAIL,g;
- s,@HADOOP_HOME@,$HADOOP_HOME,g;
-" > $TOPDIR/SPECS/hadoop-gpl-compression.spec
+cat $BINDIR/template.spec | do_substs > $TOPDIR/SPECS/${NAME}.spec
-cp $SVNTAR $TOPDIR/SOURCES
+cp $CHECKOUT_TAR $TOPDIR/SOURCES
pushd $TOPDIR/SPECS > /dev/null
rpmbuild $RPMBUILD_FLAGS \
--buildroot $(pwd)/../BUILDROOT \
--define "_topdir $(pwd)/.." \
- -ba hadoop-gpl-compression.spec
+ -ba ${NAME}.spec
popd
fi
@@ -80,11 +128,15 @@ mkdir -p $DEB_DIR
rm -Rf $DEB_DIR
mkdir $DEB_DIR
-cp -a $SVNTAR $DEB_DIR/hadoop-gpl-compression_$VERSION.orig.tar.gz
+cp -a $CHECKOUT_TAR $DEB_DIR/${NAME}_$VERSION.orig.tar.gz
pushd $DEB_DIR
tar xzf *.tar.gz
-cp -a $BINDIR/debian/ hadoop-gpl-compression-$VERSION
-pushd hadoop-gpl-compression-$VERSION
+cp -a $BINDIR/debian/ ${NAME}-$VERSION/debian
+for f in $(find ${NAME}-$VERSION/debian -type f) ; do
+ do_substs < $f > /tmp/$$.tmp && chmod --reference=$f /tmp/$$.tmp && mv /tmp/$$.tmp $f
+done
+
+pushd ${NAME}-$VERSION
dch -D $(lsb_release -cs) --newversion $VERSION-$RELEASE "Local automatic build"
debuild -uc -us -sa
View
@@ -1,11 +1,11 @@
Summary: GPL Compression Libraries for Hadoop
-Name: hadoop-gpl-compression
+Name: @PACKAGE_NAME@
Version: @VERSION@
Release: @RELEASE@
License: GPL
-Source0: hadoop-gpl-compression-@VERSION@.tar.gz
+Source0: @PACKAGE_NAME@-@VERSION@.tar.gz
Group: Development/Libraries
-URL: http://code.google.com/p/hadoop-gpl-compression/
+URL: @PACKAGE_HOMEPAGE@
Packager: @PACKAGER@ <@PACKAGER_EMAIL@>
Buildroot: %{_tmppath}/%{name}-%{version}
BuildRequires: ant, ant-nodeps, gcc-c++, lzo-devel
@@ -20,7 +20,7 @@ GPLed Compression Libraries for Hadoop, built at $DATE on $HOST
%setup
%build
-ant -Dversion=%{version} compile-native package
+ant -Dname=%{name} -Dversion=%{version} compile-native package
%install
mkdir -p $RPM_BUILD_ROOT/%{hadoop_home}/lib

0 comments on commit 23ed75a

Please sign in to comment.