ports: add gnu diffutils, patch, gzip

This commit is contained in:
Mark Poliakov 2025-03-09 01:02:15 +02:00
parent fc9018585b
commit 56640a4fc2
31 changed files with 84066 additions and 65 deletions

View File

@ -0,0 +1 @@
../meta-port-scripts/gnu-compile.sh

View File

@ -0,0 +1 @@
../meta-port-scripts/gnu-fetch.sh

View File

@ -0,0 +1,4 @@
#!/bin/sh
export GNU_PROJECT=diffutils
export SRC_SHA256=c80a3c2bf87e252fe7d605b8ba6bf928d75a90b55f3bfcf7c4a4f337ec62fc31
export GNU_CONFIGURE_OPTIONS="--disable-nls --disable-threads"

View File

@ -0,0 +1 @@
../meta-port-scripts/gnu-install.sh

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,2 @@
description = "GNU utilities to generate patch files"
version = "3.11"

1
ports/gnu-gzip/compile.sh Symbolic link
View File

@ -0,0 +1 @@
../meta-port-scripts/gnu-compile.sh

1
ports/gnu-gzip/fetch.sh Symbolic link
View File

@ -0,0 +1 @@
../meta-port-scripts/gnu-fetch.sh

4
ports/gnu-gzip/gnu-project.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
export GNU_PROJECT=gzip
export SRC_SHA256=20fc818aeebae87cdbf209d35141ad9d3cf312b35a5e6be61bfcfbf9eddd212a
export GNU_CONFIGURE_OPTIONS=

1
ports/gnu-gzip/install.sh Symbolic link
View File

@ -0,0 +1 @@
../meta-port-scripts/gnu-install.sh

File diff suppressed because it is too large Load Diff

2
ports/gnu-gzip/port.toml Normal file
View File

@ -0,0 +1,2 @@
description = "GNU compression utilities"
version = "1.13"

View File

@ -1,18 +0,0 @@
#!/bin/sh
source_dir=$2
build_dir=$3
mkdir -p $build_dir
cd $build_dir
if [ ! -f Makefile ]; then
CC="clang" CFLAGS="-DNO_ARCHIVES -fPIC -target $Y_TRIPLE --sysroot $Y_SYSROOT" \
$source_dir/make-${Y_PORT_VERSION}/configure \
--prefix=/usr \
--build=x86_64-pc-linux-gnu \
--host=x86_64-unknown-yggdrasil \
--disable-job-server
fi
make -j

1
ports/gnu-make/compile.sh Symbolic link
View File

@ -0,0 +1 @@
../meta-port-scripts/gnu-compile.sh

View File

