aptpkg/aptpkg

69 lines
1020 B
Bash
Executable File

#!/usr/bin/bash
# Init variables
APTPKG_VERSION="0.1.0-dev"
# Show help
show_help(){
cat > /dev/stdout <<EOF
aptpkg v$APTPKG_VERSION
Easily create debian packages.
Full documentation is being worked on and will be available at
Usage:
aptpkg [directory]
aptpkg -h, --help Show help
EOF
}
# Incorrect aptpkg usage: explain, show help, and exit
error_usage_die(){
echo "ERROR: " "$1"
show_help
exit 1
}
# Check that "build" file exists in directory
check(){
if ! [ -f "$1/build" ]; then
echo "No package of that name exists."
exit 1
fi
}
# Download a debian package
build_deb(){
echo "Getting $source"
wget "$source" -qO dist/"$name"_"$version"-"$rev"-amd64.deb
}
# Determine which function to run
load_build(){
# shellcheck disable=SC1090
source "$1/build"
case "$type" in
deb)
build_deb ;;
esac
}
# Run!
mkdir -p dist
if [ $# -ne 1 ]; then
error_usage_die "You must provide one directory"
fi
case $1 in
-h|--help)
show_help ;;
*)
check "$1"
load_build "$1" ;;
esac