OFFLINE ?= 0 CARGO ?= cargo VERSION = $(shell $(CARGO) metadata --no-deps --format-version 1 | jq -r '.packages[0].version') REVISION ?= 1 PPA_REVISION ?= 1 PKG_NAME = globalprotect-openconnect PKG = $(PKG_NAME)-$(VERSION) SERIES ?= $(shell lsb_release -cs) export DEBEMAIL = k3vinyue@gmail.com export DEBFULLNAME = Kevin Yue CARGO_BUILD_ARGS = --release ifeq ($(OFFLINE), 1) CARGO_BUILD_ARGS += --frozen endif default: build version: @echo $(VERSION) # Generate a vendor tarball and a .cargo/config.toml file cargo-vendor: mkdir -p .cargo $(CARGO) vendor .vendor > .cargo/config.toml tar -cJf vendor.tar.xz .vendor tarball: clean clean-tarball build-fe cargo-vendor rm -rf apps/gpgui-helper/node_modules tar --transform 's,^,${PKG}/,' -czf ../${PKG}.tar.gz * .cargo # Extract the vendor tarball to the .vendor directory if it exists extract-vendor: if [ -f vendor.tar.xz ]; then tar -xJf vendor.tar.xz; fi build: build-fe build-rs # Install and build the frontend # If OFFLINE is set to 1, skip it build-fe: if [ $(OFFLINE) -eq 0 ]; then \ cd apps/gpgui-helper && pnpm install && pnpm build; \ fi if [ ! -d apps/gpgui-helper/dist ]; then \ echo "Error: frontend build failed"; \ exit 1; \ fi build-rs: extract-vendor $(CARGO) build $(CARGO_BUILD_ARGS) -p gpauth # $(CARGO) build $(CARGO_BUILD_ARGS) -p gpgui-helper --features "tauri/custom-protocol" clean: $(CARGO) clean rm -rf .build rm -rf .vendor rm -rf apps/gpgui-helper/node_modules clean-tarball: rm -rf vendor.tar.xz rm -rf ../$(PKG).tar.gz install: install -Dm755 target/release/gpclient $(DESTDIR)/usr/bin/gpclient install -Dm755 target/release/gpauth $(DESTDIR)/usr/bin/gpauth install -Dm755 target/release/gpservice $(DESTDIR)/usr/bin/gpservice install -Dm755 target/release/gpgui-helper $(DESTDIR)/usr/bin/gpgui-helper install -Dm644 packaging/files/usr/share/applications/gpgui.desktop $(DESTDIR)/usr/share/applications/gpgui.desktop install -Dm644 packaging/files/usr/share/icons/hicolor/scalable/apps/gpgui.svg $(DESTDIR)/usr/share/icons/hicolor/scalable/apps/gpgui.svg install -Dm644 packaging/files/usr/share/icons/hicolor/32x32/apps/gpgui.png $(DESTDIR)/usr/share/icons/hicolor/32x32/apps/gpgui.png install -Dm644 packaging/files/usr/share/icons/hicolor/128x128/apps/gpgui.png $(DESTDIR)/usr/share/icons/hicolor/128x128/apps/gpgui.png install -Dm644 packaging/files/usr/share/icons/hicolor/256x256@2/apps/gpgui.png $(DESTDIR)/usr/share/icons/hicolor/256x256@2/apps/gpgui.png install -Dm644 packaging/files/usr/share/polkit-1/actions/com.yuezk.gpgui.policy $(DESTDIR)/usr/share/polkit-1/actions/com.yuezk.gpgui.policy uninstall: rm -f $(DESTDIR)/usr/bin/gpclient rm -f $(DESTDIR)/usr/bin/gpauth rm -f $(DESTDIR)/usr/bin/gpservice rm -f $(DESTDIR)/usr/bin/gpgui-helper rm -f $(DESTDIR)/usr/share/applications/gpgui.desktop rm -f $(DESTDIR)/usr/share/icons/hicolor/scalable/apps/gpgui.svg rm -f $(DESTDIR)/usr/share/icons/hicolor/32x32/apps/gpgui.png rm -f $(DESTDIR)/usr/share/icons/hicolor/128x128/apps/gpgui.png rm -f $(DESTDIR)/usr/share/icons/hicolor/256x256@2/apps/gpgui.png rm -f $(DESTDIR)/usr/share/polkit-1/actions/com.yuezk.gpgui.policy init-debian: rm -rf .vendor rm -rf debian debmake cp -f packaging/deb/control.in debian/control cp -f packaging/deb/rules debian/rules rm -f debian/changelog deb: init-debian sed -i "s/@RUST@//g" debian/control dch --create --distribution unstable --package $(PKG_NAME) --newversion $(VERSION)-$(REVISION) "Bugfix and improvements." debuild --preserve-env -e PATH -us -uc -b # Usage: make ppa SERIES=focal ppa: init-debian sed -i "s/@RUST@/rust-all(>=1.70)/g" debian/control $(eval SERIES_VER = $(shell distro-info --series $(SERIES) -r | cut -d' ' -f1)) @echo "Building for $(SERIES) $(SERIES_VER)" dch --create --distribution $(SERIES) --package $(PKG_NAME) --newversion $(VERSION)-$(REVISION)ppa$(PPA_REVISION)~ubuntu$(SERIES_VER) "Bugfix and improvements." echo "y" | debuild -e PATH -S -sa -k"$(GPG_KEY_ID)" -p"gpg --batch --passphrase $(GPG_KEY_PASS) --pinentry-mode loopback" publish-ppa: ppa dput ppa:yuezk/globalprotect-openconnect ../*.changes # Generate RPM sepc file init-rpm: rm -rf .build/rpm mkdir -p .build/rpm cp packaging/rpm/globalprotect-openconnect.spec.in .build/rpm/globalprotect-openconnect.spec cp packaging/rpm/globalprotect-openconnect.changes.in .build/rpm/globalprotect-openconnect.changes sed -i "s/@VERSION@/$(VERSION)/g" .build/rpm/globalprotect-openconnect.spec sed -i "s/@REVISION@/$(REVISION)/g" .build/rpm/globalprotect-openconnect.spec sed -i "s/@DATE@/$(shell date "+%a %b %d %Y")/g" .build/rpm/globalprotect-openconnect.spec sed -i "s/@VERSION@/$(VERSION)/g" .build/rpm/globalprotect-openconnect.changes sed -i "s/@DATE@/$(shell LC_ALL=en.US date -u "+%a %b %e %T %Z %Y")/g" .build/rpm/globalprotect-openconnect.changes # Ensure ../globalprotect-openconnect-*.tar.gz exists. rpm: init-rpm if [ ! -f ../$(PKG).tar.gz ]; then \ echo "Missing ../$(PKG).tar.gz"; \ exit 1; \ fi rm -rf $(HOME)/rpmbuild rpmdev-setuptree cp ../$(PKG).tar.gz $(HOME)/rpmbuild/SOURCES/$(PKG_NAME).tar.gz rpmbuild -ba .build/rpm/globalprotect-openconnect.spec # Copy RPM package cp $(HOME)/rpmbuild/RPMS/$(shell uname -m)/$(PKG_NAME)*.rpm .build/rpm # Copy the SRPM only for x86_64. if [ "$(shell uname -m)" = "x86_64" ]; then \ cp $(HOME)/rpmbuild/SRPMS/$(PKG_NAME)*.rpm .build/rpm; \ fi init-pkgbuild: rm -rf .build/pkgbuild mkdir -p .build/pkgbuild if [ ! -f ../$(PKG).tar.gz ]; then \ echo "Missing ../$(PKG).tar.gz"; \ exit 1; \ fi cp ../$(PKG).tar.gz .build/pkgbuild cp packaging/pkgbuild/PKGBUILD.in .build/pkgbuild/PKGBUILD sed -i "s/@PKG_NAME@/$(PKG_NAME)/g" .build/pkgbuild/PKGBUILD sed -i "s/@VERSION@/$(VERSION)/g" .build/pkgbuild/PKGBUILD sed -i "s/@REVISION@/$(REVISION)/g" .build/pkgbuild/PKGBUILD pkgbuild: init-pkgbuild cd .build/pkgbuild && makepkg -s --noconfirm