Skip to content

Commit 8e721c7

Browse files
committed
build: add binary packaging
1 parent c4dd260 commit 8e721c7

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@
33
/cmake-build-release/
44
/cmake-build-sanitize/
55

6+
# release directory
7+
/package/
8+
69
# ide settings
710
/.idea

package.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
set -e
3+
4+
BIN_NAME="objcurses"
5+
BIN_PATH="cmake-build-release/$BIN_NAME"
6+
OUT_DIR="package"
7+
DEB_DIR="$OUT_DIR/${BIN_NAME}-deb"
8+
9+
# check binary exists
10+
if [ ! -f "$BIN_PATH" ]; then
11+
echo "error: binary not found at $BIN_PATH"
12+
exit 1
13+
fi
14+
15+
# extract version from --version output
16+
VERSION=$("$BIN_PATH" --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
17+
if [ -z "$VERSION" ]; then
18+
echo "error: could not extract version"
19+
exit 1
20+
fi
21+
22+
echo "packaging $BIN_NAME version $VERSION..."
23+
24+
# prepare output directory
25+
mkdir -p "$OUT_DIR"
26+
27+
# prepare folder for tar.gz: package/objcurses-<version>-linux/objcurses
28+
TAR_DIR_NAME="${BIN_NAME}-${VERSION}-linux"
29+
TAR_DIR_PATH="$OUT_DIR/$TAR_DIR_NAME"
30+
mkdir -p "$TAR_DIR_PATH"
31+
cp "$BIN_PATH" "$TAR_DIR_PATH/$BIN_NAME"
32+
strip "$TAR_DIR_PATH/$BIN_NAME"
33+
34+
# create tar.gz archive with versioned folder and plain binary inside
35+
tar -czf "$OUT_DIR/${TAR_DIR_NAME}.tar.gz" -C "$OUT_DIR" "$TAR_DIR_NAME"
36+
rm -rf "$TAR_DIR_PATH"
37+
38+
# create .deb directory structure
39+
mkdir -p "$DEB_DIR/usr/bin" "$DEB_DIR/DEBIAN"
40+
cp "$BIN_PATH" "$DEB_DIR/usr/bin/$BIN_NAME"
41+
42+
cat > "$DEB_DIR/DEBIAN/control" <<EOF
43+
Package: $BIN_NAME
44+
Version: $VERSION
45+
Section: utils
46+
Priority: optional
47+
Architecture: amd64
48+
Depends: libc6 (>= 2.27), libncurses6 (>= 6), libtinfo6 (>= 6), libstdc++6, libgcc1
49+
Maintainer: Anton Dmitriev <contact.admtrv@gmail.com>
50+
Description: ncurses 3d object viewer
51+
It renders .obj models in real time using ASCII characters and a simple rendering pipeline.
52+
EOF
53+
54+
# build .deb package
55+
dpkg-deb --build "$DEB_DIR"
56+
mv "${DEB_DIR}.deb" "$OUT_DIR/${BIN_NAME}-${VERSION}-linux.deb"
57+
rm -rf "$DEB_DIR"
58+
59+
# final output
60+
echo "done, files created:"
61+
echo " - $OUT_DIR/${BIN_NAME}-${VERSION}-linux.tar.gz"
62+
echo " - $OUT_DIR/${BIN_NAME}-${VERSION}-linux.deb"

0 commit comments

Comments
 (0)