From af578d4af25bc4a9087f703ddc08a6d7e348ebbb Mon Sep 17 00:00:00 2001 From: ymshenyu <39402395+ymshenyu@users.noreply.github.com> Date: Sun, 8 Nov 2020 11:10:13 +0800 Subject: [PATCH] add support for debian packaging (#397) * initial debian packaging * add action for debian packaging * trigger build * fix syntax --- .github/workflows/deb.yml | 38 ++++++++++++++++++ release/debian/changelog | 5 +++ release/debian/control | 39 ++++++++++++++++++ release/debian/copyright | 40 +++++++++++++++++++ release/debian/rules | 27 +++++++++++++ release/debian/source/format | 1 + release/debian/v2ray-docs.docs | 1 + .../v2ray-domain-list-community.install | 1 + release/debian/v2ray-geoip.install | 1 + release/debian/v2ray.install | 2 + release/debian/v2ray.service | 16 ++++++++ release/debian/v2ray@.service | 16 ++++++++ 12 files changed, 187 insertions(+) create mode 100644 .github/workflows/deb.yml create mode 100644 release/debian/changelog create mode 100644 release/debian/control create mode 100644 release/debian/copyright create mode 100755 release/debian/rules create mode 100644 release/debian/source/format create mode 100644 release/debian/v2ray-docs.docs create mode 100644 release/debian/v2ray-domain-list-community.install create mode 100644 release/debian/v2ray-geoip.install create mode 100644 release/debian/v2ray.install create mode 100644 release/debian/v2ray.service create mode 100644 release/debian/v2ray@.service diff --git a/.github/workflows/deb.yml b/.github/workflows/deb.yml new file mode 100644 index 000000000..139e7fe1a --- /dev/null +++ b/.github/workflows/deb.yml @@ -0,0 +1,38 @@ +name: Build debian packages + +on: + push: + release: + types: [prereleased] + +jobs: + linux: + name: Debian sid + runs-on: ubuntu-latest + container: debian:sid + + steps: + - name: Install git + run: | + apt-get update + apt-get install -y git + - name: Checking out sources + uses: actions/checkout@v2 + with: + submodules: 'recursive' + - name: Install build dependencies + run: | + apt-get install -y build-essential dh-golang golang-any + - name: Build + run: | + cp -r release/debian . + dpkg-buildpackage -us -uc -i -b + - name: Copy binary + run: | + cp ../*.deb ./ + - name: Upload artifact + uses: actions/upload-artifact@v2 + with: + name: v2ray-debian-packages + path: ./*.deb + diff --git a/release/debian/changelog b/release/debian/changelog new file mode 100644 index 000000000..05b01be24 --- /dev/null +++ b/release/debian/changelog @@ -0,0 +1,5 @@ +v2ray-core (4.32.1-1) unstable; urgency=medium + + * Initial release + + -- ymshenyu Sun, 08 Nov 2020 08:59:07 +0800 diff --git a/release/debian/control b/release/debian/control new file mode 100644 index 000000000..275a86186 --- /dev/null +++ b/release/debian/control @@ -0,0 +1,39 @@ +Source: v2ray-core +Section: unknown +Priority: optional +Maintainer: ymshenyu +Build-Depends: debhelper-compat (= 12), + dh-golang, + golang-any +Standards-Version: 4.5.0 +Homepage: https://github.com/v2fly/v2ray-core +#Vcs-Browser: https://salsa.debian.org/debian/v2ray-core +#Vcs-Git: https://salsa.debian.org/debian/v2ray-core.git +Rules-Requires-Root: no +XS-Go-Import-Path: v2ray.com/core + +Package: v2ray +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Recommends: v2ray-domain-list-community, + v2ray-geoip +Description: Library platform for building proxies in golang + Project V2Ray is a set of network tools that help you to build your + own computer network. It secures your network connections and thus + protects your privacy. + +Package: v2ray-domain-list-community +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Library platform for building proxies in golang (routing file) + Project V2Ray is a set of network tools that help you to build your + own computer network. It secures your network connections and thus + protects your privacy. + +Package: v2ray-geoip +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Library platform for building proxies in golang (routing file) + Project V2Ray is a set of network tools that help you to build your + own computer network. It secures your network connections and thus + protects your privacy. diff --git a/release/debian/copyright b/release/debian/copyright new file mode 100644 index 000000000..26a01a1fd --- /dev/null +++ b/release/debian/copyright @@ -0,0 +1,40 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: v2ray-core +Upstream-Contact: https://github.com/v2fly/v2ray-core +Source: https://github.com/v2fly/v2ray-core + +Files: * +Copyright: 2015-2020 V2Fly Community +License: Expat + +Files: debian/* +Copyright: 2020 ymshenyu +License: Expat + +License: Expat + 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. + +# Please also look if there are files or directories which have a +# different copyright/license attached and list them here. +# Please avoid picking licenses with terms that are more restrictive than the +# packaged work, as it may make Debian's contributions unacceptable upstream. +# +# If you need, there are some extra license texts available in two places: +# /usr/share/debhelper/dh_make/licenses/ +# /usr/share/common-licenses/ diff --git a/release/debian/rules b/release/debian/rules new file mode 100755 index 000000000..2392cdd96 --- /dev/null +++ b/release/debian/rules @@ -0,0 +1,27 @@ +#!/usr/bin/make -f + +include /usr/share/dpkg/default.mk + +BUILDDIR=_build + +%: + dh $@ --builddirectory=$(BUILDDIR) --buildsystem=golang --with=golang + +execute_after_dh_auto_configure: + go mod vendor + cp -r vendor/* _build/src + +override_dh_auto_clean: + dh_auto_clean + rm -rf vendor + +override_dh_auto_build: + DH_GOPKG="v2ray.com/core/main" dh_auto_build -- -ldflags "-s -w" -tags $(DEB_VERSION_UPSTREAM) + cd $(BUILDDIR); mv bin/main bin/v2ray + DH_GOPKG="v2ray.com/core/infra/control/main" dh_auto_build -- -ldflags "-s -w" -tags $(DEB_VERSION_UPSTREAM) + cd $(BUILDDIR); mv bin/main bin/v2ctl + +override_dh_auto_install: + dh_auto_install -- --no-source + +override_dh_auto_test: diff --git a/release/debian/source/format b/release/debian/source/format new file mode 100644 index 000000000..163aaf8d8 --- /dev/null +++ b/release/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/release/debian/v2ray-docs.docs b/release/debian/v2ray-docs.docs new file mode 100644 index 000000000..b43bf86b5 --- /dev/null +++ b/release/debian/v2ray-docs.docs @@ -0,0 +1 @@ +README.md diff --git a/release/debian/v2ray-domain-list-community.install b/release/debian/v2ray-domain-list-community.install new file mode 100644 index 000000000..eb02d424c --- /dev/null +++ b/release/debian/v2ray-domain-list-community.install @@ -0,0 +1 @@ +release/config/geosite.dat usr/share/v2ray diff --git a/release/debian/v2ray-geoip.install b/release/debian/v2ray-geoip.install new file mode 100644 index 000000000..d8477a137 --- /dev/null +++ b/release/debian/v2ray-geoip.install @@ -0,0 +1 @@ +release/config/geoip.dat usr/share/v2ray diff --git a/release/debian/v2ray.install b/release/debian/v2ray.install new file mode 100644 index 000000000..b3e096afe --- /dev/null +++ b/release/debian/v2ray.install @@ -0,0 +1,2 @@ +usr/bin +release/config/config.json etc/v2ray diff --git a/release/debian/v2ray.service b/release/debian/v2ray.service new file mode 100644 index 000000000..f4821c342 --- /dev/null +++ b/release/debian/v2ray.service @@ -0,0 +1,16 @@ +[Unit] +Description=V2Ray Service +Documentation=https://www.v2fly.org/ +After=network.target nss-lookup.target + +[Service] +User=nobody +CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE +AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE +NoNewPrivileges=true +ExecStart=/usr/bin/v2ray -config /etc/v2ray/config.json +Restart=on-failure +RestartPreventExitStatus=23 + +[Install] +WantedBy=multi-user.target diff --git a/release/debian/v2ray@.service b/release/debian/v2ray@.service new file mode 100644 index 000000000..f5ed40db9 --- /dev/null +++ b/release/debian/v2ray@.service @@ -0,0 +1,16 @@ +[Unit] +Description=V2Ray Service +Documentation=https://www.v2fly.org/ +After=network.target nss-lookup.target + +[Service] +User=nobody +CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE +AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE +NoNewPrivileges=true +ExecStart=/usr/bin/v2ray -config /etc/v2ray/%i.json +Restart=on-failure +RestartPreventExitStatus=23 + +[Install] +WantedBy=multi-user.target