You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

157 lines
4.0 KiB

#!/bin/bash
# Helper script to run common operations on the PFEXTLIB Docker container
IMAGE_NAME="centos39-pfextlib:latest"
CONTAINER_NAME="pfextlib-builder"
show_usage() {
cat <<EOF
PFEXTLIB Docker Helper Script
Usage: $0 [command]
Commands:
build-image Build the Docker image from CentOS 3.9 packages
build-all Build all PFEXTLIB libraries in container
build-cppunit Build only cppunit library
build-fftw Build only fftw library
build-hdf5 Build only hdf5 library
shell Open interactive shell in container
extract Extract compiled libraries to ./output directory
clean Remove Docker image and temporary files
verify Verify libstdc++.5 is available in container
info Show information about the Docker image
Examples:
$0 build-image # First time setup
$0 build-all # Compile all libraries
$0 extract # Get the compiled libraries
$0 shell # Debug or manual operations
EOF
}
build_image() {
echo "==> Building Docker image..."
if [ ! -f "build-docker-image.sh" ]; then
echo "Error: build-docker-image.sh not found!"
exit 1
fi
chmod +x build-docker-image.sh
./build-docker-image.sh
}
build_all() {
echo "==> Building all PFEXTLIB libraries..."
docker run --rm -it "$IMAGE_NAME" /usr/local/PFEXTLIB-1.2/build-all.sh
}
build_cppunit() {
echo "==> Building cppunit..."
docker run --rm -it "$IMAGE_NAME" /usr/local/PFEXTLIB-1.2/build-cppunit.sh
}
build_fftw() {
echo "==> Building fftw..."
docker run --rm -it "$IMAGE_NAME" /usr/local/PFEXTLIB-1.2/build-fftw.sh
}
build_hdf5() {
echo "==> Building hdf5..."
docker run --rm -it "$IMAGE_NAME" /usr/local/PFEXTLIB-1.2/build-hdf5.sh
}
shell() {
echo "==> Opening shell in container..."
docker run --rm -it "$IMAGE_NAME" /bin/bash
}
extract() {
echo "==> Extracting compiled libraries..."
mkdir -p output
docker run --rm -v "$(pwd)/output:/output" "$IMAGE_NAME" bash -c \
'cp -rv /usr/local/PFEXTLIB-1.2/{cppunit,fftw,hdf5} /output/ 2>/dev/null || echo "Build libraries first!"'
if [ -d "output/cppunit" ] || [ -d "output/fftw" ] || [ -d "output/hdf5" ]; then
echo
echo "Libraries extracted to: $(pwd)/output/"
ls -la output/
else
echo
echo "No compiled libraries found. Run 'build-all' first."
fi
}
clean() {
echo "==> Cleaning Docker image and temporary files..."
docker rmi -f "$IMAGE_NAME" 2>/dev/null || true
rm -rf centos39-rootfs rpms output
echo "Clean complete."
}
verify() {
echo "==> Verifying libstdc++.5 availability..."
docker run --rm "$IMAGE_NAME" bash -c '
echo "==> Checking libstdc++ libraries:"
ldconfig -p | grep libstdc++ || echo "ldconfig not available"
echo
echo "==> Searching /usr/lib:"
ls -la /usr/lib/libstdc++* 2>/dev/null || echo "Not found in /usr/lib"
echo
echo "==> GCC version:"
gcc --version | head -1
echo
echo "==> G++ version:"
g++ --version | head -1
'
}
info() {
echo "==> Docker Image Information"
echo
if docker images "$IMAGE_NAME" --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}\t{{.CreatedAt}}" | grep -q centos39; then
docker images "$IMAGE_NAME" --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}\t{{.CreatedAt}}"
echo
echo "Image exists and ready to use."
else
echo "Image not found. Run: $0 build-image"
fi
}
# Main script
case "$1" in
build-image)
build_image
;;
build-all)
build_all
;;
build-cppunit)
build_cppunit
;;
build-fftw)
build_fftw
;;
build-hdf5)
build_hdf5
;;
shell)
shell
;;
extract)
extract
;;
clean)
clean
;;
verify)
verify
;;
info)
info
;;
*)
show_usage
exit 1
;;
esac