Browse Source

Started simple package builder

master
mid-kid 10 years ago
commit
578a7a1cdd
  1. 93
      astronaut
  2. 11
      hello.sat

93
astronaut

@ -0,0 +1,93 @@
#!/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"
if [ ! -f "$path" ]; then
msg "Downloading $name"
if [ "$2" ]; 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"
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"

11
hello.sat

@ -0,0 +1,11 @@
# Example of a satellite file, which is just a shell script with a cool name.
name=hello
version=2.9
dlextract "http://ftp.gnu.org/pub/gnu/$name/$name-$version.tar.gz"
cd "$name-$version"
./configure
make
make DESTDIR="$dir_install" install
Loading…
Cancel
Save