diff --git a/astronaut/astronaut b/astronaut/astronaut index 7524e3e..95edf96 100755 --- a/astronaut/astronaut +++ b/astronaut/astronaut @@ -8,6 +8,7 @@ dir_source="$PWD/source" dir_install="$PWD/install" cmd_download="curl -#L -o {dst} {src}" cmd_extract="tar xf {src}" +enable_check=true if [ -f /etc/astronaut.conf ]; then . /etc/astronaut.conf fi @@ -16,11 +17,13 @@ fi 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 ] +Usage: $0 [-s ] [-b ] [-i ] [-cC] -s Set source directory -b Set build directory [WARNING: Will be deleted before build] --i Set install directory" +-i Set install directory +-c Enable package checking +-C Disable package checking" } msg() { @@ -33,7 +36,7 @@ exiterr() { } # Gather info -while getopts "h?s:b:i:" opt; do +while getopts "h?s:b:i:cC" opt; do case "$opt" in h|\?) show_help @@ -48,6 +51,12 @@ while getopts "h?s:b:i:" opt; do i) dir_install="$(realpath "$OPTARG")" ;; + c) + enable_checking=true + ;; + C) + enable_checking=false + ;; esac done @@ -113,6 +122,16 @@ extrafile() { cp "$(dirname "$satellite")/$1" "$dir_build/$1" } +do_check() { + if [ "$enable_check" = true ]; then + if [ "$1" ]; then + $@ + else + echo true + fi + fi +} + # Create the satellite rm -rf "$dir_build" diff --git a/astronaut/hello.sat b/astronaut/hello.sat index ea49308..3bce414 100644 --- a/astronaut/hello.sat +++ b/astronaut/hello.sat @@ -22,4 +22,12 @@ extract "$name-$version.tar.gz" \ cd "$name-$version" ./configure make + +# Know if the user wants the package to be checked +if do_check; then + make check +fi +# Abbreviation for the above, for single commands +#do_check make check + make DESTDIR="$dir_install" install diff --git a/tools/chroot b/tools/chroot index 52c4d71..a917bbc 100755 --- a/tools/chroot +++ b/tools/chroot @@ -1,6 +1,26 @@ #!/bin/sh - umask 022 +set -e + +if [ "$(id -u)" != "0" ]; then + echo "Please run this script as root" 1>&2 + exit 1 +fi + +if [ ! "$rocket" ]; then + echo 'Please set the $rocket variable' 1>&2 + exit 1 +fi + +mkdir -p "$rocket/dev" "$rocket/proc" "$rocket/sys" "$rocket/run" +mount --bind /dev "$rocket/dev" +mount -t devpts devpts "$rocket/dev/pts" +mount -t proc proc "$rocket/proc" +mount -t tmpfs tmpfs "$rocket/run" +if [ -h "$rocket/dev/shm" ]; then + mkdir -p "$rocket/$(readlink "$rocket/dev/shm")" +fi + chroot "$rocket" /tools/bin/env -i \ HOME=/root \ TERM="$TERM" \ diff --git a/tools/prepchroot b/tools/prepchroot new file mode 100755 index 0000000..10a015c --- /dev/null +++ b/tools/prepchroot @@ -0,0 +1,25 @@ +#!/bin/sh +umask 022 +set -e + +if [ "$(id -u)" != "0" ]; then + echo "Please run this script as root" 1>&2 + exit 1 +fi + +if [ ! "$rocket" ]; then + echo 'Please set the $rocket variable' 1>&2 + exit 1 +fi + +echo "Changing ownership of $rocket to root" +chown -R 0.0 "$rocket" + +echo "Creating device nodes" +mknod -m 600 "$rocket/dev/console" c 5 1 +mknod -m 666 "$rocket/dev/null" c 1 3 + +echo "Configuring astronaut" +mkdir -p "$rocket/etc" +echo '# This is a config for use with busybox +cmd_download="wget -O {dst} {src}"' > "$rocket/etc/astronaut.conf"