commit 8e3b05f4600bf7007c83ad904592c03109fa79ab
parent 7071186e1efe2b96cfb4555aa38570bfd5ba1049
Author: Slack Coder <slackcoder@server.ky>
Date: Thu, 8 May 2025 14:10:17 -0500
Add Debian source package to contrib
Diffstat:
14 files changed, 113 insertions(+), 24 deletions(-)
diff --git a/contrib/debian/debian/changelog b/contrib/debian/debian/changelog
@@ -0,0 +1,5 @@
+mirror (#VERSION#) UNRELEASED; urgency=medium
+
+ * Initial release. (Closes: #XXXXXX)
+
+ -- Slack Coder <slackcoder@server.ky> Fri, 09 May 2025 19:56:32 +0000
diff --git a/contrib/debian/debian/control b/contrib/debian/debian/control
@@ -0,0 +1,25 @@
+Source: mirror
+Section: golang
+Priority: optional
+Maintainer: Slack Coder <slackcoder@server.ky>
+Rules-Requires-Root: no
+Build-Depends:
+ debhelper-compat (= 13),
+ dh-exec,
+ dh-sequence-golang,
+ dh-sysuser,
+ golang-any,
+Standards-Version: 0.0.3
+Homepage: https://git.server.ky/slackcoder/mirror
+Vcs-Browser: https://git.server.ky/slackcoder/mirror
+
+Package: mirror
+Section: golang
+Architecture: amd64
+Depends:
+ ${shlibs:Depends},
+ ${misc:Depends},
+ git,
+ gnupg,
+ rsync,
+Description: Mirror project assets and source code.
diff --git a/contrib/debian/debian/copyright b/contrib/debian/debian/copyright
diff --git a/contrib/debian/debian/mirror.dirs b/contrib/debian/debian/mirror.dirs
@@ -0,0 +1,2 @@
+etc/mirror
+etc/mirror/conf.d
diff --git a/contrib/debian/debian/mirror.install b/contrib/debian/debian/mirror.install
@@ -0,0 +1,2 @@
+#_build/bin/mirror usr/sbin
+contrib/slackbuild/mirror.toml etc/mirror
diff --git a/contrib/debian/debian/mirror.service b/contrib/debian/debian/mirror.service
@@ -0,0 +1,21 @@
+[Unit]
+Description=The mirror service
+Documentation=https://git.server.ky/slackcoder/mirror/
+After=network-online.target syslog.target
+Wants=network-online.target
+
+[Service]
+Type=simple
+User=mirror
+Group=mirror
+ExecStart=/usr/bin/mirror
+ExecStop=/bin/kill -TERM $MAINPID
+ExecReload=/bin/kill -HUP $MAINPID
+Restart=on-failure
+RestartSec=30
+StandardOutput=journal
+StandardError=inherit
+SyslogIdentifier=mirror
+
+[Install]
+WantedBy=multi-user.target
diff --git a/contrib/debian/debian/mirror.sysuser b/contrib/debian/debian/mirror.sysuser
@@ -0,0 +1 @@
+mirror
diff --git a/contrib/debian/debian/rules b/contrib/debian/debian/rules
@@ -0,0 +1,9 @@
+#!/usr/bin/make -f
+
+export DH_GOPKG := git.server.ky/slackcoder/mirror
+
+%:
+ dh $@ --with sysuser --builddir=_build --buildsystem=golang
+
+# Don't run strip
+override_dh_strip:
diff --git a/contrib/debian/debian/source/format b/contrib/debian/debian/source/format
@@ -0,0 +1 @@
+3.0 (quilt)
diff --git a/contrib/debian/make-package.sh b/contrib/debian/make-package.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+#
+# Created using the tutorial
+# https://john-tucker.medium.com/debian-packaging-by-example-118c18f5dbfe And
+# this confusing one -> https://wiki.debian.org/Packaging/Intro
+#
+# Define expected version when running.
+#
+# VERSION=0.0.4 ./make-package.sh
+#
+
+cd $(dirname $0) ; CWD=$(pwd)
+
+PRGNAM=mirror
+PROJECT_PATH="$(realpath ./../..)"
+VERSION="${VERSION:-#VERSION#}"
+
+TMP="${TMP:-/tmp/debian}"
+PKG="$TMP/package-$PRGNAM"
+OUTPUT="${OUTPUT:-/tmp}"
+
+set -e
+
+#
+# Prepare what the debian build tools run on from these files.
+#
+rm -fr "$PKG"
+mkdir -p "$TMP" "$PKG" "$OUTPUT"
+cd "$TMP"
+rm -fr "$PRGNAM-$VERSION"
+cp -R "$PROJECT_PATH" "$PRGNAM-$VERSION"
+cd "$PRGNAM-$VERSION"
+cp -r . "$PKG"
+#cp contrib/debian/Makefile "$PKG"
+tar -C .. -f "$PKG/${PRGNAM}_${VERSION}.orig.tar.gz" -c "${PRGNAM}-${VERSION}"
+cp -r contrib/debian/debian "$PKG"
+sed -i "s/#VERSION#/${VERSION}/g" "$PKG/debian/changelog"
+
+#
+# Make the deliverable using Debian's tools.
+#
+cd "$PKG"
+debuild -b -uc -us
+mv ../mirror_*.deb "$OUTPUT"
diff --git a/contrib/slackbuild/mirror.SlackBuild b/contrib/slackbuild/mirror.SlackBuild
@@ -2,9 +2,8 @@
cd $(dirname $0) ; CWD=$(pwd)
-GIT_COMMIT=$(git rev-parse --short HEAD)
PRGNAM=mirror
-VERSION=${VERSION:-$GIT_COMMIT}
+VERSION=${VERSION:-#VERSION#}
BUILD=${BUILD:-1}
TAG=${TAG:-_slackcoder}
PKGTYPE=${PKGTYPE:-txz}
diff --git a/contrib/systemd/mirror.service b/contrib/systemd/mirror.service
@@ -1,19 +0,0 @@
-[Unit]
-Description=The mirror service
-Documentation=https://git.server.ky/slackcoder/mirror/
-After=network-online.target syslog.target
-Wants=network-online.target
-
-[Service]
-Type=simple
-ExecStart=/usr/local/bin/mirror
-ExecStop=/bin/kill -TERM $MAINPID
-ExecReload=/bin/kill -HUP $MAINPID
-Restart=on-failure
-RestartSec=30
-StandardOutput=journal
-StandardError=inherit
-SyslogIdentifier=mirror
-
-[Install]
-WantedBy=multi-user.target
diff --git a/contrib/systemd/mirror.sysusers b/contrib/systemd/mirror.sysusers
@@ -1 +0,0 @@
-u mirror - "mirror service" - -
diff --git a/internal/service/git.go b/internal/service/git.go
@@ -111,12 +111,12 @@ func MirrorGit(dst *internal.URL, src *internal.URL, description string) error {
}
// Git mirrors are not good places for mirrored assets.
- cmd = exec.Command("git", "config", "set", "cgit.snapshots", "none")
+ cmd = exec.Command("git", "config", "--file", "config", "--add", "cgit.snapshots", "none")
cmd.Dir = dst.Path
err = cmd.Run()
if err != nil {
err = mapExecError(err)
- return fmt.Errorf("disabling cgit snapshots: %s", err)
+ return fmt.Errorf("setting git configuration cgit.snapshot to 'none': %s", err)
}
}