Skip to content

Commit 7c680f3

Browse files
CopilotProject516
andcommitted
Add Debian package support for apt installation
Co-authored-by: Project516 <138796702+Project516@users.noreply.github.com>
1 parent 4caa6b8 commit 7c680f3

7 files changed

Lines changed: 106 additions & 5 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ gradle-app.setting
2323
# Ignore Gradle build output directory
2424
build
2525

26-
archive.zip
26+
archive.zip
27+
numberguessinggame.deb

README.md

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,35 @@
22

33
A simple number guessing game where you try to guess a randomly generated number. The game will tell you if your guess is too high or too low until you find the correct number.
44

5-
## Running the Game
5+
## Installation & Running
6+
7+
### Installation via Debian Package (Linux)
8+
9+
For Debian/Ubuntu and derivatives (recommended for terminal usage):
10+
11+
1. Download the `.deb` package from the [latest release](https://github.com/Project516/NumberGuessingGame/releases)
12+
2. Install it:
13+
```bash
14+
sudo dpkg -i numberguessinggame.deb
15+
sudo apt-get install -f # Install dependencies if needed
16+
```
17+
3. Run from anywhere in your terminal:
18+
```bash
19+
numberguessinggame
20+
```
21+
22+
To uninstall:
23+
```bash
24+
sudo dpkg -r numberguessinggame
25+
```
626

7-
### Requirements
27+
### Manual Installation
28+
29+
#### Requirements
830

931
- Java 8 or higher (may require Java 17+ in future versions)
1032

11-
### How to Run
33+
#### How to Run
1234

1335
**On Windows:**
1436
Run `run.bat`
@@ -55,7 +77,9 @@ gradle build
5577
gradle test
5678
```
5779

58-
### Creating Release Archive
80+
### Creating Release Archives
81+
82+
#### Zip Archive
5983

6084
**On Windows:**
6185
Run `.\gradlew build` and `package.bat` from the project root.
@@ -64,3 +88,10 @@ Run `.\gradlew build` and `package.bat` from the project root.
6488
Run `./package.sh` from the project root.
6589

6690
This will create `archive.zip` containing the application, run scripts, and README. The archive can be released to GitHub Releases.
91+
92+
#### Debian Package
93+
94+
**On Linux:**
95+
Run `./package-deb.sh` from the project root.
96+
97+
This will create `numberguessinggame.deb` which can be installed via `apt`/`dpkg` on Debian-based systems. The package can be released to GitHub Releases for easy distribution.

debian-package/DEBIAN/control

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Package: numberguessinggame
2+
Version: 1.0.0
3+
Section: games
4+
Priority: optional
5+
Architecture: all
6+
Depends: default-jre | java8-runtime
7+
Maintainer: Project516 <project516@github.com>
8+
Description: A simple number guessing game
9+
A simple number guessing game where you try to guess a randomly
10+
generated number. The game will tell you if your guess is too high
11+
or too low until you find the correct number.

debian-package/DEBIAN/postinst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
set -e
3+
4+
# Make the game executable
5+
chmod +x /usr/games/numberguessinggame
6+
7+
exit 0
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
# Wrapper script to launch Number Guessing Game
3+
4+
java -jar /usr/share/games/numberguessinggame/game.jar "$@"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Ignore all files in this directory (they are generated during build)
2+
*
3+
# But not this file
4+
!.gitignore

package-deb.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/sh
2+
# Script to create a Debian package (.deb) for Number Guessing Game
3+
4+
set -e
5+
6+
echo "Building Number Guessing Game Debian package..."
7+
8+
# Clean up previous builds
9+
rm -rf debian-package/usr/share/games/numberguessinggame/*
10+
rm -f numberguessinggame.deb
11+
12+
# Build the application
13+
echo "Building application..."
14+
cd app
15+
gradle build
16+
cd ..
17+
18+
# Copy the jar file
19+
echo "Copying files to package directory..."
20+
cp app/build/libs/app.jar debian-package/usr/share/games/numberguessinggame/game.jar
21+
22+
# Copy documentation
23+
cp README.md debian-package/usr/share/games/numberguessinggame/README.md
24+
cp LICENSE debian-package/usr/share/games/numberguessinggame/LICENSE
25+
26+
# Set permissions
27+
chmod 755 debian-package/DEBIAN/postinst
28+
chmod 755 debian-package/usr/games/numberguessinggame
29+
30+
# Build the .deb package
31+
echo "Building .deb package..."
32+
dpkg-deb --build debian-package numberguessinggame.deb
33+
34+
echo ""
35+
echo "✓ Debian package created: numberguessinggame.deb"
36+
echo ""
37+
echo "To install, run:"
38+
echo " sudo dpkg -i numberguessinggame.deb"
39+
echo " sudo apt-get install -f # to install any missing dependencies"
40+
echo ""
41+
echo "After installation, run the game with:"
42+
echo " numberguessinggame"
43+
echo ""

0 commit comments

Comments
 (0)