-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-dist.sh
More file actions
executable file
·247 lines (195 loc) · 6.55 KB
/
build-dist.sh
File metadata and controls
executable file
·247 lines (195 loc) · 6.55 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
246
247
#!/bin/bash
set -e
VERSION="1.0.3"
DIST_NAME="quick-notepad-${VERSION}-linux-x86_64"
echo "╔════════════════════════════════════════╗"
echo "║ Building Quick Notepad Distribution ║"
echo "╚════════════════════════════════════════╝"
echo ""
# Build release binary
echo "🔨 Building release binary..."
cargo build --release
# Create distribution directory
echo "📁 Creating distribution package..."
rm -rf "$DIST_NAME"
mkdir -p "$DIST_NAME"
# Copy binary
cp target/release/quick "$DIST_NAME/"
# Copy assets
mkdir -p "$DIST_NAME/assets"
cp assets/icon.png "$DIST_NAME/assets/"
cp assets/quick-notepad.desktop "$DIST_NAME/assets/"
# Create installer script
cat > "$DIST_NAME/install.sh" << 'EOF'
#!/bin/bash
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Header
echo "╔════════════════════════════════════════╗"
echo "║ Quick Notepad Installer v1.0 ║"
echo "╚════════════════════════════════════════╝"
echo ""
# Detect if running with sudo
if [ "$EUID" -eq 0 ]; then
# Running as root - install to user's home directory
if [ -n "$SUDO_USER" ]; then
USER_HOME=$(getent passwd "$SUDO_USER" | cut -d: -f6)
INSTALL_DIR="$USER_HOME/.local/bin"
ACTUAL_USER="$SUDO_USER"
else
echo -e "${RED}✗ Please run without sudo, or use: sudo -E ./install.sh${NC}"
exit 1
fi
else
# Running as regular user
INSTALL_DIR="$HOME/.local/bin"
ACTUAL_USER="$USER"
fi
# Create installation directory if it doesn't exist
if [ ! -d "$INSTALL_DIR" ]; then
echo -e "${BLUE}📁 Creating installation directory...${NC}"
mkdir -p "$INSTALL_DIR"
if [ "$EUID" -eq 0 ]; then
chown "$ACTUAL_USER:$ACTUAL_USER" "$INSTALL_DIR"
fi
fi
# Remove existing symlink or file if it exists
TARGET="$INSTALL_DIR/quick"
if [ -L "$TARGET" ]; then
echo -e "${YELLOW}⚠ Removing existing symlink...${NC}"
rm "$TARGET"
elif [ -f "$TARGET" ]; then
echo -e "${YELLOW}⚠ Removing existing installation...${NC}"
rm "$TARGET"
fi
# Install binary
echo -e "${BLUE}📥 Installing binary...${NC}"
if cp quick "$TARGET"; then
echo -e "${GREEN}✓ Binary installed to $TARGET${NC}"
else
echo -e "${RED}✗ Failed to install binary${NC}"
exit 1
fi
# Set ownership if installed with sudo
if [ "$EUID" -eq 0 ]; then
chown "$ACTUAL_USER:$ACTUAL_USER" "$TARGET"
fi
# Make executable
chmod +x "$TARGET"
# Check if directory is in PATH
if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
echo ""
echo -e "${YELLOW}⚠ Warning: $INSTALL_DIR is not in your PATH${NC}"
echo ""
echo "Add this line to your ~/.bashrc or ~/.zshrc:"
echo -e "${BLUE}export PATH=\"\$HOME/.local/bin:\$PATH\"${NC}"
echo ""
echo "Then run: source ~/.bashrc"
else
echo -e "${GREEN}✓ Installation directory is in PATH${NC}"
fi
echo ""
echo -e "${GREEN}✓ Installation complete!${NC}"
echo ""
echo "Run 'quick' to start Quick Notepad"
echo "Run 'quick --help' for options"
echo ""
EOF
chmod +x "$DIST_NAME/install.sh"
# Create uninstaller script
cat > "$DIST_NAME/uninstall.sh" << 'EOF'
#!/bin/bash
set -e
echo "🗑️ Uninstalling Quick Notepad..."
INSTALL_DIR="$HOME/.local/bin"
APPS_DIR="$HOME/.local/share/applications"
ICONS_DIR="$HOME/.local/share/icons/hicolor/512x512/apps"
# Remove binaries
rm -f "$INSTALL_DIR/quick_notepad"
rm -f "$INSTALL_DIR/quick"
echo "✓ Removed binaries"
# Remove desktop entry
rm -f "$APPS_DIR/quick_notepad.desktop"
echo "✓ Removed desktop entry"
# Remove icon
rm -f "$ICONS_DIR/quick_notepad.png"
echo "✓ Removed icon"
# Update databases
if command -v update-desktop-database &> /dev/null; then
update-desktop-database "$APPS_DIR" 2>/dev/null || true
fi
if command -v gtk-update-icon-cache &> /dev/null; then
gtk-update-icon-cache -f -t "$HOME/.local/share/icons/hicolor" 2>/dev/null || true
fi
echo ""
echo "✅ Quick Notepad uninstalled!"
EOF
chmod +x "$DIST_NAME/uninstall.sh"
# Create README
cat > "$DIST_NAME/README.txt" << 'EOF'
╔════════════════════════════════════════════════════════════╗
║ Quick Notepad - Installation ║
╚════════════════════════════════════════════════════════════╝
QUICK START:
./install.sh
Then reload your shell:
source ~/.bashrc
USAGE:
Terminal (TUI):
quick # Start empty editor
quick file.txt # Open file
quick-notepad file.txt # Same as 'quick'
GUI:
quick --gui # Start GUI
quick --gui file.txt # Open file in GUI
quick file.txt --gui # Same as above
Other:
quick --shortcuts # Show all shortcuts
DESKTOP INTEGRATION:
After installation:
- Click "Quick Notepad" icon in application menu
- Right-click files → "Open with Quick Notepad"
- Right-click files → "Open in Terminal Mode"
UNINSTALL:
./uninstall.sh
REQUIREMENTS:
- Linux (x86_64)
- No additional dependencies
© 2024 Filip Domanski
EOF
# Copy LICENSE if exists
if [ -f "LICENSE" ]; then
cp LICENSE "$DIST_NAME/"
fi
# Create tarball
echo "📦 Creating tarball..."
tar czf "${DIST_NAME}.tar.gz" "$DIST_NAME"
# Calculate size and checksum
SIZE=$(du -h "${DIST_NAME}.tar.gz" | cut -f1)
SHA256=$(sha256sum "${DIST_NAME}.tar.gz" | cut -d' ' -f1)
echo ""
echo "╔════════════════════════════════════════╗"
echo "║ Distribution Created! 🎉 ║"
echo "╚════════════════════════════════════════╝"
echo ""
echo "📦 Package: ${DIST_NAME}.tar.gz"
echo "📏 Size: $SIZE"
echo "🔒 SHA256: $SHA256"
echo ""
echo "📂 Contents:"
ls -lh "$DIST_NAME"
echo ""
echo "To test locally:"
echo " cd $DIST_NAME"
echo " ./install.sh"
echo ""
echo "To distribute:"
echo " Share ${DIST_NAME}.tar.gz"
echo ""
# Create checksum file
echo "$SHA256 ${DIST_NAME}.tar.gz" > "${DIST_NAME}.tar.gz.sha256"
echo "✓ Created checksum file: ${DIST_NAME}.tar.gz.sha256"