Skip to content

Commit

Permalink
packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
raikoug committed Dec 4, 2024
1 parent 544979c commit 9674196
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 2 deletions.
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,13 @@ Output:

## Installation

### Requirements
### Build Your Own

#### Requirements

- **Rust**: Make sure Rust and Cargo are installed. Follow [this guide](https://www.rust-lang.org/tools/install) to set them up.

### Build
#### Build

Git clone the project (also in /tmp) and then build it:
```bash
Expand All @@ -96,6 +98,24 @@ If you want to use it everywhere, you can move the binary to `/usr/local/bin`:
sudo mv target/release/batteries /usr/local/bin/
```

### Deb package
Get the latest deb package from the [releases page](https://github.com/raikoug/batteries/releases)
```bash
sudo dpkg -i batteries_0.1.0_amd64.deb
```
For dependencies, you may need to run:
```bash
sudo apt-get install -f
```

### Make your own deb package
Build the solution following the Build section and then run:
```bash
# always inside batteries base folder
chmod +x ./packaging/make_deb.sh
./packaging/make_deb.sh
```

## Configuration

The configuration file is located at `/etc/batteries/configs.toml`. You can create this file manually (like explained in the Build section) or let the app generate it on the first run.
Expand Down
10 changes: 10 additions & 0 deletions packaging/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Package: batteries
Version: 0.1.0
Section: utils
Priority: optional
Architecture: amd64
Depends: libc6 (>= 2.28), libdbus-1-3
Maintainer: Riccardo Bella <riccardobella@gmail.com>
Description: A CLI tool to monitor battery status
A Rust-based CLI tool for monitoring the battery status of connected devices.

9 changes: 9 additions & 0 deletions packaging/DEBIAN/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -e
if [ ! -f /etc/batteries/configs.toml ]; then
echo "Creating default configuration file at /etc/batteries/configs.toml"
touch /etc/batteries/configs.toml
chmod 644 /etc/batteries/configs.toml
fi
exit 0

Empty file.
16 changes: 16 additions & 0 deletions packaging/make_deb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
set -e

echo "Building the project..."
cargo build --release

echo "Preparing the package structure..."
mkdir -p packaging/usr/bin
mkdir -p target/deb
cp target/release/batteries packaging/usr/bin/
chmod 755 packaging/usr/bin/batteries

echo "Building the .deb package..."
dpkg-deb --build packaging target/deb/batteries_0.1.0_amd64.deb
echo "Package created: target/deb/batteries_0.1.0_amd64.deb"

Binary file added packaging/usr/bin/batteries
Binary file not shown.

0 comments on commit 9674196

Please sign in to comment.