File debian.rules of Package firetools-linphone-desktop

#!/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-linphone-add
export uiappsFile=\$HOME/.config/firetools/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 linphone app to firetools uiapps
	# Create script in /usr/local/bin/firetools-linphone-add
	scriptFile="$(pkgdir)/usr/local/bin/firetools-linphone-add"
	uiappsFile="\$HOME/.config/firetools/uiapps"
	echo "#!/usr/bin/bash" > $(script_one)
	echo >> $(script_one)
	echo "if [ ! -f \"${uiappsFile}\" ]; then" >> $(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 "# Missing Firetools apps" >> $(script_one)
	echo >> $(script_one)
	echo "EOF" >> $(script_one)
	echo "else" >> $(script_one)
	echo "echo \"\\\"${uiappsFile}\\\" exists\"" >> $(script_one)
	echo "fi" >> $(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 >> $(script_one)
	echo "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 linphone to Firetools apps to \\\"${uiappsFile}\\\"\"" >> $(script_one)
	echo "echo" >> $(script_one)
	echo "echo \"if you wish to remove \\\"${uiappsFile}\\\" copy and paste the following command followed by pressing ENTER:\"" >> $(script_one)
	echo "echo \"    rm -f \\\"${uiappsFile}\\\"\"" >> $(script_one)
	echo "echo" >> $(script_one)
	echo "echo \"if you wish to edit \\\"${uiappsFile}\\\" copy and paste the following command followed by pressing ENTER:\"" >> $(script_one)
	echo "echo \"    xdg-open \\\"${uiappsFile}\\\"\"" >> $(script_one)
	echo "echo" >> $(script_one)
	echo "echo \"Done.\"" >> $(script_one)
	echo "exit 0" >> $(script_one)
	# Make script executable
	chmod +x "$(script_one)"
	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