From 05c67512ec7410353de7d6bff1a44029e5e5efb9 Mon Sep 17 00:00:00 2001 From: Evgeniy Kukhtinov <neurofreak@altlinux.org> Date: Thu, 2 Jun 2022 14:58:57 +0300 Subject: [PATCH] epm play: add snap4arduino support --- play.d/snap4arduino.sh | 31 ++++++++++++++++++++++++++++++ repack.d/snap4arduino.sh | 41 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100755 play.d/snap4arduino.sh create mode 100755 repack.d/snap4arduino.sh diff --git a/play.d/snap4arduino.sh b/play.d/snap4arduino.sh new file mode 100755 index 00000000..4532a070 --- /dev/null +++ b/play.d/snap4arduino.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +PKGNAME=snap4arduino +DESCRIPTION="Snap4Arduino binds Snap! and Arduino together" + +if [ "$1" = "--remove" ] ; then + # $PKGNAME-stable really + epm remove $(epmqp $PKGNAME) + exit +fi + +. $(dirname $0)/common.sh + +arch=$($DISTRVENDOR --distro-arch) +case $arch in + x86_64|amd64) + arch=64 ;; + i586) + arch=32 ;; + *) + fatal "Unsupported arch $arch for $($DISTRVENDOR -d)" +esac + +PKGURL=$(epm tool eget --list --latest https://github.com/bromagosa/Snap4Arduino/releases "Snap4Arduino_desktop-gnu-$arch_*.tar.gz") #" +[ -n "$PKGURL" ] || fatal "Can't get package URL" +PKGFILE=$(echo /tmp/$(basename $PKGURL) | sed -e "s|/Snap4Arduino_desktop-gnu-$arch\_|/$PKGNAME-|") +epm tool eget -O $PKGFILE $PKGURL || exit + +epm install --repack "$PKGFILE" || exit + +rm -fv $PKGFILE diff --git a/repack.d/snap4arduino.sh b/repack.d/snap4arduino.sh new file mode 100755 index 00000000..90374eae --- /dev/null +++ b/repack.d/snap4arduino.sh @@ -0,0 +1,41 @@ +#!/bin/sh -x + +# It will be run with two args: buildroot spec +BUILDROOT="$1" +SPEC="$2" + +PRODUCT=Snap4Arduino +PRODUCTCUR=snap4arduino +PRODUCTDIR=/opt/$PRODUCT + +. $(dirname $0)/common.sh + +subst "s|^Group:.*|Group: Development/Other|" $SPEC +subst "s|^License: unknown$|License: AGPL-3.0|" $SPEC +subst "s|^URL:.*|URL: http://snap4arduino.rocks/|" $SPEC +subst "s|^Summary:.*|Summary: A modification of the Snap! visual programming language that lets you seamlessly interact with almost all versions of the Arduino board.|" $SPEC + +# move package to /opt +ROOTDIR=$(basename $(find $BUILDROOT -mindepth 1 -maxdepth 1 -type d)) +mkdir $BUILDROOT/opt +mv $BUILDROOT/$ROOTDIR $BUILDROOT$PRODUCTDIR +subst "s|\"/$ROOTDIR/|\"$PRODUCTDIR/|" $SPEC + +# add binary to the search path +mkdir -p $BUILDROOT/usr/bin/ +ln -s $PRODUCTDIR/run $BUILDROOT/usr/bin/$PRODUCTCUR +subst "s|%files|%files\n/usr/bin/$PRODUCTUR|" $SPEC + +# create desktop file +mkdir -p $BUILDROOT/usr/share/applications/ +cat <<EOF >$BUILDROOT/usr/share/applications/$PRODUCT.desktop +[Desktop Entry] +Type=Application +Version=1.0 +Icon=$PRODUCTDIR/icons/128x128x32.png +Exec=$PRODUCTDIR/run +Name=Snap4Arduino +Name[en]=Snap4Arduino +GenericName[en]=Use Snap! to control Arduino boards. Arduino goes lambda! +EOF +subst "s|%files|%files\n/usr/share/applications/$PRODUCT.desktop|" $SPEC -- 2.24.1