From 649afc4d17e5f83f4bc0b1f9eeafe744cc6d717d Mon Sep 17 00:00:00 2001
From: Ribbon <ribbon_45@proton.me>
Date: Mon, 8 Jul 2024 03:19:57 +0000
Subject: [PATCH] Update and convert recipes to TOML

---
 recipes/wip/dev/lang/perl5/recipe.sh       | 34 -------------------
 recipes/wip/dev/lang/perl5/recipe.toml     | 24 ++++++++++++++
 recipes/wip/dev/lang/python310/recipe.toml | 13 ++++++--
 recipes/wip/dev/lang/python312/recipe.toml | 13 ++++++--
 recipes/wip/dev/lang/python37/recipe.sh    | 38 ----------------------
 recipes/wip/dev/lang/python37/recipe.toml  | 23 +++++++++++++
 recipes/wip/terminal/openssh/recipe.sh     | 28 ----------------
 recipes/wip/terminal/openssh/recipe.toml   | 13 ++++++++
 recipes/wip/vm/qemu/recipe.sh              | 34 -------------------
 recipes/wip/vm/qemu/recipe.toml            | 18 ++++++++++
 recipes/wip/web/servo/recipe.sh            | 27 ---------------
 recipes/wip/web/servo/recipe.toml          | 24 ++++++++++++++
 12 files changed, 124 insertions(+), 165 deletions(-)
 delete mode 100644 recipes/wip/dev/lang/perl5/recipe.sh
 create mode 100644 recipes/wip/dev/lang/perl5/recipe.toml
 delete mode 100644 recipes/wip/dev/lang/python37/recipe.sh
 create mode 100644 recipes/wip/dev/lang/python37/recipe.toml
 delete mode 100644 recipes/wip/terminal/openssh/recipe.sh
 create mode 100644 recipes/wip/terminal/openssh/recipe.toml
 delete mode 100644 recipes/wip/vm/qemu/recipe.sh
 create mode 100644 recipes/wip/vm/qemu/recipe.toml
 delete mode 100644 recipes/wip/web/servo/recipe.sh
 create mode 100644 recipes/wip/web/servo/recipe.toml

