From 4bf351cbfa12761801d7e3a989768be9a86bb12b Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Tue, 23 Dec 2025 23:23:11 +0800 Subject: [PATCH] refactor: replace BUILD_GUI with BUILD_GUI_HELPER and simplify build options --- .github/workflows/publish-ppa.yaml | 3 +- Makefile | 54 ++++++------------- README.md | 7 ++- packaging/deb/rules.in | 4 +- packaging/pkgbuild/PKGBUILD.in | 2 +- .../rpm/globalprotect-openconnect.spec.in | 2 +- 6 files changed, 24 insertions(+), 48 deletions(-) diff --git a/.github/workflows/publish-ppa.yaml b/.github/workflows/publish-ppa.yaml index bf8497b..feb0d9e 100644 --- a/.github/workflows/publish-ppa.yaml +++ b/.github/workflows/publish-ppa.yaml @@ -74,8 +74,7 @@ jobs: cp -v packaging/deb/compat .build/debian/compat cp -v packaging/deb/postrm .build/debian/postrm - sed -i "s/@OFFLINE@/1/g" .build/debian/rules - sed -i "s/@BUILD_GUI@/1/g" .build/debian/rules + sed -i "s/@BUILD_GUI_HELPER@/1/g" .build/debian/rules # Update the control file with the correct Rust version # sed -i "s/rust-[0-9.]\+-all/rust-${{ inputs.rust }}-all/g" .build/debian/control diff --git a/Makefile b/Makefile index 9c08a8b..7835448 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,5 @@ .SHELLFLAGS += -e -OFFLINE ?= 0 -BUILD_FE ?= 1 INCLUDE_GUI ?= 0 CARGO ?= cargo DISABLE_RUST_TOOLCHAIN ?= 0 @@ -17,11 +15,16 @@ SERIES ?= $(shell lsb_release -cs) PUBLISH ?= 0 # Indicates whether to build the GUI components -BUILD_GUI ?= 1 +BUILD_GUI_HELPER ?= 1 export DEBEMAIL = k3vinyue@gmail.com export DEBFULLNAME = Kevin Yue export SNAPSHOT = $(shell test -f SNAPSHOT && echo "true" || echo "false") +export OFFLINE_BUILD = $(shell test -f OFFLINE_BUILD && echo "1" || echo "0") +# If OFFLINE is not set, use OFFLINE_BUILD +ifndef OFFLINE + OFFLINE = $(OFFLINE_BUILD) +endif ifeq ($(SNAPSHOT), true) RELEASE_TAG = snapshot @@ -48,21 +51,15 @@ clean-tarball: # Create a tarball, include the cargo dependencies if OFFLINE is set to 1 tarball: clean-tarball - if [ $(BUILD_GUI) -eq 1 ] && [ $(BUILD_FE) -eq 1 ]; then \ - echo "Building frontend..."; \ - cd apps/gpgui-helper && pnpm install && pnpm build; \ - fi - - # Remove node_modules to reduce the tarball size - rm -rf apps/gpgui-helper/node_modules - mkdir -p .cargo mkdir -p .build/tarball # If OFFLINE is set to 1, vendor all cargo dependencies + # Generate a OFFLINE_BUILD file to indicate offline build if [ $(OFFLINE) -eq 1 ]; then \ $(CARGO) vendor .vendor > .cargo/config.toml; \ tar -cJf vendor.tar.xz .vendor; \ + touch OFFLINE_BUILD; \ fi @echo "Creating tarball..." @@ -81,21 +78,7 @@ download-gui: echo "Skipping GlobalProtect GUI download (INCLUDE_GUI=0)"; \ fi -build: download-gui build-fe build-rs - -# Install and build the frontend -# If OFFLINE is set to 1, skip it -build-fe: - if [ $(BUILD_GUI) -eq 0 ] || [ $(OFFLINE) -eq 1 ] || [ $(BUILD_FE) -eq 0 ]; then \ - echo "Skipping frontend build (BUILD_GUI=0 or OFFLINE=1 or BUILD_FE=0)"; \ - else \ - cd apps/gpgui-helper && pnpm install && pnpm build; \ - fi - - if [ $(BUILD_GUI) -eq 1 ] && [ ! -d apps/gpgui-helper/dist ]; then \ - echo "Error: frontend build failed"; \ - exit 1; \ - fi +build: download-gui build-rs build-rs: if [ $(OFFLINE) -eq 1 ]; then \ @@ -107,8 +90,8 @@ build-rs: rm -vf rust-toolchain.toml; \ fi - # Only build the GUI components if BUILD_GUI is set to 1 - if [ $(BUILD_GUI) -eq 1 ]; then \ + # Only build the GUI components if BUILD_GUI_HELPER is set to 1 + if [ $(BUILD_GUI_HELPER) -eq 1 ]; then \ $(CARGO) build $(CARGO_BUILD_ARGS) -p gpclient -p gpservice -p gpauth -p gpgui-helper; \ else \ $(CARGO) build $(CARGO_BUILD_ARGS) -p gpclient -p gpservice -p gpauth; \ @@ -127,8 +110,8 @@ install: install -Dm755 target/release/gpauth $(DESTDIR)/usr/bin/gpauth install -Dm755 target/release/gpservice $(DESTDIR)/usr/bin/gpservice - # Install the GUI components if BUILD_GUI is set to 1 - if [ $(BUILD_GUI) -eq 1 ]; then \ + # Install the GUI components if BUILD_GUI_HELPER is set to 1 + if [ $(BUILD_GUI_HELPER) -eq 1 ]; then \ install -Dm755 target/release/gpgui-helper $(DESTDIR)/usr/bin/gpgui-helper; \ fi @@ -187,11 +170,10 @@ init-debian: clean-debian tarball cp -f packaging/deb/postrm .build/deb/$(PKG)/debian/postrm cp -f packaging/deb/compat .build/deb/$(PKG)/debian/compat - sed -i "s/@OFFLINE@/$(OFFLINE)/g" .build/deb/$(PKG)/debian/rules - sed -i "s/@BUILD_GUI@/$(BUILD_GUI)/g" .build/deb/$(PKG)/debian/rules + sed -i "s/@BUILD_GUI_HELPER@/$(BUILD_GUI_HELPER)/g" .build/deb/$(PKG)/debian/rules - # Remove the GUI dependencies if BUILD_GUI is set to 0 - if [ $(BUILD_GUI) -eq 0 ]; then \ + # Remove the GUI dependencies if BUILD_GUI_HELPER is set to 0 + if [ $(BUILD_GUI_HELPER) -eq 0 ]; then \ sed -i "/libsecret-1-0/d" .build/deb/$(PKG)/debian/control; \ sed -i "/libayatana-appindicator3-1/d" .build/deb/$(PKG)/debian/control; \ sed -i "/gnome-keyring/d" .build/deb/$(PKG)/debian/control; \ @@ -242,7 +224,6 @@ init-rpm: clean-rpm 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|@SOURCE@|$(RPM_SOURCE)|g" .build/rpm/globalprotect-openconnect.spec - sed -i "s/@OFFLINE@/$(OFFLINE)/g" .build/rpm/globalprotect-openconnect.spec sed -i "s/@DATE@/$(shell LC_ALL=en.US date "+%a %b %d %Y")/g" .build/rpm/globalprotect-openconnect.spec sed -i "s/@VERSION@/$(VERSION)/g" .build/rpm/globalprotect-openconnect.changes @@ -275,7 +256,6 @@ init-pkgbuild: clean-pkgbuild tarball 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 - sed -i "s/@OFFLINE@/$(OFFLINE)/g" .build/pkgbuild/PKGBUILD pkgbuild: init-pkgbuild cd .build/pkgbuild && makepkg -s --noconfirm @@ -291,7 +271,7 @@ binary: clean-binary tarball mkdir -p .build/binary/$(PKG_NAME)_$(VERSION)/artifacts - make -C .build/binary/${PKG} build OFFLINE=$(OFFLINE) BUILD_FE=0 INCLUDE_GUI=$(INCLUDE_GUI) + make -C .build/binary/${PKG} build INCLUDE_GUI=$(INCLUDE_GUI) make -C .build/binary/${PKG} install DESTDIR=$(PWD)/.build/binary/$(PKG_NAME)_$(VERSION)/artifacts cp packaging/binary/Makefile.in .build/binary/$(PKG_NAME)_$(VERSION)/Makefile diff --git a/README.md b/README.md index aa67bbf..7f4f60c 100644 --- a/README.md +++ b/README.md @@ -319,7 +319,7 @@ This project includes a DevContainer configuration that provides a consistent, r - [Tauri dependencies](https://tauri.app/start/prerequisites/) - `libopenconnect-dev` (or `openconnect-devel` on RPM-based systems) - `pkexec` and `gnome-keyring` (or `pam_kwallet` on KDE) -- `nodejs` and `pnpm` (optional if using pre-built release tarballs with `BUILD_FE=0`) +- `nodejs` and `pnpm` (optional) #### Build Steps @@ -331,7 +331,7 @@ This project includes a DevContainer configuration that provides a consistent, r ```bash tar -xzf globalprotect-openconnect-${version}.tar.gz cd globalprotect-openconnect-${version} - make build BUILD_FE=0 + make build ``` 3. **Install:** @@ -351,8 +351,7 @@ Verify the CLI client is working correctly: ### Build Options -- `BUILD_GUI=0` – Build CLI components only (excludes GUI) -- `BUILD_FE=0` – Skip frontend build (uses pre-built assets) +- `BUILD_GUI_HELPER=0` – Build CLI components only (excludes GUI) - `OFFLINE=1` – Build in offline mode using vendored dependencies ## Frequently Asked Questions diff --git a/packaging/deb/rules.in b/packaging/deb/rules.in index d687954..852308f 100755 --- a/packaging/deb/rules.in +++ b/packaging/deb/rules.in @@ -1,8 +1,6 @@ #!/usr/bin/make -f -export OFFLINE = @OFFLINE@ -export BUILD_FE = 0 -export BUILD_GUI = @BUILD_GUI@ +export BUILD_GUI_HELPER = @BUILD_GUI_HELPER@ export DISABLE_RUST_TOOLCHAIN = 0 export PATH := /usr/lib/rust-1.85/bin:$(PATH) diff --git a/packaging/pkgbuild/PKGBUILD.in b/packaging/pkgbuild/PKGBUILD.in index 1ae6b21..c0fe53d 100644 --- a/packaging/pkgbuild/PKGBUILD.in +++ b/packaging/pkgbuild/PKGBUILD.in @@ -27,7 +27,7 @@ build() { # Must unset the CFLAGS, otherwise the build fails unset CFLAGS - make build OFFLINE=@OFFLINE@ BUILD_FE=0 + make build } package() { diff --git a/packaging/rpm/globalprotect-openconnect.spec.in b/packaging/rpm/globalprotect-openconnect.spec.in index 0ad50d4..01bc407 100644 --- a/packaging/rpm/globalprotect-openconnect.spec.in +++ b/packaging/rpm/globalprotect-openconnect.spec.in @@ -48,7 +48,7 @@ rm -f %{_bindir}/gpgui %build # The injected RUSTFLAGS could fail the build unset RUSTFLAGS -make build OFFLINE=@OFFLINE@ BUILD_FE=0 +make build %install %make_install