initial commit
This commit is contained in:
14
PKGBUILD
Normal file
14
PKGBUILD
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# PKGBUILD
|
||||||
|
pkgname=comp
|
||||||
|
pkgver=1.0
|
||||||
|
pkgrel=1
|
||||||
|
pkgdesc="Simple folder compression with pv and pigz"
|
||||||
|
arch=('any')
|
||||||
|
license=('MIT')
|
||||||
|
deps=('tar' 'pv' 'pigz')
|
||||||
|
source=('comp')
|
||||||
|
mdsums=('SKIP')
|
||||||
|
|
||||||
|
package() {
|
||||||
|
install -Dm755 "$srcdir/comp.sh" "$pkgdir/usr/bin/comp"
|
||||||
|
}
|
||||||
37
comp.sh
Normal file
37
comp.sh
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Usage: comp <folder_to_compress> [output_fildename]
|
||||||
|
|
||||||
|
# Check if input folder is provided
|
||||||
|
if [[ -z "$1" ]]; then
|
||||||
|
echo "Usage: comp <folder_to_compress> [output_filename]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
INPUT_FOLDER="$1"
|
||||||
|
|
||||||
|
|
||||||
|
# Remove trailing slash from folder name if present
|
||||||
|
INPUT_FOLDER="${INPUT_FOLDER%/}"
|
||||||
|
|
||||||
|
# Determine output filename
|
||||||
|
if [[ -n "$2" ]]; then
|
||||||
|
OUTPUT_FILE="$2"
|
||||||
|
else
|
||||||
|
OUTPUT_FILE="${INPUT_FOLDER}.tgz"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if input is a valid directory
|
||||||
|
if [[ ! -d "${INPUT_FOLDER}" ]]; then
|
||||||
|
echo "Error: '${INPUT_FOLDER}' is not a valid directory"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get total zie in bytes for progress bar
|
||||||
|
TOTAL_SIZE=$(du -sb "${INPUT_FOLDER}" | awk '{print $1}')
|
||||||
|
|
||||||
|
# Run compression with progress bar
|
||||||
|
echo "Compressing '${INPUT_FOLDER}' to ' ${OUTPUT_FILE}'..."
|
||||||
|
tar -cf - "${INPUT_FOLDER} | pv -s "${TOTAL_SIZE}" | pigz > "${OUTPUT_FILE}"
|
||||||
|
|
||||||
|
echo "Done!"
|
||||||
Reference in New Issue
Block a user