Skip to content

Commit

Permalink
pkg - Generic install target added
Browse files Browse the repository at this point in the history
---

We've managed to implement the generic `install` target for Nitrocid KS
PPA package so that other distributions can easily package it.

---

Type: pkg
Breaking: False
Doc Required: False
Backport Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Jan 19, 2025
1 parent 488f24c commit ecc946d
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-ppa-package-with-lintian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Initialize offline package
run: |
chmod +x tools/initializeoffline.sh
make debian-init-offline
make init-offline
make clean
- name: Make original package
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-ppa-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Initialize offline package
run: |
chmod +x tools/initializeoffline.sh
make debian-init-offline
make init-offline
make clean
- name: Make original package
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-ppa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ jobs:
run: |
sudo ip netns add no-net
chmod +x tools/initializeoffline.sh
make debian-init-offline
make init-offline
make clean
- name: Try to build
run: |
sudo ip netns exec no-net make debian-all-offline
sudo ip netns exec no-net make all-offline
2 changes: 1 addition & 1 deletion .github/workflows/pushppa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Initialize offline package
run: |
chmod +x tools/initializeoffline.sh
make debian-init-offline
make init-offline
make clean
- name: Make original package
Expand Down
63 changes: 30 additions & 33 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
OUTPUTS = public/Nitrocid/KSBuild public/*/obj public/*/*/obj private/*/bin private/*/obj debian/nitrocid-27
MODAPI = 27
OUTPUTS = public/Nitrocid/KSBuild public/*/obj public/*/*/obj private/*/bin private/*/obj debian/nitrocid-$(MODAPI) debian/nitrocid-$(MODAPI)-lite debian/tmp
OUTPUT = public/Nitrocid/KSBuild/net8.0
BINARIES = assets/ks-n assets/ks-jl
MANUALS = assets/ks.1 assets/ks-jl.1
DESKTOPS = assets/ks.desktop
BRANDINGS = public/Nitrocid/OfficialAppIcon-NitrocidKS-512.png

MODAPI = 27
ARCH := $(shell if [ `uname -m` = "x86_64" ]; then echo "linux-x64"; else echo "linux-arm64"; fi)

.PHONY: all debian-install
ifndef DESTDIR
FDESTDIR := /usr/local
else
FDESTDIR := $(DESTDIR)/usr
endif

.PHONY: all install lite

# General use

Expand All @@ -26,37 +32,28 @@ doc:
clean:
rm -rf $(OUTPUTS)

# Below targets are for Debian packaging only

debian-all-offline:
all-offline:
$(MAKE) -C tools invoke-build-offline

debian-init-offline:
$(MAKE) -C tools debian-invoke-init-offline

debian-install:
$(MAKE) debian-install-all PACKAGE=nitrocid-$(MODAPI)

debian-install-all:
mkdir -m 755 -p debian/$(PACKAGE)/usr/bin debian/$(PACKAGE)/usr/lib/ks-$(MODAPI) debian/$(PACKAGE)/usr/share/applications
install -m 755 -t debian/$(PACKAGE)/usr/bin/ $(BINARIES)
install -m 755 -t debian/ $(MANUALS)
find $(OUTPUT) -mindepth 1 -type d -exec sh -c 'mkdir -p -m 755 "debian/$(PACKAGE)/usr/lib/ks-$(MODAPI)/$$(realpath --relative-to $(OUTPUT) "$$0")"' {} \;
find $(OUTPUT) -mindepth 1 -type f -exec sh -c 'install -m 644 -t "debian/$(PACKAGE)/usr/lib/ks-$(MODAPI)/$$(dirname $$(realpath --relative-to $(OUTPUT) "$$0"))" "$$0"' {} \;
install -m 755 -t debian/$(PACKAGE)/usr/share/applications/ $(DESKTOPS)
install -m 755 -t debian/$(PACKAGE)/usr/lib/ks-$(MODAPI)/ $(BRANDINGS)
mv debian/$(PACKAGE)/usr/bin/ks-n debian/$(PACKAGE)/usr/bin/ks-$(MODAPI)
mv debian/$(PACKAGE)/usr/bin/ks-jl debian/$(PACKAGE)/usr/bin/ks-jl-$(MODAPI)
mv debian/ks.1 debian/ks-$(MODAPI).1
mv debian/ks-jl.1 debian/ks-jl-$(MODAPI).1
mv debian/$(PACKAGE)/usr/share/applications/ks.desktop debian/$(PACKAGE)/usr/share/applications/ks-$(MODAPI).desktop
sed -i 's|/usr/lib/ks|/usr/lib/ks-$(MODAPI)|g' debian/$(PACKAGE)/usr/bin/ks-*
sed -i 's|/usr/lib/ks|/usr/lib/ks-$(MODAPI)|g' debian/$(PACKAGE)/usr/share/applications/ks-$(MODAPI).desktop
sed -i 's|/usr/bin/ks|/usr/bin/ks-$(MODAPI)|g' debian/$(PACKAGE)/usr/share/applications/ks-$(MODAPI).desktop
find 'debian/$(PACKAGE)/usr/lib/' -type d -name "runtimes" -exec sh -c 'find $$0 -mindepth 1 -maxdepth 1 -not -name $(ARCH) -type d -exec rm -rf \{\} \;' {} \;

