From 3d239be7b4fdf4e460c4c1c39a468e8529cc6548 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 3 Nov 2019 10:05:02 +0100 Subject: [PATCH] Ports: Undo POSIX sh compliance changes for now Partial revert of 704f48d7f3a1a88047a64b4e2939878d6d4fafb8. These changes made the ports system unusable. --- Ports/.port_include.sh | 23 ++++++++++------------- Ports/SDL2/package.sh | 4 ++-- Ports/bash/package.sh | 4 ++-- Ports/binutils/package.sh | 2 +- Ports/curl/package.sh | 2 +- Ports/doom/package.sh | 2 +- Ports/figlet/package.sh | 2 +- Ports/gcc/package.sh | 6 +++--- Ports/less/package.sh | 2 +- Ports/libarchive/package.sh | 2 +- Ports/libexpat/package.sh | 2 +- Ports/libiconv/package.sh | 2 +- Ports/links/package.sh | 2 +- Ports/lua/package.sh | 2 +- Ports/make/package.sh | 2 +- Ports/mbedtls/package.sh | 2 +- Ports/ncurses/package.sh | 2 +- Ports/nyancat/package.sh | 2 +- Ports/quake/package.sh | 2 +- Ports/tinycc/package.sh | 2 +- Ports/vim/package.sh | 2 +- Ports/zlib/package.sh | 2 +- 22 files changed, 35 insertions(+), 38 deletions(-) diff --git a/Ports/.port_include.sh b/Ports/.port_include.sh index c3a3b1fc212..07ed859212f 100755 --- a/Ports/.port_include.sh +++ b/Ports/.port_include.sh @@ -1,7 +1,4 @@ #!/bin/bash - -# This file will need to be run in bash, for now. - if [ -z "$SERENITY_ROOT" ]; then echo "You must source UseIt.sh to build ports." exit 1 @@ -33,19 +30,19 @@ run() { (cd "$workdir" && "$@") } run_replace_in_file(){ - run perl -p -i -e "$1" "$2" + run perl -p -i -e "$1" $2 } # Checks if a function is defined. In this case, if the function is not defined in the port's script, then we will use our defaults. This way, ports don't need to include these functions every time, but they can override our defaults if needed. func_defined() { - PATH=$(command -V "$1" > /dev/null 2>&1) + PATH= command -V "$1" > /dev/null 2>&1 } func_defined fetch || fetch() { OLDIFS=$IFS IFS=$'\n' for f in $files; do IFS=$OLDIFS - read url filename <<< "$(echo $f)" - run_nocd curl "${curlopts:-}" "$url" -o "$filename" + read url filename <<< $(echo "$f") + run_nocd curl ${curlopts:-} "$url" -o "$filename" case "$filename" in *.tar*|.tbz*|*.txz|*.tgz) run_nocd tar xf "$filename" @@ -68,13 +65,13 @@ func_defined configure || configure() { run ./"$configscript" --host=i686-pc-serenity $configopts } func_defined build || build() { - run make "$makeopts" + run make $makeopts } func_defined install || install() { run make DESTDIR="$SERENITY_ROOT"/Root $installopts install } func_defined clean || clean() { - rm -rf "$workdir" -- *.out + rm -rf "$workdir" *.out } func_defined clean_dist || clean_dist() { OLDIFS=$IFS @@ -86,7 +83,7 @@ func_defined clean_dist || clean_dist() { done } func_defined clean_all || clean_all() { - rm -rf "$workdir" -- *.out + rm -rf "$workdir" *.out OLDIFS=$IFS IFS=$'\n' for f in $files; do @@ -106,7 +103,7 @@ addtodb() { echo "auto $port $version" >> "$prefix"/packages.db else echo "manual $port $version" >> "$prefix"/packages.db - if [ -n "${dependlist:-}" ]; then + if [ ! -z "${dependlist:-}" ]; then echo "dependency $port$dependlist" >> "$prefix/packages.db" fi fi @@ -197,10 +194,10 @@ if [ -z "${1:-}" ]; then else case "$1" in fetch|configure|build|install|clean|clean_dist|clean_all|uninstall) - do_"$1" + do_$1 ;; --auto) - do_all "$1" + do_all $1 ;; *) >&2 echo "I don't understand $1! Supported arguments: fetch, configure, build, install, clean, clean_dist, clean_all, uninstall." diff --git a/Ports/SDL2/package.sh b/Ports/SDL2/package.sh index 0e9018ab947..a1a2c0a8f49 100755 --- a/Ports/SDL2/package.sh +++ b/Ports/SDL2/package.sh @@ -1,4 +1,4 @@ -#!/bin/sh ../.port_include.sh +#!/bin/bash ../.port_include.sh port=SDL2 version=serenity-git workdir=SDL-master-serenity @@ -8,5 +8,5 @@ files="https://github.com/SerenityOS/SDL/archive/master-serenity.tar.gz SDL2-git configopts="-DCMAKE_TOOLCHAIN_FILE=$SERENITY_ROOT/Toolchain/CMakeToolchain.txt -DPULSEAUDIO=OFF" configure() { - run cmake "$configopts" + run cmake $configopts } diff --git a/Ports/bash/package.sh b/Ports/bash/package.sh index f378c32945a..56daeb313fb 100755 --- a/Ports/bash/package.sh +++ b/Ports/bash/package.sh @@ -1,4 +1,4 @@ -#!/bin/sh ../.port_include.sh +#!/bin/bash ../.port_include.sh port=bash version=5.0 useconfigure=true @@ -8,5 +8,5 @@ files="https://ftp.gnu.org/gnu/bash/bash-5.0.tar.gz bash-5.0.tar.gz" build() { run_replace_in_file "s/define GETCWD_BROKEN 1/undef GETCWD_BROKEN/" config.h run_replace_in_file "s/define CAN_REDEFINE_GETENV 1/undef CAN_REDEFINE_GETENV/" config.h - run make "$makeopts" + run make $makeopts } diff --git a/Ports/binutils/package.sh b/Ports/binutils/package.sh index cbf25317107..7bd21d6dd85 100755 --- a/Ports/binutils/package.sh +++ b/Ports/binutils/package.sh @@ -1,4 +1,4 @@ -#!/bin/sh ../.port_include.sh +#!/bin/bash ../.port_include.sh port=binutils version=2.32 useconfigure=true diff --git a/Ports/curl/package.sh b/Ports/curl/package.sh index 506b8ba4239..0928376f716 100755 --- a/Ports/curl/package.sh +++ b/Ports/curl/package.sh @@ -1,4 +1,4 @@ -#!/bin/sh ../.port_include.sh +#!/bin/bash ../.port_include.sh port=curl version=7.65.3 useconfigure=true diff --git a/Ports/doom/package.sh b/Ports/doom/package.sh index 4efcb070430..a58e8778c29 100755 --- a/Ports/doom/package.sh +++ b/Ports/doom/package.sh @@ -1,4 +1,4 @@ -#!/bin/sh ../.port_include.sh +#!/bin/bash ../.port_include.sh port=doom workdir=SerenityDOOM-master version=serenity-git diff --git a/Ports/figlet/package.sh b/Ports/figlet/package.sh index 2aa1829ad79..a971e021426 100755 --- a/Ports/figlet/package.sh +++ b/Ports/figlet/package.sh @@ -1,4 +1,4 @@ -#!/bin/sh ../.port_include.sh +#!/bin/bash ../.port_include.sh port=figlet version=2.2.5 files="http://ftp.figlet.org/pub/figlet/program/unix/figlet-2.2.5.tar.gz figlet-2.2.5.tar.gz" diff --git a/Ports/gcc/package.sh b/Ports/gcc/package.sh index 237a6847fb6..9b9df8f3076 100755 --- a/Ports/gcc/package.sh +++ b/Ports/gcc/package.sh @@ -1,4 +1,4 @@ -#!/bin/sh ../.port_include.sh +#!/bin/bash ../.port_include.sh port=gcc version=8.3.0 useconfigure=true @@ -18,10 +18,10 @@ fetch() { done } build() { - run make "$makeopts" + run make $makeopts run find ./host-i686-pc-serenity/gcc/ -maxdepth 1 -type f -executable -exec strip --strip-debug {} \; || echo } install() { - run make "$installopts" + run make $installopts } diff --git a/Ports/less/package.sh b/Ports/less/package.sh index 9fa9b2579a6..2cb55c6142c 100755 --- a/Ports/less/package.sh +++ b/Ports/less/package.sh @@ -1,4 +1,4 @@ -#!/bin/sh ../.port_include.sh +#!/bin/bash ../.port_include.sh port=less version=530 useconfigure="true" diff --git a/Ports/libarchive/package.sh b/Ports/libarchive/package.sh index 6573d0f0d0e..c6c41e7886f 100755 --- a/Ports/libarchive/package.sh +++ b/Ports/libarchive/package.sh @@ -1,4 +1,4 @@ -#!/bin/sh ../.port_include.sh +#!/bin/bash ../.port_include.sh port=libarchive version=3.4.0 useconfigure=true diff --git a/Ports/libexpat/package.sh b/Ports/libexpat/package.sh index 4ee86a10570..68c9d14695d 100755 --- a/Ports/libexpat/package.sh +++ b/Ports/libexpat/package.sh @@ -1,4 +1,4 @@ -#!/bin/sh ../.port_include.sh +#!/bin/bash ../.port_include.sh port=libexpat version=2.2.9 useconfigure=true diff --git a/Ports/libiconv/package.sh b/Ports/libiconv/package.sh index 99b0a59ff49..d4a5c58b27e 100755 --- a/Ports/libiconv/package.sh +++ b/Ports/libiconv/package.sh @@ -1,4 +1,4 @@ -#!/bin/sh ../.port_include.sh +#!/bin/bash ../.port_include.sh port=libiconv version=1.16 useconfigure=true diff --git a/Ports/links/package.sh b/Ports/links/package.sh index 5916ab2b893..8fa6af3d405 100755 --- a/Ports/links/package.sh +++ b/Ports/links/package.sh @@ -1,4 +1,4 @@ -#!/bin/sh ../.port_include.sh +#!/bin/bash ../.port_include.sh port=links version=2.19 useconfigure=true diff --git a/Ports/lua/package.sh b/Ports/lua/package.sh index 578dfa4ac1e..897cec6fcf1 100755 --- a/Ports/lua/package.sh +++ b/Ports/lua/package.sh @@ -1,4 +1,4 @@ -#!/bin/sh ../.port_include.sh +#!/bin/bash ../.port_include.sh port=lua version=5.3.5 files="http://www.lua.org/ftp/lua-5.3.5.tar.gz lua-5.3.5.tar.gz" diff --git a/Ports/make/package.sh b/Ports/make/package.sh index 50feed23d37..57c22af21b5 100755 --- a/Ports/make/package.sh +++ b/Ports/make/package.sh @@ -1,4 +1,4 @@ -#!/bin/sh ../.port_include.sh +#!/bin/bash ../.port_include.sh port=make version=4.2.1 useconfigure=true diff --git a/Ports/mbedtls/package.sh b/Ports/mbedtls/package.sh index af95825dac8..ab8b74081ec 100755 --- a/Ports/mbedtls/package.sh +++ b/Ports/mbedtls/package.sh @@ -1,4 +1,4 @@ -#!/bin/sh ../.port_include.sh +#!/bin/bash ../.port_include.sh port=mbedtls version=2.16.2 files="https://tls.mbed.org/download/mbedtls-2.16.2-apache.tgz mbedtls-2.16.2-apache.tgz" diff --git a/Ports/ncurses/package.sh b/Ports/ncurses/package.sh index 463f4500706..13b2901a98e 100755 --- a/Ports/ncurses/package.sh +++ b/Ports/ncurses/package.sh @@ -1,4 +1,4 @@ -#!/bin/sh ../.port_include.sh +#!/bin/bash ../.port_include.sh port=ncurses version=git workdir=ncurses-master diff --git a/Ports/nyancat/package.sh b/Ports/nyancat/package.sh index 2c4512f305f..fea6a59ea96 100755 --- a/Ports/nyancat/package.sh +++ b/Ports/nyancat/package.sh @@ -1,4 +1,4 @@ -#!/bin/sh ../.port_include.sh +#!/bin/bash ../.port_include.sh port=nyancat version=git workdir=nyancat-master diff --git a/Ports/quake/package.sh b/Ports/quake/package.sh index 356d067749d..91326e430e4 100755 --- a/Ports/quake/package.sh +++ b/Ports/quake/package.sh @@ -1,4 +1,4 @@ -#!/bin/sh ../.port_include.sh +#!/bin/bash ../.port_include.sh port=quake version=0.65 workdir=SerenityQuake-master diff --git a/Ports/tinycc/package.sh b/Ports/tinycc/package.sh index 4208f96f415..7722431730e 100755 --- a/Ports/tinycc/package.sh +++ b/Ports/tinycc/package.sh @@ -1,4 +1,4 @@ -#!/bin/sh ../.port_include.sh +#!/bin/bash ../.port_include.sh port=tinycc workdir=tinycc-dev version=dev diff --git a/Ports/vim/package.sh b/Ports/vim/package.sh index 475e9c74d7b..6843e000474 100755 --- a/Ports/vim/package.sh +++ b/Ports/vim/package.sh @@ -1,4 +1,4 @@ -#!/bin/sh ../.port_include.sh +#!/bin/bash ../.port_include.sh port=vim version=git workdir=vim-master diff --git a/Ports/zlib/package.sh b/Ports/zlib/package.sh index e923feca167..04f2a62de86 100755 --- a/Ports/zlib/package.sh +++ b/Ports/zlib/package.sh @@ -1,4 +1,4 @@ -#!/bin/sh ../.port_include.sh +#!/bin/bash ../.port_include.sh port=zlib version=1.2.11 useconfigure=true