Skip to content

Commit

Permalink
Many nice changes
Browse files Browse the repository at this point in the history
  * Add workflows for automate building
  * add deb package builder
  * move sample script
  * add daemon handler
  • Loading branch information
hermanntoast committed May 25, 2022
1 parent 831a7ec commit a42e9ad
Show file tree
Hide file tree
Showing 10 changed files with 293 additions and 6 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

workflow_dispatch:

name: Build Release

jobs:
deb-package:
name: build DEB-Package
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install dependencies
run: sudo apt update && sudo apt install debhelper -y

- name: Build
run: ./buildpackage.sh

- name: Copy artifacts
run: mkdir archives && cp ../*.* ./archives

- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: deb-package
path: archives/*

github-release:
needs: deb-package
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
name: GitHub Release
runs-on: ubuntu-20.04
steps:
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: deb-package

- name: Extract current changes
run: cat *.changes | sed '0,/^Changes:$/d' | sed '/Checksums.*/Q' | sed '1,2d' | tail >> ./current-changes

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
body_path: ./current-changes

- name: Delete current changes file
run: rm ./current-changes

- name: Upload Release Assets
id: upload-release-assets
uses: dwenegar/upload-release-assets@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ steps.create_release.outputs.id }}
assets_path: .
4 changes: 4 additions & 0 deletions buildpackage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

# build the debian package
dpkg-buildpackage -rfakeroot -tc -sa -us -uc -I".directory" -I".git" -I"buildpackage.sh"
5 changes: 5 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
tripoli (0.0.1~rc1) bullseye; urgency=medium

* First release for version 0.0.1

-- hermanntoast <[email protected]> Tue, 24 May 2022 18:12:46 +0200
1 change: 1 addition & 0 deletions debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5
12 changes: 12 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Source: tripoli
Section: admin
Priority: optional
Maintainer: hermanntoast <[email protected]>
Build-Depends: debhelper (>= 4.0.0), fakeroot

Package: tripoli
Architecture: all
Depends: python3
Homepage: hermann-toast.de
Recommends:
Description: Create XFCE Shell extentions
23 changes: 23 additions & 0 deletions debian/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh
set -e

case "$1" in
install|configure)
echo "Creating directories und copy samples..."
mkdir -p ~/.config/tripoli/
mkdir -p ~/.config/tripoli/log/
cp -f /usr/share/tripoli/samples/sampleScript.sh ~/.config/tripoli/
echo "Creating startup script for all users..."
echo "#!/bin/sh" > /etc/profile.d/tripoli.sh
echo "python3 /usr/share/tripoli/tripoli.py 2>&1 > /dev/null &" >> /etc/profile.d/tripoli.sh
chmod +x /etc/profile.d/tripoli.sh
;;
upgrade|abort-upgrade)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 0
;;
esac

exit 0
112 changes: 112 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 by Joey Hess.
#
# This version is for a hypothetical package that builds an
# architecture-dependant package, as well as an architecture-independent
# package.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# This is the debhelper compatibility version to use.
export DH_COMPAT=5

#ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
# CFLAGS += -g
#endif
#ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
# INSTALL_PROGRAM += -s
#endif

configure: configure-stamp
configure-stamp:
dh_testdir
# Add here commands to configure the package.

touch configure-stamp


build-arch: configure-stamp build-arch-stamp
build-arch-stamp:
dh_testdir

# Add here command to compile/build the package.
#$(MAKE)

touch build-arch-stamp

build-indep: configure-stamp build-indep-stamp
build-indep-stamp:
dh_testdir

# Add here command to compile/build the arch indep package.
# It's ok not to do anything here, if you don't need to build
# anything for this package.

touch build-indep-stamp

build: build-arch build-indep

clean: clean1
clean1:
dh_testdir
dh_testroot
rm -f build-indep-stamp build-arch-stamp configure-stamp

# Add here commands to clean up after the build process.
#-$(MAKE) clean

dh_clean


install: DH_OPTIONS=
install: build
dh_testdir
dh_testroot
dh_prep
dh_installdirs

# Add here commands to install the package.
dh_install
# fixing default not being installed
mkdir -p debian/tripoli
rsync -avr --exclude='.installed' usr debian/tripoli


# Build architecture-independent files here.
# Pass -i to all debhelper commands in this target to reduce clutter.
binary-indep: build install
dh_testdir
dh_testroot
dh_installdirs
dh_installdebconf
dh_installdocs
# dh_installexamples -i
# dh_installmenu -i
dh_installlogrotate -i
# dh_installemacsen -i
# dh_installpam -i
# dh_installmime -i
dh_installinit -i
dh_installcron -i
# dh_installman -i
# dh_installinfo -i
# dh_undocumented -i
dh_installchangelogs
dh_link
dh_compress
dh_fixperms
dh_installdeb
# dh_perl -i
dh_gencontrol
dh_md5sums
dh_builddeb

# Build architecture-dependent files here.
binary-arch: install
# We have nothing to do by default.


binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure clean1
58 changes: 58 additions & 0 deletions usr/bin/tripoli
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash

function start() {
if isRunning; then
echo "Tripoli is already running!"
else
echo -n "Starting tripoli... "
python3 /usr/share/tripoli/tripoli.py 2>&1 > /dev/null &
echo "[OK]"
fi
}

function stop() {
if isRunning; then
echo -n "Stopping tripoli... "
ps -aux | grep python | grep tripoli | awk '{print $2}' | xargs kill
echo "[OK]"
else
echo "Tripoli is not running!"
fi
}

function isRunning() {
if [ $(ps -aux | grep python | grep tripoli | wc -l) -gt 0 ]; then
return 0
else
return 1
fi
}

function getPID() {
return $(ps -aux | grep python | grep tripoli | awk '{print $2}')
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 2
start
;;
status)
if isRunning; then
getPID
echo "Tripoli is running with pid $?"
else
echo "Tripoli is not running!"
fi
;;
*)
echo "Option not known! Use start, stop, restart or status!"
;;
esac
File renamed without changes.
14 changes: 8 additions & 6 deletions tripoli.py → usr/share/tripoli/tripoli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@

from gi.repository import Gtk as gtk, AppIndicator3 as appindicator, GLib

logging.basicConfig(format='%(levelname)s: %(asctime)s %(message)s', level=logging.CRITICAL)
scriptPath = os.path.expanduser("~") + "/.config/tripoli/"
logPath = os.path.expanduser("~") + "/.config/tripoli/log/"

scriptPath = "~/.config/tripoli/"
logging.basicConfig(filename=logPath + 'tripoli.log', format='%(levelname)s: %(asctime)s %(message)s', level=logging.INFO)

def __execute(command) -> list:
commandline = ""
Expand Down Expand Up @@ -91,11 +92,12 @@ def main():

if __name__ == "__main__":
try:
print("Start application...")
logging.info("Starting application...")
main()
except KeyboardInterrupt:
print()
exit()
except Exception as e:
print(e)
pass
logging.critical(e)
pass
finally:
logging.info("Stopping application...")

0 comments on commit a42e9ad

Please sign in to comment.