Skip to content

Commit b5c633c

Browse files
committed
Enable cargo to build apt-cacher-rs as a Debian package
1 parent 350bf86 commit b5c633c

File tree

6 files changed

+49
-6
lines changed

6 files changed

+49
-6
lines changed

Cargo.toml

+10
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,13 @@ strip = false
104104
debug-assertions = false
105105
overflow-checks = false
106106
lto = true
107+
108+
[package.metadata.deb]
109+
assets = [
110+
["debian/apt-cacher-rs.conf", "/etc/apt-cacher-rs/apt-cacher-rs.conf", "644"],
111+
["target/release/apt-cacher-rs", "/usr/sbin/apt-cacher-rs", "755"],
112+
]
113+
conflicts = "apt-cacher-ng"
114+
extended-description = "A caching proxy for Debian style package repositories"
115+
maintainer-scripts = "debian/"
116+
systemd-units = { enable = true, start = true }

README.md

+17-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,25 @@
66
`apt-cacher-rs` is a simple caching proxy daemon for Debian style repositories.
77
It is inspired by and an alternative to [`apt-cacher`](https://salsa.debian.org/LeePen/apt-cacher) and [`apt-cacher-ng`](https://www.unix-ag.uni-kl.de/~bloch/acng/).
88

9+
## Build the Debian package
10+
11+
Before you can compile apt-cacher-rs or create a Debian package, the following commands must be run once:
12+
13+
```
14+
sqlite3 apt-cacher-rs.db < db.sqlite
15+
apt-get -y install dpkg-dev liblzma-dev
16+
cargo install cargo-deb
17+
```
18+
19+
Then run the following command to build the Debian package in `target/debian/apt-cacher-rs.deb`:
20+
21+
```
22+
cargo deb
23+
```
24+
925
## How to use
1026

11-
First install `apt-cacher-rs` on a network local system.
12-
To automatically manage the daemon via systemd an example [service file](apt-cacher-rs.service) is included.
13-
Then add the following configuration file on every client system that should utilize the proxy:
27+
Install the Debian package via dpkg on a local network server and add the following configuration file on every client system that should utilize the proxy:
1428

1529
*/etc/apt/apt.conf.d/30proxy*
1630
```
File renamed without changes.

apt-cacher-rs.service debian/apt-cacher-rs.service

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ After=network.target
55
[Service]
66
Type=simple
77
Restart=on-abnormal
8-
ExecStart=/usr/local/bin/apt-cacher-rs --skip-log-timestamp
9-
# create user via:
10-
# adduser --system --group --quiet --gecos "apt-cacher-rs daemon" --no-create-home --home /var/lib/apt-cacher-rs apt-cacher-rs
8+
ExecStart=/usr/sbin/apt-cacher-rs --skip-log-timestamp
119
User=apt-cacher-rs
1210

1311
# Hardening

debian/postinst

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
set -e
3+
4+
PACKAGE_NAME="apt-cacher-rs"
5+
6+
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
7+
adduser --quiet --system --group --comment "$PACKAGE_NAME daemon" --no-create-home "$PACKAGE_NAME"
8+
fi
9+
10+
#DEBHELPER#

debian/postrm

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
set -e
3+
4+
PACKAGE_NAME="apt-cacher-rs"
5+
6+
#DEBHELPER#
7+
8+
if [ "$1" = "purge" ]; then
9+
deluser --quiet --system "$PACKAGE_NAME"
10+
rm -rf "/var/cache/$PACKAGE_NAME" "/var/lib/$PACKAGE_NAME"
11+
fi

0 commit comments

Comments
 (0)