diff options
| author | cpplover0 <osdev555@yandex.com> | 2025-09-25 21:32:38 +0300 |
|---|---|---|
| committer | cpplover0 <osdev555@yandex.com> | 2025-09-25 21:32:38 +0300 |
| commit | 8c701b78363e3d3d4d6f373ce5642435c651e76a (patch) | |
| tree | 1cffa6b7e5e7f15b8494d5b99da28556b4143c81 | |
| parent | af06ca180e33f80fd9e95f2101e6a17728fc7178 (diff) | |
trying to use jinx
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | Jinxfile | 184 | ||||
| -rw-r--r-- | build-pkg.sh | 12 | ||||
| -rw-r--r-- | build-x86_64/.jinx-parameters | 5 | ||||
| -rwxr-xr-x | jinx | 1778 | ||||
| -rw-r--r-- | recipes/mlibc | 27 | ||||
| -rw-r--r-- | tar-initrd.sh | 60 | ||||
| -rw-r--r-- | tools/build-init.sh | 10 | ||||
| -rw-r--r-- | tools/pkg/0/mlibc/pkg.sh | 2 | ||||
| -rw-r--r-- | tools/pkg/1/libgpg-error/diff/libgpg-error.diff | 41 | ||||
| -rw-r--r-- | tools/pkg/1/libgpg-error/info.txt | 1 | ||||
| -rw-r--r-- | tools/pkg/1/libgpg-error/pkg.sh | 22 | ||||
| -rw-r--r-- | tools/pkg/2/libgcrypt/diff/libgcrypt.diff | 12 | ||||
| -rw-r--r-- | tools/pkg/2/libgcrypt/info.txt | 1 | ||||
| -rw-r--r-- | tools/pkg/2/libgcrypt/pkg.sh | 24 | ||||
| -rw-r--r-- | tools/pkg/4/xorg-server/diff/xorg-server.diff | 12 | ||||
| -rw-r--r-- | tools/pkg/4/xorg-server/info.txt | 1 | ||||
| -rw-r--r-- | tools/pkg/4/xorg-server/pkg.sh | 52 |
18 files changed, 2213 insertions, 33 deletions
@@ -14,11 +14,13 @@ kernel/cc-runtime-x86_64 kernel/freestnd-c-hdrs
kernel/freestnd-cxx-hdrs
main.o
+.jinx-cache
serial.txt
output.txt
Orange-distro-build
ovmf
cached
+.vscode
linux-headers
initrd/usr/lib
initrd/usr/include
diff --git a/Jinxfile b/Jinxfile new file mode 100644 index 0000000..ab64744 --- /dev/null +++ b/Jinxfile @@ -0,0 +1,184 @@ +#! /bin/sh + +JINX_MAJOR_VER=0.7 + +HOST_CFLAGS="-O2 -pipe -fstack-clash-protection" +HOST_CXXFLAGS="${HOST_CFLAGS} -Wp,-D_GLIBCXX_ASSERTIONS" +HOST_LDFLAGS="-Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now" + +TARGET_CFLAGS="$HOST_CFLAGS" +TARGET_CXXFLAGS="$HOST_CXXFLAGS" +TARGET_LDFLAGS="$HOST_LDFLAGS" + +OS_TRIPLET=${JINX_ARCH}-orange + +case "${JINX_ARCH}" in + x86_64) + TARGET_CFLAGS="$TARGET_CFLAGS -march=x86-64 -mtune=generic -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer" + TARGET_CXXFLAGS="$TARGET_CXXFLAGS -march=x86-64 -mtune=generic -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer" + TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,-z,pack-relative-relocs" + ;; +esac + +post_package_strip() { + if [ -z "$strip_command" ]; then + strip_command="${OS_TRIPLET}-strip" + fi + + for f in $(find "${dest_dir}"); do + if file "$f" | grep 'not stripped' >/dev/null; then + echo "* stripping '$f'..." + stripped_file="$(mktemp)" + ${strip_command} "$f" -o "$stripped_file" + chmod --reference="$f" "$stripped_file" + mv -f "$stripped_file" "$f" + fi + done +} + +autotools_configure() { + CFLAGS="$TARGET_CFLAGS" \ + CXXFLAGS="$TARGET_CXXFLAGS" \ + LDFLAGS="$TARGET_LDFLAGS" \ + autotools_configure_noflags "$@" +} + +autotools_configure_noflags() { + if [ -z "${configure_script_path}" ]; then + configure_script_path="${source_dir}/configure" + fi + + ac_cv_func_malloc_0_nonnull=yes \ + ac_cv_func_calloc_0_nonnull=yes \ + ac_cv_func_realloc_0_nonnull=yes \ + ${configure_script_path} \ + --host=${OS_TRIPLET} \ + --with-sysroot=${sysroot_dir} \ + --prefix=${prefix} \ + --sysconfdir=/etc \ + --localstatedir=/var \ + --bindir=${prefix}/bin \ + --sbindir=${prefix}/bin \ + --libdir=${prefix}/lib \ + --disable-static \ + --enable-shared \ + --disable-malloc0returnsnull \ + "$@" +} + +checked_subst() { + tmpfile="$2".checked_subst + sed -z -E -e "$1" "$2" >"$tmpfile" + if cmp -s "$2" "$tmpfile"; then + rm -f "$2".checked_subst + if [ "$3" = no_die ]; then + return 1 + else + die "*** substitution '$1' failed for file '$2'" + fi + fi + + #diff --color=auto -ur "$2" "$tmpfile" || true + + touch -r "$2" "$2".checked_subst + chmod --reference="$2" "$2".checked_subst + mv -f "$2".checked_subst "$2" +} + +autotools_recursive_regen() { + for f in $(grep -rl 'GNU config.sub ($timestamp)'); do + mv "$f" "$f".reference + cp -v ${base_dir}/build-support/config.sub "$f" + touch -r "$f".reference "$f" + rm -f "$f".reference + done + for f in $(grep -rl 'GNU config.guess ($timestamp)'); do + mv "$f" "$f".reference + cp -v ${base_dir}/build-support/config.guess "$f" + touch -r "$f".reference "$f" + rm -f "$f".reference + done + + if ! [ -z "$(grep -rl "# No shared lib support for Linux oldld, aout, or coff.")" ]; then + if [ -z "$(grep -rl "dynamic_linker='mlibc ld.so'")" ]; then + echo "*** Missing libtool support for mlibc - trying to patch support in :3 ***" + for f in $(grep -rl "We cannot seem to hardcode it, guess we'll fake it."); do + if grep -q 'add_dir="\?-L$lt_sysroot$libdir"\?' "$f"; then + continue + fi + checked_subst 's/add_dir=(")?-L\$libdir(")?/add_dir=\1-L$lt_sysroot$libdir\1/g' "$f" + done + for f in $(grep -rl "# No shared lib support for Linux oldld, aout, or coff."); do + if grep -q 'AC_DEFUN(\[AC_PROG_LIBTOOL\]' "$f"; then + continue + fi + if grep -q 'ltconfig - Create a system-specific libtool' "$f"; then + continue + fi + checked_subst 's/(# This must be (glibc\/|Linux )?ELF.\nlinux\* \| k\*bsd\*-gnu \| kopensolaris\*-gnu( \| gnu\*)?( \| uclinuxfdpiceabi)?)(\)\n lt_cv_deplibs_check_method=pass_all)/\1 | *-mlibc\5/g' "$f" + checked_subst 's/(\)\n # FreeBSD uses GNU C)/ | *-mlibc\1/g' "$f" no_die || true + checked_subst 's/(lt_prog_compiler_static(_[^=]*)?='"'"'-non_shared'"'"'\n ;;)(\n\n linux\* \| k\*bsd\*-gnu \| kopensolaris\*-gnu( \| gnu\*)?\))/\1\n\n *-mlibc)\n lt_prog_compiler_wl\2='"'"'-Wl,'"'"'\n lt_prog_compiler_pic\2='"'"'-fPIC'"'"'\n lt_prog_compiler_static\2='"'"'-static'"'"'\n ;;\3/g' "$f" + checked_subst 's/( (haiku|interix\[3-9\])?\*\)\n (archive_cmds|hardcode_direct)?(_[^=]*)?=)/ *-mlibc)\n archive_cmds\4='"'"'$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'"'"'\n archive_expsym_cmds\4='"'"'$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'"'"'\n ;;\n\n\1/g' "$f" + checked_subst 's/(\)\n # FreeBSD 3 and later use GNU C)/ | *-mlibc\1/g' "$f" no_die || true + # putting this last to avoid a bug with determining whether the substitutions should be run or not. + checked_subst 's/(hardcode_into_libs=yes\n ;;\n\n)(# No shared lib support for Linux oldld, aout, or coff.)/\1*-mlibc)\n version_type=linux\n need_lib_prefix=no\n need_version=no\n library_names_spec='"'"'$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'"'"'\n soname_spec='"'"'$libname$release$shared_ext$major'"'"'\n dynamic_linker='"'"'mlibc ld.so'"'"'\n shlibpath_var=LD_LIBRARY_PATH\n shlibpath_overrides_runpath=no\n hardcode_into_libs=yes\n ;;\n\n\2/g' "$f" + done + fi + fi +} + +meson_configure() { + CFLAGS="$TARGET_CFLAGS" \ + CXXFLAGS="$TARGET_CXXFLAGS" \ + LDFLAGS="$TARGET_LDFLAGS" \ + meson_configure_noflags "$@" +} + +meson_configure_noflags() { + if [ -z "${meson_source_dir}" ]; then + meson_source_dir="${source_dir}" + fi + + meson setup "${meson_source_dir}" \ + --cross-file "${base_dir}/build-support/cross_file-${JINX_ARCH}.txt" \ + --prefix=${prefix} \ + --sysconfdir=/etc \ + --localstatedir=/var \ + --libdir=lib \ + --sbindir=bin \ + --buildtype=release \ + --wrap-mode=nodownload \ + -Ddefault_library=shared \ + "$@" +} + +cmake_configure() { + CFLAGS="$TARGET_CFLAGS" \ + CXXFLAGS="$TARGET_CXXFLAGS" \ + LDFLAGS="$TARGET_LDFLAGS" \ + cmake_configure_noflags \ + "$@" +} + +cmake_configure_noflags() { + if [ -z "${cmake_source_dir}" ]; then + cmake_source_dir="${source_dir}" + fi + + cmake "${cmake_source_dir}" \ + -DCMAKE_MODULE_PATH="${base_dir}/build-support/cmake-host" \ + -DCMAKE_TOOLCHAIN_FILE="${base_dir}/build-support/CMakeToolchain-${JINX_ARCH}.txt" \ + -DCMAKE_INSTALL_PREFIX=${prefix} \ + -DCMAKE_INSTALL_SYSCONFDIR=/etc \ + -DCMAKE_INSTALL_LOCALSTATEDIR=/var \ + -DCMAKE_INSTALL_LIBDIR=lib \ + -DCMAKE_INSTALL_SBINDIR=bin \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=ON \ + -DBUILD_STATIC_LIBS=OFF \ + -DENABLE_STATIC=OFF \ + -DPKG_CONFIG_EXECUTABLE="/usr/local/bin/$OS_TRIPLET-pkg-config" \ + -DCMAKE_COLOR_DIAGNOSTICS=ON \ + -GNinja \ + "$@" +} diff --git a/build-pkg.sh b/build-pkg.sh index 9637c6d..188beeb 100644 --- a/build-pkg.sh +++ b/build-pkg.sh @@ -9,27 +9,27 @@ cd ../../../../ cd initrd/lib -echo Creating symlinks ./*.so +#echo Creating symlinks ./*.so for file in ../usr/lib/*.so; do - echo $file "$(basename "$file")" + #echo $file "$(basename "$file")" ln -sf "$file" "$(basename "$file")" done for file in ../usr/local/lib/*.so; do - echo $file "$(basename "$file")" + #echo $file "$(basename "$file")" ln -sf "$file" "$(basename "$file")" done cd ../bin -echo Creating symlinks ./* +#echo Creating symlinks ./* for file in ../usr/bin/*; do - echo $file "$(basename "$file")" + #echo $file "$(basename "$file")" ln -sf "$file" "$(basename "$file")" done for file in ../usr/local/bin/*; do - echo $file "$(basename "$file")" + #echo $file "$(basename "$file")" ln -sf "$file" "$(basename "$file")" done diff --git a/build-x86_64/.jinx-parameters b/build-x86_64/.jinx-parameters new file mode 100644 index 0000000..40c09e5 --- /dev/null +++ b/build-x86_64/.jinx-parameters @@ -0,0 +1,5 @@ +#! /bin/sh + +JINX_SOURCE_DIR="/home/cpplover0/orange" +JINX_ARCH="x86_64" +JINX_ARCH="x86_64" @@ -0,0 +1,1778 @@ +#! /bin/sh + +# Copyright (C) 2022-2025 mintsuki + +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: + +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. + +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +set -e + +IFS=" "" "' +' + +LC_COLLATE=C +export LC_COLLATE + +umask 0022 + +jinx_major_ver="0.7" +jinx_minor_ver="9" + +jinx_version="${jinx_major_ver}.${jinx_minor_ver}" + +debian_snapshot="20250627T143139Z" + +XBPS_VERSION=213c8290ceca38264d2907d6d01f91775951bd14 +XBPS_SHA256SUM=6c4420c86212be203cdbc061ab2e53255f6407e15b7aee307eac2a8f370eb3c4 + +debootstrap_version=1.0.141 +debootstrap_sha256sum=1066dd75b337156cdc4ebace2ad38f68fdff56fb8b7d20a1a4eb9739afe55c12 + +die() { + echo "$1" 1>&2 + exit 1 +} + +if [ -z "$1" ]; then + die "$0: no command specified." +fi + +cmd_help() { + echo "usage: $0 <command> <package(s)>" + printf "\n help|--help Displays this message" + printf "\n version|--version Prints the version" + printf "\n init Initialises a build directory" + printf "\n build Builds package(s), does incremental builds" + printf "\n update Update package(s) and their dependencies if necessary" + printf "\n rebuild Rebuilds package(s)" + printf "\n host-build Same as build, but for host package(s)" + printf "\n host-rebuild Same as rebuild, but for host package(s)" + printf "\n regenerate|regen Regenerates patch for package(s) and re-runs prepare step" + printf "\n install Installs package(s)" + printf "\n reinstall Reinstalls package(s)" + printf "\n rebuild-cache Rebuilds Jinx cache" + printf "\n\nexample: $0 update '*'\n" +} + +cmd_init() { + if ! [ -f "$1"/Jinxfile ]; then + die "$0: Provided source directory contains no Jinxfile" + fi + + srcdir="$1" + + if [ -f ".jinx-parameters" ]; then + die "$0: Current directory already initialised, run '$0 deinit' first" + fi + + if [ -f "Jinxfile" ]; then + die "$0: In-tree builds are not supported" + fi + + cat <<EOF >.jinx-parameters +#! /bin/sh + +JINX_SOURCE_DIR="${srcdir}" +JINX_ARCH="$(uname -m)" +EOF + + shift 1 + + for p in "$@"; do + echo "JINX_$p" | sed 's/=/="/g;s/$/"/g' >>.jinx-parameters + done + + echo "Initialised with '${srcdir}' as source directory" +} + +case "$1" in + version|--version) + echo "Jinx version $jinx_version" + exit 0 + ;; + help|--help) + cmd_help + exit 0 + ;; + init) + shift 1 + cmd_init "$@" + exit 0 + ;; +esac + +if ! [ "$(uname -s)" = "Linux" ]; then + die "$0: Jinx only supports running on Linux hosts." +fi + +script_name="$(basename "$0")" +script_dir="$(dirname "$0")" +if [ "$script_dir" = "." ] || [ -z "$script_dir" ]; then + if echo "$0" | grep "/" >/dev/null 2>&1; then + script_dir=. + else + script_dir="$(dirname $(which "${script_name}"))" + fi +fi +script_dir="$(cd "${script_dir}" && pwd -P)" +script="${script_dir}/${script_name}" + +in_container=false +if [ "$script" = "/base_dir/jinx" ]; then + in_container=true +fi + +case "$1" in + install) + ;; + *) + if [ "${in_container}" = "false" ] && [ "$(id -u)" = "0" ]; then + die "$0: Jinx does not support running as root." + fi + ;; +esac + +if [ -z "$JINX_PARALLELISM" ]; then + max_threads_by_mem="$(( ((($(free | awk '/^Mem:/{print $2}') + 1048575) / 1048576) + 1) / 2 ))" + parallelism="$(nproc 2>/dev/null || echo 1)" + parallelism="$(( $parallelism < $max_threads_by_mem ? $parallelism : $max_threads_by_mem ))" +else + parallelism="$JINX_PARALLELISM" +fi + +if [ "$in_container" = "false" ]; then + build_dir="$(pwd -P)" +else + build_dir=/build_dir +fi + +if ! [ -f "${build_dir}"/.jinx-parameters ]; then + die "$0: Please run '$0 init <source dir> <parameters>' first" +fi + +. "${build_dir}"/.jinx-parameters + +if [ "$in_container" = "false" ]; then + base_dir="$(cd "$JINX_SOURCE_DIR" && pwd -P)" +else + base_dir=/base_dir +fi + +JINX_CONFIG_FILE="${base_dir}/Jinxfile" + +if ! [ -d "$(dirname "$JINX_CONFIG_FILE")" ]; then + die "$0: cannot access Jinxfile directory" +fi +JINX_CONFIG_FILE="$(cd "$(dirname "$JINX_CONFIG_FILE")" && pwd -P)"/"$(basename "$JINX_CONFIG_FILE")" + +if [ -z "$JINX_CACHE_DIR" ]; then + JINX_CACHE_DIR="${base_dir}/.jinx-cache" +fi +if ! [ -d "$(dirname "$JINX_CACHE_DIR")" ]; then + die "$0: cannot access cache directory parent" +fi + +if [ "$in_container" = "false" ]; then + mkdir -p "$JINX_CACHE_DIR" + JINX_CACHE_DIR="$(cd "$JINX_CACHE_DIR" && pwd -P)" + + export PATH="${JINX_CACHE_DIR}/xbps/bin:${JINX_CACHE_DIR}/debootstrap/usr/sbin:${PATH}:/usr/sbin:/sbin" + if ! [ -z "${LD_LIBRARY_PATH}" ]; then + LD_LIBRARY_PATH=":${LD_LIBRARY_PATH}" + fi + export LD_LIBRARY_PATH="${JINX_CACHE_DIR}/xbps/lib${LD_LIBRARY_PATH}" + + mkdir -p "${base_dir}/sources" "${build_dir}/host-builds" "${build_dir}/host-pkgs" "${build_dir}/builds" "${build_dir}/pkgs" +fi + +apt_cache="$JINX_CACHE_DIR/apt-cache" + +temp_collect="" + +cleanup_done=no +cleanup() { + if [ "${cleanup_done}" = "yes" ]; then + return + fi + cleanup_done=yes + eval "rm -rf ${temp_collect}" +} + +trap 'tmp_ret=$?; set +e; cleanup; trap - EXIT; exit ${tmp_ret}' INT TERM HUP QUIT +trap 'tmp_ret=$?; set +e; cleanup; trap - EXIT; exit ${tmp_ret}' EXIT + +make_temp() { + mkdir -p "$JINX_CACHE_DIR/tmp" + tmp="$(mktemp $1 "$JINX_CACHE_DIR/tmp/tmp.XXXXXXXX")" + temp_collect="${temp_collect} \"${tmp}\"" +} + +tracked_subshell() { + ( + temp_collect="" + cleanup_done=no + trap 'tmp_ret=$?; set +e; cleanup; trap - EXIT; exit ${tmp_ret}' INT TERM HUP QUIT + trap 'tmp_ret=$?; set +e; cleanup; trap - EXIT; exit ${tmp_ret}' EXIT + set -e + eval "$1" + ) + retval=$? + if ! [ ${retval} = 0 ]; then + exit ${retval} + fi +} + +include_recipe() { + unset cross_compile + unset name + unset version + unset revision + unset from_source + unset deps + unset builddeps + unset hostdeps + unset hostrundeps + unset imagedeps + unset allow_network + unset source_deps + unset source_hostdeps + unset source_imagedeps + unset source_allow_network + unset clean_workdirs + unset bootstrap_pkg + unset from_source + unset source_dir + unset hg_url + unset tag + unset git_url + unset commit + unset shallow + unset tarball_url + unset tarball_sha256 + unset tarball_sha512 + unset tarball_blake2b + + early_prepare() { + : + } + + prepare() { + : + } + + configure() { + : + } + + build() { + : + } + + package() { + : + } + + if ! [ -f "$1" ]; then + die "$0: recipe '$1' not found" + fi + + . "$1" +} + +build_hostdeps() { + for hostdep in ${hostdeps} ${hostrundeps}; do + [ -f "${base_dir}"/host-recipes/${hostdep} ] || die "missing host dependency '${hostdep}' for recipe '${name}'" + + tracked_subshell ' + do_host_build_if_needed ${hostdep} + ' + done +} + +build_deps() { + for dep in ${deps} ${builddeps}; do + [ -f "${base_dir}"/recipes/${dep} ] || die "missing dependency '${dep}' for recipe '${name}'" + + tracked_subshell ' + do_update ${dep} + ' + done +} + +get_hostdeps_file_run() { + deps_to_do="" + + for hostdep in ${hostrundeps}; do + if ! grep " ${hostdep} " "${hostdeps_file}" >/dev/null 2>&1; then + deps_to_do="${deps_to_do} ${hostdep}" + new_hostdeps_file=" ${hostdep} $(cat "${hostdeps_file}") " + echo "${new_hostdeps_file}" >"${hostdeps_file}" + fi + done + + for hostdep in ${deps_to_do}; do + tracked_subshell ' + include_recipe "${base_dir}"/host-recipes/${hostdep} + get_hostdeps_file + ' + done +} + +get_hostdeps_file() { + deps_to_do="" + + for hostdep in ${hostdeps} ${hostrundeps}; do + if ! grep " ${hostdep} " "${hostdeps_file}" >/dev/null 2>&1; then + deps_to_do="${deps_to_do} ${hostdep}" + new_hostdeps_file=" ${hostdep} $(cat "${hostdeps_file}") " + echo "${new_hostdeps_file}" >"${hostdeps_file}" + fi + done + + for hostdep in ${deps_to_do}; do + tracked_subshell ' + include_recipe "${base_dir}"/host-recipes/${hostdep} + get_hostdeps_file + ' + done +} + +topo_sort_visit() { + case " $_global_visited " in + *" $1 "*) return ;; + esac + _global_visited="$_global_visited $1" + + _deps=$(awk -F: -v node="$1" '$1 == node {print $2; exit}' "$_graph") + for _dep in $_deps; do + [ -n "$_dep" ] && topo_sort_visit "$_dep" + done + + _global_result="$_global_result$1 +" +} + +topo_sort() { + make_temp + _graph="${tmp}" + _global_visited=" " + _global_result="" + + printf '%s\n' "$1" > "$_graph" + + awk -F: '{print $1}' "$_graph" | sort -u | { + while read _node; do + topo_sort_visit "$_node" + done + printf '%s' "$_global_result" | tr '\n' ' ' | sed 's/ $/\n/' + } +} + +get_builddeps() { + pkg="$1" + + include_recipe "${base_dir}/recipes/${pkg}" + + make_temp + deps_file="${tmp}" + + get_builddeps_file + + graph="${pkg}:${deps}" + if ! [ -z "${builddeps}" ]; then + graph=$(echo "${graph} ${builddeps}" | sed 's/: /:/g') + fi + + for dep in $(cat "${deps_file}"); do + if ! [ -f "${base_dir}/recipes/${dep}" ]; then + die "$0: dependency '${dep}' for recipe '${pkg}' not found" + fi + + graph="${graph} +${dep}:$(include_recipe "${base_dir}/recipes/${dep}" && echo ${deps})" + done + + topo_sort "${graph}" +} + +get_builddeps_file() { + deps_to_do="" + + for dep in ${deps} ${builddeps}; do + if ! grep " ${dep} " "${deps_file}" >/dev/null 2>&1; then + deps_to_do="${deps_to_do} ${dep}" + printf " ${dep} " >>"${deps_file}" + fi + done + + for dep in ${deps_to_do}; do + tracked_subshell ' + include_recipe "${base_dir}"/recipes/${dep} + get_deps_file + ' + done +} + +get_deps_file() { + deps_to_do="" + + for dep in ${deps}; do + if ! grep " ${dep} " "${deps_file}" >/dev/null 2>&1; then + deps_to_do="${deps_to_do} ${dep}" + printf " ${dep} " >>"${deps_file}" + fi + done + + for dep in ${deps_to_do}; do + tracked_subshell ' + include_recipe "${base_dir}"/recipes/${dep} + get_deps_file + ' + done +} + +run_in_container1() { + run_in_cont1_root="$1" + shift 1 + + unshare --user --map-root-user --mount --pid --fork -- sh -c " + set -e + + mount --rbind --make-rslave /dev '${run_in_cont1_root}/dev' + mount -t proc proc '${run_in_cont1_root}/proc' + mount --rbind --make-rslave /sys '${run_in_cont1_root}/sys' + mount -t tmpfs run '${run_in_cont1_root}/run' + mount -t tmpfs tmpfs '${run_in_cont1_root}/tmp' + mount -t tmpfs tmpfs '${run_in_cont1_root}/var/tmp' + + mount -o ro --bind /etc/resolv.conf '${run_in_cont1_root}/etc/resolv.conf' + mount --bind '${apt_cache}' '${run_in_cont1_root}/var/cache/apt/archives' + + env -i PATH="${PATH}" chroot '${run_in_cont1_root}' /bin/sh -c ' + set -e + + LD_PRELOAD=/nochown.so \ + HOME=/root \ + LANG=en_US.UTF-8 \ + LC_COLLATE=C \ + PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin \ + LD_LIBRARY_PATH=/usr/local/lib64:/usr/local/lib:/usr/lib64:/usr/lib \ + DEBIAN_FRONTEND=noninteractive \ + $(for arg in "$@"; do echo '"'"$(echo "${arg}" | sed 's/"/\\"/g')"'" \'; done) + # keep this whitespace + ' + " +} + +check_duplicates() { + for elem in $(cd "$1" && find .); do + if [ -f "$2"/${elem} ] || [ -L "$2"/${elem} ]; then + return 1 + fi + done +} + +prepare_container() { + cd "${build_dir}" + + make_temp + hostdeps_file="${tmp}" + make_temp + deps_file="${tmp}" + + build_hostdeps + build_deps + + get_hostdeps_file + get_builddeps_file + + make_temp -d + container_pkgs="${tmp}" + make_temp -d + sysroot_dir="${tmp}" + + for dep in $(cat "${deps_file}"); do + XBPS_ARCH=invalid \ + XBPS_TARGET_ARCH="${JINX_ARCH}" \ + xbps-install -y -r "${sysroot_dir}" -R "${build_dir}"/pkgs "${dep}" >/dev/null 2>&1 + done + + if [ "$JINX_NATIVE_MODE" = "yes" ] && [ -z "$cross_compile" ]; then + imgroot="${sysroot_dir}" + else + for hostdep in $(cat "${hostdeps_file}"); do + if ! check_duplicates "${build_dir}"/host-pkgs/${hostdep}/usr/local "${container_pkgs}"; then + die "jinx: error: Dependency '${hostdep}' contains file confilcts" + fi + cp -Pplr "${build_dir}"/host-pkgs/${hostdep}/usr/local/. "${container_pkgs}"/ + done + + imagedeps="$(echo "${imagedeps}" | xargs -n1 | sort -u | xargs)" + + pkgset="" + for pkg in ${imagedeps}; do + pkgset="${pkgset}${pkg}/" + + if [ -f "$JINX_CACHE_DIR/sets/${pkgset}.image/.jinx-set-valid" ]; then + continue + fi + + rm -rf "$JINX_CACHE_DIR/sets/${pkgset}" + mkdir -p "$JINX_CACHE_DIR/sets/${pkgset}" + + want_link='l' + want_experimental='' + if echo "${pkg}" | grep -q '^experimental:'; then + want_link='' + want_experimental='-t experimental' + pkg="$(echo "${pkg}" | sed 's/^experimental://g')" + fi + + cp -Pp${want_link}rf "$JINX_CACHE_DIR/sets/${pkgset}../.image" "$JINX_CACHE_DIR/sets/${pkgset}.image" + + rm -f "$JINX_CACHE_DIR/sets/${pkgset}.image/.jinx-set-valid" + + run_in_container1 "$JINX_CACHE_DIR/sets/${pkgset}.image" apt-get install -y ${want_experimental} "${pkg}" + + # Fix permissions of files + for f in $(find "$JINX_CACHE_DIR/sets/${pkgset}.image" -perm 000 2>/dev/null); do + chmod 755 "$f" + done + + touch "$JINX_CACHE_DIR/sets/${pkgset}.image/.jinx-set-valid" + done + + imgroot="$JINX_CACHE_DIR/sets/${pkgset}.image" + fi +} + +run_in_container() { + if [ "${allow_network}" = "yes" ]; then + unshare_net_flag="" + else + unshare_net_flag="--net" + fi + + if [ ! -z "$TERM" ]; then + run_in_cont_term="TERM=\"$TERM\"" + fi + + if ! [ -z "$COLORTERM" ]; then + run_in_cont_colorterm="COLORTERM=\"$COLORTERM\"" + fi + + mkdir -p "${imgroot}/base_dir" "${imgroot}/sources" "${imgroot}/build_dir" + + container_pkgs_native_mount="" + sysroot_native_mount="" + if ( [ "$JINX_NATIVE_MODE" = "yes" ] && [ "$cross_compile" = "yes" ] ) || ( ! [ "$JINX_NATIVE_MODE" = "yes" ] ); then + mkdir -p "${imgroot}/sysroot" + + container_pkgs_native_mount="mount -o ro --bind '${container_pkgs}' '${imgroot}/usr/local'" + sysroot_native_mount="mount -o ro --bind '${sysroot_dir}' '${imgroot}/sysroot'" + + run_in_cont_lang=en_US.UTF-8 + else + if ! [ -z "$JINX_NATIVE_LANG" ]; then + run_in_cont_lang="$JINX_NATIVE_LANG" + else + run_in_cont_lang=C + fi + fi + + shadow_git_dir_build="" + if [ -d "${build_dir}"/.git ]; then + make_temp -d + shadow_git_dir_build="mount --bind '${tmp}' '${imgroot}/build_dir/.git'" + fi + + shadow_git_dir_base="" + if [ -d "${base_dir}"/.git ]; then + make_temp -d + shadow_git_dir_base="mount --bind '${tmp}' '${imgroot}/base_dir/.git'" + fi + + unshare --user --map-root-user --mount --pid --fork ${unshare_net_flag} -- sh -c " + set -e + + mount -o ro --bind '${imgroot}' '${imgroot}' + + mount --rbind --make-rslave /dev '${imgroot}/dev' + mount -t proc proc '${imgroot}/proc' + mount --rbind --make-rslave /sys '${imgroot}/sys' + mount -t tmpfs run '${imgroot}/run' + mount -t tmpfs tmpfs '${imgroot}/tmp' + mount -t tmpfs tmpfs '${imgroot}/var/tmp' + + mount -o ro --bind /etc/resolv.conf '${imgroot}/etc/resolv.conf' + + mount ${container_base_dir_ro} --bind '${base_dir}' '${imgroot}/base_dir' + mount --bind '${base_dir}/.jinx-cache/tmp' '${imgroot}/base_dir/.jinx-cache/tmp' + mount --bind '${build_dir}' '${imgroot}/build_dir' + mount ${container_sources_ro} --bind '${base_dir}/sources' '${imgroot}/base_dir/sources' + ${container_pkgs_native_mount} + ${sysroot_native_mount} + ${shadow_git_dir_base} + ${shadow_git_dir_build} + + env -i PATH="${PATH}" chroot '${imgroot}' /bin/sh -c ' + set -e + + cd /build_dir + + LD_PRELOAD=/nochown.so \ + HOME=/root \ + LANG=${run_in_cont_lang} \ + LC_COLLATE=C \ + PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin \ + LD_LIBRARY_PATH=/usr/local/lib64:/usr/local/lib:/usr/lib64:/usr/lib \ + ${run_in_cont_term} \ + ${run_in_cont_colorterm} \ + JINX_PARALLELISM=${parallelism} \ + JINX_CONFIG_FILE=/base_dir/Jinxfile \ + JINX_SOURCE_DIR=/base_dir \ + /bin/bash /base_dir/jinx \ + $(for arg in "$@"; do echo '"'"$(echo "${arg}" | sed 's/"/\\"/g')"'" \'; done) + # keep this whitespace + ' + " + + rm -rf "${imgroot}/sysroot" "${imgroot}/base_dir" "${imgroot}/sources" "${imgroot}/build_dir" +} + +destroy_container() { + rm -rf "${container_pkgs}" "${sysroot_dir}" +} + +do_hg_fetch() { + hg clone "${hg_url}" "${base_dir}"/sources/${name} + ( cd "${base_dir}"/sources/${name} && hg up "${tag}" ) +} + +do_git_fetch() { + if [ -z "${commit}" ]; then + die "* error: Git commit not specified" + fi + + if ! ( echo "${commit}" | grep -qE '^[0-9a-f]{40}$' ); then + die "* error: Invalid commit hash" + fi + + if [ "${shallow}" = "no" ]; then + git clone "${git_url}" "${base_dir}"/sources/${name} + git -C "${base_dir}"/sources/${name} -c advice.detachedHead=false checkout "${commit}" + else + git clone "${git_url}" -c advice.detachedHead=false --revision="${commit}" --depth=1 "${base_dir}"/sources/${name} + fi +} + +do_tarball_fetch() { + tarball_path="${base_dir}"/sources/"$(basename "${tarball_url}")" + + if ! [ -f "$tarball_path" ]; then + make_temp + download_path="${tmp}" + + curl -L -o "${download_path}" "${tarball_url}" + mv "${download_path}" "${tarball_path}" + fi + + checksum_verified=no + + if ! [ -z "${tarball_sha256}" ]; then + actual_sha256="$(sha256sum "${tarball_path}" | awk '{print $1;}')" + if ! [ ${actual_sha256} = ${tarball_sha256} ]; then + die "* error: Failed to verify SHA256 for ${name}. + Expected '${tarball_sha256}'; + got '${actual_sha256}'." + fi + checksum_verified=yes + fi + if ! [ -z "${tarball_sha512}" ]; then + actual_sha512="$(sha512sum "${tarball_path}" | awk '{print $1;}')" + if ! [ ${actual_sha512} = ${tarball_sha512} ]; then + die "* error: Failed to verify SHA512 for ${name}. + Expected '${tarball_sha512}'; + got '${actual_sha512}'." + fi + checksum_verified=yes + fi + if ! [ -z "${tarball_blake2b}" ]; then + actual_blake2b="$(b2sum "${tarball_path}" | awk '{print $1;}')" + if ! [ ${actual_blake2b} = ${tarball_blake2b} ]; then + die "* error: Failed to verify BLAKE2B for ${name}. + Expected '${tarball_blake2b}'; + got '${actual_blake2b}'." + fi + checksum_verified=yes + fi + + if [ "${checksum_verified}" = "no" ]; then + die "* error: No checksum method specified for ${name}" + fi + + make_temp -d + extract_dir="${tmp}" + + ( cd "${extract_dir}" && tar -xf "${tarball_path}" ) + + mv "${extract_dir}"/* "${base_dir}"/sources/${name} >/dev/null 2>&1 || ( + mkdir -p "${base_dir}"/sources/${name} + mv "${extract_dir}"/* "${base_dir}"/sources/${name}/ + ) + + rm -rf "${extract_dir}" "${tarball_path}" +} + +get_real_source_dir() { + unset is_local_package + unset is_sourceless_package + + if [ -z "${source_dir}" ] && [ -z "${git_url}" ] && [ -z "${hg_url}" ] && [ -z "${tarball_url}" ]; then + source_dir=/dev/null + is_local_package=true + is_sourceless_package=true + return + fi + + if [ -z "${source_dir}" ]; then + source_dir="${base_dir}"/sources/${name} + else + source_dir="${base_dir}"/"${source_dir}" + if ! [ -d "${source_dir}" ]; then + die "* source_dir of a local package is not a valid path" + fi + is_local_package=true + fi +} + +source_source_recipe() { + if [ -f "${base_dir}"/source-recipes/$1 ]; then + include_recipe "${base_dir}"/source-recipes/$1 + elif [ -f "${base_dir}"/recipes/$1 ]; then + include_recipe "${base_dir}"/recipes/$1 + + imagedeps="${source_imagedeps}" + hostdeps="${source_hostdeps}" + deps="${source_deps}" + allow_network="${source_allow_network}" + else + die "* could not find source recipe '$1'" + fi +} + +do_fetch() { + source_source_recipe $1 + + get_real_source_dir + + sysroot_dir="/sysroot" + + if ! [ "${is_local_package}" = true ] && ! [ "${is_sourceless_package}" = true ]; then + if ! [ -z "${git_url}" ]; then + do_git_fetch + elif ! [ -z "${hg_url}" ]; then + do_hg_fetch + elif ! [ -z "${tarball_url}" ]; then + do_tarball_fetch + fi + fi + + if ! [ "${is_sourceless_package}" = true ]; then + tracked_subshell ' + cd "${source_dir}" + early_prepare + ' + fi +} + +do_patch() { + source_source_recipe $1 + + get_real_source_dir + + make_temp + patch_trash="${tmp}" + + cd "${source_dir}" + + needs_match_timestamps=no + rm -rf "${base_dir}"/sources/${name}-clean + if [ -d "${base_dir}"/patches/${name} ]; then + for patch in "${base_dir}"/patches/${name}/*; do + [ "${patch}" = "${base_dir}/patches/${name}/*" ] && break + [ "${patch}" = "${base_dir}"/patches/${name}/jinx-working-patch.patch ] && continue + + if ! [ -d "${base_dir}"/sources/${name}-clean ]; then + cp -rp "${source_dir}" "${base_dir}"/sources/${name}-clean + needs_match_timestamps=yes + fi + + patch --no-backup-if-mismatch -p1 -r "${patch_trash}" < "${patch}" + done + + if [ "${needs_match_timestamps}" = yes ]; then + # make sure timestamps match + for f in $(diff -rq --no-dereference "${base_dir}"/sources/${name}-clean "${source_dir}" | sed '/^Only in/d;s/^Files //g;s/ and.*$//g'); do + touch --reference="$f" "$(echo "$f" | sed "s|sources/${name}-clean|sources/${name}|g")" + done + rm -rf "${base_dir}"/sources/${name}-clean + fi + fi + + cp -rp "${source_dir}" "${base_dir}"/sources/${name}-clean + + if [ -f "${base_dir}"/patches/${name}/jinx-working-patch.patch ]; then + patch --no-backup-if-mismatch -p1 -r "${patch_trash}" < "${base_dir}"/patches/${name}/jinx-working-patch.patch + + # make sure timestamps match + for f in $(diff -rq --no-dereference "${base_dir}"/sources/${name}-clean "${source_dir}" | sed '/^Only in/d;s/^Files //g;s/ and.*$//g'); do + touch --reference="$f" "$(echo "$f" | sed "s|sources/${name}-clean|sources/${name}|g")" + done + fi + + cp -rp "${source_dir}" "${base_dir}"/sources/${name}-workdir + + cd "${base_dir}" +} + +do_prepare() { + source_source_recipe $1 + + get_real_source_dir + + sysroot_dir="/sysroot" + + cd "${source_dir}" + prepare + cd "${base_dir}" +} + +do_configure_host() { + include_recipe "${base_dir}"/host-recipes/$1 + + mkdir -p "${build_dir}"/host-builds/${name} + + if ! [ -z "${from_source}" ]; then + version=$(unset version && source_source_recipe ${from_source} && echo "$version") + source_dir="$(unset source_dir && source_source_recipe ${from_source} && echo "$source_dir")" + + if [ -z "${source_dir}" ]; then + source_dir="${base_dir}"/sources/${from_source} + else + source_dir="${base_dir}"/"${source_dir}" + fi + fi + + prefix="/usr/local" + sysroot_dir="/sysroot" + + cd "${build_dir}"/host-builds/${name} + configure + cd "${base_dir}" +} + +do_build_host() { + include_recipe "${base_dir}"/host-recipes/$1 + + mkdir -p "${build_dir}"/host-builds/${name} + + if ! [ -z "${from_source}" ]; then + version=$(unset version && source_source_recipe ${from_source} && echo "$version") + source_dir="$(unset source_dir && source_source_recipe ${from_source} && echo "$source_dir")" + + if [ -z "${source_dir}" ]; then + source_dir="${base_dir}"/sources/${from_source} + else + source_dir="${base_dir}"/"${source_dir}" + fi + fi + + prefix="/usr/local" + sysroot_dir="/sysroot" + + cd "${build_dir}"/host-builds/${name} + build + cd "${base_dir}" +} + +do_package_host() { + include_recipe "${base_dir}"/host-recipes/$1 + + dest_dir="${build_dir}"/host-pkgs/${name} + + rm -rf "${dest_dir}" + mkdir -p "${dest_dir}" + + if ! [ -z "${from_source}" ]; then + version=$(unset version && source_source_recipe ${from_source} && echo "$version") + source_dir="$(unset source_dir && source_source_recipe ${from_source} && echo "$source_dir")" + + if [ -z "${source_dir}" ]; then + source_dir="${base_dir}"/sources/${from_source} + else + source_dir="${base_dir}"/"${source_dir}" + fi + fi + + prefix="/usr/local" + sysroot_dir="/sysroot" + + mkdir -p "${dest_dir}${prefix}" + + cd "${build_dir}"/host-builds/${name} + package + + # Remove libtool files + for i in $(find "${dest_dir}${prefix}" -name "*.la"); do + rm -rvf $i + done + + cd "${base_dir}" +} + +do_configure() { + include_recipe "${base_dir}"/recipes/$1 + + mkdir -p "${build_dir}"/builds/${name} + + if ! [ -z "${from_source}" ] || ! [ -z "${tarball_url}" ] || ! [ -z "${git_url}" ] || ! [ -z "${hg_url}" ] || ! [ -z "${source_dir}" ]; then + if ! [ -z "${from_source}" ]; then + version=$(unset version && source_source_recipe ${from_source} && echo "$version") + source_dir="$(unset source_dir && source_source_recipe ${from_source} && echo "$source_dir")" + else + from_source=${name} + fi + + if [ -z "${source_dir}" ]; then + source_dir="${base_dir}"/sources/${from_source} + else + source_dir="${base_dir}"/"${source_dir}" + fi + fi + + prefix="/usr" + sysroot_dir="/sysroot" + + cd "${build_dir}"/builds/${name} + configure + cd "${base_dir}" +} + +do_build() { + include_recipe "${base_dir}"/recipes/$1 + + mkdir -p "${build_dir}"/builds/${name} + + if ! [ -z "${from_source}" ] || ! [ -z "${tarball_url}" ] || ! [ -z "${git_url}" ] || ! [ -z "${hg_url}" ] || ! [ -z "${source_dir}" ]; then + if ! [ -z "${from_source}" ]; then + version=$(unset version && source_source_recipe ${from_source} && echo "$version") + source_dir="$(unset source_dir && source_source_recipe ${from_source} && echo "$source_dir")" + else + from_source=${name} + fi + + if [ -z "${source_dir}" ]; then + source_dir="${base_dir}"/sources/${from_source} + else + source_dir="${base_dir}"/"${source_dir}" + fi + fi + + prefix="/usr" + sysroot_dir="/sysroot" + + cd "${build_dir}"/builds/${name} + build + cd "${base_dir}" +} + +do_package() { + include_recipe "${base_dir}"/recipes/$1 + + dest_dir="${build_dir}"/pkgs/${name} + + rm -rf "${dest_dir}" + mkdir -p "${dest_dir}" + + if ! [ -z "${from_source}" ] || ! [ -z "${tarball_url}" ] || ! [ -z "${git_url}" ] || ! [ -z "${hg_url}" ] || ! [ -z "${source_dir}" ]; then + if ! [ -z "${from_source}" ]; then + version=$(unset version && source_source_recipe ${from_source} && echo "$version") + source_dir="$(unset source_dir && source_source_recipe ${from_source} && echo "$source_dir")" + else + from_source=${name} + fi + + if [ -z "${source_dir}" ]; then + source_dir="${base_dir}"/sources/${from_source} + else + source_dir="${base_dir}"/"${source_dir}" + fi + fi + + prefix="/usr" + sysroot_dir="/sysroot" + + mkdir -p "${dest_dir}${prefix}" + + cd "${build_dir}"/builds/${name} + package + + # Remove libtool files + for i in $(find "${dest_dir}${prefix}" -name "*.la"); do + rm -rvf $i + done + + cd "${base_dir}" +} + +clean_sources() { + rm -rf "${base_dir}"/sources/$1 + rm -rf "${base_dir}"/sources/$1-clean + rm -rf "${base_dir}"/sources/$1-workdir + rm -rf "${base_dir}"/sources/$1.version + rm -rf "${base_dir}"/sources/$1.patched + rm -rf "${base_dir}"/sources/$1.prepared +} + +need_repatch() { + rm -rf "${base_dir}"/sources/$1 + + if [ -d "${base_dir}"/sources/$1-clean ]; then + mv "${base_dir}"/sources/$1-clean "${base_dir}"/sources/$1 + fi + + rm -rf "${base_dir}"/sources/$1-workdir + rm -rf "${base_dir}"/sources/$1.patched + rm -rf "${base_dir}"/sources/$1.prepared +} + +do_source() { + source_source_recipe $1 + + get_real_source_dir + + cross_compile=yes + prepare_container + + if ! [ -f "${base_dir}"/sources/$1.version ] || ! [ "$(cat "${base_dir}"/sources/$1.version)" = "${version}" ]; then + tracked_subshell ' + allow_network="yes" + clean_sources '$1' + [ "${is_local_package}" = true ] || container_base_dir_ro="-o ro" + run_in_container internal-fetch '$1' + echo "${version}" >"${base_dir}"/sources/'$1'.version + ' + fi + + if ! [ -f "${base_dir}"/sources/$1.patched ]; then + tracked_subshell ' + if ! [ "${is_local_package}" = true ] && ! [ "${is_sourceless_package}" = true ]; then + allow_network="yes" + run_in_container internal-patch '$1' + fi + touch "${base_dir}"/sources/'$1'.patched + ' + fi + + if ! [ -f "${base_dir}"/sources/$1.prepared ]; then + tracked_subshell ' + if ! [ "${is_sourceless_package}" = true ]; then + [ "${is_local_package}" = true ] || container_base_dir_ro="-o ro" + run_in_container internal-prepare '$1' + fi + touch "${base_dir}"/sources/'$1'.prepared + ' + fi + + destroy_container +} + +do_rebuild() { + rm -rf "${build_dir}"/builds/"$1" + + do_pkg "$1" +} + +do_host_rebuild() { + rm -rf "${build_dir}"/host-builds/"$1" + + do_host_pkg "$1" +} + +do_regen() { + source_source_recipe $1 + + [ -f "${base_dir}"/sources/$1.patched ] || die "cannot regenerate non-built package" + + get_real_source_dir + + make_temp + patch_file="${tmp}" + + if ! [ "${is_local_package}" = true ]; then + cd "${base_dir}"/sources + + # exclude version control dirs + make_temp -d + vc_dir_clean="${tmp}" + rm -rf "${vc_dir_clean}" + make_temp -d + vc_dir_workdir="${tmp}" + rm -rf "${vc_dir_workdir}" + + if ! [ -z "${git_url}" ]; then + mv $1-clean/.git "${vc_dir_clean}" + mv $1-workdir/.git "${vc_dir_workdir}" + elif ! [ -z "${hg_url}" ]; then + mv $1-clean/.hg "${vc_dir_clean}" + mv $1-workdir/.hg "${vc_dir_workdir}" + fi + + git diff --no-index --no-prefix $1-clean $1-workdir >"${patch_file}" || true + + if ! [ -z "${git_url}" ]; then + mv "${vc_dir_clean}" $1-clean/.git + mv "${vc_dir_workdir}" $1-workdir/.git + elif ! [ -z "${hg_url}" ]; then + mv "${vc_dir_clean}" $1-clean/.hg + mv "${vc_dir_workdir}" $1-workdir/.hg + fi + + if [ -s "${patch_file}" ]; then + mkdir -p "${base_dir}"/patches/$1 + mv "${patch_file}" "${base_dir}"/patches/$1/jinx-working-patch.patch + fi + + cd "${base_dir}" + + rm -rf "${source_dir}" + cp -rp "${base_dir}"/sources/$1-workdir "${source_dir}" + fi + + rm -rf "${base_dir}"/sources/$1.prepared + + cross_compile=yes + prepare_container + run_in_container internal-prepare $1 + destroy_container +} + +do_host_pkg() { + include_recipe "${base_dir}"/host-recipes/$1 + + echo "* building host package: $name" + + if ! [ -z "${from_source}" ]; then + tracked_subshell 'do_source "${from_source}"' + else + tracked_subshell 'do_source "${name}"' + fi + + cross_compile=yes + prepare_container + + container_sources_ro="-o ro" + if ! [ -d "${build_dir}"/host-builds/$1 ]; then + run_in_container internal-configure-host $1 + fi + run_in_container internal-build-host $1 + rm -rf "${build_dir}"/host-pkgs/$1 + run_in_container internal-package-host $1 + unset container_sources_ro + + destroy_container + + if [ "$JINX_CLEAN_WORKDIRS" = "yes" ]; then + if ! [ "$clean_workdirs" = "no" ]; then + rm -rf "${build_dir}"/host-builds/$1 + + if [ -z "${from_source}" ]; then + source_source_recipe $1 + else + source_source_recipe ${from_source} + fi + + get_real_source_dir + + if ! [ "${is_sourceless_package}" = true ] && ! [ "${is_local_package}" = true ]; then + clean_sources "${name}" + fi + fi + fi +} + +do_pkg() { + include_recipe "${base_dir}"/recipes/$1 + + echo "* building package: $name" + + if ! [ -z "${from_source}" ]; then + version=$(unset version && source_source_recipe ${from_source} && echo "$version") + fi + + case "${version}" in + *git) + if ! [ -f "${build_dir}"/pkgs/${name}-${version}_${revision}.${JINX_ARCH}.xbps ]; then + rm -rf "${build_dir}"/builds/"$1" + tracked_subshell ' + if ! [ -z "${from_source}" ]; then + name=$(unset name && source_source_recipe ${from_source} && echo "${name}") + fi + clean_sources "${name}" + ' + fi + ;; + esac + + if ! [ -f "${build_dir}"/pkgs/${name}-${version}_${revision}.${JINX_ARCH}.xbps ]; then + rm -rf "${build_dir}"/builds/"$1" + tracked_subshell ' + if ! [ -z "${from_source}" ]; then + name=$(unset name && source_source_recipe ${from_source} && echo "${name}") + fi + need_repatch "${name}" + ' + fi + + if ! [ -z "${from_source}" ]; then + tracked_subshell 'do_source "${from_source}"' + else + tracked_subshell 'do_source "${name}"' + fi + + prepare_container + + container_sources_ro="-o ro" + if ! [ -d "${build_dir}"/builds/$1 ]; then + run_in_container internal-configure $1 + fi + run_in_container internal-build $1 + rm -rf "${build_dir}"/pkgs/$1 + run_in_container internal-package $1 + unset container_sources_ro + + destroy_container + + xbps_deps="" + for dep in ${deps}; do + bootstrap_pkg=$(unset bootstrap_pkg && . "${base_dir}"/recipes/${dep} && echo "${bootstrap_pkg}") + if [ "${bootstrap_pkg}" = "yes" ]; then + continue + fi + + xbps_deps="${xbps_deps} ${dep}>=0.0" + done + + dest_dir="${build_dir}"/pkgs/${name} + + cd "${build_dir}"/pkgs + XBPS_ARCH=invalid \ + XBPS_TARGET_ARCH="${JINX_ARCH}" \ + xbps-create \ + -A $JINX_ARCH \ + -s ${name} \ + -n ${name}-${version}_${revision} \ + -D "${xbps_deps}" \ + "${dest_dir}" + + rm -rf "${dest_dir}" + + XBPS_ARCH=invalid \ + XBPS_TARGET_ARCH="${JINX_ARCH}" \ + xbps-rindex \ + -a "${build_dir}"/pkgs/${name}-${version}_${revision}.${JINX_ARCH}.xbps \ + -f + + if [ "$JINX_CLEAN_WORKDIRS" = "yes" ]; then + if ! [ "$clean_workdirs" = "no" ]; then + rm -rf "${build_dir}"/builds/$1 + + if [ -z "${from_source}" ]; then + source_source_recipe $1 + else + source_source_recipe ${from_source} + fi + + get_real_source_dir + + if ! [ "${is_sourceless_package}" = true ] && ! [ "${is_local_package}" = true ]; then + clean_sources "${name}" + fi + fi + fi +} + +cmd_host_build() { + for ppkg in "$@"; do + for pkg in $(eval '(' cd "'${base_dir}'"/host-recipes '&&' echo "${ppkg}" ')' ); do + tracked_subshell 'do_host_pkg "${pkg}"' + done + done +} + +cmd_build() { + for ppkg in "$@"; do + for pkg in $(eval '(' cd "'${base_dir}'"/recipes '&&' echo "${ppkg}" ')' ); do + tracked_subshell 'do_pkg "${pkg}"' + done + done +} + +do_build_if_needed() { + include_recipe "${base_dir}"/recipes/$1 + if ! [ -z "${from_source}" ]; then + version=$(unset version && source_source_recipe ${from_source} && echo "$version") + fi + + if ! [ -f "${build_dir}"/pkgs/${name}-${version}_${revision}.${JINX_ARCH}.xbps ]; then + tracked_subshell 'do_pkg "'$1'"' + fi +} + +do_host_build_if_needed() { + if ! [ -d "${build_dir}"/host-pkgs/${hostdep} ]; then + tracked_subshell 'do_host_pkg "'$1'"' + fi +} + +do_update() { + include_recipe "${base_dir}"/recipes/$1 + if ! [ -z "${from_source}" ]; then + version=$(unset version && source_source_recipe ${from_source} && echo "$version") + fi + + if ! [ -f "${build_dir}"/pkgs/${name}-${version}_${revision}.${JINX_ARCH}.xbps ]; then + make_temp + hostdeps_file="${tmp}" + + get_hostdeps_file + + for hostdep in $(cat "${hostdeps_file}"); do + tracked_subshell 'do_host_build_if_needed "${hostdep}"' + done + builddeps_var="$(tracked_subshell 'get_builddeps "${name}"')" + for dep in ${builddeps_var}; do + tracked_subshell 'do_build_if_needed "${dep}"' + done + fi +} + +cmd_update() { + if [ -z "$1" ]; then + set -- '*' + fi + + for ppkg in "$@"; do + for pkg in $(eval '(' cd "'${base_dir}'"/recipes '&&' echo "${ppkg}" ')' ); do + tracked_subshell 'do_update "${pkg}"' + done + done +} + +cmd_regen() { + for i in "$@"; do + tracked_subshell 'do_regen "$i"' + done +} + +cmd_host_rebuild() { + for ppkg in "$@"; do + for pkg in $(eval '(' cd "'${base_dir}'"/host-recipes '&&' echo "${ppkg}" ')' ); do + tracked_subshell 'do_host_rebuild "${pkg}"' + done + done +} + +cmd_rebuild() { + for ppkg in "$@"; do + for pkg in $(eval '(' cd "'${base_dir}'"/recipes '&&' echo "${ppkg}" ')' ); do + tracked_subshell 'do_rebuild "${pkg}"' + done + done +} + +cmd_install() { + force_install="" + if [ "$1" = "-f" ]; then + force_install="$1" + shift 1 + fi + sysroot="$1" + shift 1 + mkdir -m 755 -p "${sysroot}" + + pkgs_to_install="" + for ppkg in "$@"; do + for pkg in $(eval '(' cd "'${base_dir}'"/recipes '&&' echo "${ppkg}" ')' ); do + bootstrap_pkg=$(unset bootstrap_pkg && . "${base_dir}"/recipes/${pkg} && echo "${bootstrap_pkg}") + if [ "${bootstrap_pkg}" = "yes" ]; then + continue + fi + + pkgs_to_install="${pkgs_to_install} ${pkg}" + done + done + + files_to_ignore='\.keep +\.plist +/INSTALL +/REMOVE' + + make_temp + all_files="${tmp}" + + for pkg in ${pkgs_to_install}; do + echo "* installing ${pkg}..." + + tracked_subshell ' + include_recipe "${base_dir}"/recipes/${pkg} + + if ! [ -z "${from_source}" ]; then + version=$(unset version && source_source_recipe ${from_source} && echo "$version") + fi + + if ! [ -f "${build_dir}"/pkgs/${name}-${version}_${revision}.${JINX_ARCH}.xbps ]; then + if [ "$(id -u)" = "0" ]; then + die "$0: a package needs to be built, but Jinx was invoked as root" + fi + tracked_subshell '\''do_pkg "${pkg}"'\'' + fi + + # xbps seems to only install the package every second time when reinstalling. + # Remove the package to be sure it gets reinstalled. + if ! [ -z "${force_install}" ]; then + XBPS_ARCH=invalid \ + XBPS_TARGET_ARCH="${JINX_ARCH}" \ + xbps-remove -Ffy -r "${sysroot}" ${pkg} >/dev/null 2>&1 || true + fi + + XBPS_ARCH=invalid \ + XBPS_TARGET_ARCH="${JINX_ARCH}" \ + xbps-install -y $force_install -r "${sysroot}" -R "${build_dir}"/pkgs ${pkg} >/dev/null 2>&1 + + zstdcat "${build_dir}"/pkgs/${name}-${version}_${revision}.${JINX_ARCH}.xbps | tar -tf - | ( grep -v "${files_to_ignore}" || true ) >>"${all_files}" + ' + done + + echo "* checking for conflicts..." + + make_temp + all_files_sorted="${tmp}" + + make_temp + all_files_uniq="${tmp}" + + sort <"${all_files}" >"${all_files_sorted}" + uniq <"${all_files_sorted}" >"${all_files_uniq}" + + dup_elements="$(comm -23 "${all_files_sorted}" "${all_files_uniq}" | uniq)" + + if ! [ -z "${dup_elements}" ]; then + echo "* error: duplicate files were found." + for elem in ${dup_elements}; do + echo " file path: ${elem}" + printf " in packages:" + for pkg in ${pkgs_to_install}; do + tracked_subshell ' + include_recipe "${base_dir}"/recipes/${pkg} + + if ! [ -z "${from_source}" ]; then + version=$(unset version && source_source_recipe ${from_source} && echo "$version") + fi + + if zstdcat "${build_dir}"/pkgs/${name}-${version}_${revision}.${JINX_ARCH}.xbps | tar -tf - | ( grep -v "${files_to_ignore}" || true ) | grep -q "${elem}"; then + printf " ${pkg}" + fi + ' + done + printf "\n" + done + exit 1 + fi +} + +reinit_container() { + chmod -R 777 "$JINX_CACHE_DIR/sets" 2>/dev/null || true + chmod -R 777 "$JINX_CACHE_DIR/apt-cache" 2>/dev/null || true + rm -rf "$JINX_CACHE_DIR/sets" "$JINX_CACHE_DIR/apt-cache" + + mkdir -p "${apt_cache}" + + mkdir -p "$JINX_CACHE_DIR/sets/.image" + + SHA256_COMMAND="sha256sum" + if ! command -v "${SHA256_COMMAND%% *}" >/dev/null 2>&1; then + SHA256_COMMAND="sha256" + if ! command -v "${SHA256_COMMAND%% *}" >/dev/null 2>&1; then + die "error: Cannot find sha256(sum) command" + fi + fi + + cat >"$JINX_CACHE_DIR/nochown.c" <<EOF +#include <stdio.h> +#include <unistd.h> +#include <fcntl.h> + +int chown(const char *pathname, uid_t owner, gid_t group) { + (void)pathname; (void)owner; (void)group; + return 0; +} + +int fchown(int fd, uid_t owner, gid_t group) { + (void)fd; (void)owner; (void)group; + return 0; +} + +int lchown(const char *pathname, uid_t owner, gid_t group) { + (void)pathname; (void)owner; (void)group; + return 0; +} + +int fchownat(int dirfd, const char *pathname, + uid_t owner, gid_t group, int flags) { + (void)dirfd; (void)pathname; (void)owner; (void)group; (void)flags; + return 0; +} +EOF + cc -O2 -pipe -std=gnu99 -Wall -Wextra -fPIC -shared "$JINX_CACHE_DIR/nochown.c" -o "$JINX_CACHE_DIR/sets/.image/nochown.so" + rm "$JINX_CACHE_DIR/nochown.c" + + DEBOOTSTRAP_ARCH="$(uname -m)" + case "${DEBOOTSTRAP_ARCH}" in + i?86) DEBOOTSTRAP_ARCH=i386 ;; + x86_64) DEBOOTSTRAP_ARCH=amd64 ;; + arm*) DEBOOTSTRAP_ARCH=armhf ;; + aarch64) DEBOOTSTRAP_ARCH=arm64 ;; + loongarch64) DEBOOTSTRAP_ARCH=loong64 ;; + ppc64le) DEBOOTSTRAP_ARCH=ppc64el ;; + esac + + # Install debootstrap + tracked_subshell ' + cd "${JINX_CACHE_DIR}" + wget -O debootstrap.tar.gz https://salsa.debian.org/installer-team/debootstrap/-/archive/${debootstrap_version}/debootstrap-${debootstrap_version}.tar.gz + if ! "${SHA256_COMMAND}" debootstrap.tar.gz | grep "${debootstrap_sha256sum}" >/dev/null 2>&1; then + die "Jinx: Failed to verify debootstrap tarball" + fi + tar -zxf debootstrap.tar.gz + make -C debootstrap-${debootstrap_version} DESTDIR="$(pwd -P)/debootstrap" install + rm -rf debootstrap.tar.gz debootstrap-${debootstrap_version} + sed "s/HOST_ARCH=[^;#]*/HOST_ARCH=${DEBOOTSTRAP_ARCH}/g;s|DEBOOTSTRAP_DIR=/usr/share/debootstrap|DEBOOTSTRAP_DIR=\"$(pwd -P)/debootstrap/usr/share/debootstrap\"|g" debootstrap/usr/sbin/debootstrap >debootstrap.sed + mv debootstrap.sed debootstrap/usr/sbin/debootstrap + chmod +x debootstrap/usr/sbin/debootstrap + ' + + mkdir -p "$JINX_CACHE_DIR/sets/.image/var/cache/apt/archives" + + unshare --user --map-root-user --mount --pid --fork -- sh -c " + set -e + + mount --bind '${apt_cache}' '$JINX_CACHE_DIR/sets/.image/var/cache/apt/archives' + + LD_PRELOAD='$JINX_CACHE_DIR/sets/.image/nochown.so' debootstrap \ + --foreign sid '$JINX_CACHE_DIR/sets/.image' https://snapshot.debian.org/archive/debian/${debian_snapshot}/ + " + + for dir in dev proc sys run tmp var/tmp; do + rm -rf "${JINX_CACHE_DIR}/sets/.image/${dir}" + mkdir -p "${JINX_CACHE_DIR}/sets/.image/${dir}" + done + + echo >"${JINX_CACHE_DIR}/sets/.image/etc/resolv.conf" + echo localhost >"${JINX_CACHE_DIR}/sets/.image/etc/hostname" + + run_in_container1 "$JINX_CACHE_DIR/sets/.image" /debootstrap/debootstrap --second-stage + + echo 'en_US.UTF-8 UTF-8' > "$JINX_CACHE_DIR/sets/.image/etc/locale.gen" + echo 'APT::Install-Suggests "0"; +APT::Install-Recommends "0"; +APT::Sandbox::User "root"; +Acquire::Check-Valid-Until "0";' >> "$JINX_CACHE_DIR/sets/.image/etc/apt/apt.conf" + + sources_list_tmp="$(sed 's/sid/experimental/g' "$JINX_CACHE_DIR/sets/.image/etc/apt/sources.list")" + echo "${sources_list_tmp}" >>"$JINX_CACHE_DIR/sets/.image/etc/apt/sources.list" + + run_in_container1 "$JINX_CACHE_DIR/sets/.image" apt-get update + run_in_container1 "$JINX_CACHE_DIR/sets/.image" apt-get install -y locales + run_in_container1 "$JINX_CACHE_DIR/sets/.image" locale-gen + + # Fix permissions of files + for f in $(find "$JINX_CACHE_DIR/sets/.image" -perm 000 2>/dev/null); do + chmod 755 "$f" + done + + run_in_container1 "$JINX_CACHE_DIR/sets/.image" apt-get install -y autopoint bash bison bzip2 cmake curl diffutils docbook-xsl doxygen file findutils flex gawk gettext git grep gzip lzip m4 make mercurial meson ninja-build patch perl python3 sed tar texinfo w3m which xmlto xsltproc xz-utils zstd + + # Build xbps + wget -O "${JINX_CACHE_DIR}/xbps-${XBPS_VERSION}.tar.gz" https://github.com/void-linux/xbps/archive/${XBPS_VERSION}.tar.gz + if ! "${SHA256_COMMAND}" "${JINX_CACHE_DIR}/xbps-${XBPS_VERSION}.tar.gz" | grep "${XBPS_SHA256SUM}" >/dev/null 2>&1; then + die "Jinx: Failed to verify XBPS tarball" + fi + + tracked_subshell ' + + cd "$JINX_CACHE_DIR" + tar -zxf xbps-${XBPS_VERSION}.tar.gz + cd xbps-${XBPS_VERSION} + + # XXX: xbps upstream forgot to bump version string + sed "s/0\.60/0.60.5/g" configure >configure.sed + mv configure.sed configure + sed "s/&& DEBUG=yes/&& DEBUG=no/g" configure >configure.sed + mv configure.sed configure + chmod +x configure + + CFLAGS="-O2 -pipe -Wno-error" ./configure --verbose --prefix="$JINX_CACHE_DIR/xbps" --localstatedir=/var + + sed "/DBDIR/d" data/Makefile >data/Makefile.sed + mv data/Makefile.sed data/Makefile + + sed "s/-lxml2/-lxml2 -llzma -lm/g" config.mk >config.mk.sed + mv config.mk.sed config.mk + + if command -v gmake >/dev/null 2>&1; then + MAKE=gmake + else + MAKE=make + fi + + ${MAKE} -j${parallelism} + ${MAKE} install + + cd .. + rm -rf xbps-${XBPS_VERSION}* + + ' +} + +first_use() { + echo "* preparing Jinx cache..." + + mkdir -p "$JINX_CACHE_DIR" + + reinit_container + + echo "$jinx_version" > "$JINX_CACHE_DIR/version" + + echo "* done" +} + +redo_first_use() { + echo "* purging old Jinx cache..." + chmod -R 777 "$JINX_CACHE_DIR" || true + rm -rf "$JINX_CACHE_DIR" + first_use +} + +if ! [ -f "$JINX_CONFIG_FILE" ]; then + die "$0: missing Jinxfile in directory '$base_dir'" +fi + +. "${JINX_CONFIG_FILE}" + +if [ -z "$JINX_MAJOR_VER" ]; then + die "$0: required config variable \$JINX_MAJOR_VER missing" +fi + +if ! [ "$JINX_MAJOR_VER" = "$jinx_major_ver" ]; then + die "$0: needed major version ($JINX_MAJOR_VER) differs from Jinx-provided major version ($jinx_major_ver)" +fi + +if [ -z "$JINX_ARCH" ]; then + die "$0: required config variable \$JINX_ARCH missing" +fi + +if ! [ -d "$JINX_CACHE_DIR" ]; then + first_use +fi + +if ! [ -f "$JINX_CACHE_DIR/version" ] || ! [ "$(cat "$JINX_CACHE_DIR/version")" = "$jinx_version" ]; then + redo_first_use +fi + +case "$1" in + internal-prepare) + do_prepare "$2" + ;; + internal-fetch) + do_fetch "$2" + ;; + internal-patch) + do_patch "$2" + ;; + internal-configure-host) + do_configure_host "$2" + ;; + internal-build-host) + do_build_host "$2" + ;; + internal-package-host) + do_package_host "$2" + ;; + internal-configure) + do_configure "$2" + ;; + internal-build) + do_build "$2" + ;; + internal-package) + do_package "$2" + ;; + host-build) + shift 1 + cmd_host_build "$@" + ;; + build) + shift 1 + cmd_build "$@" + ;; + update) + shift 1 + cmd_update "$@" + ;; + regenerate|regen) + shift 1 + cmd_regen "$@" + ;; + host-rebuild) + shift 1 + cmd_host_rebuild "$@" + ;; + rebuild) + shift 1 + cmd_rebuild "$@" + ;; + install) + shift 1 + cmd_install "$@" + ;; + reinstall) + shift 1 + cmd_install -f "$@" + ;; + rebuild-cache) + redo_first_use + ;; + *) + die "$0: unknown command: $1" + ;; +esac diff --git a/recipes/mlibc b/recipes/mlibc new file mode 100644 index 0000000..ef0d746 --- /dev/null +++ b/recipes/mlibc @@ -0,0 +1,27 @@ +#! /bin/sh + +name=mlibc +skip_pkg_check=yes +version=0.0git +revision=44 +git_url="https://github.com/cppLover0/orange-mlibc.git" +commit=0cc3366d0b8be7bf3ac38700ce3ae6ec68062586 +hostdeps="" +deps="" + +early_prepare() { + +} + +configure() { + +} + +build() { + +} + +package() { + mkdir -p "${dest_dir}/usr/lib" "${dest_dir}/usr/bin" "${dest_dir}/bin" "${dest_dir}/lib" + sh build_to_cross.sh "${dest_dir}" +} diff --git a/tar-initrd.sh b/tar-initrd.sh index 0c7b287..d48be91 100644 --- a/tar-initrd.sh +++ b/tar-initrd.sh @@ -12,38 +12,48 @@ if [ ! "$(which x86_64-orange-gcc)" ]; then exit 1 fi +chmod +x jinx -bash tools/pkg/build-pkg.sh "$(realpath initrd)" +mkdir -p initrd/lib initrd/bin initrd/usr/bin initrd/usr/lib -cd initrd/lib +script_dir="$(dirname "$0")" +source_dir="$(cd "${script_dir}" && pwd -P)" -echo Creating symlinks ./*.so -for file in ../usr/lib/*.so; do - echo $file "$(basename "$file")" - ln -s "$file" "$(basename "$file")" -done +chmod +x "${source_dir}/jinx" -for file in ../usr/local/lib/*.so; do - echo $file "$(basename "$file")" - ln -s "$file" "$(basename "$file")" -done +cd "${source_dir}/build-x86_64" +"${source_dir}"/jinx update base "*" +sudo "${source_dir}"/jinx install "sysroot" base "*" -cd ../bin +# cd initrd/lib -echo Creating symlinks ./* -for file in ../usr/bin/*; do - echo $file "$(basename "$file")" - ln -sf "$file" "$(basename "$file")" -done +# echo Creating symlinks ./*.so +# for file in ../usr/lib/*.so; do +# echo $file "$(basename "$file")" +# ln -s "$file" "$(basename "$file")" +# done -for file in ../usr/local/bin/*; do - echo $file "$(basename "$file")" - ln -sf "$file" "$(basename "$file")" -done +# for file in ../usr/local/lib/*.so; do +# echo $file "$(basename "$file")" +# ln -s "$file" "$(basename "$file")" +# done -cd ../../ +# cd ../bin -cp -rf tools/initbase/* initrd +# echo Creating symlinks ./* +# for file in ../usr/bin/*; do +# echo $file "$(basename "$file")" +# ln -sf "$file" "$(basename "$file")" +# done -mkdir -p tools/base/boot -tar -cf tools/base/boot/initrd.tar -C initrd . +# for file in ../usr/local/bin/*; do +# echo $file "$(basename "$file")" +# ln -sf "$file" "$(basename "$file")" +# done + +# cd ../../ + +# cp -rf tools/initbase/* initrd + +# mkdir -p tools/base/boot +# tar -cf tools/base/boot/initrd.tar -C initrd . diff --git a/tools/build-init.sh b/tools/build-init.sh new file mode 100644 index 0000000..3c1fa91 --- /dev/null +++ b/tools/build-init.sh @@ -0,0 +1,10 @@ + +ARCH=x86_64 + +script_dir="$(dirname "$0")" +source_dir="$(cd "${script_dir}"/.. && pwd -P)" + +chmod +x "${source_dir}/jinx" + +mkdir -p "${source_dir}/build-$ARCH" && cd "${source_dir}/build-$ARCH" +"${source_dir}"/jinx init "${source_dir}" ARCH=$ARCH
\ No newline at end of file diff --git a/tools/pkg/0/mlibc/pkg.sh b/tools/pkg/0/mlibc/pkg.sh index 72d5a23..48ae07a 100644 --- a/tools/pkg/0/mlibc/pkg.sh +++ b/tools/pkg/0/mlibc/pkg.sh @@ -28,8 +28,6 @@ mkdir -p "$1/usr/include" cp -rf linux-headers/* "$1/usr/include" cd pack - -export CFLAGS="-std=gnu11" # mlibc doesn't need to be cached git clone https://github.com/cpplover0/orange-mlibc --depth=1 diff --git a/tools/pkg/1/libgpg-error/diff/libgpg-error.diff b/tools/pkg/1/libgpg-error/diff/libgpg-error.diff new file mode 100644 index 0000000..4bb0ba7 --- /dev/null +++ b/tools/pkg/1/libgpg-error/diff/libgpg-error.diff @@ -0,0 +1,41 @@ +diff -Naur libgpg-error-1.55/build-aux/config.sub libgpg-error-1.55-patched/build-aux/config.sub +--- libgpg-error-1.55/build-aux/config.sub 2022-08-02 15:53:50.000000000 +0300 ++++ libgpg-error-1.55-patched/build-aux/config.sub 2025-09-25 13:58:17.464414286 +0300 +@@ -1750,7 +1750,7 @@ + | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \ + | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \ + | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \ +- | skyos* | haiku* | rdos* | toppers* | drops* | es* \ ++ | skyos* | orange* | haiku* | rdos* | toppers* | drops* | es* \ + | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ + | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ + | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \ +diff -Naur libgpg-error-1.55/src/syscfg/lock-obj-pub.orange.h libgpg-error-1.55-patched/src/syscfg/lock-obj-pub.orange.h +--- libgpg-error-1.55/src/syscfg/lock-obj-pub.orange.h 1970-01-01 03:00:00.000000000 +0300 ++++ libgpg-error-1.55-patched/src/syscfg/lock-obj-pub.orange.h 2018-10-12 18:12:38.000000000 +0300 +@@ -0,0 +1,25 @@ ++## lock-obj-pub.x86_64-pc-linux-gnu.h ++## File created by gen-posix-lock-obj - DO NOT EDIT ++## To be included by mkheader into gpg-error.h ++ ++typedef struct ++{ ++ long _vers; ++ union { ++ volatile char _priv[40]; ++ long _x_align; ++ long *_xp_align; ++ } u; ++} gpgrt_lock_t; ++ ++#define GPGRT_LOCK_INITIALIZER {1,{{0,0,0,0,0,0,0,0, \ ++ 0,0,0,0,0,0,0,0, \ ++ 0,0,0,0,0,0,0,0, \ ++ 0,0,0,0,0,0,0,0, \ ++ 0,0,0,0,0,0,0,0}}} ++## ++## Local Variables: ++## mode: c ++## buffer-read-only: t ++## End: ++## diff --git a/tools/pkg/1/libgpg-error/info.txt b/tools/pkg/1/libgpg-error/info.txt new file mode 100644 index 0000000..1180ed7 --- /dev/null +++ b/tools/pkg/1/libgpg-error/info.txt @@ -0,0 +1 @@ +libgpg-error
\ No newline at end of file diff --git a/tools/pkg/1/libgpg-error/pkg.sh b/tools/pkg/1/libgpg-error/pkg.sh new file mode 100644 index 0000000..0c8421c --- /dev/null +++ b/tools/pkg/1/libgpg-error/pkg.sh @@ -0,0 +1,22 @@ +. ../../pkg-lib.sh + +mkdir -p cached + +rm -rf pack + +mkdir -p pack + +cd pack + +wget https://www.gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-1.55.tar.bz2 +tar -xvf libgpg-error-1.55.tar.bz2 + +cd libgpg-error-1.55 +diff_patch ../../diff/libgpg-error.diff + +./configure --prefix=/usr --host=x86_64-orange --enable-threads --enable-install-gpg-error-config + +make install -j$(nproc) DESTDIR="$1" + +cd .. + diff --git a/tools/pkg/2/libgcrypt/diff/libgcrypt.diff b/tools/pkg/2/libgcrypt/diff/libgcrypt.diff new file mode 100644 index 0000000..0e4a540 --- /dev/null +++ b/tools/pkg/2/libgcrypt/diff/libgcrypt.diff @@ -0,0 +1,12 @@ +diff -Naur libgcrypt-1.11.2/build-aux/config.sub libgcrypt-patched/build-aux/config.sub +--- libgcrypt-1.11.2/build-aux/config.sub 2025-03-17 12:55:03.000000000 +0300 ++++ libgcrypt-patched/build-aux/config.sub 2025-09-25 14:03:00.968482285 +0300 +@@ -1750,7 +1750,7 @@ + | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \ + | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \ + | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \ +- | skyos* | haiku* | rdos* | toppers* | drops* | es* \ ++ | skyos* | orange* | haiku* | rdos* | toppers* | drops* | es* \ + | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ + | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ + | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \ diff --git a/tools/pkg/2/libgcrypt/info.txt b/tools/pkg/2/libgcrypt/info.txt new file mode 100644 index 0000000..2d59ed1 --- /dev/null +++ b/tools/pkg/2/libgcrypt/info.txt @@ -0,0 +1 @@ +libgcrypt
\ No newline at end of file diff --git a/tools/pkg/2/libgcrypt/pkg.sh b/tools/pkg/2/libgcrypt/pkg.sh new file mode 100644 index 0000000..2e074b6 --- /dev/null +++ b/tools/pkg/2/libgcrypt/pkg.sh @@ -0,0 +1,24 @@ +. ../../pkg-lib.sh + +mkdir -p cached + +rm -rf pack + +mkdir -p pack + +cd pack + +wget https://www.gnupg.org/ftp/gcrypt/libgcrypt/libgcrypt-1.11.2.tar.bz2 +tar -xvf libgcrypt-1.11.2.tar.bz2 + +cd libgcrypt-1.11.2 + +diff_patch ../../diff/libgcrypt.diff + +./configure --prefix=/usr --host=x86_64-orange --with-libgpg-error-prefix="$1/usr" + +make -j$(nproc) +make install -j$(nproc) DESTDIR="$1" + +cd .. + diff --git a/tools/pkg/4/xorg-server/diff/xorg-server.diff b/tools/pkg/4/xorg-server/diff/xorg-server.diff new file mode 100644 index 0000000..faf4b88 --- /dev/null +++ b/tools/pkg/4/xorg-server/diff/xorg-server.diff @@ -0,0 +1,12 @@ +diff -Naur xorg-server-1.12.2/config.sub xorg-server-patched/config.sub +--- xorg-server-1.12.2/config.sub 2012-05-30 00:06:13.000000000 +0400 ++++ xorg-server-patched/config.sub 2025-09-25 09:22:35.671059204 +0300 +@@ -1362,7 +1362,7 @@ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ +- | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) ++ | -skyos* | -orange* | -haiku* | -rdos* | -toppers* | -drops* | -es*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) diff --git a/tools/pkg/4/xorg-server/info.txt b/tools/pkg/4/xorg-server/info.txt new file mode 100644 index 0000000..0e680f2 --- /dev/null +++ b/tools/pkg/4/xorg-server/info.txt @@ -0,0 +1 @@ +xorg-server
\ No newline at end of file diff --git a/tools/pkg/4/xorg-server/pkg.sh b/tools/pkg/4/xorg-server/pkg.sh new file mode 100644 index 0000000..3b8a846 --- /dev/null +++ b/tools/pkg/4/xorg-server/pkg.sh @@ -0,0 +1,52 @@ + +# https://www.x.org/releases/X11R7.7/src/xserver/xorg-server-1.12.2.tar.gz + +. ../../pkg-lib.sh + +mkdir -p cached + +rm -rf pack + +mkdir -p pack + +cd pack + +wget https://www.x.org/releases/X11R7.7/src/xserver/xorg-server-1.12.2.tar.gz + +tar -xvf xorg-server-1.12.2.tar.gz + +cd xorg-server-1.12.2 +diff_patch ../../diff/xorg-server.diff +./configure CFLAGS="$TARGET_CFLAGS -Wno-error=array-bounds" \ + --with-xkb-bin-directory=/usr/bin \ + --with-xkb-path=/usr/share/X11/xkb \ + --with-xkb-output=/var/lib/xkb \ + --prefix=/usr \ + --with-fontrootdir=/usr/share/fonts/X11 \ + --enable-xorg \ + --enable-xv \ + --enable-xvfb \ + --disable-xephyr \ + --disable-xnest \ + --disable-suid-wrapper \ + --disable-pciaccess \ + --disable-dpms \ + --enable-screensaver \ + --disable-xres \ + --disable-xvmc \ + --disable-systemd-logind \ + --disable-secure-rpc \ + --disable-config-udev \ + --disable-dri \ + --disable-dri2 \ + --disable-dri3 \ + --disable-int10-module \ + --disable-vgahw \ + --disable-libdrm \ + --disable-glamor \ + --disable-glx + +make -j$(nproc) +make install -j$(nproc) DESTDIR="$1" + +cd ..
\ No newline at end of file |