debian-install-lite:
$(MAKE) debian-install-all PACKAGE=nitrocid-$(MODAPI)-lite
rm -rf debian/nitrocid-$(MODAPI)-lite/usr/lib/ks-$(MODAPI)/Addons
init-offline:
$(MAKE) -C tools invoke-init-offline

install:
mkdir -m 755 -p $(FDESTDIR)/bin $(FDESTDIR)/lib/ks-$(MODAPI) $(FDESTDIR)/share/applications $(FDESTDIR)/share/man/man1/
install -m 755 -t $(FDESTDIR)/bin/ $(BINARIES)
install -m 644 -t $(FDESTDIR)/share/man/man1/ $(MANUALS)
find $(OUTPUT) -mindepth 1 -type d -exec sh -c 'mkdir -p -m 755 "$(FDESTDIR)/lib/ks-$(MODAPI)/$$(realpath --relative-to $(OUTPUT) "$$0")"' {} \;
find $(OUTPUT) -mindepth 1 -type f -exec sh -c 'install -m 644 -t "$(FDESTDIR)/lib/ks-$(MODAPI)/$$(dirname $$(realpath --relative-to $(OUTPUT) "$$0"))" "$$0"' {} \;
install -m 755 -t $(FDESTDIR)/share/applications/ $(DESKTOPS)
install -m 755 -t $(FDESTDIR)/lib/ks-$(MODAPI)/ $(BRANDINGS)
mv $(FDESTDIR)/bin/ks-n $(FDESTDIR)/bin/ks-$(MODAPI)
mv $(FDESTDIR)/bin/ks-jl $(FDESTDIR)/bin/ks-jl-$(MODAPI)
mv $(FDESTDIR)/share/man/man1/ks.1 $(FDESTDIR)/share/man/man1/ks-$(MODAPI).1
mv $(FDESTDIR)/share/man/man1/ks-jl.1 $(FDESTDIR)/share/man/man1/ks-jl-$(MODAPI).1
mv $(FDESTDIR)/share/applications/ks.desktop $(FDESTDIR)/share/applications/ks-$(MODAPI).desktop
sed -i 's|/usr/lib/ks|/usr/lib/ks-$(MODAPI)|g' $(FDESTDIR)/bin/ks-*
sed -i 's|/usr/lib/ks|/usr/lib/ks-$(MODAPI)|g' $(FDESTDIR)/share/applications/ks-$(MODAPI).desktop
sed -i 's|/usr/bin/ks|/usr/bin/ks-$(MODAPI)|g' $(FDESTDIR)/share/applications/ks-$(MODAPI).desktop
find '$(FDESTDIR)/lib/' -type d -name "runtimes" -exec sh -c 'find $$0 -mindepth 1 -maxdepth 1 -not -name $(ARCH) -type d -exec rm -rf \{\} \;' {} \;

# This makefile is just a wrapper for tools scripts.
7 changes: 3 additions & 4 deletions PKGBUILD-REL
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ sha256sums=('SKIP')

prepare() {
cd "${pkgname}"
HOME=`pwd`/nuget DOTNET_CLI_TELEMETRY_OPTOUT=1 dotnet restore Nitrocid.sln
HOME=`pwd`/nuget DOTNET_CLI_TELEMETRY_OPTOUT=1 dotnet restore Nitrocid.sln
mkdir -p deps
cp nuget/.nuget/packages/*/*/*.nupkg deps/
rm -rf nuget
Expand All @@ -28,11 +28,10 @@ prepare() {

build() {
cd "${pkgname}"
HOME="$srcdir/homedir" DOTNET_CLI_TELEMETRY_OPTOUT=1 make debian-all-offline
HOME="$srcdir/homedir" DOTNET_CLI_TELEMETRY_OPTOUT=1 make all-offline
}

package() {
cd "${pkgname}"
make debian-install
cp -dr --no-preserve='ownership' debian/${pkgname%-git}/usr "$pkgdir"
make install DESTDIR="$pkgdir"
}
5 changes: 2 additions & 3 deletions PKGBUILD-VCS
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pkgver() {

prepare() {
cd "${pkgname}"
HOME=`pwd`/nuget DOTNET_CLI_TELEMETRY_OPTOUT=1 dotnet restore Nitrocid.sln
HOME=`pwd`/nuget DOTNET_CLI_TELEMETRY_OPTOUT=1 dotnet restore Nitrocid.sln
mkdir -p deps
cp nuget/.nuget/packages/*/*/*.nupkg deps/
rm -rf nuget
Expand All @@ -40,6 +40,5 @@ build() {

package() {
cd "${pkgname}"
make debian-install
cp -dr --no-preserve='ownership' debian/${pkgname%-git}/usr "$pkgdir"
make install DESTDIR="$pkgdir"
}
2 changes: 0 additions & 2 deletions debian/nitrocid-27-lite.manpages

This file was deleted.

2 changes: 0 additions & 2 deletions debian/nitrocid-27.manpages

This file was deleted.

7 changes: 4 additions & 3 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@

override_dh_auto_build:
mkdir debian/homedir
$(MAKE) debian-all-offline
$(MAKE) all-offline

override_dh_auto_install:
$(MAKE) debian-install
$(MAKE) debian-install-lite
$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp
find $(CURDIR)/debian/tmp/usr -mindepth 1 -type f -exec sh -c 'printf "%s" "$$(realpath --relative-to . "$$0")" ; printf " usr/" ; dirname $$(realpath --relative-to $(CURDIR)/debian/tmp/usr "$$0")' "{}" \; | tee $(CURDIR)/debian/nitrocid-27.install
find $(CURDIR)/debian/tmp/usr -type d -name Addons -prune -o -type f -exec sh -c 'printf "%s" "$$(realpath --relative-to . "$$0")" ; printf " usr/" ; dirname $$(realpath --relative-to $(CURDIR)/debian/tmp/usr "$$0")' "{}" \; | tee $(CURDIR)/debian/nitrocid-27-lite.install
2 changes: 1 addition & 1 deletion tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ invoke-build-offline:
chmod +x ./build.sh
HOME=`pwd`"/debian/homedir" ./build.sh Release -p:NitrocidFlags=PACKAGEMANAGERBUILD || (echo Retrying with heap limit 0x$(DOTNET_HEAP_LIMIT)... && DOTNET_GCHeapHardLimit=$(DOTNET_HEAP_LIMIT) HOME=`pwd`"/debian/homedir" ./build.sh Release -p:NitrocidFlags=PACKAGEMANAGERBUILD)

debian-invoke-init-offline:
invoke-init-offline:
chmod +x ./initializeoffline.sh
cd .. && ./tools/initializeoffline.sh || (echo Retrying with heap limit 0x$(DOTNET_HEAP_LIMIT)... && DOTNET_GCHeapHardLimit=$(DOTNET_HEAP_LIMIT) ./tools/initializeoffline.sh)

0 comments on commit ecc946d

Please sign in to comment.