<commit_before>#!/bin/sh

PATH="/usr/bin:/bin:/usr/sbin:/sbin"

#src root
if [ -z "${EXT2BUILD}" ]; then
	echo "EXT2BUILD is not defined, using current directory"
	EXT2BUILD=`pwd`
fi

BUILD="${EXT2BUILD}/build"
INSTALL="${BUILD}/install"

if [ ! -d "${BUILD}" ]; then
	echo "Invalid source directory."
	exit 1
fi

if [ ! -d "${INSTALL}" ]; then
	mkdir "${INSTALL}"
else
	sudo rm -rf "${INSTALL}"
	mkdir "${INSTALL}"
fi

mkdir -p "${INSTALL}/System/Library/Extensions"
mkdir -p "${INSTALL}/System/Library/FileSystems"
mkdir "${INSTALL}/sbin"
mkdir -p "${INSTALL}/usr/share/man/man8"
mkdir -p "${INSTALL}/usr/local/lib"

#install e2fsprogs
cd "${EXT2BUILD}/src/e2fsprogs"
DESTDIR="${INSTALL}" make install

cd "${EXT2BUILD}"

#mv fsck to /sbin and then remake the links
mv "${INSTALL}/usr/local/sbin/e2fsck" "${INSTALL}/sbin/fsck_ext2"

cd "${INSTALL}/usr/local/sbin"
rm fsck.ext2 fsck.ext3
ln -sf ../../../sbin/fsck_ext2 ./e2fsck
ln -sf ../../../sbin/fsck_ext2 ./fsck.ext2
ln -sf ../../../sbin/fsck_ext2 ./fsck.ext3

cd ../share/man/man8
ln -f e2fsck.8 fsck_ext2.8

cd "${EXT2BUILD}"

cp -R "${BUILD}/ext2fs.kext" "${INSTALL}/System/Library/Extensions"
cp -R "${BUILD}/ext2.fs" "${INSTALL}/System/Library/FileSystems"

#mount
cp "${BUILD}/mount_ext2" "${INSTALL}/sbin"
cp "${EXT2BUILD}/src/mount_ext2fs/mount_ext2fs.8" "${INSTALL}/usr/share/man/man8/mount_ext2.8"

#strip binaries for prod build here

#get rid of unwanted files
find "${INSTALL}" -name "\.DS_Store" -exec rm {} \;
find "${INSTALL}" -name "pbdevelopment.plist" -exec rm {} \;
find "${INSTALL}" -name "CVS" -type d -exec rm -fr {} \;

sudo chown -R root:wheel "${INSTALL}"
sudo chmod -R go-w "${INSTALL}"
sudo chmod -R u-w build/install/sbin/* 
sudo chmod -R u-w build/install/usr/local/bin/*
sudo chmod -R u-w build/install/usr/local/sbin/* 
sudo chmod -R u-w build/install/usr/local/lib/*<commit_msg>Added manpage links, lib symlinks and a symlink for newfs_ext2. Added GNU copyright. Change cp to preserve date and time.<commit_after>#!/bin/sh

PATH="/usr/bin:/bin:/usr/sbin:/sbin"

#src root
if [ -z "${EXT2BUILD}" ]; then
	echo "EXT2BUILD is not defined, using current directory"
	EXT2BUILD=`pwd`
fi

BUILD="${EXT2BUILD}/build"
INSTALL="${BUILD}/install"

if [ ! -d "${BUILD}" ]; then
	echo "Invalid source directory."
	exit 1
fi

if [ ! -d "${INSTALL}" ]; then
	mkdir "${INSTALL}"
else
	sudo rm -rf "${INSTALL}"
	mkdir "${INSTALL}"
fi

mkdir -p "${INSTALL}/System/Library/Extensions"
mkdir -p "${INSTALL}/System/Library/FileSystems"
mkdir "${INSTALL}/sbin"
mkdir -p "${INSTALL}/usr/share/man/man8"
mkdir -p "${INSTALL}/usr/local/lib"

#install e2fsprogs
cd "${EXT2BUILD}/src/e2fsprogs"
DESTDIR="${INSTALL}" make install

cd "${EXT2BUILD}"

#mv fsck to /sbin and then remake the links
mv "${INSTALL}/usr/local/sbin/e2fsck" "${INSTALL}/sbin/fsck_ext2"

cd "${INSTALL}/usr/local/sbin"
rm fsck.ext2 fsck.ext3
ln -sf ../../../sbin/fsck_ext2 ./e2fsck
ln -sf ../../../sbin/fsck_ext2 ./fsck.ext2
ln -sf ../../../sbin/fsck_ext2 ./fsck.ext3

cd ../share/man/man8
ln -f e2fsck.8 ./fsck_ext2.8
ln -f mke2fs.8 ./newfs_ext2.8

#mkfs symlink
cd "${INSTALL}/sbin"
ln -sf ../usr/local/sbin/mke2fs ./newfs_ext2

#lib sym links
cd "${INSTALL}/usr/local/lib"

ln -sf ./libcom_err.1.0.dylib ./libcom_err.dylib
ln -sf ./libe2p.2.1.dylib ./libe2p.dylib
ln -sf ./libext2fs.2.1.dylib ./libext2fs.dylib
ln -sf ./libss.1.0.dylib ./libss.dylib
ln -sf ./libuuid.1.1.dylib ./libuuid.dylib

cd "${EXT2BUILD}"

cp -pR "${BUILD}/ext2fs.kext" "${INSTALL}/System/Library/Extensions"
cp -pR "${BUILD}/ext2.fs" "${INSTALL}/System/Library/FileSystems"

#mount
cp -p "${BUILD}/mount_ext2" "${INSTALL}/sbin"
cp -p "${EXT2BUILD}/src/mount_ext2fs/mount_ext2fs.8" "${INSTALL}/usr/share/man/man8/mount_ext2.8"

#strip binaries for prod build here

#get rid of unwanted files
find "${INSTALL}" -name "\.DS_Store" -exec rm {} \;
find "${INSTALL}" -name "pbdevelopment.plist" -exec rm {} \;
find "${INSTALL}" -name "CVS" -type d -exec rm -fr {} \;

#e2fsprogs copyright
cp -p "${EXT2BUILD}/src/e2fsprogs/COPYING" "${INSTALL}/usr/local/share/E2FSPROGS_COPYRIGHT"

sudo chown -R root:wheel "${INSTALL}"
sudo chmod -R go-w "${INSTALL}"
sudo chmod -R u-w build/install/sbin/* 
sudo chmod -R u-w build/install/usr/local/bin/*
sudo chmod -R u-w build/install/usr/local/sbin/* 
sudo chmod -R u-w build/install/usr/local/lib/*
{'fraction_non_alphanumeric': 0.2017968210089841, 'fraction_numerical': 0.022345081778392076, 'mean_word_length': 3.745355191256831, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '175554', 'n_tokens_mistral': 1807, 'n_tokens_neox': 1697, 'n_words': 427}