commit 578a7a1cdda7a2caeed4acef3fcdc52c53dda1c5 Author: mid-kid Date: Sun Nov 9 13:08:36 2014 +0100 Started simple package builder diff --git a/astronaut b/astronaut new file mode 100755 index 0000000..757702a --- /dev/null +++ b/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 ] [-b ] [-i ] + +-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" diff --git a/hello.sat b/hello.sat new file mode 100644 index 0000000..19e006f --- /dev/null +++ b/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