Posts Tagged ‘SPK’

Synology DSM: How to package SPK files?

Saturday, December 22nd, 2012

Some people say that coders would be lazy …

#!/bin/bash
# SPK Package Script
# Written in 2012 by Martin Zeitler
# usage: ./package.sh APP VERSION ARCH
TAR="$(which tar)"
APP=$1
VERSION=$2
ARCH=$3

if [ $# -ne 3 ]; then
	echo &quot;Usage: ./<code>basename $0</code> {APP VERSION ARCH}&quot;
	exit 65
fi

cd packages/$APP/
WD=&quot;$(pwd)&quot;
RELEASE=&quot;../../releases/$APP-$ARCH-$VERSION.spk&quot;
PACKAGE=&quot;$WD/install/package.tgz&quot;

chmod -R 755 package/
cd $WD/package &amp;&amp; $TAR -zcvf $PACKAGE * &amp;&amp; cd ..

chmod 755 &quot;$PACKAGE&quot;
cd $WD/install/
PACKAGE_MD5=<code>md5sum package.tgz | awk '{ print $1 }'</code>
cd $WD/install &amp;&amp; $TAR -cvf $WD/release.tar * &amp;&amp; cd ..
rm $WD/install/package.tgz
mv $WD/release.tar $RELEASE

SIZE=$(stat -c%s &quot;$RELEASE&quot;)
echo &quot;-----------------------------------------&quot;
echo &quot;Package: $APP v$VERSION ($ARCH)&quot;
echo &quot;    MD5: $PACKAGE_MD5&quot;
echo &quot;   Size: $SIZE bytes&quot;
echo &quot;-----------------------------------------&quot;

It can be conveniently called by a second script, which passes predefined parameters:

#!/bin/bash
APP=&quot;SomeApplication&quot;
VERSION=&quot;101&quot;
ARCH=&quot;noarch&quot;

BASE_DIR=<code>dirname $0</code>
echo &quot;-----------------------------------------&quot;
echo &quot;Now Packaging: $APP $VERSION ($ARCH)&quot;
echo &quot;-----------------------------------------&quot;
$BASE_DIR/package.sh $APP $VERSION $ARCH

Related Links: