From d5f06cc47dcdfa4b61219ffbf280157a312e0efa Mon Sep 17 00:00:00 2001 From: "Kali Kaneko (leap communications)" Date: Mon, 29 Jul 2019 18:06:53 +0200 Subject: [pkg] debian template --- branding/scripts/generate-debian.py | 43 ++++++++++++++++++++++++++ branding/templates/debian/app.desktop-template | 14 +++++++++ branding/templates/debian/changelog-template | 5 +++ branding/templates/debian/compat | 1 + branding/templates/debian/control-template | 23 ++++++++++++++ branding/templates/debian/copyright | 25 +++++++++++++++ branding/templates/debian/generate.py | 32 +++++++++++++++++++ branding/templates/debian/rules-template | 37 ++++++++++++++++++++++ branding/templates/debian/source/format | 1 + branding/templates/makefile/Makefile | 36 +++++++++------------ 10 files changed, 195 insertions(+), 22 deletions(-) create mode 100755 branding/scripts/generate-debian.py create mode 100644 branding/templates/debian/app.desktop-template create mode 100644 branding/templates/debian/changelog-template create mode 100644 branding/templates/debian/compat create mode 100644 branding/templates/debian/control-template create mode 100644 branding/templates/debian/copyright create mode 100755 branding/templates/debian/generate.py create mode 100755 branding/templates/debian/rules-template create mode 100644 branding/templates/debian/source/format (limited to 'branding') diff --git a/branding/scripts/generate-debian.py b/branding/scripts/generate-debian.py new file mode 100755 index 0000000..56e533b --- /dev/null +++ b/branding/scripts/generate-debian.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 + +import json +import os +import sys + +import configparser + +from provider import getDefaultProvider +from provider import getProviderData + + +VERSION = os.environ.get('VERSION', 'unknown') +SCRIPT = 'generate-debian.py' + + +def writeOutput(data, outfile): + + with open(outfile, 'w') as outf: + outf.write(json.dumps(data)) + + +if __name__ == "__main__": + env_provider_conf = os.environ.get('PROVIDER_CONFIG') + if env_provider_conf: + if os.path.isfile(env_provider_conf): + print("[+] Overriding provider config per " + "PROVIDER_CONFIG variable") + configfile = env_provider_conf + + config = configparser.ConfigParser() + config.read(configfile) + provider = getDefaultProvider(config) + data = getProviderData(provider, config) + + if len(sys.argv) != 2: + print('Usage: {} '.format(SCRIPT)) + sys.exit(1) + + outputf = sys.argv[1] + + data['version'] = VERSION + writeOutput(data, outputf) diff --git a/branding/templates/debian/app.desktop-template b/branding/templates/debian/app.desktop-template new file mode 100644 index 0000000..eb831f7 --- /dev/null +++ b/branding/templates/debian/app.desktop-template @@ -0,0 +1,14 @@ +[Desktop Entry] +Version=1.0 +Type=Application +Name=${applicationName} +Comment=Easy VPN by ${name} +Comment[es]=VPN Facil de ${name} +Comment[de]=Easy VPN by ${name} +Exec=${binaryName} %U +Terminal=false +Icon=riseupvpn +Categories=Network;Application; +StartupNotify=true +X-AppInstall-Package=${binaryName} +Keywords=encryption;vpn;${name};leap diff --git a/branding/templates/debian/changelog-template b/branding/templates/debian/changelog-template new file mode 100644 index 0000000..7e44a93 --- /dev/null +++ b/branding/templates/debian/changelog-template @@ -0,0 +1,5 @@ +${binaryName} (${version}) unstable; urgency=medium + + * Initial package. + + -- LEAP Encryption Access Project Mon, 29 Jul 2019 10:00:00 +0100 diff --git a/branding/templates/debian/compat b/branding/templates/debian/compat new file mode 100644 index 0000000..f599e28 --- /dev/null +++ b/branding/templates/debian/compat @@ -0,0 +1 @@ +10 diff --git a/branding/templates/debian/control-template b/branding/templates/debian/control-template new file mode 100644 index 0000000..aaec638 --- /dev/null +++ b/branding/templates/debian/control-template @@ -0,0 +1,23 @@ +Source: ${binaryName} +Section: net +Priority: extra +Maintainer: LEAP Encryption Access Project +Build-Depends: debhelper (>= 10.0.0), dh-golang, golang-go (> 2:1.9), + golang-golang-x-text-dev (>= 0.3.0-2), + libgtk-3-dev, libappindicator3-dev, pkg-config +Standards-Version: 3.9.8 + +Package: ${binaryName} +Architecture: any +Multi-Arch: foreign +Depends: ${misc:Depends}, + openvpn, libgtk-3-0, libappindicator3-1, + policykit-1-gnome | polkit-1-auth-agent, + python3, +Enhances: openvpn +Description: Easy, fast, and secure VPN service from ${name}. + This package is a custom build of the new Bitmask VPN client, preconfigured + to use the ${providerURL} provider. + . + The service does not require a user account, keep logs, or track you in any + way. The service is paid for entirely by donations from users. diff --git a/branding/templates/debian/copyright b/branding/templates/debian/copyright new file mode 100644 index 0000000..e2a1670 --- /dev/null +++ b/branding/templates/debian/copyright @@ -0,0 +1,25 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: auth-pam +Source: + +Files: * +Copyright: 2018 LEAP Encryption Access Project +License: GPLv3 + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + . + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + . + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/branding/templates/debian/generate.py b/branding/templates/debian/generate.py new file mode 100755 index 0000000..141d8f9 --- /dev/null +++ b/branding/templates/debian/generate.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 +""" +generate.py + +Generate a snap package for a given provider. +""" + +import json +import os +from string import Template + + +TEMPLATES = ('app.desktop', 'changelog', 'control', 'rules') + + +here = os.path.split(os.path.realpath(__file__))[0] +data = json.load(open(os.path.join(here, 'data.json'))) + + +def write_from_template(target): + template = Template(open(target + '-template').read()) + + with open(target, 'w') as output: + output.write(template.safe_substitute(data)) + + +for target in TEMPLATES: + write_from_template(target) + + +print("[+] Debian files written to {path}".format( + path=os.path.abspath(here))) diff --git a/branding/templates/debian/rules-template b/branding/templates/debian/rules-template new file mode 100755 index 0000000..686cdd7 --- /dev/null +++ b/branding/templates/debian/rules-template @@ -0,0 +1,37 @@ +#!/usr/bin/make -f +# -*- makefile -*- + +# This has to be exported to make some magic below work. +export DH_OPTIONS + +export DH_GOPKG = 0xacab.org/leap/bitmask-vpn +export DH_GOLANG_EXCLUDES = vendor + +# TODO get the static version that gen_pkg generated instead?? +VERSION = debian-$(shell git describe --tags --always) +APPNAME = ${binaryName} + +%: + dh $@ --with golang --buildsystem golang + +override_dh_auto_test: + +override_dh_auto_build: + rm -rf src/0xacab.org/leap/bitmask-vpn/tools/transifex + rm -rf obj-$(DEB_BUILD_GNU_TYPE)/src/0xacab.org/leap/bitmask-vpn/tools/transifex + rm -rf tools + dh_auto_build -O--buildsystem=golang -- -ldflags "-X main.version=$(VERSION)" + +override_dh_install: + mkdir -p $(CURDIR)/debian/${APPNAME}/usr/sbin + cp $(CURDIR)/helpers/bitmask-root $(CURDIR)/debian/${binaryName}/usr/sbin/ + mkdir -p $(CURDIR)/debian/${APPNAME}/usr/share/polkit-1/actions + cp $(CURDIR)/helpers/se.leap.bitmask.policy $(CURDIR)/debian/${APPNAME}/usr/share/polkit-1/actions + rm -fr $(CURDIR)/debian/${APPNAME}/usr/share/gocode + strip $(CURDIR)/debian/${APPNAME}/usr/bin/bitmask-vpn + rm $(CURDIR)/debian/${APPNAME}/usr/bin/bitmask-helper + rm $(CURDIR)/debian/${APPNAME}/usr/bin/bitmask-connect + mv $(CURDIR)/debian/${APPNAME}/usr/bin/bitmask-vpn $(CURDIR)/debian/${APPNAME}/usr/bin/${APPNAME} + mkdir -p $(CURDIR)/debian/${APPNAME}/usr/share/${APPNAME} + cp $(CURDIR)/debian/icons/scalable/icon.svg $(CURDIR)/debian/${APPNAME}/usr/share/${APPNAME}/icon.svg + dh_install diff --git a/branding/templates/debian/source/format b/branding/templates/debian/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/branding/templates/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/branding/templates/makefile/Makefile b/branding/templates/makefile/Makefile index c8ade84..c66880c 100755 --- a/branding/templates/makefile/Makefile +++ b/branding/templates/makefile/Makefile @@ -15,17 +15,8 @@ BUILD_RELEASE?=no WIN_CERT_PATH?=z:\leap\LEAP.pfx WIN_CERT_PASS?= OSX_CERT = "Developer ID Installer: LEAP Encryption Access Project" +DEB_VERSION = $(shell echo ${VERSION} | cut -d '-' -f 1,2) -TGZ_PATH = $(shell pwd)/dist/$(BINNAME)-$(VERSION) -tgz: - mkdir -p $(TGZ_PATH) - git -C `go env GOPATH`/src/$(SYSTRAY) archive HEAD | tar -x -C $(TGZ_PATH) - mkdir $(TGZ_PATH)/helpers - wget -O $(TGZ_PATH)/helpers/bitmask-root https://0xacab.org/leap/bitmask-dev/raw/master/src/leap/bitmask/vpn/helpers/linux/bitmask-root - chmod +x $(TGZ_PATH)/helpers/bitmask-root - wget -O $(TGZ_PATH)/helpers/se.leap.bitmask.policy https://0xacab.org/leap/bitmask-dev/raw/master/src/leap/bitmask/vpn/helpers/linux/se.leap.bitmask.policy - cd dist; tar cvzf $(BINNAME)-$(VERSION).tgz $(BINNAME)-$(VERSION) - rm -r $(TGZ_PATH) # ----------------------------------------------------------------------------- # Windows @@ -54,7 +45,7 @@ openvpn_cross_win: # TODO no need to build systray in windows, but move this powershell hack to main build makefile #powershell '$$gopath=go env GOPATH;$$version=git -C $$gopath/src/$(SYSTRAY) describe --tags; go build -ldflags "-H windowsgui -s -w -X main.version=$$version" -o $(STAGING)/$(SYSTRAY_BIN).exe $(SYSTRAY)/cmd/bitmask-vpn' -package_win: staging\nssm.exe helper_win systray_win +pkg_win: staging\nssm.exe helper_win systray_win # I assume you did bootstrap openvpn_win manually already. echo "[+] building windows" "C:\Program Files (x86)\NSIS\makensis.exe" windows/$(APPNAME)-installer.nsi @@ -75,7 +66,7 @@ build_cross_win: staging/nssm.exe # OSX # ----------------------------------------------------------------------------- -package_osx: +pkg_osx: echo "[+] Building osx package..." osx/quickpkg --output dist/$(APPNAME)-$(VERSION)_unsigned.pkg --scripts osx/scripts/ dist/$(APPNAME).app/ @if [ $(BUILD_RELEASE) = no ]; then\ @@ -89,27 +80,28 @@ package_osx: # Linux # ----------------------------------------------------------------------------- -build_snap: +pkg_snap: echo "[+] building snap..." snapcraft build snapcraft snap mkdir -p dist mv $(BINNAME)* dist/ -build_deb: tgz - echo "[+] building deb..." +pkg_deb: + echo "[+] building debian package version" ${DEB_VERSION} @if [ $(BUILD_RELEASE) = no ]; then\ dch -v $(VERSION) -M "debian package generated from the git repository" && echo "[!] BUILD_RELEASE=no, incrementing changelog";\ else\ echo "[!] BUILD_RELEASE";\ fi - mkdir -p build - cp dist/$(BINNAME)-$(VERSION).tgz build/$(BINNAME)_$(shell echo ${VERSION} | cut -d '-' -f 1-2).orig.tar.gz - cd build && tar xzf $(BINNAME)_$(shell echo ${VERSION} | cut -d '-' -f 1-2).orig.tar.gz - cp -r debian/ build/$(BINNAME)-$(VERSION)/ - cd build/$(BINNAME)-$(VERSION) && debuild -us -uc - cp build/*.deb dist/ - git checkout -- debian/changelog + mkdir -p build ../dist + # bitmask-vpn tar.gz should be placed in parent forlder after doing 'make prepare' with the + # bitmask-vpn topmost Makefile. + cp ../bitmask-vpn_$(VERSION).tgz build/$(BINNAME)_${DEB_VERSION}.orig.tar.gz + cd build && tar xzf $(BINNAME)_${DEB_VERSION}.orig.tar.gz && mv bitmask-vpn_${VERSION}-src ${BINNAME}_${DEB_VERSION} + cp -r debian/ build/$(BINNAME)_$(DEB_VERSION)/ + cd build/$(BINNAME)_$(DEB_VERSION) && debuild -us -uc + cp build/*.deb ../dist/ # ----------------------------------------------------------------------------- # Utils -- cgit v1.2.3