Update build

This commit is contained in:
Kevin Yue 2024-02-25 17:30:41 +08:00
parent 3daad748ae
commit e8a64539aa
6 changed files with 138 additions and 51 deletions

View File

@ -34,7 +34,8 @@ jobs:
with: with:
name: artifact-tarball name: artifact-tarball
path: | path: |
globalprotect-openconnect-*.tar.gz gp/.build/tarball/*.tar.gz
deb: deb:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [tarball] needs: [tarball]
@ -50,12 +51,13 @@ jobs:
name: artifact-tarball name: artifact-tarball
- name: Build DEB package - name: Build DEB package
run: | run: |
tar -xzf globalprotect-openconnect-*.tar.gz tar -xzf *.tar.gz
cd globalprotect-openconnect-* cd globalprotect-openconnect-*
make deb make deb
- name: Install DEB package - name: Install DEB package
run: | run: |
sudo dpkg -i globalprotect-openconnect_*.deb cd globalprotect-openconnect-*/
sudo dpkg -i .build/deb/*.deb
gpclient --version gpclient --version
gpservice --version gpservice --version
@ -66,7 +68,7 @@ jobs:
with: with:
name: artifact-deb name: artifact-deb
path: | path: |
globalprotect-openconnect_*.deb globalprotect-openconnect-*/.build/deb/*.deb
rpm: rpm:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -104,6 +106,7 @@ jobs:
path: | path: |
globalprotect-openconnect-*/.build/rpm/*.rpm globalprotect-openconnect-*/.build/rpm/*.rpm
# Include arm64 if ref is a tag # Include arm64 if ref is a tag
# setup-matrix: # setup-matrix:
# runs-on: ubuntu-latest # runs-on: ubuntu-latest

137
Makefile
View File

@ -7,6 +7,7 @@ PPA_REVISION ?= 1
PKG_NAME = globalprotect-openconnect PKG_NAME = globalprotect-openconnect
PKG = $(PKG_NAME)-$(VERSION) PKG = $(PKG_NAME)-$(VERSION)
SERIES ?= $(shell lsb_release -cs) SERIES ?= $(shell lsb_release -cs)
PUBLISH ?= 0
export DEBEMAIL = k3vinyue@gmail.com export DEBEMAIL = k3vinyue@gmail.com
export DEBFULLNAME = Kevin Yue export DEBFULLNAME = Kevin Yue
@ -22,21 +23,27 @@ default: build
version: version:
@echo $(VERSION) @echo $(VERSION)
# Generate a vendor tarball and a .cargo/config.toml file clean-tarball:
cargo-vendor: rm -rf .build/tarball
mkdir -p .cargo rm -rf .vendor
rm -rf vendor.tar.xz
rm -rf .cargo
$(CARGO) vendor .vendor > .cargo/config.toml # Create a tarball, include the cargo dependencies if OFFLINE is set to 1
tar -cJf vendor.tar.xz .vendor tarball: clean-tarball build-fe
# Remove node_modules to reduce the tarball size
tarball: clean clean-tarball build-fe cargo-vendor
rm -rf apps/gpgui-helper/node_modules rm -rf apps/gpgui-helper/node_modules
tar --transform 's,^,${PKG}/,' -czf ../${PKG}.tar.gz * .cargo mkdir -p .cargo
mkdir -p .build/tarball
# Extract the vendor tarball to the .vendor directory if it exists # If OFFLINE is set to 1, vendor all cargo dependencies
extract-vendor: if [ $(OFFLINE) -eq 1 ]; then \
if [ -f vendor.tar.xz ]; then tar -xJf vendor.tar.xz; fi $(CARGO) vendor .vendor > .cargo/config.toml; \
tar -cJf vendor.tar.xz .vendor; \
fi
tar --exclude .vendor --exclude target --transform 's,^,${PKG}/,' -czf .build/tarball/${PKG}.tar.gz * .cargo
build: build-fe build-rs build: build-fe build-rs
@ -52,9 +59,13 @@ build-fe:
exit 1; \ exit 1; \
fi fi
build-rs: extract-vendor build-rs:
$(CARGO) build $(CARGO_BUILD_ARGS) -p gpauth if [ $(OFFLINE) -eq 1 ]; then \
# $(CARGO) build $(CARGO_BUILD_ARGS) -p gpgui-helper --features "tauri/custom-protocol" tar -xJf vendor.tar.xz; \
fi
$(CARGO) build $(CARGO_BUILD_ARGS) -p gpclient -p gpservice -p gpauth
$(CARGO) build $(CARGO_BUILD_ARGS) -p gpgui-helper --features "tauri/custom-protocol"
clean: clean:
$(CARGO) clean $(CARGO) clean
@ -62,11 +73,9 @@ clean:
rm -rf .vendor rm -rf .vendor
rm -rf apps/gpgui-helper/node_modules rm -rf apps/gpgui-helper/node_modules
clean-tarball:
rm -rf vendor.tar.xz
rm -rf ../$(PKG).tar.gz
install: install:
@echo "Installing $(PKG_NAME) $(VERSION)"
install -Dm755 target/release/gpclient $(DESTDIR)/usr/bin/gpclient install -Dm755 target/release/gpclient $(DESTDIR)/usr/bin/gpclient
install -Dm755 target/release/gpauth $(DESTDIR)/usr/bin/gpauth install -Dm755 target/release/gpauth $(DESTDIR)/usr/bin/gpauth
install -Dm755 target/release/gpservice $(DESTDIR)/usr/bin/gpservice install -Dm755 target/release/gpservice $(DESTDIR)/usr/bin/gpservice
@ -80,10 +89,13 @@ install:
install -Dm644 packaging/files/usr/share/polkit-1/actions/com.yuezk.gpgui.policy $(DESTDIR)/usr/share/polkit-1/actions/com.yuezk.gpgui.policy install -Dm644 packaging/files/usr/share/polkit-1/actions/com.yuezk.gpgui.policy $(DESTDIR)/usr/share/polkit-1/actions/com.yuezk.gpgui.policy
uninstall: uninstall:
@echo "Uninstalling $(PKG_NAME) $(VERSION)"
rm -f $(DESTDIR)/usr/bin/gpclient rm -f $(DESTDIR)/usr/bin/gpclient
rm -f $(DESTDIR)/usr/bin/gpauth rm -f $(DESTDIR)/usr/bin/gpauth
rm -f $(DESTDIR)/usr/bin/gpservice rm -f $(DESTDIR)/usr/bin/gpservice
rm -f $(DESTDIR)/usr/bin/gpgui-helper rm -f $(DESTDIR)/usr/bin/gpgui-helper
rm -f $(DESTDIR)/usr/bin/gpgui
rm -f $(DESTDIR)/usr/share/applications/gpgui.desktop 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/scalable/apps/gpgui.svg
@ -92,25 +104,45 @@ uninstall:
rm -f $(DESTDIR)/usr/share/icons/hicolor/256x256@2/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 rm -f $(DESTDIR)/usr/share/polkit-1/actions/com.yuezk.gpgui.policy
init-debian: clean-debian:
rm -rf .vendor rm -rf .build/deb
rm -rf debian
# Generate the debian package structure, without the changelog
init-debian: clean-debian tarball
mkdir -p .build/deb
cp .build/tarball/${PKG}.tar.gz .build/deb
tar -xzf .build/deb/${PKG}.tar.gz
cd .build/deb/${PKG}
debmake debmake
cp -f packaging/deb/control.in debian/control cp -f packaging/deb/control.in debian/control
cp -f packaging/deb/rules debian/rules cp -f packaging/deb/rules debian/rules
sed -i "s/@OFFLINE@/$(OFFLINE)/g" debian/rules
rm -f debian/changelog rm -f debian/changelog
deb: init-debian deb: init-debian
cd .build/deb/${PKG}
# Remove the rust build depdency from the control file
sed -i "s/@RUST@//g" debian/control sed -i "s/@RUST@//g" debian/control
dch --create --distribution unstable --package $(PKG_NAME) --newversion $(VERSION)-$(REVISION) "Bugfix and improvements." dch --create --distribution unstable --package $(PKG_NAME) --newversion $(VERSION)-$(REVISION) "Bugfix and improvements."
debuild --preserve-env -e PATH -us -uc -b debuild --preserve-env -e PATH -us -uc -b
# Usage: make ppa SERIES=focal check-ppa:
ppa: init-debian if [ $(OFFLINE) -eq 0 ]; then \
@echo "Error: ppa build requires offline mode (OFFLINE=1)"; \
fi
# Usage: make ppa SERIES=focal OFFLINE=1 PUBLISH=1
ppa: check-ppa init-debian
cd .build/deb/${PKG}
sed -i "s/@RUST@/rust-all(>=1.70)/g" debian/control sed -i "s/@RUST@/rust-all(>=1.70)/g" debian/control
$(eval SERIES_VER = $(shell distro-info --series $(SERIES) -r | cut -d' ' -f1)) $(eval SERIES_VER = $(shell distro-info --series $(SERIES) -r | cut -d' ' -f1))
@ -120,12 +152,17 @@ ppa: init-debian
echo "y" | debuild -e PATH -S -sa -k"$(GPG_KEY_ID)" -p"gpg --batch --passphrase $(GPG_KEY_PASS) --pinentry-mode loopback" echo "y" | debuild -e PATH -S -sa -k"$(GPG_KEY_ID)" -p"gpg --batch --passphrase $(GPG_KEY_PASS) --pinentry-mode loopback"
publish-ppa: ppa if [ $(PUBLISH) -eq 1 ]; then \
dput ppa:yuezk/globalprotect-openconnect ../*.changes dput ppa:yuezk/globalprotect-openconnect ../*.changes; \
else
@echo "Skipping ppa publish (PUBLISH=0)"
fi
clean-rpm:
rm -rf .build/rpm
# Generate RPM sepc file # Generate RPM sepc file
init-rpm: init-rpm: clean-rpm
rm -rf .build/rpm
mkdir -p .build/rpm mkdir -p .build/rpm
cp packaging/rpm/globalprotect-openconnect.spec.in .build/rpm/globalprotect-openconnect.spec cp packaging/rpm/globalprotect-openconnect.spec.in .build/rpm/globalprotect-openconnect.spec
@ -133,26 +170,20 @@ init-rpm:
sed -i "s/@VERSION@/$(VERSION)/g" .build/rpm/globalprotect-openconnect.spec 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/@REVISION@/$(REVISION)/g" .build/rpm/globalprotect-openconnect.spec
sed -i "s/@OFFLINE@/$(OFFLINE)/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/@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/@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 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 tarball
rpm: init-rpm
if [ ! -f ../$(PKG).tar.gz ]; then \
echo "Missing ../$(PKG).tar.gz"; \
exit 1; \
fi
rm -rf $(HOME)/rpmbuild rm -rf $(HOME)/rpmbuild
rpmdev-setuptree rpmdev-setuptree
cp ../$(PKG).tar.gz $(HOME)/rpmbuild/SOURCES/$(PKG_NAME).tar.gz cp .build/tarball/${PKG}.tar.gz $(HOME)/rpmbuild/SOURCES
rpmbuild -ba .build/rpm/globalprotect-openconnect.spec rpmbuild -ba .build/rpm/globalprotect-openconnect.spec
# Copy RPM package # Copy RPM package from build directory
cp $(HOME)/rpmbuild/RPMS/$(shell uname -m)/$(PKG_NAME)*.rpm .build/rpm cp $(HOME)/rpmbuild/RPMS/$(shell uname -m)/$(PKG_NAME)*.rpm .build/rpm
# Copy the SRPM only for x86_64. # Copy the SRPM only for x86_64.
@ -160,20 +191,38 @@ rpm: init-rpm
cp $(HOME)/rpmbuild/SRPMS/$(PKG_NAME)*.rpm .build/rpm; \ cp $(HOME)/rpmbuild/SRPMS/$(PKG_NAME)*.rpm .build/rpm; \
fi fi
init-pkgbuild: clean-pkgbuild:
rm -rf .build/pkgbuild rm -rf .build/pkgbuild
init-pkgbuild: clean-pkgbuild tarball
mkdir -p .build/pkgbuild mkdir -p .build/pkgbuild
if [ ! -f ../$(PKG).tar.gz ]; then \ cp .build/tarball/${PKG}.tar.gz .build/pkgbuild
echo "Missing ../$(PKG).tar.gz"; \
exit 1; \
fi
cp ../$(PKG).tar.gz .build/pkgbuild
cp packaging/pkgbuild/PKGBUILD.in .build/pkgbuild/PKGBUILD cp packaging/pkgbuild/PKGBUILD.in .build/pkgbuild/PKGBUILD
sed -i "s/@PKG_NAME@/$(PKG_NAME)/g" .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/@VERSION@/$(VERSION)/g" .build/pkgbuild/PKGBUILD
sed -i "s/@REVISION@/$(REVISION)/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 pkgbuild: init-pkgbuild
cd .build/pkgbuild && makepkg -s --noconfirm cd .build/pkgbuild && makepkg -s --noconfirm
clean-binary:
rm -rf .build/binary
binary: clean-binary tarball
mkdir -p .build/binary
cp .build/tarball/${PKG}.tar.gz .build/binary
tar -xzf .build/binary/${PKG}.tar.gz -C .build/binary
mkdir -p .build/binary/$(PKG_NAME)_$(VERSION)_$(shell uname -m)/artifacts
make -C .build/binary/${PKG} build OFFLINE=$(OFFLINE)
make -C .build/binary/${PKG} install DESTDIR=$(PWD)/.build/binary/$(PKG_NAME)_$(VERSION)_$(shell uname -m)/artifacts
cp packaging/binary/Makefile.in .build/binary/$(PKG_NAME)_$(VERSION)_$(shell uname -m)/Makefile
# Create a tarball for the binary package
tar -czf .build/binary/$(PKG_NAME)_$(VERSION)_$(shell uname -m).bin.tar.gz -C .build/binary $(PKG_NAME)_$(VERSION)_$(shell uname -m)

View File

@ -0,0 +1,30 @@
install:
@echo "===> Installing..."
install -Dm755 artifacts/usr/bin/gpclient $(DESTDIR)/usr/bin/gpclient
install -Dm755 artifacts/usr/bin/gpservice $(DESTDIR)/usr/bin/gpservice
install -Dm755 artifacts/usr/bin/gpauth $(DESTDIR)/usr/bin/gpauth
install -Dm755 artifacts/usr/bin/gpgui-helper $(DESTDIR)/usr/bin/gpgui-helper
install -Dm644 artifacts/usr/share/applications/gpgui.desktop $(DESTDIR)/usr/share/applications/gpgui.desktop
install -Dm644 artifacts/usr/share/icons/hicolor/scalable/apps/gpgui.svg $(DESTDIR)/usr/share/icons/hicolor/scalable/apps/gpgui.svg
install -Dm644 artifacts/usr/share/icons/hicolor/32x32/apps/gpgui.png $(DESTDIR)/usr/share/icons/hicolor/32x32/apps/gpgui.png
install -Dm644 artifacts/usr/share/icons/hicolor/128x128/apps/gpgui.png $(DESTDIR)/usr/share/icons/hicolor/128x128/apps/gpgui.png
install -Dm644 artifacts/usr/share/icons/hicolor/256x256@2/apps/gpgui.png $(DESTDIR)/usr/share/icons/hicolor/256x256@2/apps/gpgui.png
install -Dm644 artifacts/usr/share/polkit-1/actions/com.yuezk.gpgui.policy $(DESTDIR)/usr/share/polkit-1/actions/com.yuezk.gpgui.policy
uninstall:
@echo "===> Uninstalling from $(DESTDIR)..."
rm -f $(DESTDIR)/usr/bin/gpclient
rm -f $(DESTDIR)/usr/bin/gpservice
rm -f $(DESTDIR)/usr/bin/gpauth
rm -f $(DESTDIR)/usr/bin/gpgui-helper
rm -f $(DESTDIR)/usr/bin/gpgui
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

View File

@ -1,6 +1,6 @@
#!/usr/bin/make -f #!/usr/bin/make -f
export OFFLINE = 1 export OFFLINE = @OFFLINE@
%: %:
dh $@ dh $@

View File

@ -21,10 +21,15 @@ options=('!strip')
build() { build() {
cd "$pkgname-$pkgver" cd "$pkgname-$pkgver"
make build OFFLINE=1
# Must unset the CFLAGS, otherwise the build fails
unset CFLAGS
make build OFFLINE=@OFFLINE@
} }
package() { package() {
cd "$pkgname-$pkgver" cd "$pkgname-$pkgver"
make install DESTDIR="$pkgdir" make install DESTDIR="$pkgdir"
} }

View File

@ -35,7 +35,7 @@ A GUI for GlobalProtect VPN, based on OpenConnect, supports the SSO authenticati
%setup %setup
%build %build
make build OFFLINE=1 make build OFFLINE=@OFFLINE@
%install %install
%make_install %make_install