-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild-deb.sh
More file actions
executable file
·245 lines (206 loc) · 8.39 KB
/
Copy pathbuild-deb.sh
File metadata and controls
executable file
·245 lines (206 loc) · 8.39 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
#!/bin/bash
set -e
# Read version directly from Cargo.toml so it never drifts out of sync
VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
PACKAGE="notas"
ARCH="amd64" # Change to arm64 if needed
echo "╔════════════════════════════════════════════════════════════════════════════╗"
echo "║ ║"
echo "║ _ _ _ _ _ ║"
echo "║ | \ | | ___ | |_ __ _ ___ __| | ___| |__ ║"
echo "║ | \| |/ _ \| __/ _\` / __| / _\` |/ _ \ '_ \ ║"
echo "║ | |\ | (_) | || (_| \__ \ | (_| | __/ |_) | ║"
echo "║ |_| \_|\___/ \__\__,_|___/ (_)__,_|\___|_.__/ ║"
echo "║ ║"
echo "║ ____ _ ____ _ _ _ ║"
echo "║ | _ \ __ _ ___| | ____ _ __ _ ___ | __ ) _ _(_) | __| | ___ _ __ ║"
echo "║ | |_) / _\` |/ __| |/ / _\` |/ _\` |/ _ \ | _ \| | | | | |/ _\` |/ _ \ '__| ║"
echo "║ | __/ (_| | (__| < (_| | (_| | __/ | |_) | |_| | | | (_| | __/ | ║"
echo "║ |_| \__,_|\___|_|\_\__,_|\__, |\___| |____/ \__,_|_|_|\__,_|\___|_| ║"
echo "║ |___/ ║"
echo "║ ║"
echo "╚════════════════════════════════════════════════════════════════════════════╝"
# ── Dependency checks ────────────────────────────────────────────────────────
MISSING_APT=()
MISSING_OTHER=()
# rustup / cargo
if ! command -v cargo &> /dev/null; then
if ! command -v rustup &> /dev/null; then
MISSING_OTHER+=("rustup → curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh")
else
MISSING_OTHER+=("cargo toolchain → run: rustup default stable")
fi
fi
# dpkg-deb
if ! command -v dpkg-deb &> /dev/null; then
MISSING_APT+=("dpkg")
fi
# pkg-config
if ! command -v pkg-config &> /dev/null; then
MISSING_APT+=("pkg-config")
fi
# libgtk-4-dev (check via pkg-config so version mismatches are caught too)
if command -v pkg-config &> /dev/null && ! pkg-config --exists gtk4 2>/dev/null; then
MISSING_APT+=("libgtk-4-dev")
fi
# libadwaita-1-dev
if command -v pkg-config &> /dev/null && ! pkg-config --exists libadwaita-1 2>/dev/null; then
MISSING_APT+=("libadwaita-1-dev")
fi
# Report and exit if anything is missing
if [ ${#MISSING_APT[@]} -gt 0 ] || [ ${#MISSING_OTHER[@]} -gt 0 ]; then
echo ""
echo "❌ Missing dependencies:"
for dep in "${MISSING_OTHER[@]}"; do
echo " • $dep"
done
if [ ${#MISSING_APT[@]} -gt 0 ]; then
echo " • apt packages: ${MISSING_APT[*]}"
echo ""
echo " Install with:"
echo " sudo apt install ${MISSING_APT[*]}"
fi
echo ""
exit 1
fi
echo "✓ All build dependencies found"
# Font is bundled in the repo — always included
FONT_FILE="fonts/DotGothic16-Regular.ttf"
if [ ! -f "$FONT_FILE" ]; then
echo "❌ Error: fonts/DotGothic16-Regular.ttf not found."
echo " It should be committed to the repository. Check your checkout."
exit 1
fi
echo "✓ Found DotGothic16-Regular.ttf (bundled)"
INCLUDE_FONT=true
echo ""
echo "📦 Step 1: Building Notas with Cargo..."
cargo build --release
echo ""
echo "📁 Step 2: Creating package structure..."
# Create package directory structure
PKG_DIR="${PACKAGE}_${VERSION}_${ARCH}"
rm -rf "$PKG_DIR"
mkdir -p "$PKG_DIR/DEBIAN"
mkdir -p "$PKG_DIR/usr/bin"
mkdir -p "$PKG_DIR/usr/share/applications"
mkdir -p "$PKG_DIR/usr/share/metainfo"
mkdir -p "$PKG_DIR/usr/share/icons/hicolor/16x16/apps"
mkdir -p "$PKG_DIR/usr/share/icons/hicolor/32x32/apps"
mkdir -p "$PKG_DIR/usr/share/icons/hicolor/48x48/apps"
mkdir -p "$PKG_DIR/usr/share/icons/hicolor/64x64/apps"
mkdir -p "$PKG_DIR/usr/share/icons/hicolor/128x128/apps"
mkdir -p "$PKG_DIR/usr/share/icons/hicolor/256x256/apps"
mkdir -p "$PKG_DIR/usr/share/icons/hicolor/512x512/apps"
# Create font directory (always bundled)
mkdir -p "$PKG_DIR/usr/share/fonts/truetype/notas"
echo ""
echo "📋 Step 3: Copying files..."
# Copy binary
cp target/release/notas "$PKG_DIR/usr/bin/"
chmod 755 "$PKG_DIR/usr/bin/notas"
# Copy desktop file
cp notas.desktop "$PKG_DIR/usr/share/applications/"
# Copy metainfo
cp com.jegly.Notas.metainfo.xml "$PKG_DIR/usr/share/metainfo/"
# Copy icons
cp icons/hicolor/16x16/apps/notas.png "$PKG_DIR/usr/share/icons/hicolor/16x16/apps/"
cp icons/hicolor/32x32/apps/notas.png "$PKG_DIR/usr/share/icons/hicolor/32x32/apps/"
cp icons/hicolor/48x48/apps/notas.png "$PKG_DIR/usr/share/icons/hicolor/48x48/apps/"
cp icons/hicolor/64x64/apps/notas.png "$PKG_DIR/usr/share/icons/hicolor/64x64/apps/"
cp icons/hicolor/128x128/apps/notas.png "$PKG_DIR/usr/share/icons/hicolor/128x128/apps/"
cp icons/hicolor/256x256/apps/notas.png "$PKG_DIR/usr/share/icons/hicolor/256x256/apps/"
cp icons/hicolor/512x512/apps/notas.png "$PKG_DIR/usr/share/icons/hicolor/512x512/apps/"
# Copy font and its license
cp "$FONT_FILE" "$PKG_DIR/usr/share/fonts/truetype/notas/"
cp "fonts/OFL.txt" "$PKG_DIR/usr/share/fonts/truetype/notas/"
echo "✓ Bundled DotGothic16 font (OFL licensed)"
INCLUDE_FONT=true
# Calculate installed size (in KB)
INSTALLED_SIZE=$(du -sk "$PKG_DIR" | cut -f1)
echo ""
echo "📝 Step 4: Creating control file..."
# Create control file
cat > "$PKG_DIR/DEBIAN/control" << EOF
Package: ${PACKAGE}
Version: ${VERSION}
Section: utils
Priority: optional
Architecture: ${ARCH}
Installed-Size: ${INSTALLED_SIZE}
Depends: libgtk-4-1, libadwaita-1-0
Maintainer: Jegly <jjjegly@gmail.com>
Homepage: https://github.com/jegly/notas
Description: Secure encrypted notes application
Notas is a privacy-focused encrypted notes application built with
GTK4 and Rust. Features include AES-256-GCM encryption, Argon2id
key derivation, auto-lock, clipboard clearing, and beautiful themes.
EOF
# Create postinst script
cat > "$PKG_DIR/DEBIAN/postinst" << 'EOF'
#!/bin/sh
set -e
# Update icon cache
if [ -x /usr/bin/gtk-update-icon-cache ]; then
gtk-update-icon-cache -f -t /usr/share/icons/hicolor 2>/dev/null || true
fi
# Update desktop database
if [ -x /usr/bin/update-desktop-database ]; then
update-desktop-database /usr/share/applications 2>/dev/null || true
fi
# Update font cache (for bundled DotGothic16 font)
if [ -x /usr/bin/fc-cache ]; then
fc-cache -f /usr/share/fonts/truetype/notas 2>/dev/null || true
fi
exit 0
EOF
chmod 755 "$PKG_DIR/DEBIAN/postinst"
# Create postrm script
cat > "$PKG_DIR/DEBIAN/postrm" << 'EOF'
#!/bin/sh
set -e
# Update icon cache
if [ -x /usr/bin/gtk-update-icon-cache ]; then
gtk-update-icon-cache -f -t /usr/share/icons/hicolor 2>/dev/null || true
fi
# Update desktop database
if [ -x /usr/bin/update-desktop-database ]; then
update-desktop-database /usr/share/applications 2>/dev/null || true
fi
# Update font cache after removal
if [ -x /usr/bin/fc-cache ]; then
fc-cache -f 2>/dev/null || true
fi
# Remove user data and config so a reinstall starts clean.
# Without this, a new master password fails to decrypt the old vault.
REAL_USER="${SUDO_USER:-$(logname 2>/dev/null || true)}"
if [ -n "$REAL_USER" ]; then
USER_HOME=$(getent passwd "$REAL_USER" | cut -d: -f6)
if [ -n "$USER_HOME" ]; then
rm -rf "$USER_HOME/.local/share/notas"
rm -rf "$USER_HOME/.config/notas"
fi
fi
exit 0
EOF
chmod 755 "$PKG_DIR/DEBIAN/postrm"
echo ""
echo "🔨 Step 5: Building .deb package..."
# Build the package
dpkg-deb --build --root-owner-group "$PKG_DIR"
echo ""
echo "✅ Package built successfully!"
echo ""
echo "📦 Output: ${PKG_DIR}.deb"
if [ "$INCLUDE_FONT" = true ]; then
echo " ✓ Includes bundled DotGothic16 font"
fi
echo ""
echo "To install:"
echo " sudo dpkg -i ${PKG_DIR}.deb"
echo ""
echo "To uninstall:"
echo " sudo apt remove notas"
echo ""
# Clean up build directory (optional)
# rm -rf "$PKG_DIR"