Skip to content

Commit

Permalink
Add "deb" Makefile target
Browse files Browse the repository at this point in the history
  • Loading branch information
iBug committed Jul 23, 2024
1 parent 72adaa2 commit 4a245a5
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Build output files
/yukictl
/yukid
/*.deb

.idea/
/debian/
dist/

*.swp
Expand Down
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.PHONY: all
all: yukid yukictl

.PHONY: lint
lint:
golangci-lint run --fix ./...
Expand Down Expand Up @@ -27,3 +30,16 @@ yukictl:
-X github.com/ustclug/Yuki/pkg/info.GitCommit=$(git_commit) \
-X github.com/ustclug/Yuki/pkg/info.Version=$(version)" \
-trimpath ./cmd/yukictl

.PHONY: deb

deb_dir := $(shell mktemp -d)
deb: | yukid yukictl
mkdir -p $(addprefix $(deb_dir)/, DEBIAN etc/bash_completion.d etc/yuki lib/systemd/system usr/local/bin)
cp etc/daemon.example.toml $(deb_dir)/etc/yuki
cp etc/yukid.service $(deb_dir)/lib/systemd/system
cp yukid yukictl $(deb_dir)/usr/local/bin
$(deb_dir)/usr/local/bin/yukictl completion bash > $(deb_dir)/etc/bash_completion.d/yukictl
sed "s/\$$VERSION\>/$(version)/g;s/^Version: v/Version: /g;s/\$$ARCH\>/$(shell go env GOARCH)/g" \
etc/debian-control > $(deb_dir)/DEBIAN/control
dpkg-deb --build -Zxz $(deb_dir) .
12 changes: 0 additions & 12 deletions deploy/yukid.service

This file was deleted.

24 changes: 24 additions & 0 deletions etc/daemon.example.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
debug = false

listen_addr = "127.0.0.1:9999"
db_url = "/home/mirror/yukid.db"
repo_config_dir = "/home/mirror/repos/"

fs = "zfs"

# uid:gid
owner = "1000:1000"

log_file = "/home/mirror/log/yukid.log"
repo_logs_dir = "/home/mirror/log/"
log_level = "error"

bind_ip = "0.0.0.0"

name_prefix = "syncing-"

images_upgrade_interval = "1h"

post_sync = ["/home/mirror/scripts/post_sync.sh"]

sync_timeout = "48h"
9 changes: 9 additions & 0 deletions etc/debian-control
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Package: yuki
Version: $VERSION
Architecture: $ARCH
Priority: optional
Section: admin
Maintainer: USTC LUG <[email protected]>
Homepage: https://github.com/ustclug/Yuki
Depends: docker-engine | docker.io | docker-ce
Description: USTC Mirror Manager
18 changes: 18 additions & 0 deletions etc/yukid.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[Unit]
Description=Yuki - USTC Mirror Manager
After=docker.service
Requires=docker.service
PartOf=docker.service
ConditionPathExists=/etc/yuki/daemon.toml

[Service]
Type=exec
User=mirror
ExecStart=/usr/local/bin/yukid
ExecReload=/usr/local/bin/yukictl reload
Restart=on-failure
RestartSec=5

[Install]
Alias=yuki.service
WantedBy=multi-user.target

0 comments on commit 4a245a5

Please sign in to comment.