-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild_deb.sh
More file actions
executable file
·106 lines (91 loc) · 3.12 KB
/
Copy pathbuild_deb.sh
File metadata and controls
executable file
·106 lines (91 loc) · 3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/bash
set -e
VERSION="2.0.0"
ARCH="amd64"
PKG_NAME="clack"
BUILD_DIR="build_deb"
OUT_DIR="$HOME/Projects/binaries"
# Create output directory
mkdir -p "$OUT_DIR"
# Clean old build
rm -rf "$BUILD_DIR"
mkdir -p "$BUILD_DIR/DEBIAN"
mkdir -p "$BUILD_DIR/usr/bin"
mkdir -p "$BUILD_DIR/usr/share/clack"
mkdir -p "$BUILD_DIR/usr/share/applications"
mkdir -p "$BUILD_DIR/usr/share/icons/hicolor/scalable/apps"
# 1. Control File
cat <<EOF > "$BUILD_DIR/DEBIAN/control"
Package: $PKG_NAME
Version: $VERSION
Architecture: $ARCH
Maintainer: ThisWasAryan
Depends: xdotool, ydotool, ydotoold, python3-pynput, python3-gi, python3-gi-cairo, gir1.2-gtk-4.0
Description: Behaviorally realistic human typing simulator
Clack simulates human typing by injecting keystrokes securely via /dev/uinput.
It includes a CLI simulation engine and a GTK4 graphical interface.
EOF
# 2. Postinst Script
cat <<EOF > "$BUILD_DIR/DEBIAN/postinst"
#!/bin/bash
set -e
echo "Configuring Clack udev rules for ydotool..."
echo 'KERNEL=="uinput", GROUP="input", MODE="0660", OPTIONS+="static_node=uinput"' > /etc/udev/rules.d/99-uinput.rules
udevadm control --reload-rules
udevadm trigger
# Try to enable ydotoold service if it exists
if systemctl list-unit-files | grep -q ydotoold; then
systemctl enable --now ydotoold || true
fi
if [ -n "\$SUDO_USER" ]; then
usermod -aG input "\$SUDO_USER"
echo "Added \$SUDO_USER to the 'input' group. You may need to log out and back in."
fi
exit 0
EOF
chmod 755 "$BUILD_DIR/DEBIAN/postinst"
# 3. Binaries and Python files
# The binary name might be htype or clack depending on cargo configuration
if [ -f "target/release/htype" ]; then
cp target/release/htype "$BUILD_DIR/usr/bin/clack"
else
cp target/release/clack "$BUILD_DIR/usr/bin/clack"
fi
chmod 755 "$BUILD_DIR/usr/bin/clack"
cp -r gui "$BUILD_DIR/usr/share/clack/"
# Clean up any pycache before packaging
find "$BUILD_DIR/usr/share/clack/gui" -type d -name "__pycache__" -exec rm -r {} + || true
# Entrypoint script
cat <<EOF > "$BUILD_DIR/usr/bin/clack-gui"
#!/bin/bash
# Start ydotoold in background if not running
if ! pgrep ydotoold > /dev/null; then
# Use --socket-perm 0666 to ensure socket accessibility if run globally or as root.
ydotoold --socket-perm 0666 &
sleep 0.5
fi
export PYTHONPATH="/usr/share/clack:\$PYTHONPATH"
exec python3 -m gui "\$@"
EOF
chmod 755 "$BUILD_DIR/usr/bin/clack-gui"
# 4. Desktop Entry
cat <<EOF > "$BUILD_DIR/usr/share/applications/clack.desktop"
[Desktop Entry]
Name=Clack
Comment=Human Typing Simulator
Exec=clack-gui
Icon=clack
Terminal=false
Type=Application
Categories=Utility;
EOF
# 5. Simple SVG Icon
cat <<EOF > "$BUILD_DIR/usr/share/icons/hicolor/scalable/apps/clack.svg"
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
<rect width="64" height="64" rx="12" fill="#3B82F6"/>
<text x="50%" y="50%" font-family="monospace" font-size="32" font-weight="bold" fill="white" text-anchor="middle" dominant-baseline="central">C_</text>
</svg>
EOF
# Build package
dpkg-deb --build "$BUILD_DIR" "${OUT_DIR}/${PKG_NAME}-gui_v${VERSION}_${ARCH}.deb"
echo "Success! Package built at ${OUT_DIR}/${PKG_NAME}-gui_v${VERSION}_${ARCH}.deb"