diff --git a/recipes/wip/dev/lang/perl5/recipe.sh b/recipes/wip/dev/lang/perl5/recipe.sh
deleted file mode 100644
index eb5caac92..000000000
--- a/recipes/wip/dev/lang/perl5/recipe.sh
+++ /dev/null
@@ -1,34 +0,0 @@
-VERSION=5.24.2
-TAR=https://www.cpan.org/src/5.0/perl-$VERSION.tar.gz
-
-unset AR AS CC CXX LD NM OBJCOPY OBJDUMP RANLIB READELF STRIP
-
-function recipe_version {
-    echo "$VERSION"
-    skip=1
-}
-
-function recipe_build {
-    curl -L -O --time-cond perl-cross-1.1.6.tar.gz https://github.com/arsv/perl-cross/releases/download/1.1.6/perl-cross-1.1.6.tar.gz
-    tar --strip-components=1 -xvf perl-cross-1.1.6.tar.gz
-    wget -O cnf/config.sub "https://gitlab.redox-os.org/redox-os/gnu-config/-/raw/master/config.sub?inline=false"
-    sysroot="$($HOST-gcc -print-sysroot)"
-    ./configure --build=${BUILD} --target=${HOST} --prefix='/' --sysroot="$sysroot" --disable-mod=Sys-Syslog,Time-HiRes --with-libs='m'
-    sed -i "s/^#define Netdb_name_t.*/#define Netdb_name_t const char*/" config.h # XXX
-    sed -i 's/#define Strerror(e).*$/#define Strerror(e) strerror(e)/' config.h #
-    echo "#define HAS_VPRINTF" >> config.h
-    "$REDOX_MAKE" -j"$($NPROC)"
-    skip=1
-}
-
-function recipe_clean {
-    "$REDOX_MAKE" clean
-    skip=1
-}
-
-function recipe_stage {
-    dest="$(realpath $1)"
-    "$REDOX_MAKE" DESTDIR="$dest" install
-    rm -rf "$1/man"
-    skip=1
-}
diff --git a/recipes/wip/dev/lang/perl5/recipe.toml b/recipes/wip/dev/lang/perl5/recipe.toml
new file mode 100644
index 000000000..d40745280
--- /dev/null
+++ b/recipes/wip/dev/lang/perl5/recipe.toml
@@ -0,0 +1,24 @@
+#TODO incomplete script
+#TODO does the patch is still needed?
+#TODO update the patch to match the current version
+[source]
+tar = "https://www.cpan.org/src/5.0/perl-5.40.0.tar.gz"
+patches = [
+    "perl.patch",
+]
+[build]
+template = "custom"
+script = """
+curl -L -O --time-cond perl-cross-1.5.3.tar.gz https://github.com/arsv/perl-cross/releases/download/1.5.3/perl-cross-1.5.3.tar.gz
+tar --strip-components=1 -xvf perl-cross-1.5.3.tar.gz
+wget -O cnf/config.sub "https://gitlab.redox-os.org/redox-os/gnu-config/-/raw/master/config.sub?inline=false"
+sysroot="$($HOST-gcc -print-sysroot)" # does it is still needed?
+sed -i "s/^#define Netdb_name_t.*/#define Netdb_name_t const char*/" config.h # XXX
+sed -i 's/#define Strerror(e).*$/#define Strerror(e) strerror(e)/' config.h #
+echo "#define HAS_VPRINTF" >> config.h
+COOKBOOK_CONFIGURE_FLAGS+=(
+    --disable-mod=Sys-Syslog,Time-HiRes
+    --with-libs='m'
+)
+cookbook_configure
+"""
diff --git a/recipes/wip/dev/lang/python310/recipe.toml b/recipes/wip/dev/lang/python310/recipe.toml
index c2d9436e2..8ed9e88e9 100644
--- a/recipes/wip/dev/lang/python310/recipe.toml
+++ b/recipes/wip/dev/lang/python310/recipe.toml
@@ -1,5 +1,14 @@
-#TODO configuration error
+#TODO not compiled or tested
 [source]
 tar = "https://www.python.org/ftp/python/3.10.13/Python-3.10.13.tar.xz"
 [build]
-template = "configure"
+template = "custom"
+dependencies = [
+    "openssl1",
+]
+script = """
+COOKBOOK_CONFIGURE_FLAGS+=(
+    --disable-ipv6
+)
+cookbook_configure
+"""
diff --git a/recipes/wip/dev/lang/python312/recipe.toml b/recipes/wip/dev/lang/python312/recipe.toml
index 51c7f2322..598eef14a 100644
--- a/recipes/wip/dev/lang/python312/recipe.toml
+++ b/recipes/wip/dev/lang/python312/recipe.toml
@@ -1,5 +1,14 @@
-#TODO configuration error
+#TODO not compiled or tested
 [source]
 tar = "https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tar.xz"
 [build]
