diff --git a/repo/sing-box-git/0001-sing-box-service.patch b/repo/sing-box-git/0001-sing-box-service.patch new file mode 100644 index 0000000..a8409c6 --- /dev/null +++ b/repo/sing-box-git/0001-sing-box-service.patch @@ -0,0 +1,30 @@ +diff --git a/sing-box.service b/sing-box.service +--- a/sing-box.service ++++ b/sing-box.service +@@ -4,9 +4,10 @@ Documentation=https://sing-box.sagernet.org + After=network.target nss-lookup.target + + [Service] ++User=sing-box + CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_SYS_PTRACE CAP_DAC_READ_SEARCH + AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_SYS_PTRACE CAP_DAC_READ_SEARCH +-ExecStart=/usr/bin/sing-box -D /var/lib/sing-box -C /etc/sing-box run ++ExecStart=/usr/bin/sing-box -D /var/lib/sing-box/sing-box -C /etc/sing-box run + ExecReload=/bin/kill -HUP $MAINPID + Restart=on-failure + RestartSec=10s +diff --git a/sing-box@.service b/sing-box@.service +--- a/sing-box@.service ++++ b/sing-box@.service +@@ -4,9 +4,10 @@ Documentation=https://sing-box.sagernet.org + After=network.target nss-lookup.target + + [Service] ++User=sing-box + CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_SYS_PTRACE CAP_DAC_READ_SEARCH + AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_SYS_PTRACE CAP_DAC_READ_SEARCH +-ExecStart=/usr/bin/sing-box -D /var/lib/sing-box-%i -c /etc/sing-box/%i.json run ++ExecStart=/usr/bin/sing-box -D /var/lib/sing-box/sing-box-%i -c /etc/sing-box/%i.json run + ExecReload=/bin/kill -HUP $MAINPID + Restart=on-failure + RestartSec=10s diff --git a/repo/sing-box-git/PKGBUILD b/repo/sing-box-git/PKGBUILD index 5830aa0..801dbe7 100644 --- a/repo/sing-box-git/PKGBUILD +++ b/repo/sing-box-git/PKGBUILD @@ -1,17 +1,17 @@ -# Maintainer: everyx -# Contributor: BGME +# Maintainer: BGME +# Contributor: everyx pkgname=sing-box-git _pkgname=sing-box pkgver=1.3beta11.r9.g5065ab3e -pkgrel=1 +pkgrel=2 pkgdesc='The universal proxy platform (git version).' arch=('x86_64' 'i686') url='https://sing-box.sagernet.org/' -license=('GPL3 with name use or association addition') +license=('GPL3') -provides=("$_pkgname") +provides=("${_pkgname}") conflicts=("sing-box" "sing-box-beta") makedepends=('go' 'git') @@ -20,19 +20,29 @@ optdepends=( 'sing-geoip: sing-geoip database' ) -backup=("etc/$_pkgname/config.json") +backup=("etc/${_pkgname}/config.json") -source=("$_pkgname::git+https://github.com/SagerNet/sing-box.git#branch=dev-next") -sha256sums=(SKIP) +source=( + "${_pkgname}::git+https://github.com/SagerNet/sing-box.git#branch=dev-next" + "sing-box.sysusers" + "sing-box.tmpfiles" + "0001-sing-box-service.patch" +) +sha256sums=( + 'SKIP' + '35b9966604f3e5cf2acf9b86a7a1826b73829d59e04f283acaf89e84d9f4f4f7' + '83f27690c2b37823b4de56d890462ac32118c6984554e32b4f6d25b93426a94f' + 'b7a21a59ce2ec82fdded6b8a9e337c4f43e85a0688ad4a26f0f601aefa44dc54' +) pkgver() { - cd "$_pkgname" + cd "${srcdir}/${_pkgname}" git describe --tags --long | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-\([^-]*\)-\([^-]*\)$/.\1.\2/;s/-//' } _tags=with_quic,with_grpc,with_dhcp,with_wireguard,with_ech,with_utls,with_reality_server,with_clash_api,with_v2ray_api,with_gvisor build() { - cd "$_pkgname" + cd "${srcdir}/${_pkgname}" export CGO_CPPFLAGS="$CPPFLAGS" export CGO_CFLAGS="$CFLAGS" @@ -53,18 +63,19 @@ build() { -linkmode=external" \ ./cmd/sing-box - sed -i "/^\[Service\]$/a User=$_pkgname" release/config/$_pkgname*.service - - echo 'u sing-box - "Sing-box Service" - -' >"release/config/$_pkgname.sysusers" + cd release/config/ + patch -p1 <"${srcdir}/0001-sing-box-service.patch" } package() { - cd "$_pkgname" + cd "${srcdir}/${_pkgname}" - install -Dm644 LICENSE -t "$pkgdir/usr/share/licenses/$_pkgname" - install -Dm755 "$_pkgname" -t "$pkgdir/usr/bin" - install -Dm644 "release/config/config.json" -t "$pkgdir/etc/$_pkgname" - install -Dm644 "release/config/$_pkgname.service" -t "$pkgdir/usr/lib/systemd/system" - install -Dm644 "release/config/$_pkgname@.service" -t "$pkgdir/usr/lib/systemd/system" - install -Dm644 "release/config/$_pkgname.sysusers" "$pkgdir/usr/lib/sysusers.d/$_pkgname.conf" + install -Dm644 LICENSE -t "${pkgdir}/usr/share/licenses/${_pkgname}" + install -Dm755 "${_pkgname}" -t "${pkgdir}/usr/bin" + install -Dm644 "release/config/config.json" -t "${pkgdir}/etc/${_pkgname}" + install -Dm644 "release/config/${_pkgname}.service" -t "${pkgdir}/usr/lib/systemd/system" + install -Dm644 "release/config/${_pkgname}@.service" -t "${pkgdir}/usr/lib/systemd/system" + + install -Dm644 "${srcdir}/sing-box.sysusers" "${pkgdir}/usr/lib/sysusers.d/${_pkgname}.conf" + install -Dm644 "${srcdir}/sing-box.tmpfiles" "${pkgdir}/usr/lib/tmpfiles.d/${_pkgname}.conf" } diff --git a/repo/sing-box-git/sing-box.sysusers b/repo/sing-box-git/sing-box.sysusers new file mode 100644 index 0000000..2cec318 --- /dev/null +++ b/repo/sing-box-git/sing-box.sysusers @@ -0,0 +1 @@ +u sing-box - "Sing-box Service" /var/lib/sing-box - \ No newline at end of file diff --git a/repo/sing-box-git/sing-box.tmpfiles b/repo/sing-box-git/sing-box.tmpfiles new file mode 100644 index 0000000..b913708 --- /dev/null +++ b/repo/sing-box-git/sing-box.tmpfiles @@ -0,0 +1 @@ +d /var/lib/sing-box 0700 sing-box sing-box \ No newline at end of file