Skip to content

Commit

Permalink
Add .deb packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
benbjohnson committed Jan 16, 2021
1 parent 78563f8 commit b4e5079
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/dist
.DS_Store
/dist
14 changes: 12 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,18 @@ default:

dist:
mkdir -p dist
cp etc/litestream.yml dist/litestream.yml
docker run --rm -v "${PWD}":/usr/src/litestream -w /usr/src/litestream -e GOOS=linux -e GOARCH=amd64 golang:1.15 go build -v -o dist/litestream ./cmd/litestream
tar -cz -f dist/litestream-linux-amd64.tar.gz -C dist litestream
rm dist/litestream

.PHONY: dist
deb: dist
ifndef VERSION
$(error VERSION is undefined)
endif
cat etc/nfpm.yml | envsubst > dist/nfpm.yml
nfpm pkg --config dist/nfpm.yml --packager deb --target dist/litestream.deb

clean:
rm -rf dist

.PHONY: deb dist clean
9 changes: 9 additions & 0 deletions etc/litestream.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=Litestream

[Service]
Restart=always
ExecStart=/usr/bin/litestream replicate

[Install]
WantedBy=multi-user.target
10 changes: 10 additions & 0 deletions etc/litestream.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# AWS credentials
# access-key-id: AKIAxxxxxxxxxxxxxxxx
# secret-access-key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxxxx

# dbs:
# - path: /path/to/primary/db # Database to replicate from
# replicas:
# - path: /path/to/replica # File-based replication
# - path: s3://my.bucket.com/db # S3-based replication

19 changes: 19 additions & 0 deletions etc/nfpm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: litestream
arch: amd64
platform: linux
version: "${LITESTREAM_VERSION}"
section: "default"
priority: "extra"
maintainer: "Ben Johnson <benbjohnson@yahoo.com>"
description: Litestream is a tool for real-time replication of SQLite databases.
homepage: "https://github.com/benbjohnson/litestream"
license: "GPLv3"
contents:
- src: ./dist/litestream
dst: /usr/bin/litestream
- src: ./etc/litestream.yml
dst: /etc/litestream.yml
type: config
- src: ./etc/litestream.service
dst: /usr/lib/systemd/system/litestream.service
type: config

0 comments on commit b4e5079

Please sign in to comment.