Files
hfsutils/build.sh
T
Pablo Lezaeta Reyes 2f09df5627 feat: complete integration and testing of HFS+ journaling support
Comprehensive update to fully integrate HFS+ journaling across the project:

### Build System Updates:
- **build.sh**: Enhanced with journaling-aware hfsck compilation
  * Automatic fallback to manual compilation if autotools fails
  * Proper journaling support compilation flags
  * Improved error handling and reporting

- **Makefile**: Updated main Makefile with journaling support
  * Enhanced hfsck build rule with manual fallback
  * Proper dependency handling for journal.o
  * Improved error handling for autotools issues

### Configuration Updates:
- **.gitattributes**: Comprehensive LF enforcement for all text files
  * Added support for all file types (.c, .h, .sh, .md, .1, .8, etc.)
  * Proper handling of build files and documentation
  * Consistent line ending management

- **.gitignore**: Enhanced with journaling-specific ignores
  * Added hfsutils.log and other log files
  * Added hfsck build artifacts
  * Better organization of ignored files

### Documentation Updates:
- **doc/man/fsck.hfs+.8**: Enhanced manual page with journaling documentation
  * Detailed journaling support description
  * Journal replay and validation features
  * Comprehensive logging information
  * Usage examples and troubleshooting

### Testing Infrastructure:
- **test/test_journaling.sh**: Comprehensive journaling test suite
  * Version and functionality verification
  * Error handling validation
  * Binary symbol verification
  * Log file creation testing
  * HFS+ image creation and validation

- **test/run_tests.sh**: Integrated journaling tests
  * Added test_hfsplus_journaling function
  * Integrated into hfsplus and all test patterns
  * Proper error handling and reporting

### Project Status:
- **TODO**: Updated with completed journaling features
- **CHANGELOG**: Added version 4.1.0 with journaling features

This completes the enterprise-level HFS+ journaling implementation with:
 Full crash recovery support
 Journal validation and repair
 Comprehensive testing suite
 Complete documentation
 Robust build system
 Professional logging and error handling
2025-10-21 20:29:10 -03:00

111 lines
3.7 KiB
Bash
Executable File

#!/bin/bash
# HFSUtils - Simple Build Script
# This script builds hfsutils without needing autoconf/configure
# Pass through environment variables
export CC="${CC:-gcc}"
export CXX="${CXX:-g++}"
export CFLAGS="${CFLAGS:--g -O2}"
export CXXFLAGS="${CXXFLAGS:--g -O2}"
export LDFLAGS="${LDFLAGS:-}"
export PREFIX="${PREFIX:-/usr/local}"
export DESTDIR="${DESTDIR:-}"
echo "Building HFSUtils..."
echo "CC=$CC"
echo "CFLAGS=$CFLAGS"
echo "PREFIX=$PREFIX"
if [ -n "$DESTDIR" ]; then
echo "DESTDIR=$DESTDIR"
fi
# Create build directory if it doesn't exist
mkdir -p build/obj
# Create .stamp if it doesn't exit too
mkdir -p libhfs/.stamp
mkdir -p librsrc/.stamp
mkdir -p hfsck/.stamp
# Build libhfs
echo "Building libhfs..."
cd libhfs
if [ ! -f configure ]; then
echo "Error: libhfs/configure not found!"
exit 1
fi
if [ ! -f config.status ]; then
echo "Configuring libhfs..."
CC="$CC" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" ./configure --prefix="$PREFIX"
fi
make CC="$CC" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" || { echo "Failed to build libhfs"; exit 1; }
cd ..
# Build librsrc
echo "Building librsrc..."
cd librsrc
if [ ! -f configure ]; then
echo "Error: librsrc/configure not found!"
exit 1
fi
if [ ! -f config.status ]; then
echo "Configuring librsrc..."
CC="$CC" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" ./configure --prefix="$PREFIX"
fi
make CC="$CC" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" || { echo "Failed to build librsrc"; exit 1; }
cd ..
# Build hfsck with journaling support
echo "Building hfsck..."
cd hfsck
if [ ! -f configure ]; then
echo "Error: hfsck/configure not found!"
exit 1
fi
if [ ! -f config.status ]; then
echo "Configuring hfsck..."
CC="$CC" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" ./configure --prefix="$PREFIX"
fi
# Compile hfsck with journaling support manually if autotools fails
if ! make CC="$CC" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" 2>/dev/null; then
echo "Autotools build failed, building hfsck manually with journaling support..."
# Compile all source files
$CC $CFLAGS -I./../include -I./../include/common -I./../libhfs -I./../src/common -DHAVE_CONFIG_H -c *.c || { echo "Failed to compile hfsck sources"; exit 1; }
# Compile common sources
$CC $CFLAGS -I./../include -I./../include/common -I./../libhfs -I./../src/common -DHAVE_CONFIG_H -c ../src/common/suid.c -o suid.o || { echo "Failed to compile suid.c"; exit 1; }
$CC $CFLAGS -I./../include -I./../include/common -I./../libhfs -I./../src/common -DHAVE_CONFIG_H -c ../src/common/version.c -o version.o || { echo "Failed to compile version.c"; exit 1; }
$CC $CFLAGS -I./../include -I./../include/common -I./../libhfs -I./../src/common -DHAVE_CONFIG_H -c ../src/common/hfs_detect.c -o hfs_detect.o || { echo "Failed to compile hfs_detect.c"; exit 1; }
# Link hfsck with journaling support
$CC $CFLAGS -o hfsck ck_btree.o ck_mdb.o ck_volume.o hfsck.o main.o util.o journal.o suid.o version.o hfs_detect.o ./../libhfs/libhfs.a || { echo "Failed to link hfsck"; exit 1; }
echo "hfsck built successfully with journaling support"
fi
cd ..
# Build main utilities
echo "Building hfsutil..."
make CC="$CC" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" PREFIX="$PREFIX" || { echo "Failed to build hfsutil"; exit 1; }
if [ -f hfsutil ]; then
echo "Build complete! The hfsutil binary is ready."
echo ""
echo "To install system-wide, run:"
echo " sudo make install"
echo ""
echo "To install to a custom location, run:"
echo " make install PREFIX=/custom/path"
echo " make install DESTDIR=/staging/area"
echo ""
echo "To create traditional command symlinks, run:"
echo " sudo make install-symlinks"
else
echo "Build failed - hfsutil binary not created"
exit 1
fi