Skip to content

Instantly share code, notes, and snippets.

@kshcherban
Last active December 28, 2015 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kshcherban/39d79f7a175a02519a65 to your computer and use it in GitHub Desktop.
Save kshcherban/39d79f7a175a02519a65 to your computer and use it in GitHub Desktop.
Script to quickly build python-packages
#!/bin/bash
set -e -u
if [ $# -ne 1 ]; then
echo "Usage: $0 <packagename-version>"
exit 0
fi
PACKAGE="$(echo $1 | awk -F'-' '{$(NF--)=""; print}' | sed -e 's/\s/-/g;s/-$//')"
VERSION="$(echo $1 | awk -F'-' '{print $NF}')"
BUILDROOT="/opt/buildroot"
MAINTAINER="Konstantin Shcherban <k.scherban@gmail.com>"
CHDATE="$(date '+%a, %d %b %Y %H:%M:%S %z')"
mkdir -vp $BUILDROOT/$PACKAGE
cd $BUILDROOT/$PACKAGE
wget https://pypi.python.org/packages/source/$(echo $PACKAGE | head -c 1)/${PACKAGE}/${PACKAGE}-${VERSION}.tar.gz -O python-${PACKAGE}-${VERSION}.tar.gz
tar -xzf python-${PACKAGE}-${VERSION}.tar.gz
mkdir ${PACKAGE}-${VERSION}/debian
cat << EOF > ${PACKAGE}-${VERSION}/debian/control
Source: python-$PACKAGE
Section: python
Priority: optional
Maintainer: $MAINTAINER
Build-Depends:
debhelper (>= 9),
dh-python,
python-all-dev,
python-all-dbg,
libgmp-dev,
python3-all-dev (>= 3.3.2-5~),
python3-all-dbg,
python-setuptools,
python3-setuptools
X-Python-Version: >= 2.1
X-Python3-Version: >= 3.0
Standards-Version: 3.9.5
Homepage: https://pypi.python.org/pypi/$PACKAGE
Package: python-$PACKAGE
Architecture: any
Depends: \${python:Depends}, \${shlibs:Depends}, \${misc:Depends}
Provides: \${python:Provides}
Description: $PACKAGE
Package: python3-$PACKAGE
Architecture: any
Depends: \${python3:Depends}, \${shlibs:Depends}, \${misc:Depends}
Provides: \${python3:Provides}
Description: $PACKAGE
EOF
cat << EOF > ${PACKAGE}-${VERSION}/debian/changelog
python-$PACKAGE (${VERSION}-1iow1) UNRELEASED; urgency=medium
* Initial release.
-- $MAINTAINER $CHDATE
EOF
cat << EOF > ${PACKAGE}-${VERSION}/debian/rules
#!/usr/bin/make -f
export PYBUILD_NAME=$PACKAGE
export PYBUILD_DISABLE=test
#export PYBUILD_INTERPRETERS=python{version} python{version}-dbg
#export PYBUILD_VERSIONS=2.7 3.5
%:
dh \$@ --with=python2,python3 --buildsystem=pybuild
EOF
echo 9 > ${PACKAGE}-${VERSION}/debian/compat
cd ${PACKAGE}-${VERSION}
dpkg-buildpackage -rfakeroot -uc -F
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment