Skip to content

Commit

Permalink
Added support for custom shell installer
Browse files Browse the repository at this point in the history
  • Loading branch information
ppacher committed Apr 5, 2022
1 parent 4de0b78 commit de2eaaa
Show file tree
Hide file tree
Showing 15 changed files with 459 additions and 122 deletions.
8 changes: 6 additions & 2 deletions linux/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ NFPM ?= nfpm

.PHONY: icons test-debian test-ubuntu nfpm.yaml

all: deb rpm
all: deb rpm gen-pkgbuild gen-archive

nfpm.yaml: portmaster-start
sed -e "s/^version:.*$$/version: v$(shell ./portmaster-start version --short)-$(shell cat ./pkgrev)/g" ./nfpm.yaml.template > ./nfpm.yaml
Expand All @@ -31,7 +31,7 @@ distdir:
mkdir -p ./dist

clean:
rm -r ./portmaster-start ./scripts ./dist icons/ PKGBUILD arch.install nfpm.yaml src pkg portmaster-bin-*.pkg.tar.xz|| true
rm -r ./portmaster-start ./scripts ./dist icons/ PKGBUILD arch.install nfpm.yaml src pkg portmaster-bin-*.pkg.tar.xz archive.install || true

test-debian: build deb
docker run -ti --rm -v $(shell pwd)/dist:/work -w /work debian:latest bash -c 'apt update && apt install -y ca-certificates && dpkg -i /work/portmaster*.deb ; bash'
Expand All @@ -55,5 +55,9 @@ gen-pkgbuild: nfpm.yaml
gomplate -d "nfpm=./nfpm.yaml" -f templates/arch.install > arch.install
gomplate -d "nfpm=./nfpm.yaml" -f templates/PKGBUILD > PKGBUILD

gen-archive: nfpm.yaml icons
gomplate -d "nfpm=./nfpm.yaml" -f templates/no-log-install.sh > archive.install
gomplate -d "nfpm=./nfpm.yaml" -f templates/create-archive.sh | bash

lint:
shellcheck ./scripts/* ./arch.install
55 changes: 0 additions & 55 deletions linux/PKGBUILD

This file was deleted.

48 changes: 24 additions & 24 deletions linux/arch.install → linux/archive.install
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@




post_install() {
log() {
echo "$@"
}

#
# Prepares systemd support by creating a symlink for the .service file
# and enabling/disabling certain features of our .service unit based on
Expand All @@ -26,7 +28,7 @@ post_install() {
systemctl daemon-reload ||:
fi

log "Configuring portmaster.service to launch at boot"
log "info" "Configuring portmaster.service to launch at boot"
systemctl enable portmaster.service ||:
fi
}
Expand All @@ -47,8 +49,12 @@ post_install() {
#
# Fix selinux permissions for portmaster-start
#
if command -V getenforce >/dev/null 2>&1; then
chcon -t bin_t /opt/safing/portmaster/portmaster-start
if command -V chcon >/dev/null 2>&1; then
# chcon -t bin_t -u system_u /opt/safing/portmaster/portmaster-start || :
fi
if command -V semanage >/dev/null 2>&1; then
# semanage fcontext -m -t bin_t -s system_u /opt/safing/portmaster/portmaster-start || :
# restorecon -v /opt/safing/portmaster/portmaster-start || :
fi

#
Expand All @@ -61,21 +67,19 @@ post_install() {
# it is more likely to fail and is thus the last thing we do.
#
if [ "${skip_downloads}" = "True" ]; then
log "Downloading of Portmaster modules skipped!"
log "Please run '/opt/safing/portmaster/portmaster-start --data /opt/safing/portmaster update' manually.\n"
log "info" "Downloading of Portmaster modules skipped!"
log "info" "Please run '/opt/safing/portmaster/portmaster-start --data /opt/safing/portmaster update' manually.\n"
return
fi
log "Downloading portmaster modules. This may take a while ..."
/opt/safing/portmaster/portmaster-start --data /opt/safing/portmaster update --update-agent "${download_agent}" 2>/dev/null >/dev/null || (
log "Failed to download modules"
log "Please run '/opt/safing/portmaster/portmaster-start --data /opt/safing/portmaster update' manually.\n"
log "error" "Failed to download modules"
log "error" "Please run '/opt/safing/portmaster/portmaster-start --data /opt/safing/portmaster update' manually.\n"
)
}

post_upgrade() {
log() {
echo "$@"
}

#
# Prepares systemd support by creating a symlink for the .service file
# and enabling/disabling certain features of our .service unit based on
Expand All @@ -100,7 +104,7 @@ post_upgrade() {
systemctl daemon-reload ||:
fi

log "Configuring portmaster.service to launch at boot"
log "info" "Configuring portmaster.service to launch at boot"
systemctl enable portmaster.service ||:
fi
}
Expand All @@ -120,37 +124,33 @@ post_upgrade() {
#
if [ -d /var/lib/portmaster ]; then
if [ ! -d /opt/safing/portmaster/config.json ]; then
log "Migrating from previous installation at /var/lib/portmaster to /opt/safing/portmaster ..."
log "info" "Migrating from previous installation at /var/lib/portmaster to /opt/safing/portmaster ..."
mv /var/lib/portmaster/databases /opt/safing/portmaster/databases ||:
mv /var/lib/portmaster/config.json /opt/safing/portmaster/config.json ||:
fi
log "Removing previous installation directory at /var/lib/portmaster"
log "info" "Removing previous installation directory at /var/lib/portmaster"
rm -r /var/lib/portmaster 2>/dev/null >&2 ||:
fi

}

pre_remove() {
log() {
echo "$@"
}

# stop the portmaster service and disable it if it's enabled.
if command -V systemctl >/dev/null 2>&1; then
if (systemctl -q is-active portmaster.service); then
log "Stopping portmaster.service"
log "info" "Stopping portmaster.service"
systemctl stop portmaster.service ||:
fi
if (systemctl -q is-enabled portmaster.service); then
log "Disabling portmaster.service to launch at boot"
log "info" "Disabling portmaster.service to launch at boot"
systemctl disable portmaster.service ||:
fi
fi
}

post_remove() {
log() {
echo "$@"
}

rm -rf /opt/safing/portmaster/updates ||:

# file is marked as a ghost on RPM system so it might have
Expand Down
Loading

0 comments on commit de2eaaa

Please sign in to comment.