File debian.rules of Package firetools-add-missing-apps

#!/usr/bin/make -f
# -*- makefile -*-
# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1
# Get some information about the machine we are building on:
export numberOfProcessorsOnMachine=$(shell nproc)
export wantedJobs=$(shell echo "1.25*$(numberOfProcessorsOnMachine)" | bc -l)
export jobsIget=$(shell echo $(wantedJobs) | awk '{print int($$1+0.5)}')
export numberOfProcessorsOnMachine=4
#export wantedJobs=4
#export jobsIget=$(shell nproc)
export TOTAL_DISK=$(shell df -h --total | awk 'END{print $$2}')
export FREEMEM=$(shell free --mega)
export TOTAL_MEM=$(shell free --total --mega | xargs | awk '{print $$19"MB"}')
export TOTAL_RAM=$(shell free --total --mega | xargs | awk '{print $$8"MB"}')
export TOTAL_SWAP=$(shell free --total --mega | xargs | awk '{print $$15"MB"}')
export DISTRO=$(shell awk -F= '/^NAME/{print $2}' /etc/os-release | cut -d'=' -f2)
export DISTROVERSION=$(shell awk -F= '/^VERSION_ID/{print $2}' /etc/os-release)
export THISMONTH=$(shell LC_TIME='en_US.UTF-8' date +%B)
export THISYEAR=$(shell date +%Y)
# Add support for different Debian based distributions
export VERSION_CODENAME=$(shell cat /etc/os-release | grep VERSION_CODENAME | awk -F= '{print $$2}')
export VERSION_ID=$(shell cat /etc/os-release | grep VERSION_ID | awk -F= '{print $$2}')
export PRETTY_NAME="$(shell cat /etc/*-release | egrep "PRETTY_NAME" | cut -d = -f 2)"
# Variables
export pkgname=firejail-linphone-desktop
export executable=linphone
# format manpage_date=January 2024
export manpage_date="$(THISMONTH) $(THISYEAR)"
export _topdir=/usr/src/packages
export _builddir=$(_topdir)/BUILD
#export _builddir=/usr/src/packages/BUILD
export _sourcedir=$(_topdir)/SOURCES
#export _sourcedir=/usr/src/packages/SOURCES
export _uploaddir=/usr/src/packages/SOURCES
export srcdir=/usr/src/packages/SOURCES
export pkgdir_head=$(_builddir)/debian
#export pkgdir_head=/usr/src/packages/BUILD/debian
#export pkgdir=$(pkgdir_head)/$(pkgname)
export pkgdir=$(pkgdir_head)/tmp
export pkgdir=/usr/src/packages/BUILD/debian/tmp
export buildroot=/usr/src/packages/BUILD/debian/tmp
export buildroot=$(_builddir)/debian/$(pkgname)
export buildroot=$(_builddir)/debian/$(pkgname)
#export buildroot=$(pkgdir)
export _installToDir=$(pkgdir)
#export _installToDir=/usr/src/packages/BUILD/debian/tmp
ifeq ($(findstring Raspbian,$(PRETTY_NAME)),Raspbian)
    # Found
    export PLATFORM=Raspbian
    export BUILDDIR=obj-arm-linux-gnueabihf
    export LIBDIR=lib/arm-linux-gnueabihf
else
    # Not found
    export PLATFORM=DebianOrUbuntu
    export BUILDDIR=obj-x86_64-linux-gnu
    export LIBDIR=lib/x86_64-linux-gnu
endif
#export PLATFORM=DebianOrUbuntu
#export BUILDDIR=obj-x86_64-linux-gnu
#export LIBDIR=lib/x86_64-linux-gnu
# Set debhelper options
DEB_BUILD_OPTIONS=nocheck
export script_one=$(pkgdir)/usr/local/bin/firetools-add-missing-apps
export script_two=$(pkgdir)/usr/local/bin/firetools-uiapps-reset
export uiappsDir=\$$HOME/.config/firetools
#export uiappsFile=\$$HOME/.config/firetools/uiapps
export uiappsFile=$(uiappsDir)/uiapps

