Was supposed to be a linux distribution, now just a collection of build scripts for packages on top of (ideally) any distribution.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
1.8 KiB

#!/bin/sh
set -e
# Paths
dir_build="$PWD/build"
dir_source="$PWD/source"
dir_install="$PWD/install"
show_help() {
echo "This astronaut will help you build some satellites.
Just describe what he's got to do in a satellite file.
Usage: $0 [-s <dir>] [-b <dir>] [-i <dir>] <satellite>
-s Set source directory
-b Set build directory
-i Set install directory"
}
# Gather info
while getopts "h?s:b:i:" opt; do
case "$opt" in
h|\?)
show_help
exit 0
;;
s)
dir_source=$(realpath "$OPTARG")
;;
b)
dir_build=$(realpath "$OPTARG")
;;
i)
dir_install=$(realpath "$OPTARG")
;;
esac
done
shift $((OPTIND-1))
[ "$1" = "--" ] && shift
if [ ! "$1" ]; then
show_help
exit 1
fi
satellite=$(realpath "$1")
# Tools for the astronaut
msg() {
echo "=> $@"
}
download() {
local name=$(basename "$1")
local path="$dir_source/$name"
local checksum=""
if [ "$2" -a -f "$path" ]; then
checksum="$(md5sum ""$path"" 2> /dev/null | cut -d' ' -f1)"
fi
if [ ! -f "$path" -o "$checksum" != "$2" ]; then
msg "Downloading $name"
if [ "$3" ]; then
local cmd="$(echo "$2" | sed -e 's@{dst}@'"$path"'@g' -e 's@{source}@'"$1"'@g')"
$cmd
else
curl -#L -o "$path" "$1"
fi
fi
}
extract() {
msg "Extracting $1"
if [ "$2" ]; then
local cmd="$(echo "$2" | sed -e 's@{src}@'"$dir_source/$1"'@g')"
$cmd
else
tar xf "$dir_source/$1"
fi
}
dlextract() {
download "$1" "$2"
extract "$(basename ""$1"")"
}
extrafile() {
cp "$(dirname ""$satellite"")/$1" "$dir_build/$1"
}
# Create the satellite
mkdir -p "$dir_source"
mkdir -p "$dir_build"
mkdir -p "$dir_install"
cd "$dir_build"
. "$satellite"