Skip to content

Instantly share code, notes, and snippets.

@almostearthling
Last active December 6, 2015 15:29
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 almostearthling/009fbbe27ea5ca921452 to your computer and use it in GitHub Desktop.
Save almostearthling/009fbbe27ea5ca921452 to your computer and use it in GitHub Desktop.
Create /opt based packages for When
#!/bin/bash
PKGBASE=when-command-opt
REPOBASE=when-command
VERSION_MARKER=APPLET_VERSION
PROJECTS=~/Projects/Managed
EXECS="$REPOBASE/when-command.py"
sourcedir=$PROJECTS
curdir=`pwd`
curuser=$USER
curgrp=`getent group $USER | cut -d: -f1`
cd $sourcedir
tar cf - $REPOBASE | ( cd $curdir && tar xBf - )
cd $curdir
for x in `cat $REPOBASE/.gitignore` ; do
rm -f $REPOBASE/$x
done
rm -Rf $REPOBASE/MANIFEST.in
rm -Rf $REPOBASE/setup.py
rm -Rf $REPOBASE/setup.cfg
rm -Rf $REPOBASE/stdeb.cfg
rm -Rf $REPOBASE/scripts
rm -Rf $REPOBASE/po
rm -Rf $REPOBASE/.temp
rm -Rf $REPOBASE/.git*
rm -Rf $REPOBASE/share/icons/hicolor
mv -f $REPOBASE/share/when-command/*.glade $REPOBASE/share
mv -f $REPOBASE/share/when-command/when-command.py $REPOBASE
mv -f $REPOBASE/share/when-command/icons/* $REPOBASE/share/icons
mv -f $REPOBASE/share/doc/when-command/*.md $REPOBASE
rm -Rf $REPOBASE/share/when-command
rm -Rf $REPOBASE/share/doc
rm -Rf $REPOBASE/share/man
for x in $EXECS ; do
v=$(echo "`grep ^$VERSION_MARKER $x`; print $VERSION_MARKER" | python)
[ -z $VERSION ] && VERSION=$v
done
[ -z $VERSION ] && VERSION=0.0-transient.0
echo Package version is: $VERSION
DIRNAME=$PKGBASE-$VERSION
[ -d $DIRNAME ] && sudo chown -Rh $USER $DIRNAME && rm -Rf $DIRNAME
[ -f $DIRNAME.deb ] && rm -f $DIRNAME
mkdir -p $DIRNAME/DEBIAN
mkdir -p $DIRNAME/opt
mv $REPOBASE $DIRNAME/opt
for x in `find $DIRNAME -type f` ; do
chmod 644 $x
done
for x in `find $DIRNAME -type d` ; do
chmod 755 $x
done
for x in $EXECS ; do
chmod 755 $DIRNAME/opt/$x
cmd=${x%.*}
cd `dirname $curdir/$DIRNAME/opt/$x`
echo "Symlinking: `basename $x` --> `basename $cmd`"
ln -s `basename $x` `basename $cmd`
cd $curdir
done
KBYTES=`du -s -B 1024 $DIRNAME/opt | awk '{print $1}'`
cat control_template \
| sed "s/xxVERSIONxx/$VERSION/g" \
| sed "s/xxKBYTESxx/$KBYTES/g" \
> $DIRNAME/DEBIAN/control
echo "Fixing permissions in $DIRNAME/opt (--> /opt)"
sudo chown -Rh root:root $DIRNAME/opt
dpkg-deb --build $DIRNAME
sudo chown -Rh $curuser:$curgrp $DIRNAME/opt
@almostearthling
Copy link
Author

This script includes commands to recreate the contents of the /opt based .deb file using the source tree as it is in the packaging branch.

@almostearthling
Copy link
Author

The referred control_template text file has the following contents:

Package: when-command-opt
Version: xxVERSIONxx
Section: base
Priority: optional
Architecture: all
Installed-Size: xxKBYTESxx
Maintainer: Francesco Garosi <franz.g@no-spam-please.infinito.it>
Depends: python3-gi, xprintidle, gir1.2-appindicator3-0.1
Homepage: http://almostearthling.github.io/when-command/
Description: When Gnome Task Scheduler
 When is a configurable user task scheduler, designed with Ubuntu
 in mind. It interacts with the user through a GUI, where the user
 can define tasks and conditions, as well as relationships of
 causality that bind conditions to tasks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment