Unverified Commit d5f06cc4 authored by Kali Kaneko's avatar Kali Kaneko Committed by meskio

[pkg] debian template

parent e709b420
......@@ -10,6 +10,9 @@ VERSION ?= $(shell git describe)
# detect OS, we use it for dependencies
UNAME = `uname`
TEMPLATES = "branding/templates"
SCRIPTS = "branding/scripts"
all: icon locales get build
depends:
......@@ -40,18 +43,18 @@ ifneq (,$(wildcard ${DEFAULT_PROVIDER}))
endif
cd branding/assets && ln -s ${PROVIDER} default
prepare: generate relink_default
prepare: generate relink_default tgz
mkdir -p build/${PROVIDER}/bin/
cp branding/templates/makefile/Makefile build/${PROVIDER}/Makefile
VERSION=${VERSION} PROVIDER_CONFIG=${PROVIDER_CONFIG} branding/scripts/generate-vendor-make.py build/${PROVIDER}/vendor.mk
branding/scripts/check-ca-crt.py ${PROVIDER} ${PROVIDER_CONFIG}
cp ${TEMPLATES}/makefile/Makefile build/${PROVIDER}/Makefile
VERSION=${VERSION} PROVIDER_CONFIG=${PROVIDER_CONFIG} ${SCRIPTS}/generate-vendor-make.py build/${PROVIDER}/vendor.mk
${SCRIPTS}/check-ca-crt.py ${PROVIDER} ${PROVIDER_CONFIG}
# FIXME trouble in win - better get into repo
#-@make icon
gen_pkg_win:
mkdir -p build/${PROVIDER}/windows/
cp -r branding/templates/windows build/${PROVIDER}
VERSION=${VERSION} PROVIDER_CONFIG=${PROVIDER_CONFIG} branding/scripts/generate-win.py build/${PROVIDER}/windows/data.json
cp -r ${TEMPLATES}/windows build/${PROVIDER}
VERSION=${VERSION} PROVIDER_CONFIG=${PROVIDER_CONFIG} ${SCRIPTS}/generate-win.py build/${PROVIDER}/windows/data.json
cd build/${PROVIDER}/windows && python3 generate.py
# TODO create/copy build/PROVIDER/assets/
# TODO create/copy build/PROVIDER/staging/
......@@ -65,21 +68,25 @@ endif
ifeq (,$(wildcard build/${PROVIDER}/staging/openvpn-osx))
curl -L https://downloads.leap.se/thirdparty/osx/openvpn/openvpn -o build/${PROVIDER}/staging/openvpn-osx
endif
cp -r branding/templates/osx build/${PROVIDER}
VERSION=${VERSION} PROVIDER_CONFIG=${PROVIDER_CONFIG} branding/scripts/generate-osx.py build/${PROVIDER}/osx/data.json
cp -r ${TEMPLATES}/osx build/${PROVIDER}
VERSION=${VERSION} PROVIDER_CONFIG=${PROVIDER_CONFIG} ${SCRIPTS}/generate-osx.py build/${PROVIDER}/osx/data.json
cd build/${PROVIDER}/osx && python3 generate.py
cd build/${PROVIDER}/osx/scripts && chmod +x preinstall postinstall
gen_pkg_snap:
cp -r branding/templates/snap build/${PROVIDER}
VERSION=${VERSION} PROVIDER_CONFIG=${PROVIDER_CONFIG} branding/scripts/generate-snap.py build/${PROVIDER}/snap/data.json
cp -r ${TEMPLATES}/snap build/${PROVIDER}
VERSION=${VERSION} PROVIDER_CONFIG=${PROVIDER_CONFIG} S{SCRIPTS}/generate-snap.py build/${PROVIDER}/snap/data.json
cd build/${PROVIDER}/snap && python3 generate.py
rm build/${PROVIDER}/snap/data.json build/${PROVIDER}/snap/snapcraft-template.yaml
mkdir -p build/${PROVIDER}/snap/gui && cp branding/assets/default/icon.svg build/${PROVIDER}/snap/gui/icon.svg
# TODO missing hooks
gen_pkg_deb:
echo "debian..."
cp -r ${TEMPLATES}/debian build/${PROVIDER}
VERSION=${VERSION} PROVIDER_CONFIG=${PROVIDER_CONFIG} ${SCRIPTS}/generate-debian.py build/${PROVIDER}/debian/data.json
mkdir -p build/${PROVIDER}/debian/icons/scalable && cp branding/assets/default/icon.svg build/${PROVIDER}/debian/icons/scalable/icon.svg
cd build/${PROVIDER}/debian && python3 generate.py
cd build/${PROVIDER}/debian && rm app.desktop-template changelog-template rules-template control-template generate.py data.json && chmod +x rules
gen_pkg_all: prepare gen_pkg_win gen_pkg_osx gen_pkg_snap gen_pkg_deb
......@@ -103,6 +110,20 @@ build_bitmaskd:
build_win:
powershell -Command '$$version=git describe --tags; go build -ldflags "-H windowsgui -X main.version=$$version" ./cmd/*'
TGZ_NAME = bitmask-vpn_${VERSION}-src
TGZ_PATH = $(shell pwd)/build/${TGZ_NAME}
tgz:
mkdir -p $(TGZ_PATH)
git 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 build/ && tar cvzf bitmask-vpn_$(VERSION).tgz ${TGZ_NAME}
rm -r $(TGZ_PATH)
clean:
make -C icon clean
rm -f build/${PROVIDER}/bin/bitmask-*
......
#!/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: {} <output_file>'.format(SCRIPT))
sys.exit(1)
outputf = sys.argv[1]
data['version'] = VERSION
writeOutput(data, outputf)
[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
${binaryName} (${version}) unstable; urgency=medium
* Initial package.
-- LEAP Encryption Access Project <debian@leap.se> Mon, 29 Jul 2019 10:00:00 +0100
Source: ${binaryName}
Section: net
Priority: extra
Maintainer: LEAP Encryption Access Project <debian@leap.se>
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.
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: auth-pam
Source: <https://0xacab.org/leap/riseup_vpn>
Files: *
Copyright: 2018 LEAP Encryption Access Project <info@leap.se>
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.
#!/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)))
#!/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
......@@ -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
......
// Code generated by go generate; DO NOT EDIT.
// This file was generated by vendorize.py
// At 2019-07-16 21:41:09
// At 2019-07-29 21:55:46
package config
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment