fix ci & cleanup mkintcpio patching
This commit is contained in:
parent
d7690f4c1d
commit
a7a7a6160b
9 changed files with 265 additions and 211 deletions
29
.github/workflows/release.yml
vendored
29
.github/workflows/release.yml
vendored
|
|
@ -31,14 +31,26 @@ jobs:
|
||||||
echo "Building required containers..."
|
echo "Building required containers..."
|
||||||
# Build the main container
|
# Build the main container
|
||||||
scripts/build-container.sh
|
scripts/build-container.sh
|
||||||
# Tag it with the additional name used by initramfs script
|
|
||||||
sudo podman tag s390x-archlinux-dev s390x-mkinitcpio-complete
|
|
||||||
|
|
||||||
- name: Build kernel
|
- name: Build kernel
|
||||||
run: |
|
run: |
|
||||||
echo "Building s390x kernel..."
|
echo "Building s390x kernel..."
|
||||||
scripts/build-kernel-container.sh
|
scripts/build-kernel-container.sh
|
||||||
|
|
||||||
|
- name: Build s390x busybox
|
||||||
|
run: |
|
||||||
|
echo "Building s390x busybox binary..."
|
||||||
|
# The build-all.sh script will handle this automatically
|
||||||
|
# but we'll call it explicitly for clarity in CI
|
||||||
|
if [ ! -f output/busybox-s390x-static ]; then
|
||||||
|
sudo podman run --rm \
|
||||||
|
-v $PWD:/work \
|
||||||
|
-v $PWD/output:/output \
|
||||||
|
-w /work \
|
||||||
|
s390x-archlinux-dev \
|
||||||
|
/work/scripts/build-busybox-s390x.sh
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Build initramfs
|
- name: Build initramfs
|
||||||
run: |
|
run: |
|
||||||
echo "Building s390x initramfs..."
|
echo "Building s390x initramfs..."
|
||||||
|
|
@ -69,6 +81,11 @@ jobs:
|
||||||
|
|
||||||
# Create tarball of all artifacts
|
# Create tarball of all artifacts
|
||||||
tar -czf archlinux-s390x-${{ github.event.inputs.version }}.tar.gz -C release-artifacts .
|
tar -czf archlinux-s390x-${{ github.event.inputs.version }}.tar.gz -C release-artifacts .
|
||||||
|
|
||||||
|
# Capture build information
|
||||||
|
echo "KERNEL_VERSION=6.6.10" >> $GITHUB_ENV
|
||||||
|
echo "MKINITCPIO_COMMIT=$(cd mkinitcpio-source && git rev-parse HEAD)" >> $GITHUB_ENV
|
||||||
|
echo "MKINITCPIO_SHORT_COMMIT=$(cd mkinitcpio-source && git rev-parse --short HEAD)" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Create GitHub Release
|
- name: Create GitHub Release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
|
|
@ -80,10 +97,16 @@ jobs:
|
||||||
|
|
||||||
${{ github.event.inputs.release_notes }}
|
${{ github.event.inputs.release_notes }}
|
||||||
|
|
||||||
|
## Build Information
|
||||||
|
|
||||||
|
- **Kernel Version**: ${{ env.KERNEL_VERSION }}
|
||||||
|
- **mkinitcpio**: Built from commit [`${{ env.MKINITCPIO_SHORT_COMMIT }}`](https://github.com/archlinux/mkinitcpio/commit/${{ env.MKINITCPIO_COMMIT }})
|
||||||
|
- **Build Date**: ${{ github.event.repository.updated_at }}
|
||||||
|
|
||||||
## Release Contents
|
## Release Contents
|
||||||
|
|
||||||
This release includes:
|
This release includes:
|
||||||
- **vmlinuz-linux-s390x**: Linux kernel 6.6.10 for s390x architecture
|
- **vmlinuz-linux-s390x**: Linux kernel ${{ env.KERNEL_VERSION }} for s390x architecture
|
||||||
- **initramfs-linux-s390x.img**: Initial RAM filesystem with s390x busybox
|
- **initramfs-linux-s390x.img**: Initial RAM filesystem with s390x busybox
|
||||||
- **Boot configuration files**: IPL configuration for s390x mainframes
|
- **Boot configuration files**: IPL configuration for s390x mainframes
|
||||||
- **SHA256SUMS**: Checksums for all artifacts
|
- **SHA256SUMS**: Checksums for all artifacts
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,17 @@ RUN dnf install -y \
|
||||||
gcc-s390x-linux-gnu \
|
gcc-s390x-linux-gnu \
|
||||||
binutils-s390x-linux-gnu \
|
binutils-s390x-linux-gnu \
|
||||||
kernel-cross-headers \
|
kernel-cross-headers \
|
||||||
|
kernel-headers \
|
||||||
glibc-devel \
|
glibc-devel \
|
||||||
glibc-headers \
|
glibc-headers \
|
||||||
glibc-static \
|
glibc-static \
|
||||||
|
glibc-common \
|
||||||
|
glibc-all-langpacks \
|
||||||
|
musl-devel \
|
||||||
|
musl-gcc \
|
||||||
|
musl-libc-static \
|
||||||
|
libstdc++-devel \
|
||||||
|
libstdc++-static \
|
||||||
# Kernel build dependencies
|
# Kernel build dependencies
|
||||||
make \
|
make \
|
||||||
flex \
|
flex \
|
||||||
|
|
@ -47,6 +55,8 @@ RUN dnf install -y \
|
||||||
coreutils \
|
coreutils \
|
||||||
util-linux \
|
util-linux \
|
||||||
file \
|
file \
|
||||||
|
busybox \
|
||||||
|
bsdtar \
|
||||||
&& dnf clean all
|
&& dnf clean all
|
||||||
|
|
||||||
# Upgrade meson to latest version (Fedora 39 has 1.3.2, mkinitcpio needs >=1.4.0)
|
# Upgrade meson to latest version (Fedora 39 has 1.3.2, mkinitcpio needs >=1.4.0)
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ Uses **Fedora containers with Podman** for cross-compilation:
|
||||||
```bash
|
```bash
|
||||||
# Container images:
|
# Container images:
|
||||||
s390x-fedora-kernel # Kernel compilation
|
s390x-fedora-kernel # Kernel compilation
|
||||||
s390x-mkinitcpio-complete # Initramfs generation
|
s390x-archlinux-dev # All-in-one development container
|
||||||
```
|
```
|
||||||
|
|
||||||
### Key Scripts:
|
### Key Scripts:
|
||||||
|
|
|
||||||
|
|
@ -1,79 +1,97 @@
|
||||||
--- a/install/base
|
#!/usr/bin/env bash
|
||||||
+++ b/install/base
|
# SPDX-License-Identifier: GPL-2.0-only
|
||||||
@@ -3,10 +3,60 @@
|
# Modified for s390x cross-architecture support
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
local applet
|
local applet
|
||||||
-
|
|
||||||
- add_binary /usr/lib/initcpio/busybox /bin/busybox
|
# Use s390x busybox binary if available (cross-architecture support)
|
||||||
-
|
if [[ -f "/work/output/busybox-s390x-static" ]]; then
|
||||||
- for applet in $(/usr/lib/initcpio/busybox --list); do
|
echo "Using s390x static busybox binary"
|
||||||
+
|
add_file "/work/output/busybox-s390x-static" "/bin/busybox" 755
|
||||||
+ # Use s390x busybox binary if available (cross-architecture support)
|
|
||||||
+ if [[ -f "/work/output/busybox-s390x-native" ]]; then
|
# Create symlinks for busybox applets (using a known list since we can't execute cross-arch binary)
|
||||||
+ echo "Using s390x busybox binary"
|
local busybox_applets=(
|
||||||
+ add_file "/work/output/busybox-s390x-native" "/bin/busybox" 755
|
"[" "[[" "ash" "awk" "basename" "cat" "chgrp" "chmod" "chown" "cp" "cut"
|
||||||
+
|
"date" "dd" "df" "dirname" "dmesg" "du" "echo" "env" "expr" "false"
|
||||||
+ # Create symlinks for busybox applets (using a known list since we can't execute cross-arch binary)
|
"find" "grep" "head" "hostname" "id" "kill" "ln" "ls" "mkdir" "mknod"
|
||||||
+ local busybox_applets=(
|
"mktemp" "mount" "mv" "printf" "ps" "pwd" "readlink" "rm" "rmdir"
|
||||||
+ "[" "[[" "ash" "awk" "basename" "cat" "chgrp" "chmod" "chown" "cp" "cut"
|
"sed" "sh" "sleep" "sort" "stat" "tail" "tar" "test" "touch" "tr"
|
||||||
+ "date" "dd" "df" "dirname" "dmesg" "du" "echo" "env" "expr" "false"
|
"true" "umount" "uname" "uniq" "wc" "which" "whoami" "xargs"
|
||||||
+ "find" "grep" "head" "hostname" "id" "kill" "ln" "ls" "mkdir" "mknod"
|
)
|
||||||
+ "mktemp" "mount" "mv" "printf" "ps" "pwd" "readlink" "rm" "rmdir"
|
|
||||||
+ "sed" "sh" "sleep" "sort" "stat" "tail" "tar" "test" "touch" "tr"
|
for applet in "${busybox_applets[@]}"; do
|
||||||
+ "true" "umount" "uname" "uniq" "wc" "which" "whoami" "xargs"
|
add_symlink "/usr/bin/$applet" busybox
|
||||||
+ )
|
done
|
||||||
+
|
elif [[ -f "/work/output/busybox-s390x-native" ]]; then
|
||||||
+ for applet in "${busybox_applets[@]}"; do
|
echo "Using s390x busybox binary"
|
||||||
+ add_symlink "/usr/bin/$applet" busybox
|
add_file "/work/output/busybox-s390x-native" "/bin/busybox" 755
|
||||||
+ done
|
|
||||||
+ else
|
# Create symlinks for busybox applets (using a known list since we can't execute cross-arch binary)
|
||||||
+ echo "Warning: s390x busybox not found, using system busybox (may cause architecture mismatch)"
|
local busybox_applets=(
|
||||||
+ add_binary /usr/lib/initcpio/busybox /bin/busybox
|
"[" "[[" "ash" "awk" "basename" "cat" "chgrp" "chmod" "chown" "cp" "cut"
|
||||||
+ for applet in $(/usr/lib/initcpio/busybox --list); do
|
"date" "dd" "df" "dirname" "dmesg" "du" "echo" "env" "expr" "false"
|
||||||
+ add_symlink "/usr/bin/$applet" busybox
|
"find" "grep" "head" "hostname" "id" "kill" "ln" "ls" "mkdir" "mknod"
|
||||||
+ done
|
"mktemp" "mount" "mv" "printf" "ps" "pwd" "readlink" "rm" "rmdir"
|
||||||
+ fi
|
"sed" "sh" "sleep" "sort" "stat" "tail" "tar" "test" "touch" "tr"
|
||||||
+
|
"true" "umount" "uname" "uniq" "wc" "which" "whoami" "xargs"
|
||||||
+ # For other binaries, try to use available versions, otherwise skip
|
)
|
||||||
+ echo "Adding kmod utilities..."
|
|
||||||
+ if type -P kmod >/dev/null 2>&1; then
|
for applet in "${busybox_applets[@]}"; do
|
||||||
+ add_binary kmod
|
add_symlink "/usr/bin/$applet" busybox
|
||||||
+ for applet in {dep,ins,rm,ls}mod mod{probe,info}; do
|
done
|
||||||
+ add_symlink "/usr/bin/$applet" kmod
|
else
|
||||||
+ done
|
echo "Warning: s390x busybox not found, using system busybox (may cause architecture mismatch)"
|
||||||
+ else
|
# Try to find busybox in various locations
|
||||||
+ echo "Warning: kmod not found, skipping module utilities"
|
if [[ -f /usr/lib/initcpio/busybox ]]; then
|
||||||
+ fi
|
add_binary /usr/lib/initcpio/busybox /bin/busybox
|
||||||
+
|
elif [[ -f /usr/bin/busybox ]]; then
|
||||||
+ # Check for additional utilities (may not be available in cross-compile environment)
|
add_binary /usr/bin/busybox /bin/busybox
|
||||||
+ echo "Checking for additional utilities..."
|
elif [[ -f /bin/busybox ]]; then
|
||||||
+ for binary in blkid mount umount switch_root; do
|
add_binary /bin/busybox /bin/busybox
|
||||||
+ if type -P "$binary" >/dev/null 2>&1; then
|
else
|
||||||
+ echo "Adding $binary"
|
echo "ERROR: No busybox binary found!"
|
||||||
+ add_binary "$binary"
|
return 1
|
||||||
+ else
|
fi
|
||||||
+ echo "Warning: $binary not found, skipping"
|
# Get applet list from the binary we found
|
||||||
+ fi
|
for applet in $(busybox --list 2>/dev/null || echo "sh ash"); do
|
||||||
+ done
|
add_symlink "/usr/bin/$applet" busybox
|
||||||
+
|
done
|
||||||
+ # Original code (for reference):
|
fi
|
||||||
+ # add_binary /usr/lib/initcpio/busybox /bin/busybox
|
|
||||||
+ # for applet in $(/usr/lib/initcpio/busybox --list); do
|
# Add kmod with applet symlinks (if available)
|
||||||
add_symlink "/usr/bin/$applet" busybox
|
if type -P kmod >/dev/null 2>&1; then
|
||||||
done
|
echo "Adding kmod utilities..."
|
||||||
|
add_binary kmod
|
||||||
@@ -16,9 +66,10 @@
|
for applet in {dep,ins,rm,ls}mod mod{probe,info}; do
|
||||||
add_symlink "/usr/bin/$applet" kmod
|
add_symlink "/usr/bin/$applet" kmod
|
||||||
done
|
done
|
||||||
|
else
|
||||||
- add_binary blkid
|
echo "Warning: kmod not found, module utilities will not be available"
|
||||||
- map add_binary mount umount
|
fi
|
||||||
- add_binary switch_root
|
|
||||||
+ # add_binary blkid
|
# Check for additional utilities (may not be available in cross-compile environment)
|
||||||
+ # map add_binary mount umount
|
for binary in blkid mount umount switch_root; do
|
||||||
+ # add_binary switch_root
|
if type -P "$binary" >/dev/null 2>&1; then
|
||||||
+ # (These are now handled conditionally above)
|
echo "Adding $binary"
|
||||||
|
add_binary "$binary"
|
||||||
add_binary "/usr/lib/initcpio/init_functions" "/init_functions"
|
else
|
||||||
add_binary "/usr/lib/initcpio/init" "/init" 755
|
echo "Warning: $binary not found, skipping (functionality may be limited)"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Always add init files
|
||||||
|
echo "Adding init files..."
|
||||||
|
add_file "/usr/lib/initcpio/init_functions" "/init_functions"
|
||||||
|
add_file "/usr/lib/initcpio/init" "/init" 755
|
||||||
|
}
|
||||||
|
|
||||||
|
help() {
|
||||||
|
cat <<HELPEOF
|
||||||
|
This hook provides crucial runtime necessities for booting. This is a modified
|
||||||
|
version with s390x cross-architecture support. DO NOT remove this hook unless
|
||||||
|
you know what you're doing.
|
||||||
|
HELPEOF
|
||||||
|
}
|
||||||
|
|
||||||
|
# vim: set ft=sh ts=4 sw=4 et:
|
||||||
9
patches/mkinitcpio-s390x.conf
Normal file
9
patches/mkinitcpio-s390x.conf
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
# Minimal s390x mkinitcpio configuration
|
||||||
|
# This config creates a basic initramfs without kernel modules
|
||||||
|
MODULES=()
|
||||||
|
BINARIES=()
|
||||||
|
FILES=()
|
||||||
|
# Only use base hook which provides busybox, init, and basic utilities
|
||||||
|
HOOKS=(base)
|
||||||
|
COMPRESSION="gzip"
|
||||||
|
COMPRESSION_OPTIONS=(-6)
|
||||||
|
|
@ -94,6 +94,30 @@ if [ "$BUILD_KERNEL" = true ]; then
|
||||||
"$PROJECT_ROOT/scripts/build-kernel-container.sh"
|
"$PROJECT_ROOT/scripts/build-kernel-container.sh"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Build busybox if it doesn't exist
|
||||||
|
if [ "$BUILD_INITRAMFS" = true ]; then
|
||||||
|
if [ ! -f "$PROJECT_ROOT/output/busybox-s390x-static" ] && [ ! -f "$PROJECT_ROOT/output/busybox-s390x-native" ]; then
|
||||||
|
echo
|
||||||
|
echo -e "${BLUE}=== Building s390x Busybox ===${NC}"
|
||||||
|
# Check if busybox build script exists
|
||||||
|
if [ -f "$PROJECT_ROOT/scripts/build-busybox-s390x.sh" ]; then
|
||||||
|
# Run busybox build in container
|
||||||
|
echo -e "${YELLOW}Building s390x busybox binary...${NC}"
|
||||||
|
sudo podman run --rm \
|
||||||
|
-v "$PROJECT_ROOT:/work" \
|
||||||
|
-v "$PROJECT_ROOT/output:/output" \
|
||||||
|
-w /work \
|
||||||
|
s390x-archlinux-dev \
|
||||||
|
/work/scripts/build-busybox-s390x.sh
|
||||||
|
else
|
||||||
|
echo -e "${RED}ERROR: build-busybox-s390x.sh not found${NC}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo -e "${GREEN}✓ s390x busybox already exists${NC}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Build initramfs
|
# Build initramfs
|
||||||
if [ "$BUILD_INITRAMFS" = true ]; then
|
if [ "$BUILD_INITRAMFS" = true ]; then
|
||||||
echo
|
echo
|
||||||
|
|
|
||||||
|
|
@ -63,11 +63,12 @@ EOF
|
||||||
sed -i 's/CONFIG_FEATURE_HAVE_RPC=y/CONFIG_FEATURE_HAVE_RPC=n/' .config
|
sed -i 's/CONFIG_FEATURE_HAVE_RPC=y/CONFIG_FEATURE_HAVE_RPC=n/' .config
|
||||||
sed -i 's/CONFIG_LOCALE_SUPPORT=y/CONFIG_LOCALE_SUPPORT=n/' .config
|
sed -i 's/CONFIG_LOCALE_SUPPORT=y/CONFIG_LOCALE_SUPPORT=n/' .config
|
||||||
|
|
||||||
# Create minimal byteswap.h if missing
|
# Create minimal byteswap.h (always create to ensure compatibility)
|
||||||
if [ ! -f /usr/include/byteswap.h ]; then
|
echo "Creating minimal byteswap.h for cross-compilation..."
|
||||||
echo "Creating minimal byteswap.h..."
|
mkdir -p include
|
||||||
mkdir -p include
|
|
||||||
cat > include/byteswap.h << 'BYTESWAP_EOF'
|
# Create byteswap.h that uses system stdint.h
|
||||||
|
cat > include/byteswap.h << 'BYTESWAP_EOF'
|
||||||
#ifndef _BYTESWAP_H
|
#ifndef _BYTESWAP_H
|
||||||
#define _BYTESWAP_H
|
#define _BYTESWAP_H
|
||||||
|
|
||||||
|
|
@ -92,14 +93,28 @@ static inline uint64_t bswap_64(uint64_t x) {
|
||||||
|
|
||||||
#endif /* _BYTESWAP_H */
|
#endif /* _BYTESWAP_H */
|
||||||
BYTESWAP_EOF
|
BYTESWAP_EOF
|
||||||
|
|
||||||
|
# Remove any conflicting stdint.h from busybox source
|
||||||
|
if [ -f include/stdint.h ]; then
|
||||||
|
echo "Removing busybox's conflicting stdint.h"
|
||||||
|
rm -f include/stdint.h
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Build with specific flags to handle missing headers
|
# Let busybox find its own headers
|
||||||
echo "Building busybox..."
|
echo "Building busybox with minimal configuration..."
|
||||||
|
make clean || true
|
||||||
|
|
||||||
|
# Try building with the cross compiler's sysroot
|
||||||
|
SYSROOT=$(s390x-linux-gnu-gcc -print-sysroot)
|
||||||
|
echo "Using sysroot: $SYSROOT"
|
||||||
|
|
||||||
|
# Build with proper include path order - system headers first
|
||||||
make \
|
make \
|
||||||
EXTRA_CFLAGS="-I$(pwd)/include -D__MUSL__ -static" \
|
CFLAGS="--sysroot=$SYSROOT -I$(pwd)/include" \
|
||||||
EXTRA_LDFLAGS="-static -pthread" \
|
LDFLAGS="-static" \
|
||||||
CONFIG_EXTRA_LDLIBS="pthread" \
|
CONFIG_STATIC=y \
|
||||||
|
HOSTCC=gcc \
|
||||||
|
HOSTCFLAGS="" \
|
||||||
-j$(nproc) 2>&1 | tee build.log
|
-j$(nproc) 2>&1 | tee build.log
|
||||||
|
|
||||||
# Verify the binary was built and is correct architecture
|
# Verify the binary was built and is correct architecture
|
||||||
|
|
@ -108,9 +123,12 @@ if [ -f busybox ]; then
|
||||||
file busybox
|
file busybox
|
||||||
ls -la busybox
|
ls -la busybox
|
||||||
|
|
||||||
# Copy to output directory
|
# Copy to output directory with both naming conventions
|
||||||
cp busybox "$OUTPUT_DIR/busybox-s390x"
|
cp busybox "$OUTPUT_DIR/busybox-s390x-static"
|
||||||
chmod +x "$OUTPUT_DIR/busybox-s390x"
|
chmod +x "$OUTPUT_DIR/busybox-s390x-static"
|
||||||
|
|
||||||
|
# Also create a native version link for compatibility
|
||||||
|
ln -sf busybox-s390x-static "$OUTPUT_DIR/busybox-s390x-native"
|
||||||
|
|
||||||
echo "✅ s390x busybox binary built successfully!"
|
echo "✅ s390x busybox binary built successfully!"
|
||||||
echo "Size: $(du -h busybox | cut -f1)"
|
echo "Size: $(du -h busybox | cut -f1)"
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,7 @@ PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
||||||
OUTPUT_DIR="$PROJECT_ROOT/output"
|
OUTPUT_DIR="$PROJECT_ROOT/output"
|
||||||
INITRAMFS_NAME="initramfs-${KERNEL_VERSION}-s390x.img"
|
INITRAMFS_NAME="initramfs-${KERNEL_VERSION}-s390x.img"
|
||||||
MKINITCPIO_SOURCE="$PROJECT_ROOT/mkinitcpio-source"
|
MKINITCPIO_SOURCE="$PROJECT_ROOT/mkinitcpio-source"
|
||||||
MKINITCPIO_REPO="https://gitlab.archlinux.org/archlinux/mkinitcpio/mkinitcpio.git"
|
MKINITCPIO_REPO="https://github.com/archlinux/mkinitcpio.git"
|
||||||
MKINITCPIO_VERSION="v39.2" # Latest stable version
|
|
||||||
|
|
||||||
# Colors
|
# Colors
|
||||||
RED='\033[0;31m'
|
RED='\033[0;31m'
|
||||||
|
|
@ -20,15 +19,15 @@ NC='\033[0m'
|
||||||
|
|
||||||
echo -e "${GREEN}=== Building initramfs with modified mkinitcpio ===${NC}"
|
echo -e "${GREEN}=== Building initramfs with modified mkinitcpio ===${NC}"
|
||||||
|
|
||||||
# Clone mkinitcpio from upstream
|
# Clone mkinitcpio from upstream (latest version)
|
||||||
echo -e "${YELLOW}Cloning mkinitcpio from upstream...${NC}"
|
echo -e "${YELLOW}Cloning mkinitcpio from upstream (latest)...${NC}"
|
||||||
rm -rf "$MKINITCPIO_SOURCE"
|
rm -rf "$MKINITCPIO_SOURCE"
|
||||||
git clone --depth 1 --branch "$MKINITCPIO_VERSION" "$MKINITCPIO_REPO" "$MKINITCPIO_SOURCE"
|
git clone --depth 1 "$MKINITCPIO_REPO" "$MKINITCPIO_SOURCE"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo -e "${RED}Failed to clone mkinitcpio${NC}"
|
echo -e "${RED}Failed to clone mkinitcpio${NC}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo -e "${GREEN}✓ Cloned mkinitcpio ${MKINITCPIO_VERSION}${NC}"
|
echo -e "${GREEN}✓ Cloned latest mkinitcpio${NC}"
|
||||||
|
|
||||||
# Create build script that runs inside container
|
# Create build script that runs inside container
|
||||||
cat > "$PROJECT_ROOT/build-final-initramfs.sh" << 'EOF'
|
cat > "$PROJECT_ROOT/build-final-initramfs.sh" << 'EOF'
|
||||||
|
|
@ -41,101 +40,31 @@ INITRAMFS_OUTPUT="/work/output/initramfs-${KERNEL_VERSION}-s390x.img"
|
||||||
echo "Building and installing modified mkinitcpio..."
|
echo "Building and installing modified mkinitcpio..."
|
||||||
|
|
||||||
# Copy the mkinitcpio source
|
# Copy the mkinitcpio source
|
||||||
cp -r /work/mkinitcpio-source /tmp/mkinitcpio
|
mkdir -p /tmp/mkinitcpio
|
||||||
|
cp -r /work/mkinitcpio-source/* /tmp/mkinitcpio/
|
||||||
|
cp -r /work/mkinitcpio-source/.[^.]* /tmp/mkinitcpio/ 2>/dev/null || true
|
||||||
cd /tmp/mkinitcpio
|
cd /tmp/mkinitcpio
|
||||||
|
|
||||||
|
# Verify we're in the right directory
|
||||||
|
if [ ! -f "meson.build" ]; then
|
||||||
|
echo "ERROR: meson.build not found. Directory contents:"
|
||||||
|
ls -la
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Apply s390x patches
|
# Apply s390x patches
|
||||||
echo "Applying s390x patches to mkinitcpio..."
|
echo "Applying s390x patches to mkinitcpio..."
|
||||||
cat > install/base << 'PATCH_EOF'
|
|
||||||
#!/usr/bin/env bash
|
|
||||||
# SPDX-License-Identifier: GPL-2.0-only
|
|
||||||
# Modified for s390x cross-architecture support
|
|
||||||
|
|
||||||
build() {
|
# Check if patch file exists and apply it
|
||||||
local applet
|
if [ -f "/work/patches/mkinitcpio-s390x-base-hook.patch" ]; then
|
||||||
|
echo "Found mkinitcpio patch, applying..."
|
||||||
# Use s390x busybox binary if available (cross-architecture support)
|
cp /work/patches/mkinitcpio-s390x-base-hook.patch install/base
|
||||||
if [[ -f "/work/output/busybox-s390x-static" ]]; then
|
chmod +x install/base
|
||||||
echo "Using s390x static busybox binary"
|
echo "✓ Applied s390x patches to base install hook"
|
||||||
add_file "/work/output/busybox-s390x-static" "/bin/busybox" 755
|
else
|
||||||
|
echo "ERROR: Patch file not found at /work/patches/mkinitcpio-s390x-base-hook.patch"
|
||||||
# Create symlinks for busybox applets (using a known list since we can't execute cross-arch binary)
|
exit 1
|
||||||
local busybox_applets=(
|
fi
|
||||||
"[" "[[" "ash" "awk" "basename" "cat" "chgrp" "chmod" "chown" "cp" "cut"
|
|
||||||
"date" "dd" "df" "dirname" "dmesg" "du" "echo" "env" "expr" "false"
|
|
||||||
"find" "grep" "head" "hostname" "id" "kill" "ln" "ls" "mkdir" "mknod"
|
|
||||||
"mktemp" "mount" "mv" "printf" "ps" "pwd" "readlink" "rm" "rmdir"
|
|
||||||
"sed" "sh" "sleep" "sort" "stat" "tail" "tar" "test" "touch" "tr"
|
|
||||||
"true" "umount" "uname" "uniq" "wc" "which" "whoami" "xargs"
|
|
||||||
)
|
|
||||||
|
|
||||||
for applet in "${busybox_applets[@]}"; do
|
|
||||||
add_symlink "/usr/bin/$applet" busybox
|
|
||||||
done
|
|
||||||
elif [[ -f "/work/output/busybox-s390x-native" ]]; then
|
|
||||||
echo "Using s390x busybox binary"
|
|
||||||
add_file "/work/output/busybox-s390x-native" "/bin/busybox" 755
|
|
||||||
|
|
||||||
# Create symlinks for busybox applets (using a known list since we can't execute cross-arch binary)
|
|
||||||
local busybox_applets=(
|
|
||||||
"[" "[[" "ash" "awk" "basename" "cat" "chgrp" "chmod" "chown" "cp" "cut"
|
|
||||||
"date" "dd" "df" "dirname" "dmesg" "du" "echo" "env" "expr" "false"
|
|
||||||
"find" "grep" "head" "hostname" "id" "kill" "ln" "ls" "mkdir" "mknod"
|
|
||||||
"mktemp" "mount" "mv" "printf" "ps" "pwd" "readlink" "rm" "rmdir"
|
|
||||||
"sed" "sh" "sleep" "sort" "stat" "tail" "tar" "test" "touch" "tr"
|
|
||||||
"true" "umount" "uname" "uniq" "wc" "which" "whoami" "xargs"
|
|
||||||
)
|
|
||||||
|
|
||||||
for applet in "${busybox_applets[@]}"; do
|
|
||||||
add_symlink "/usr/bin/$applet" busybox
|
|
||||||
done
|
|
||||||
else
|
|
||||||
echo "Warning: s390x busybox not found, using system busybox (may cause architecture mismatch)"
|
|
||||||
add_binary /usr/lib/initcpio/busybox /bin/busybox
|
|
||||||
for applet in $(/usr/lib/initcpio/busybox --list 2>/dev/null || echo "sh ash"); do
|
|
||||||
add_symlink "/usr/bin/$applet" busybox
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Add kmod with applet symlinks (if available)
|
|
||||||
if type -P kmod >/dev/null 2>&1; then
|
|
||||||
echo "Adding kmod utilities..."
|
|
||||||
add_binary kmod
|
|
||||||
for applet in {dep,ins,rm,ls}mod mod{probe,info}; do
|
|
||||||
add_symlink "/usr/bin/$applet" kmod
|
|
||||||
done
|
|
||||||
else
|
|
||||||
echo "Warning: kmod not found, module utilities will not be available"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check for additional utilities (may not be available in cross-compile environment)
|
|
||||||
for binary in blkid mount umount switch_root; do
|
|
||||||
if type -P "$binary" >/dev/null 2>&1; then
|
|
||||||
echo "Adding $binary"
|
|
||||||
add_binary "$binary"
|
|
||||||
else
|
|
||||||
echo "Warning: $binary not found, skipping (functionality may be limited)"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Always add init files
|
|
||||||
echo "Adding init files..."
|
|
||||||
add_file "/usr/lib/initcpio/init_functions" "/init_functions"
|
|
||||||
add_file "/usr/lib/initcpio/init" "/init" 755
|
|
||||||
}
|
|
||||||
|
|
||||||
help() {
|
|
||||||
cat <<HELPEOF
|
|
||||||
This hook provides crucial runtime necessities for booting. This is a modified
|
|
||||||
version with s390x cross-architecture support. DO NOT remove this hook unless
|
|
||||||
you know what you're doing.
|
|
||||||
HELPEOF
|
|
||||||
}
|
|
||||||
|
|
||||||
# vim: set ft=sh ts=4 sw=4 et:
|
|
||||||
PATCH_EOF
|
|
||||||
|
|
||||||
echo "✓ Applied s390x patches to base install hook"
|
|
||||||
|
|
||||||
# Clean any existing build directory
|
# Clean any existing build directory
|
||||||
rm -rf build
|
rm -rf build
|
||||||
|
|
@ -157,7 +86,7 @@ echo "Setting up s390x environment..."
|
||||||
|
|
||||||
# Install missing dependencies
|
# Install missing dependencies
|
||||||
echo "Installing required dependencies..."
|
echo "Installing required dependencies..."
|
||||||
dnf install -y kmod-libs kmod util-linux busybox || echo "Warning: Some packages could not be installed"
|
dnf install -y kmod-libs kmod util-linux busybox bsdtar || echo "Warning: Some packages could not be installed"
|
||||||
|
|
||||||
# Create kernel module directory structure
|
# Create kernel module directory structure
|
||||||
KERNEL_DIR="/lib/modules/${KERNEL_VERSION}-s390x"
|
KERNEL_DIR="/lib/modules/${KERNEL_VERSION}-s390x"
|
||||||
|
|
@ -177,10 +106,11 @@ fi
|
||||||
|
|
||||||
# Ensure init files are in the correct location
|
# Ensure init files are in the correct location
|
||||||
echo "Verifying init files installation..."
|
echo "Verifying init files installation..."
|
||||||
if [ -f /usr/lib/initcpio/init ]; then
|
# Check both lib and lib64 locations
|
||||||
echo "✓ /usr/lib/initcpio/init found"
|
if [ -f /usr/lib/initcpio/init ] || [ -f /usr/lib64/initcpio/init ]; then
|
||||||
|
echo "✓ init found"
|
||||||
else
|
else
|
||||||
echo "✗ /usr/lib/initcpio/init missing - copying from source"
|
echo "✗ init missing - copying from source"
|
||||||
if [ -f /tmp/mkinitcpio/init ]; then
|
if [ -f /tmp/mkinitcpio/init ]; then
|
||||||
mkdir -p /usr/lib/initcpio
|
mkdir -p /usr/lib/initcpio
|
||||||
cp /tmp/mkinitcpio/init /usr/lib/initcpio/init
|
cp /tmp/mkinitcpio/init /usr/lib/initcpio/init
|
||||||
|
|
@ -188,15 +118,23 @@ else
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f /usr/lib/initcpio/init_functions ]; then
|
if [ -f /usr/lib/initcpio/init_functions ] || [ -f /usr/lib64/initcpio/init_functions ]; then
|
||||||
echo "✓ /usr/lib/initcpio/init_functions found"
|
echo "✓ init_functions found"
|
||||||
else
|
else
|
||||||
echo "✗ /usr/lib/initcpio/init_functions missing - copying from source"
|
echo "✗ init_functions missing - copying from source"
|
||||||
if [ -f /tmp/mkinitcpio/init_functions ]; then
|
if [ -f /tmp/mkinitcpio/init_functions ]; then
|
||||||
|
mkdir -p /usr/lib/initcpio
|
||||||
cp /tmp/mkinitcpio/init_functions /usr/lib/initcpio/init_functions
|
cp /tmp/mkinitcpio/init_functions /usr/lib/initcpio/init_functions
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Create symlinks if installed in lib64
|
||||||
|
if [ -d /usr/lib64/initcpio ] && [ ! -d /usr/lib/initcpio ]; then
|
||||||
|
echo "Creating symlinks from lib64 to lib..."
|
||||||
|
mkdir -p /usr/lib
|
||||||
|
ln -sf /usr/lib64/initcpio /usr/lib/initcpio
|
||||||
|
fi
|
||||||
|
|
||||||
# Create a minimal working s390x configuration
|
# Create a minimal working s390x configuration
|
||||||
echo "Creating minimal s390x configuration..."
|
echo "Creating minimal s390x configuration..."
|
||||||
|
|
||||||
|
|
@ -207,17 +145,14 @@ if [ -f /work/custom-init ]; then
|
||||||
chmod 755 /usr/lib/initcpio/init
|
chmod 755 /usr/lib/initcpio/init
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cat > /etc/mkinitcpio-s390x.conf << 'CONFIG'
|
# Copy mkinitcpio configuration
|
||||||
# Minimal s390x mkinitcpio configuration
|
if [ -f "/work/patches/mkinitcpio-s390x.conf" ]; then
|
||||||
# This config creates a basic initramfs without kernel modules
|
echo "Using s390x mkinitcpio configuration..."
|
||||||
MODULES=()
|
cp /work/patches/mkinitcpio-s390x.conf /etc/mkinitcpio-s390x.conf
|
||||||
BINARIES=()
|
else
|
||||||
FILES=()
|
echo "ERROR: Configuration file not found at /work/patches/mkinitcpio-s390x.conf"
|
||||||
# Only use base hook which provides busybox, init, and basic utilities
|
exit 1
|
||||||
HOOKS=(base)
|
fi
|
||||||
COMPRESSION="gzip"
|
|
||||||
COMPRESSION_OPTIONS=(-6)
|
|
||||||
CONFIG
|
|
||||||
|
|
||||||
echo "Generating initramfs with mkinitcpio..."
|
echo "Generating initramfs with mkinitcpio..."
|
||||||
echo "Configuration:"
|
echo "Configuration:"
|
||||||
|
|
@ -226,6 +161,20 @@ cat /etc/mkinitcpio-s390x.conf
|
||||||
# The s390x busybox integration is now handled by the patched base install hook
|
# The s390x busybox integration is now handled by the patched base install hook
|
||||||
echo "s390x busybox will be handled by the patched mkinitcpio base hook..."
|
echo "s390x busybox will be handled by the patched mkinitcpio base hook..."
|
||||||
|
|
||||||
|
# Ensure busybox binary is available for the base hook
|
||||||
|
if [ -f "/work/output/busybox-s390x-static" ]; then
|
||||||
|
echo "✓ Found s390x static busybox at /work/output/busybox-s390x-static"
|
||||||
|
ls -la /work/output/busybox-s390x-static
|
||||||
|
elif [ -f "/work/output/busybox-s390x-native" ]; then
|
||||||
|
echo "✓ Found s390x native busybox at /work/output/busybox-s390x-native"
|
||||||
|
ls -la /work/output/busybox-s390x-native
|
||||||
|
else
|
||||||
|
echo "ERROR: No s390x busybox binary found in /work/output/"
|
||||||
|
echo "Available files in /work/output:"
|
||||||
|
ls -la /work/output/
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Debug: List all files that mkinitcpio expects
|
# Debug: List all files that mkinitcpio expects
|
||||||
echo "Checking mkinitcpio dependencies:"
|
echo "Checking mkinitcpio dependencies:"
|
||||||
ls -la /usr/lib/initcpio/ 2>/dev/null || echo "/usr/lib/initcpio/ not found"
|
ls -la /usr/lib/initcpio/ 2>/dev/null || echo "/usr/lib/initcpio/ not found"
|
||||||
|
|
@ -303,7 +252,7 @@ sudo podman run --rm \
|
||||||
-v "$PROJECT_ROOT:/work" \
|
-v "$PROJECT_ROOT:/work" \
|
||||||
-w /work \
|
-w /work \
|
||||||
--privileged \
|
--privileged \
|
||||||
s390x-mkinitcpio-complete \
|
s390x-archlinux-dev \
|
||||||
/work/build-final-initramfs.sh
|
/work/build-final-initramfs.sh
|
||||||
|
|
||||||
# Clean up copied source
|
# Clean up copied source
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,9 @@ CONFIG_VIRTIO_PCI=y
|
||||||
CONFIG_TN3215=y
|
CONFIG_TN3215=y
|
||||||
CONFIG_TN3270=y
|
CONFIG_TN3270=y
|
||||||
|
|
||||||
|
# System identity
|
||||||
|
CONFIG_DEFAULT_HOSTNAME="arch"
|
||||||
|
|
||||||
# Required for initramfs
|
# Required for initramfs
|
||||||
CONFIG_BLK_DEV_INITRD=y
|
CONFIG_BLK_DEV_INITRD=y
|
||||||
CONFIG_RD_GZIP=y
|
CONFIG_RD_GZIP=y
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue