Browse Source

add support for debian packaging (#397)

* initial debian packaging

* add action for debian packaging

* trigger build

* fix syntax
ymshenyu 5 years ago
parent
commit
af578d4af2

+ 38 - 0
.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
+      

+ 5 - 0
release/debian/changelog

@@ -0,0 +1,5 @@
+v2ray-core (4.32.1-1) unstable; urgency=medium
+
+  * Initial release
+
+ -- ymshenyu <ymshenyu@gmail.com>  Sun, 08 Nov 2020 08:59:07 +0800

+ 39 - 0
release/debian/control

@@ -0,0 +1,39 @@
+Source: v2ray-core
+Section: unknown
+Priority: optional
+Maintainer: ymshenyu <ymshenyu@gmail.com>
+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.

+ 40 - 0
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 <ymshenyu@gmail.com>
+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/

+ 27 - 0
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:

+ 1 - 0
release/debian/source/format

@@ -0,0 +1 @@
+3.0 (quilt)

+ 1 - 0
release/debian/v2ray-docs.docs

@@ -0,0 +1 @@
+README.md

+ 1 - 0
release/debian/v2ray-domain-list-community.install

@@ -0,0 +1 @@
+release/config/geosite.dat usr/share/v2ray

+ 1 - 0
release/debian/v2ray-geoip.install

@@ -0,0 +1 @@
+release/config/geoip.dat usr/share/v2ray

+ 2 - 0
release/debian/v2ray.install

@@ -0,0 +1,2 @@
+usr/bin
+release/config/config.json etc/v2ray

+ 16 - 0
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

+ 16 - 0
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