Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 34 additions & 3 deletions buildenv
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ BASH_VERSION="5.3"
export ZOPEN_BUILD_LINE="STABLE" # default build level is stable
export ZOPEN_STABLE_URL="https://ftp.gnu.org/gnu/bash/bash-${BASH_VERSION}.tar.gz"
export ZOPEN_CATEGORIES="shell"
export ZOPEN_STABLE_DEPS="curl gzip tar make zoslib coreutils diffutils sed ncurses grep gettext zusage util-linux readline"
export ZOPEN_STABLE_DEPS="curl gzip tar make zoslib coreutils diffutils sed ncurses grep gettext zusage util-linux readline patch"

export ZOPEN_DEV_URL="https://github.com/bminor/bash.git"
export ZOPEN_DEV_DEPS="perl m4 autoconf curl gzip tar make zoslib coreutils diffutils sed ncurses bison grep gettext zusage"
Expand All @@ -22,9 +22,40 @@ export ZOPEN_CHECK_TIMEOUT="${ZOPEN_CHECK_NO_TIMEOUT}"

export ZOPEN_EXTRA_CONFIGURE_OPTS="--with-installed-readline=\${READLINE_HOME}"

zopen_init()
zopen_post_extract()
{
cp ../stdlib.h .
# Download and apply official bash patches
src_dir="$1"
original_dir=$(pwd)

cp rename_builtins_header.sh $src_dir
cd "${src_dir}" || return 1

major_minor=$(echo "${BASH_VERSION}" | cut -d. -f1,2 | tr -d '.')
patches_url="https://ftp.gnu.org/gnu/bash/bash-${BASH_VERSION}-patches"

echo "Checking for bash patches at ${patches_url}..."

# Try to fetch the patches directory listing
patches_list=$(curl -s "${patches_url}/" | grep -o "bash${major_minor}-[0-9]\{3\}" | sort -u)

if [ -n "${patches_list}" ]; then
echo "Found patches, downloading and applying..."
for patch_name in ${patches_list}; do
echo "Applying ${patch_name}..."
curl -s "${patches_url}/${patch_name}" | patch -p0 -s
if [ $? -ne 0 ]; then
echo "Warning: Failed to apply ${patch_name}"
fi
done
echo "Finished applying patches"
else
echo "No patches found for bash ${BASH_VERSION}"
fi

/bin/sh rename_builtins_header.sh
rm rename_builtins_header.sh
cd "${original_dir}"
}

zopen_post_buildenv()
Expand Down
39 changes: 39 additions & 0 deletions rename_builtins_header.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/sh
# Script to rename builtins.h to bashbuiltins.h to avoid z/OS header collision
# Run this from the bash-5.3 source directory

set -e

BASH_SRC_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$BASH_SRC_DIR"

echo "Renaming builtins.h to bashbuiltins.h..."

# Step 1: Rename the header file
if [ -f "builtins.h" ]; then
mv builtins.h bashbuiltins.h
echo " Renamed: builtins.h -> bashbuiltins.h"
else
echo " Warning: builtins.h not found in current directory"
fi

# Step 2: Update include guard in the renamed file
if [ -f "bashbuiltins.h" ]; then
tmpfile="bashbuiltins.h.tmp.$$"
sed 's/BUILTINS_H/BASHBUILTINS_H/g' bashbuiltins.h > "$tmpfile" && mv "$tmpfile" bashbuiltins.h
echo " Updated include guard in bashbuiltins.h"
fi

# Step 3: Global find and replace in all source files
echo "Updating includes globally..."

find . -type f \( -name "*.c" -o -name "*.h" -o -name "*.def" -o -name "*.in" \) | while read file; do
if grep -q 'builtins\.h' "$file"; then
sed -i 's|builtins\.h|bashbuiltins.h|g' "$file"
echo " Updated: $file"
fi
done

echo ""
echo "Done! The header has been renamed to bashbuiltins.h"

22 changes: 0 additions & 22 deletions stable-patches/anonfile.c.patch

This file was deleted.

File renamed without changes.
Loading
Loading