Commit
Author: Kevin Schoon [kevinschoon@gmail.com]
Hash: 04d4e2b49812685c47f17b586be19446ef8ca542
Timestamp: Thu, 10 Sep 2020 21:44:33 +0000 (4 years ago)

+47 -10 +/-3 browse
add deb packaging script
1diff --git a/bin/dune b/bin/dune
2index 06efa69..4b92468 100644
3--- a/bin/dune
4+++ b/bin/dune
5 @@ -7,9 +7,7 @@
6
7 (install
8 (section man)
9- (files ../doc/note.1)
10- )
11+ (files ../doc/note.1))
12 (install
13 (section share)
14- (files ../completion/note.bash)
15- )
16+ (files ../completion/note.bash))
17 diff --git a/scripts/generate_build_artifact.sh b/scripts/generate_build_artifact.sh
18index 8f1c588..3a553bc 100755
19--- a/scripts/generate_build_artifact.sh
20+++ b/scripts/generate_build_artifact.sh
21 @@ -29,13 +29,16 @@ dune clean
22 dune build
23
24 PKG="note-$PREFIX-$VERSION"
25- mkdir -p "pkg/$PKG"
26- cp -rLv _build/install/default/* "pkg/$PKG/"
27- rm -vf "pkg/$PKG/bin/note"
28+ PKG_PATH="pkg/$PKG"
29+ PKG_TARGET="pkg/$PKG.tar.gz"
30+
31+ mkdir -p "$PKG_PATH"
32+ cp -rLv _build/install/default/* "$PKG_PATH"
33+ rm -vf "$PKG_PATH/bin/note"
34 docker build -t "$PKG" -f "$DOCKER_FILE" .
35 container_id="$(docker create $PKG)"
36- docker cp "$container_id:/usr/bin/note" "pkg/$PKG/bin/note"
37+ docker cp "$container_id:/usr/bin/note" "$PKG_PATH/bin/note"
38 docker rm "$container_id" 1>/dev/null
39
40- tar -C "pkg/$PKG" -czvf "pkg/$PKG.tar.gz" .
41- md5sum "pkg/$PKG.tar.gz" > "pkg/$PKG.tar.gz.md5"
42+ tar -C "$PKG_PATH" -czvf "$PKG_TARGET" .
43+ md5sum "$PKG_TARGET" > "$PKG_TARGET.md5"
44 diff --git a/scripts/generate_deb_artifact.sh b/scripts/generate_deb_artifact.sh
45new file mode 100755
46index 0000000..a5ce37f
47--- /dev/null
48+++ b/scripts/generate_deb_artifact.sh
49 @@ -0,0 +1,36 @@
50+ #!/bin/bash
51+ # generate a deb package for debian based systems
52+ set -e
53+
54+
55+ _usage () {
56+ echo "USAGE: "
57+ echo "generate_debian_artifact.sh VERSION"
58+ }
59+
60+ VERSION="$1"
61+
62+ [[ -z "$VERSION" ]] && {
63+ _usage
64+ exit 1
65+ }
66+
67+ BUILD_ARTIFACT="pkg/note-glibc-$VERSION"
68+ PKG="note-$VERSION-debian"
69+ PKG_PATH="pkg/$PKG"
70+ mkdir -p "$PKG_PATH/DEBIAN"
71+
72+ cat >"$PKG_PATH/DEBIAN/control"<<EOF
73+ Package: note-ocaml
74+ Version: $VERSION
75+ Maintainer: Kevin Schoon <kevinschoon@gmail.com>
76+ Architecture: amd64
77+ Description: simple note taking cli
78+ EOF
79+
80+ cp -r "$BUILD_ARTIFACT"/* "$PKG_PATH/"
81+
82+ # TODO: dune doesn't allow this path somehow
83+ mkdir -p "$PKG_PATH/usr/share/bash-completion/completions"
84+ mv "$PKG_PATH/share/note/note.bash" "$PKG_PATH/usr/share/bash-completion/completions/"
85+ dpkg-deb -b "$PKG_PATH"