Compare commits
7 Commits
fix/greeti
...
feature/ad
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f0338740a | ||
|
|
ae8a44fe76 | ||
| 64985fa2d8 | |||
|
|
d8b3795b3e | ||
| 9157b3514a | |||
|
|
4ed8cdc792 | ||
|
|
23f5ff77ec |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -36,4 +36,4 @@ hs_err_pid*
|
||||
.project
|
||||
.settings/
|
||||
.vscode/
|
||||
PKGBUILD
|
||||
.claude/
|
||||
|
||||
35
PKGBUILD
Normal file
35
PKGBUILD
Normal file
@@ -0,0 +1,35 @@
|
||||
# Maintainer: Cametendo cameronmathis08@gmail.com
|
||||
pkgname=cflash
|
||||
pkgver=1.0.0
|
||||
pkgrel=1
|
||||
pkgdesc="Small and lightweight image and iso flasher build on dd."
|
||||
arch=('any')
|
||||
url="https://github.com/cametendo/cflash-git"
|
||||
license=('MIT')
|
||||
depends=('java-runtime>=21')
|
||||
makedepends=('java-environment>=21' 'maven')
|
||||
source=("cflash::git+https://github.com/cametendo/cflash-git.git")
|
||||
sha256sums=('SKIP')
|
||||
|
||||
build() {
|
||||
cd "$pkgname"
|
||||
# using 'package' because pom.xml triggers the assembly plugin during this phase
|
||||
mvn clean package
|
||||
}
|
||||
|
||||
package() {
|
||||
cd "$srcdir/cflash"
|
||||
|
||||
# for some reason MAKEPKD won't accept my version, using the wildcard for literally anything if may find
|
||||
install -Dm644 target/cflash-*-jar-with-dependencies.jar \
|
||||
"$pkgdir/usr/share/java/cflash/cflash.jar"
|
||||
|
||||
# Create the executable
|
||||
install -d "$pkgdir/usr/bin"
|
||||
cat <<EOF > "$pkgdir/usr/bin/cflash"
|
||||
#!/bin/sh
|
||||
exec /usr/bin/java -jar /usr/share/java/cflash/cflash.jar "\$@"
|
||||
EOF
|
||||
# makes the program executable
|
||||
chmod +x "$pkgdir/usr/bin/cflash"
|
||||
}
|
||||
70
README.md
70
README.md
@@ -9,10 +9,74 @@ Small and lightweight image and iso flasher build on `dd`.
|
||||
# About
|
||||
Java program using `dd` to make flashing iso and image files easier on the terminal. This program allows anyone to flash iso and image files without having to search for extra GUI tools by keeping it simple and resource-friendly.
|
||||
|
||||
## Getting Started
|
||||
|
||||
# Requirements
|
||||
- `Java`: 21 (Download [here](https://www.oracle.com/java/technologies/downloads/#java21)
|
||||
- `Java`: 21 (Download [here](https://www.oracle.com/java/technologies/downloads/#java21))
|
||||
- `util-linux`: 2.41
|
||||
- `coreutils`: 9.10
|
||||
- `maven`: 3.9.15
|
||||
- Operating System: Linux
|
||||
### Building and Running Locally
|
||||
|
||||
1. Clone the repository:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/cametendo/cflash-git.git
|
||||
cd cflash-git
|
||||
```
|
||||
|
||||
2. Compile the code:
|
||||
|
||||
```bash
|
||||
mvn clean package
|
||||
```
|
||||
|
||||
3. Run the application:
|
||||
|
||||
```bash
|
||||
java -jar target/cflash-<version>.jar (optionally add arguments here, like with dd)
|
||||
```
|
||||
|
||||
### System-wide Installation
|
||||
|
||||
To install cflash globally so that it can be run from any terminal:
|
||||
|
||||
1. Clone the repository (if not done already):
|
||||
|
||||
```bash
|
||||
git clone https://github.com/cametendo/cflash-git.git
|
||||
cd cflash-git
|
||||
```
|
||||
|
||||
2. Make the build and install scripts executable:
|
||||
|
||||
```bash
|
||||
chmod +x build.sh install.sh
|
||||
```
|
||||
|
||||
3. Build the project using the provided build script:
|
||||
|
||||
```bash
|
||||
./build.sh
|
||||
```
|
||||
|
||||
4. Install globally (requires root privileges):
|
||||
|
||||
```bash
|
||||
sudo ./install.sh
|
||||
```
|
||||
|
||||
5. Run cflash from anywhere:
|
||||
|
||||
```bash
|
||||
cflash
|
||||
```
|
||||
|
||||
**Notes:**
|
||||
|
||||
* The `build.sh` script compiles all Java source files and creates an executable `cflash.jar`.
|
||||
* The `install.sh` script copies `cflash.jar` to `/usr/local/lib/cflash` and installs a wrapper script in `/usr/local/bin` for easy execution.
|
||||
|
||||
# Usage
|
||||
- Using the command `cflash` in the terminal, will start the flashing process. You will be asked several question before the flashing begins:
|
||||
@@ -30,10 +94,10 @@ Java program using `dd` to make flashing iso and image files easier on the termi
|
||||
- Linux
|
||||
|
||||
# Installation
|
||||
1. Clone the repository onto your local device.
|
||||
1. Clone the repository onto your device and cd into it.
|
||||
2. Run the `build.sh` file to build the program.
|
||||
3. Run the `ìnstall.sh`to install the program.
|
||||
4. Open a terminal and use the program with `cflash`.
|
||||
4. Open a terminal and use the program with `cflash`, optionally add all the arguments you need.
|
||||
|
||||
# License and Credits
|
||||
**Author**: [Cametendo](https://www.github.com/Cametendo)
|
||||
|
||||
86
build.sh
Executable file
86
build.sh
Executable file
@@ -0,0 +1,86 @@
|
||||
#!/usr/bin/env bash
|
||||
# --- Build script for cflash ---
|
||||
# Compiles sources and bundles jline via Maven into a single fat JAR.
|
||||
# If Maven is missing, prompts the user to install it using the detected package manager.
|
||||
|
||||
set -e
|
||||
|
||||
JAR_FILE="cflash.jar"
|
||||
|
||||
# --- Detect package manager ---
|
||||
detect_package_manager() {
|
||||
if command -v pacman >/dev/null 2>&1; then
|
||||
echo "pacman"
|
||||
elif command -v apt >/dev/null 2>&1; then
|
||||
echo "apt"
|
||||
elif command -v dnf >/dev/null 2>&1; then
|
||||
echo "dnf"
|
||||
elif command -v yum >/dev/null 2>&1; then
|
||||
echo "yum"
|
||||
elif command -v zypper >/dev/null 2>&1; then
|
||||
echo "zypper"
|
||||
elif command -v brew >/dev/null 2>&1; then
|
||||
echo "brew"
|
||||
elif command -v apk >/dev/null 2>&1; then
|
||||
echo "apk"
|
||||
elif command -v emerge >/dev/null 2>&1; then
|
||||
echo "emerge"
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
# --- Generate Maven install command ---
|
||||
maven_install_command() {
|
||||
local pm="$1"
|
||||
case "$pm" in
|
||||
pacman) echo "pacman -Sy --noconfirm maven" ;;
|
||||
apt) echo "apt update && apt install -y maven" ;;
|
||||
dnf) echo "dnf install -y maven" ;;
|
||||
yum) echo "yum install -y maven" ;;
|
||||
zypper) echo "zypper install -y maven" ;;
|
||||
brew) echo "brew install maven" ;;
|
||||
apk) echo "apk add maven" ;;
|
||||
emerge) echo "emerge dev-java/maven-bin" ;;
|
||||
*) echo "" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# --- Check for mvn ---
|
||||
if ! command -v mvn >/dev/null 2>&1; then
|
||||
echo "Maven (mvn) not found."
|
||||
PM=$(detect_package_manager)
|
||||
|
||||
if [[ -z "$PM" ]]; then
|
||||
echo "Please install Maven manually and rerun this script."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CMD=$(maven_install_command "$PM")
|
||||
if [[ $EUID -ne 0 && "$PM" != "brew" ]]; then
|
||||
echo "Please run this script as root to install Maven, or install it manually."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
read -rp "Do you want to run the following command to install Maven? [$CMD] (y/n): " ANSWER
|
||||
case "$ANSWER" in
|
||||
y|Y)
|
||||
echo "Installing Maven..."
|
||||
eval "$CMD"
|
||||
echo "Maven installed successfully."
|
||||
;;
|
||||
*)
|
||||
echo "Maven installation cancelled. Please install manually and rerun."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# --- Build process ---
|
||||
echo "Building cflash with Maven..."
|
||||
mvn package -q
|
||||
|
||||
echo "Copying fat JAR to ${JAR_FILE}..."
|
||||
cp target/cflash-*-jar-with-dependencies.jar "$JAR_FILE"
|
||||
|
||||
echo "Build completed successfully: ${JAR_FILE}"
|
||||
84
cflash.sh
Executable file
84
cflash.sh
Executable file
@@ -0,0 +1,84 @@
|
||||
#!/usr/bin/env bash
|
||||
# cflash launcher with self-update via git + rebuild (requires sudo for update)
|
||||
|
||||
CFLASH_DIR="/usr/local/lib/cflash"
|
||||
CFLASH_JAR="$CFLASH_DIR/cflash.jar"
|
||||
GIT_REPO="https://gitea.cametendo.org/cametendo/cflash.git"
|
||||
|
||||
update_cflash() {
|
||||
# Check for sudo/root
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "cflash --update requires root privileges. Please run with sudo."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Updating cflash from repository..."
|
||||
|
||||
TMP_DIR=$(mktemp -d)
|
||||
echo "Cloning repository into $TMP_DIR..."
|
||||
|
||||
if ! git clone --depth 1 "$GIT_REPO" "$TMP_DIR"; then
|
||||
echo "Failed to clone repository."
|
||||
rm -rf "$TMP_DIR"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
pushd "$TMP_DIR" >/dev/null
|
||||
|
||||
# Logic to handle if the repo contents are nested inside a 'cflash' folder
|
||||
if [[ ! -f "./build.sh" && -d "cflash" ]]; then
|
||||
echo "Detected nested directory, moving into cflash/..."
|
||||
cd cflash
|
||||
fi
|
||||
|
||||
# Ensure build.sh is executable (git usually preserves this, but just in case)
|
||||
if [[ -f "./build.sh" ]]; then
|
||||
chmod +x ./build.sh
|
||||
echo "Building cflash..."
|
||||
if ! ./build.sh; then
|
||||
echo "Build failed."
|
||||
popd >/dev/null
|
||||
rm -rf "$TMP_DIR"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Error: build.sh not found in the repository root or cflash/ directory."
|
||||
popd >/dev/null
|
||||
rm -rf "$TMP_DIR"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Installing new version..."
|
||||
if [[ -f "./install.sh" ]]; then
|
||||
chmod +x ./install.sh
|
||||
if ! ./install.sh; then
|
||||
echo "Install failed."
|
||||
popd >/dev/null
|
||||
rm -rf "$TMP_DIR"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Error: install.sh not found."
|
||||
popd >/dev/null
|
||||
rm -rf "$TMP_DIR"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
popd >/dev/null
|
||||
rm -rf "$TMP_DIR"
|
||||
echo "Update completed successfully!"
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Handle --update argument
|
||||
if [[ "$1" == "--update" ]]; then
|
||||
update_cflash
|
||||
fi
|
||||
|
||||
# Run cflash normally
|
||||
if [[ -f "$CFLASH_JAR" ]]; then
|
||||
java --enable-native-access=ALL-UNNAMED -jar "$CFLASH_JAR" "$@"
|
||||
else
|
||||
echo "Error: $CFLASH_JAR not found. Please run 'sudo cflash --update' to install."
|
||||
exit 1
|
||||
fi
|
||||
16
install.sh
Executable file
16
install.sh
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
# Install script for system-wide usage
|
||||
|
||||
# Ensure running as root
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "Please run as root to install globally."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create installation directories
|
||||
mkdir -p /usr/local/lib/cflash
|
||||
cp cflash.jar /usr/local/lib/cflash/
|
||||
cp cflash.sh /usr/local/bin/cflash
|
||||
chmod +x /usr/local/bin/cflash
|
||||
|
||||
echo "cflash installed successfully! You can now run 'cflash' from anywhere."
|
||||
5
pom.xml
5
pom.xml
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>org.cametendo</groupId>
|
||||
<artifactId>cflash</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<version>1.0.1</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
@@ -32,6 +32,9 @@
|
||||
<manifest>
|
||||
<mainClass>org.cametendo.Main</mainClass>
|
||||
</manifest>
|
||||
<manifestEntries>
|
||||
<Enable-Native-Access>ALL-UNNAMED</Enable-Native-Access>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
|
||||
@@ -7,12 +7,12 @@ public class BlockSize {
|
||||
|
||||
public static String mapBlockSize(String input) {
|
||||
return switch (input) {
|
||||
case "1" -> "512K";
|
||||
case "2" -> "1M";
|
||||
case "3" -> "2M";
|
||||
case "4" -> "4M";
|
||||
case "5" -> "8M";
|
||||
case "6" -> "16M";
|
||||
case "1", "512K" -> "512K";
|
||||
case "2", "1M" -> "1M";
|
||||
case "3", "2M" -> "2M";
|
||||
case "4", "4M" -> "4M";
|
||||
case "5", "8M" -> "8M";
|
||||
case "6", "16M" -> "16M";
|
||||
default -> blockSizeString;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -7,11 +7,10 @@ public class OflagHandler {
|
||||
|
||||
public static String mapOflagHandle(String input) {
|
||||
return switch (input) {
|
||||
case "1" -> "direct";
|
||||
case "2" -> "dsync";
|
||||
case "3" -> "sync";
|
||||
case "4" -> "nocache";
|
||||
case "5" -> "direct";
|
||||
case "1", "direct" -> "direct";
|
||||
case "2", "dsync" -> "dsync";
|
||||
case "3", "sync" -> "sync";
|
||||
case "4", "nocache" -> "nocache";
|
||||
default -> oflagHandleString;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user