-
-
Save awesomebytes/c2b5129d7df83b251ce4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PIP_PKG=$1 | |
if [ -z $PIP_PKG ]; then | |
echo "Usage is $0 python_pkg_name" | |
exit -1 | |
fi | |
INSTALL_DIR=`mktemp -d` | |
cd $INSTALL_DIR | |
DEB_NAME="pal-python-"`echo $PIP_PKG | sed s/_/-/` | |
mkdir $DEB_NAME | |
ls | |
pip install $PIP_PKG --root $PWD/$DEB_NAME --no-deps --force-reinstall --upgrade | |
EGG_INFO_DIR=$DEB_NAME/usr/local/lib/python2.7/dist-packages/$PIP_PKG*-info | |
VERSION=`grep "^Version: " $EGG_INFO_DIR/* | cut -d' ' -f2` | |
if [ -f $EGG_INFO_DIR/requires.txt ]; then | |
DEPS=`cat $EGG_INFO_DIR/requires.txt` | |
PYTHON_SCRIPT="import re | |
python_deps=\"\"\"$DEPS\"\"\" | |
deb_deps='' | |
for dep in python_deps.split(): | |
match = re.match('([0-9a-zA-Z_]*)([<>=]*)([0-9\.]*)', dep) | |
python_pkg=match.group(1) | |
deb_pkg_name=raw_input('Enter debian pkg name for python pkg \'{}\':'.format(python_pkg)) | |
if deb_deps != '': | |
deb_deps = deb_deps + ', ' | |
deb_deps=deb_deps + '{} ({} {})'.format(deb_pkg_name, match.group(2), match.group(3)) | |
with open('depends', 'w') as f: | |
f.write(deb_deps) | |
" | |
python -c "$PYTHON_SCRIPT" | |
DEB_DEPS=`cat depends` | |
DEPS="Depends: $DEB_DEPS" | |
fi | |
mkdir $DEB_NAME/DEBIAN | |
echo "Package: $DEB_NAME | |
Version: $VERSION | |
Maintainer: Victor Lopez <victor.lopez@pal-robotics.com | |
Architecture: all | |
Description: Auto genereated PAL debian package for $PIP_PKG version $VERSION | |
$DEPS | |
" > $DEB_NAME/DEBIAN/control | |
VERSIONED_DEB_NAME="$DEB_NAME"_$VERSION | |
mv $DEB_NAME $VERSIONED_DEB_NAME | |
dpkg -b $VERSIONED_DEB_NAME | |
ls $PWD/$VERSIONED_DEB_NAME.deb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment