1BINFILE=$1 2 3VERSION=`git describe --tags --always |cut -c2-`-github 4DISTRIB=`lsb_release -d |sed 's/Description:\s//g' |sed 's/\s/_/g'` 5echo "Distribution: "$DISTRIB 6if [ "${DISTRIB/Ubuntu}" != "$DISTRIB" ] ; then 7 DISTRIB=`echo $DISTRIB |sed 's/\(Ubuntu_[0-9]\+\.[0-9]\+\).*/\1/g'` 8fi 9 10echo "Packaging FMIT "$VERSION 11echo "Distribution: "$DISTRIB 12BINARCH=`objdump -p $BINFILE |grep 'file format' |sed 's/^.*file format\s//g'` 13if [ "${BINARCH/elf64}" = "${BINARCH}" ] ; then 14 ARCH=i386 15else 16 ARCH=amd64 17fi 18echo "Architecture: "$ARCH 19 20PKGNAME=fmit_$VERSION\_$ARCH 21echo "Package name "$PKGNAME 22 23rm -fr $PKGNAME 24mkdir -p $PKGNAME 25 26echo "List dependencies:" 27DEPS=`objdump -p $BINFILE |grep NEEDED |awk '{ print $2 }'` 28for dep in $DEPS; do 29 dpkg -S $dep |grep -v chefdk 30 deplist=`dpkg -S $dep |grep -v chefdk |sed 's/:.*$//g'` 31 depdpkg=`echo "$deplist" |sort |uniq` 32 depcurver=`dpkg -s $depdpkg |grep 'Version' |awk '{ print $2 }' |sed 's/:.*$//g' |sed 's/-.*$//g' |sed 's/+.*$//g'` 33 echo "Dependency "$dep" in package:"$depdpkg" version:"$depcurver 34 echo $depdpkg >> Depends_$PKGNAME 35done 36DEPENDS=`cat Depends_$PKGNAME |sort |uniq` 37rm -f Depends_$PKGNAME 38DEPENDS=`echo $DEPENDS |sed 's/ /,\ /g'` 39echo "Automatic detection of Depends: "$DEPENDS 40# This list if too dependent on external repo used for Travis CI ... 41# ... so let's overwrite it with a predefined list of packages 42# (http://packages.ubuntu.com/precise/allpackages can help to build it) 43DEPENDS=`cat package_deb.Depends_$DISTRIB` 44# If cannot list the dependencies properly, skip them ... 45# DEPENDS="" 46echo "Replaced by predefined list Depends: "$DEPENDS 47 48 49# Build the file tree 50 51# Copy files 52mkdir -p $PKGNAME/DEBIAN 53cp package_deb.control $PKGNAME/DEBIAN/control 54sed -i "s/^Version:.*$/Version: $VERSION/g" $PKGNAME/DEBIAN/control 55sed -i "s/^Architecture:.*$/Architecture: $ARCH/g" $PKGNAME/DEBIAN/control 56sed -i "s/^Depends:.*$/Depends: $DEPENDS/g" $PKGNAME/DEBIAN/control 57 58# The binary 59mkdir -p $PKGNAME/usr/bin 60cp $BINFILE $PKGNAME/usr/bin/ 61 62# Any legal and info txt 63mkdir -p $PKGNAME/usr/share/doc/fmit 64cp ../README.txt $PKGNAME/usr/share/doc/fmit/ 65cp ../COPYING_*.txt $PKGNAME/usr/share/doc/fmit/ 66 67# The menu related files 68mkdir -p $PKGNAME/usr/share/appdata 69cp fmit.appdata.xml $PKGNAME/usr/share/appdata/ 70mkdir -p $PKGNAME/usr/share/applications 71cp fmit.desktop $PKGNAME/usr/share/applications/ 72mkdir -p $PKGNAME/usr/share/menu 73cp fmit.menu $PKGNAME/usr/share/menu/fmit 74 75# The icon 76mkdir -p $PKGNAME/usr/share/icons/hicolor/scalable/apps 77cp ../ui/images/fmit.svg $PKGNAME/usr/share/icons/hicolor/scalable/apps/ 78mkdir -p $PKGNAME/usr/share/icons/hicolor/128x128/apps 79cp ../ui/images/fmit.png $PKGNAME/usr/share/icons/hicolor/128x128/apps/ 80 81# Translations *.qm in share/fmit/tr/ 82mkdir -p $PKGNAME/usr/share/fmit/tr 83cp ../tr/*.qm $PKGNAME/usr/share/fmit/tr/ 84 85# Scales 86mkdir -p $PKGNAME/usr/share/fmit/scales 87cp ../scales/* $PKGNAME/usr/share/fmit/scales/ 88 89dpkg-deb --build $PKGNAME 90 91ls $PKGNAME.deb 92