@ -1,31 +0,0 @@
#!/bin/sh
. $Y_PORT_UTILS/sig.sh
set -e
SRC_FILENAME="make-${Y_PORT_VERSION}.tar.gz"
SRC_SHA256="dd16fb1d67bfab79a72f5e8390735c49e3e8e70b4945a15ab1f81ddb78658fb3"
RELEASE_BASE="https://ftp.gnu.org/gnu/make"
RELEASE_URL="$RELEASE_BASE/$SRC_FILENAME"
source_dir=$2
build_dir=$3
mkdir -p $source_dir
cd $source_dir
if [ ! -f .source-ready ]; then
curl -LO $RELEASE_URL
verify_sha256 $SRC_SHA256 $SRC_FILENAME
tar xf $SRC_FILENAME
cd make-${Y_PORT_VERSION}
for patch in $1/patches/*.patch; do
echo Apply $patch
patch -p1 <$patch
done
touch $source_dir/.source-ready
fi

1
ports/gnu-make/fetch.sh Symbolic link
View File

@ -0,0 +1 @@
../meta-port-scripts/gnu-fetch.sh

View File

@ -0,0 +1,4 @@
#!/bin/sh
export GNU_PROJECT=make
export SRC_SHA256=dd16fb1d67bfab79a72f5e8390735c49e3e8e70b4945a15ab1f81ddb78658fb3
export GNU_CONFIGURE_OPTIONS=--disable-job-server

View File

@ -1,5 +0,0 @@
#!/bin/sh
build_dir=$3
cd $build_dir
make -j install DESTDIR=$Y_SYSROOT >/dev/null

1
ports/gnu-make/install.sh Symbolic link
View File

@ -0,0 +1 @@
../meta-port-scripts/gnu-install.sh

1
ports/gnu-patch/compile.sh Symbolic link
View File

@ -0,0 +1 @@
../meta-port-scripts/gnu-compile.sh

1
ports/gnu-patch/fetch.sh Symbolic link
View File

@ -0,0 +1 @@
../meta-port-scripts/gnu-fetch.sh

View File

@ -0,0 +1,4 @@
#!/bin/sh
GNU_PROJECT=patch
SRC_SHA256=8cf86e00ad3aaa6d26aca30640e86b0e3e1f395ed99f189b06d4c9f74bc58a4e
GNU_CONFIGURE_OPTIONS=

1
ports/gnu-patch/install.sh Symbolic link
View File

@ -0,0 +1 @@
../meta-port-scripts/gnu-install.sh

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,2 @@
description = "GNU utilities for patching files"
version = "2.7.6"

View File

@ -0,0 +1,7 @@
#!/bin/sh
set -e
. $1/gnu-project.sh
. $Y_PORT_UTILS/gnu.sh
gnu_compile "$@"

View File

@ -0,0 +1,7 @@
#!/bin/sh
set -e
. $1/gnu-project.sh
. $Y_PORT_UTILS/gnu.sh
gnu_fetch "$@"

View File

@ -0,0 +1,7 @@
#!/bin/sh
set -e
. $1/gnu-project.sh
. $Y_PORT_UTILS/gnu.sh
gnu_install "$@"

55
ports/meta-port-scripts/gnu.sh Executable file
View File

@ -0,0 +1,55 @@
#!/bin/sh
. $Y_PORT_UTILS/sig.sh
SRC_FILENAME="${GNU_PROJECT}-${Y_PORT_VERSION}.tar.gz"
RELEASE_BASE="https://ftp.gnu.org/gnu/${GNU_PROJECT}"
RELEASE_URL="$RELEASE_BASE/$SRC_FILENAME"
gnu_fetch() {
source_dir=$2
build_dir=$3
mkdir -p $source_dir
cd $source_dir
if [ ! -f .source-ready ]; then
curl -LO $RELEASE_URL
verify_sha256 $SRC_SHA256 $SRC_FILENAME
tar xf $SRC_FILENAME
cd ${GNU_PROJECT}-${Y_PORT_VERSION}
for patch in $1/patches/${Y_PORT_VERSION}/*.patch; do
echo Apply $patch
patch -p1 <$patch
done
touch $source_dir/.source-ready
fi
}
gnu_compile() {
source_dir=$2
build_dir=$3
mkdir -p $build_dir
cd $build_dir
if [ ! -f Makefile ]; then
CC="clang" CFLAGS="-DNO_ARCHIVES -fPIC -target $Y_TRIPLE --sysroot $Y_SYSROOT" \
$source_dir/${GNU_PROJECT}-${Y_PORT_VERSION}/configure \
--prefix=/usr \
--build=x86_64-pc-linux-gnu \
--host=x86_64-unknown-yggdrasil \
$GNU_CONFIGURE_OPTIONS
fi
make -j
}
gnu_install() {
build_dir=$3
cd $build_dir
make -j install DESTDIR=$Y_SYSROOT >/dev/null
}

0
ports/meta-port-scripts/sig.sh Normal file → Executable file
View File

View File

@ -44,22 +44,24 @@ unsafe extern "C" fn remove(path: *const c_char) -> CIntZeroResult {
#[no_mangle]
unsafe extern "C" fn rename(src: *const c_char, dst: *const c_char) -> CIntZeroResult {
renameat(AT_FDCWD, src, dst)
renameat(AT_FDCWD, src, AT_FDCWD, dst)
}
#[no_mangle]
unsafe extern "C" fn renameat(
atfd: c_int,
old_atfd: c_int,
src: *const c_char,
new_atfd: c_int,
dst: *const c_char,
) -> CIntZeroResult {
let at = util::at_fd(atfd)?;
let old_at = util::at_fd(old_atfd)?;
let new_at = util::at_fd(new_atfd)?;
let source = src.ensure_str();
let destination = dst.ensure_str();
syscall::rename(&Rename {
source_at: at,
destination_at: at,
source_at: old_at,
destination_at: new_at,
source,
destination,
})

View File

@ -432,15 +432,13 @@ impl FILE {
match mode {
BufferingMode::None => self.read_buffer = None,
BufferingMode::Line | BufferingMode::Full => {
if buffer.is_null() {
if read_capacity == 0 {
read_capacity = BUFSIZ;
}
if read_capacity == 0 {
read_capacity = BUFSIZ;
}
if buffer.is_null() {
self.read_buffer = Some(ReadBuffer::owned(read_capacity));
} else {
assert_ne!(read_capacity, 0);
let slice =
unsafe { core::slice::from_raw_parts_mut(buffer.cast(), read_capacity) };
self.read_buffer = Some(ReadBuffer::borrowed(slice));

View File

@ -74,6 +74,8 @@ fn panic_handler(pi: &core::panic::PanicInfo) -> ! {
use crate::{error::EResult, process, thread::Thread};
yggdrasil_rt::debug_trace!(Error, "{:?}", pi);
match PANIC_COUNT.fetch_add(1, Ordering::Relaxed) {
0 => {
let mut printer = PanicPrinter::new();