-template = "configure"
+template = "custom"
+dependencies = [
+    "openssl1",
+]
+script = """
+COOKBOOK_CONFIGURE_FLAGS+=(
+    --disable-ipv6
+)
+cookbook_configure
+"""
diff --git a/recipes/wip/dev/lang/python37/recipe.sh b/recipes/wip/dev/lang/python37/recipe.sh
deleted file mode 100644
index 1c92b6d6e..000000000
--- a/recipes/wip/dev/lang/python37/recipe.sh
+++ /dev/null
@@ -1,38 +0,0 @@
-VERSION=3.7.4
-TAR=https://www.python.org/ftp/python/$VERSION/Python-$VERSION.tar.xz
-BUILD_DEPENDS=(openssl1)
-
-export CONFIG_SITE=config.site
-
-function recipe_version {
-    echo "$VERSION"
-    skip=1
-}
-
-function recipe_build {
-    export LDFLAGS="-static"
-    cp ../config.site ./
-    ./configure \
-        --build=${BUILD} \
-        --host=${HOST} \
-        --build=${ARCH} \
-        --prefix=/ \
-        --disable-ipv6
-    sed -i 's|#define HAVE_PTHREAD_KILL 1|/* #undef HAVE_PTHREAD_KILL */|g' pyconfig.h
-    sed -i 's|#define HAVE_SCHED_SETSCHEDULER 1|/* #undef HAVE_SCHED_SETSCHEDULER */|g' pyconfig.h
-    sed -i 's|#define HAVE_SYS_RESOURCE_H 1|/* #undef HAVE_SYS_RESOURCE_H */|g' pyconfig.h
-    "$REDOX_MAKE" -j"$($NPROC)"
-    skip=1
-}
-
-function recipe_clean {
-    "$REDOX_MAKE" clean
-    skip=1
-}
-
-function recipe_stage {
-    dest="$(realpath $1)"
-    "$REDOX_MAKE" DESTDIR="$dest" install -j"$($NPROC)"
-    "$STRIP" "$dest/bin/python3.7" "$dest/bin/python3.7m"
-    skip=1
-}
diff --git a/recipes/wip/dev/lang/python37/recipe.toml b/recipes/wip/dev/lang/python37/recipe.toml
new file mode 100644
index 000000000..beb86e4c6
--- /dev/null
+++ b/recipes/wip/dev/lang/python37/recipe.toml
@@ -0,0 +1,23 @@
+#TODO not compiled or tested
+#TODO does the patch is still needed?
+#TODO maybe the script is wrong
+[source]
+tar = "https://www.python.org/ftp/python/3.7.17/Python-3.7.17.tar.xz"
+patches = [
+    "redox.patch",
+]
+[build]
+template = "custom"
+dependencies = [
+    "openssl1",
+]
+script = """
+cp ../config.site ./
+sed -i 's|#define HAVE_PTHREAD_KILL 1|/* #undef HAVE_PTHREAD_KILL */|g' pyconfig.h
+sed -i 's|#define HAVE_SCHED_SETSCHEDULER 1|/* #undef HAVE_SCHED_SETSCHEDULER */|g' pyconfig.h
+sed -i 's|#define HAVE_SYS_RESOURCE_H 1|/* #undef HAVE_SYS_RESOURCE_H */|g' pyconfig.h
+COOKBOOK_CONFIGURE_FLAGS+=(
+    --disable-ipv6
+)
+cookbook_configure
+"""
diff --git a/recipes/wip/terminal/openssh/recipe.sh b/recipes/wip/terminal/openssh/recipe.sh
deleted file mode 100644
index 6b8e08fb1..000000000
--- a/recipes/wip/terminal/openssh/recipe.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-VERSION=7.9p1
-TAR=https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-$VERSION.tar.gz
-BUILD_DEPENDS=(openssl1 zlib)
-
-function recipe_version {
-    echo "$VERSION"
-    skip=1
-}
-
-function recipe_build {
-    sysroot="$(realpath ../sysroot)"
-    export LDFLAGS="-L$sysroot/lib"
-    export CPPFLAGS="-I$sysroot/include"
-    ./configure --build=${BUILD} --host=${HOST} --prefix=/
-    "$REDOX_MAKE" -j$(nproc)
-    skip=1
-}
-
-function recipe_clean {
-    "$REDOX_MAKE" clean
-    skip=1
-}
-
-function recipe_stage {
-    dest="$(realpath $1)"
-    "$REDOX_MAKE" DESTDIR="$dest" install
-    skip=1
-}
diff --git a/recipes/wip/terminal/openssh/recipe.toml b/recipes/wip/terminal/openssh/recipe.toml
new file mode 100644
index 000000000..4d7261da5
--- /dev/null
+++ b/recipes/wip/terminal/openssh/recipe.toml
@@ -0,0 +1,13 @@
+#TODO update the patch to match the current version
+#TODO does the patch is still needed?
+[source]
+tar = "https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.8p1.tar.gz"
+patches = [
+    "redox.patch",
+]
+[build]
+template = "configure"
+dependencies = [
+    "openssl1",
+    "zlib",
+]
diff --git a/recipes/wip/vm/qemu/recipe.sh b/recipes/wip/vm/qemu/recipe.sh
deleted file mode 100644
index b0c3d46d2..000000000
--- a/recipes/wip/vm/qemu/recipe.sh
+++ /dev/null
@@ -1,34 +0,0 @@
-VERSION=3.1.0
-TAR=https://download.qemu.org/qemu-$VERSION.tar.xz
-BUILD_DEPENDS=(curl glib libiconv libpng pcre pixman sdl1 zlib)
-
-function recipe_version {
-    echo "$VERSION"
-    skip=1
-}
-
-function recipe_build {
-    sysroot="$(realpath ../sysroot)"
-    export CFLAGS="-I$sysroot/include"
-    export CPPFLAGS="-I$sysroot/include"
-    export LDFLAGS="-L$sysroot/lib"
-    ./configure \
-        --build=${BUILD} \
-        --host="${HOST}" \
-        --prefix=/
-    "$REDOX_MAKE" -j"$($NPROC)"
-    skip=1
-}
-
-function recipe_clean {
-    "$REDOX_MAKE" clean
-    skip=1
-}
-
-function recipe_stage {
-    #export LLVM_CONFIG="x86_64-unknown-redox-llvm-config"
-    dest="$(realpath $1)"
-    "$REDOX_MAKE" DESTDIR="$dest" install
-    rm -f "$dest/lib/"*.la
-    skip=1
-}
diff --git a/recipes/wip/vm/qemu/recipe.toml b/recipes/wip/vm/qemu/recipe.toml
new file mode 100644
index 000000000..0ef0c8238
--- /dev/null
+++ b/recipes/wip/vm/qemu/recipe.toml
@@ -0,0 +1,18 @@
+#TODO update the patch to match the current qemu version
+[source]
+tar = "https://download.qemu.org/qemu-9.0.1.tar.xz"
+patches = [
+    "redox.patch",
+]
+[build]
+template = "configure"
+dependencies = [
+    "curl",
+    "glib",
+    "libiconv",
+    "libpng",
+    "pcre",
+    "pixman",
+    "sdl2",
+    "zlib",
+]
diff --git a/recipes/wip/web/servo/recipe.sh b/recipes/wip/web/servo/recipe.sh
deleted file mode 100644
index b24a58048..000000000
--- a/recipes/wip/web/servo/recipe.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-GIT=https://gitlab.redox-os.org/redox-os/servo.git
-GIT_UPSTREAM=https://github.com/servo/servo.git
-BRANCH=redox
-BUILD_DEPENDS=(freetype2 gettext glib gstreamer harfbuzz libffi libiconv libpng openssl1 pcre zlib)
-PREPARE_COPY=0
-
-function recipe_version {
-    printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
-    skip=1
-}
-
-function recipe_build {
-    source="$(realpath ../source)"
-    unset AR AS CC CXX LD NM OBJCOPY OBJDUMP RANLIB READELF STRIP
-    "$source/mach" build --target "${TARGET}" --release --with-frame-pointer # --jobs "$(nproc)"
-    skip=1
-}
-
-function recipe_clean {
-    echo "skipping clean"
-    skip=1
-}
-
-function recipe_stage {
-    echo "skipping stage"
-    skip=1
-}
diff --git a/recipes/wip/web/servo/recipe.toml b/recipes/wip/web/servo/recipe.toml
new file mode 100644
index 000000000..83b7873f4
--- /dev/null
+++ b/recipes/wip/web/servo/recipe.toml
@@ -0,0 +1,24 @@
+#TODO not compiled or tested
+# if the script is wrong, read this - https://github.com/servo/servo#release-build
+# advanced build instructions - https://github.com/servo/servo/wiki/Building#manual-build-setup
+[source]
+git = "https://github.com/servo/servo"
+#git = "https://gitlab.redox-os.org/redox-os/servo"
+[build]
+template = "custom"
+dependencies = [
+    "freetype2",
+    "gettext",
+    "glib",
+    "gstreamer",
+    "harfbuzz",
+    "libffi",
+    "libiconv",
+    "libpng",
+    "openssl1",
+    "pcre",
+    "zlib",
+]
+script = """
+cookbook_cargo_packages servoshell
+"""
-- 
GitLab