%:
	dh $@
    
override_dh_auto_configure:

override_dh_auto_build:
	echo "--- Machine data we are building on ---"
	echo "Total disk: $$TOTAL_DISK"
	echo "Output of free -h:"
	echo "$$FREEMEM"
	echo "Total memory: $$TOTAL_MEM"
	echo "Total RAM: $$TOTAL_RAM"
	echo "Total SWAP: $$TOTAL_SWAP"
	echo "numberOfProcessorsOnMachine=$$numberOfProcessorsOnMachine"
	echo "wantedJobs=$$wantedJobs"
	echo "jobsIget=$$jobsIget"
	echo "--- End machine data we are building on ---"
	echo DISTRO=$$DISTRO
	if [ "$$DISTRO" = "Ubuntu" ] ; then echo "Distro is Ubuntu" ; fi
	if [ "$$DISTRO" = "Debian" ] ; then echo "Distro is Debian" ; fi
	if [ "$$DISTRO" = "Fedora" ] ; then echo "Distro is Fedora" ; fi
	# Not working
	#ifeq ($(shell dpkg-vendor --is Ubuntu && echo yes),yes)
	#echo "This is Ubuntu"
	#endif
	#ifeq ($(shell dpkg-vendor --is Debian && echo yes),yes)
	#echo "This is Debian"
	#endif
	echo "--- List variables ---"
	echo "DH_VERBOSE=$(DH_VERBOSE)"
	echo "DISTRO_VERSION=$(DISTRO_VERSION)"
	echo "DISTRO=$(DISTRO)"
	echo "DISTROVERSION=$(DISTROVERSION)"
	echo "TOTAL_SWAP=$(TOTAL_SWAP)"
	echo "VERSION_CODENAME=$(VERSION_CODENAME)"
	echo "VERSION_ID=$(VERSION_ID)"
	echo "PRETTY_NAME=$(PRETTY_NAME)"
	echo "PLATFORM=$(PLATFORM)"
	echo "BUILDDIR=$(BUILDDIR)"
	echo "LIBDIR=$(LIBDIR)"
	echo "THISMONTH=$(THISMONTH)"
	echo "THISYEAR=$(THISYEAR)"
	echo "pkgname=$(pkgname)"
	echo "install_prefix=$(install_prefix)"
	echo "manpage_date=$(manpage_date)"
	echo "_topdir=$(_topdir)"
	echo "_builddir=$(_builddir)"
	echo "_sourcedir=$(_sourcedir)"
	echo "_uploaddir=$(_uploaddir)"
	echo "srcdir=$(srcdir)"
	echo "pkgdir_head=$(pkgdir_head)"
	echo "pkgdir=$(pkgdir)"
	echo "buildroot=$(buildroot)"
	echo "_installToDir=$(_installToDir)"
	echo "--- End list variables ---"

override_dh_usrlocal:

override_dh_auto_install:
	mkdir -pv "$(pkgdir)/usr/local/bin"
	# Create a script to add additional firetools apps
	# Create script in /usr/local/bin/firetools-add-missing-apps
	scriptFile="$(pkgdir)/usr/local/bin/firetools-add-missing-apps"
	uiappsFile="\$$HOME/.config/firetools/uiapps"
	#echo "#!/usr/bin/bash" > $(script_one)
	#echo >> $(script_one)
	#echo "echo \"# Program list for Firetools\" >> \"$(uiappsFile)\"" >> $(script_one)
	#echo "echo \"#\" >> \"$(uiappsFile)\"" >> $(script_one)
	#echo "echo \"# Each line defines an application, with semicolons separated fields as follows:\" >> \"$(uiappsFile)\"" >> $(script_one)
	#echo "echo \"#\" >> \"$(uiappsFile)\"" >> $(script_one)
	#echo "echo \"#       executable; description; icon; (optional) command for starting Firejail\" >> \"$(uiappsFile)\"" >> $(script_one)
	#echo "echo \"#\" >> \"$(uiappsFile)\"" >> $(script_one)
	#echo "echo \"# Examples:\" >> \"$(uiappsFile)\"" >> $(script_one)
	#echo "echo \"#\" >> \"$(uiappsFile)\"" >> $(script_one)
	#echo "echo \"#       inkscape;Inkscape SVG Editor;inkscape\" >> \"$(uiappsFile)\"" >> $(script_one)
	#echo "echo \"#       calibre;Calibre eBook Reader;/usr/share/calibre/images/lt.png\" >> \"$(uiappsFile)\"" >> $(script_one)
	#echo "echo \"#\" >> \"$(uiappsFile)\"" >> $(script_one)
	#echo "echo \"# Lines starting in # are comments.\" >> \"$(uiappsFile)\"" >> $(script_one)
	#echo "echo \"#\" >> \"$(uiappsFile)\"" >> $(script_one)
	#echo "echo >> \"$(uiappsFile)\"" >> $(script_one)
	#echo "echo \"# Missing Firetools apps\" >> \"$(uiappsFile)\"" >> $(script_one)
	#echo "echo >> \"$(uiappsFile)\"" >> $(script_one)
	#echo "echo \"zoom;Zoom;Zoom\" >> \"$(uiappsFile)\"" >> $(script_one)
	#echo "echo \"linphone;Linphone;linphone\" >> \"$(uiappsFile)\"" >> $(script_one)
	#echo "echo \"/opt/appimages/linphone.AppImage;Linphone AppImage;linphone-appimage;firejail --appimage --profile=/etc/firejail/linphone.profile /opt/appimages/linphone.AppImage\" >> \"$(uiappsFile)\"" >> $(script_one)
	#echo "echo \"/opt/linphone/linphone-launcher;Linphone /opt/linphone/linphone-launcher;linphone-desktop;firejail --profile=/etc/firejail/linphone.profile /opt/linphone/linphone-launcher\" >> \"$(uiappsFile)\"" >> $(script_one)
	#echo "echo \"/opt/appimages/teams-for-linux.AppImage;Teams for Linux AppImage;teams-for-linux-appimage;firejail --appimage --profile=/etc/firejail/teams-for-linux.profile /opt/appimages/teams-for-linux.AppImage\" >> \"$(uiappsFile)\"" >> $(script_one)
	#echo "echo \"teams-for-linux;Teams for Linux;teams-for-linux;firejail --profile=/etc/firejail/teams-for-linux.profile /usr/bin/teams-for-linux\" >> \"$(uiappsFile)\"" >> $(script_one)
	echo "#!/usr/bin/bash" > $(script_one)
	echo >> $(script_one)
	echo "mkdir -p \"$(uiappsDir)\"" >> $(script_one)
	echo "cat <<EOF > \"$(uiappsFile)\"" >> $(script_one)
	echo "# Program list for Firetools" >> $(script_one)
	echo "#" >> $(script_one)
	echo "# Each line defines an application, with semicolons separated fields as follows:" >> $(script_one)
	echo "#" >> $(script_one)
	echo "#       executable; description; icon; (optional) command for starting Firejail" >> $(script_one)
	echo "#" >> $(script_one)
	echo "# Examples:" >> $(script_one)
	echo "#" >> $(script_one)
	echo "#       inkscape;Inkscape SVG Editor;inkscape" >> $(script_one)
	echo "#       calibre;Calibre eBook Reader;/usr/share/calibre/images/lt.png" >> $(script_one)
	echo "#" >> $(script_one)
	echo "# Lines starting in # are comments." >> $(script_one)
	echo "#" >> $(script_one)
	echo >> $(script_one)
	#echo "echo >> \"$(uiappsFile)\"" >> $(script_one)
	echo "# Missing Firetools apps" >> $(script_one)
	echo >> $(script_one)
	#echo "echo >> \"$(uiappsFile)\"" >> $(script_one)
	echo "zoom;Zoom;Zoom" >> $(script_one)
	echo "/opt/appimages/zoom.AppImage;Zoom AppImage;zoom-appimage;firejail --appimage --profile=/etc/firejail/zoom.profile /opt/appimages/zoom.AppImage" >> $(script_one)
	echo "linphone;Linphone;linphone" >> $(script_one)
	echo "/opt/appimages/linphone.AppImage;Linphone AppImage;linphone-appimage;firejail --appimage --profile=/etc/firejail/linphone.profile /opt/appimages/linphone.AppImage" >> $(script_one)
	echo "/opt/linphone/linphone-launcher;Linphone /opt/linphone/linphone-launcher;linphone-desktop;firejail --profile=/etc/firejail/linphone.profile /opt/linphone/linphone-launcher" >> $(script_one)
	echo "/opt/appimages/teams-for-linux.AppImage;Teams for Linux AppImage;teams-for-linux-appimage;firejail --appimage --profile=/etc/firejail/teams-for-linux.profile /opt/appimages/teams-for-linux.AppImage" >> $(script_one)
	echo "teams-for-linux;Teams for Linux;teams-for-linux;firejail --profile=/etc/firejail/teams-for-linux.profile /usr/bin/teams-for-linux" >> $(script_one)
	echo "vivaldi;Vivaldi;vivaldi" >> $(script_one)
	echo "brave;Brave Web Browser;brave" >> $(script_one)
	echo "brave-browser;Brave Web Browser;brave-browser" >> $(script_one)
	echo "libreoffice;LibreOffice;libreoffice" >> $(script_one)
	echo "localc;LibreOffice Calc;libreoffice-calc" >> $(script_one)
	echo "loimpress;LibreOffice Impress;libreoffice-impress" >> $(script_one)
	echo "element-desktop;Element;element-desktop;firejail --ignore=apparmor --apparmor-replace /usr/bin/element-desktop" >> $(script_one)
	echo "atril;Atril;atril" >> $(script_one)
	echo "EOF" >> $(script_one)
	echo >> $(script_one)
	echo "echo \"cat \\\"$(uiappsFile)\\\"\"" >> $(script_one)
	echo "echo" >> $(script_one)
	echo "cat \"$(uiappsFile)\"" >> $(script_one)
	echo "echo" >> $(script_one)
	echo "echo" >> $(script_one)
	echo "echo \"added \\\"Missing Firetools apps\\\" to \\\"$(uiappsFile)\\\"\"" >> $(script_one)
	echo "echo \"Done.\"" >> $(script_one)
	echo "exit 0" >> $(script_one)
	# Make script executable
	chmod +x "$(script_one)"
	# Create a script to reset firetools uiapps
	# Create script in /usr/local/bin/firetools-uiapps-reset
	scriptFile="$(pkgdir)/usr/local/bin/firetools-uiapps-reset"
	uiappsFile="\$$HOME/.config/firetools/uiapps"
	echo "#!/usr/bin/bash" > $(script_two)
	echo "rm -f \"$(uiappsFile)\"" >> $(script_two)
	echo "echo \"Removed \\\"$(uiappsFile)\\\"\"" >> $(script_two)
	echo "echo \"Please restart Firetools to reflect changes.\"" >> $(script_two)
	echo "echo \"Done.\"" >> $(script_two)
	echo "exit 0" >> $(script_two)
	# Make script executable
	chmod +x "$(script_two)"
	install -m0755 $(_uploaddir)/firejail-brave-keyboard-not-working-fix "$(pkgdir)/usr/local/bin/"
	install -m0755 $(_uploaddir)/firejail-thunderbird-keyboard-not-working-fix "$(pkgdir)/usr/local/bin/"
	echo "--- Show files that will be packaged ---"
	echo "find debian"
	find $(pkgdir) | sed "s|$(pkgdir)||g"
	echo "--- End show files that will be packaged ---"
openSUSE Build Service is sponsored by