Created
January 9, 2015 23:13
-
-
Save bdrewery/757e0983eec65906c7aa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
TMPFS_DIR=/tmp/split-package-${BUILDNAME} | |
if [ "$1" = "start" ]; then | |
# Create a tmpfs to store the final files in. It will be null-mounted | |
# into each child jail. | |
rm -rf ${TMPFS_DIR} | |
install -d -m 0600 ${TMPFS_DIR} | |
mount -t tmpfs tmpfs ${TMPFS_DIR} | |
# null mount it into the ref jail | |
SPLIT_PACKAGES_DST=/tmp/split-package | |
mkdir ${MASTERMNT}${SPLIT_PACKAGES_DST} | |
mount -t nullfs ${TMPFS_DIR} ${MASTERMNT}${SPLIT_PACKAGES_DST} | |
# Add to make.conf for ports hook to pickup | |
echo "SPLIT_PACKAGES_DST=${SPLIT_PACKAGES_DST}" >> \ | |
${MASTERMNT}/etc/make.conf | |
elif [ "$1" = "stop" ]; then | |
# If the tmpfs is missing, something went wrong with starting the jail. | |
[ -d "${TMPFS_DIR}" ] || exit 0 | |
find ${TMPFS_DIR} | |
# XXX: sync to DESTDIR | |
# Unmount the nullfs in the ref jail | |
umount ${MASTERMNT}/tmp/split-package | |
# Unmount the tmpfs | |
umount ${TMPFS_DIR} | |
rm -rf ${TMPFS_DIR} | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USES_LOCAL= split_packages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
. ${SCRIPTSDIR}/functions.sh | |
MOVE_FILES=$(mktemp -t tar_files) | |
PLIST_FILES=$(mktemp -t plist_files) | |
PLIST_DIRS=/dev/null | |
SED_FILE=$(mktemp -t sed_file) | |
PARSE_COMMENTS=1 | |
parse_plist "${PREFIX}" ${PARSE_COMMENTS} < "${TMPPLIST}" 3>${PLIST_DIRS} \ | |
>${PLIST_FILES} | |
msg() { | |
echo "====> split-package: $@" | |
} | |
while read line; do | |
case "${line}" in | |
*/man/*[123456789].gz|*.a) | |
# Echo the file to be moved. Add a ./ to avoid | |
# looking in real /. tar -C is not enough. | |
echo "./${line}" >&1 | |
# Echo the sed command to remove this from plist | |
echo "\\#(^${line}|^${line#${PREFIX}/})#d" >&3 | |
;; | |
esac | |
done < ${PLIST_FILES} > ${MOVE_FILES} 3> ${SED_FILE} | |
# Move the files over to the dest. tar is used to preserve hardlinks. | |
msg "Moving files from ${STAGEDIR}" | |
tar -C ${STAGEDIR} -T ${MOVE_FILES} -cf - | tar -C ${SPLIT_PACKAGES_DST} -xf - | |
# Remove them from STAGEDIR | |
( | |
cd ${STAGEDIR} | |
cat ${MOVE_FILES} | xargs rm -vf | |
) | |
# Fixup plist | |
msg "Fixing plist" | |
sed -i '' -E -f ${SED_FILE} ${TMPPLIST} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.if !defined(_INCLUDE_USES_SPLIT_PACKAGES_MK) | |
_INCLUDE_USES_SPLIT_PACKAGES_MK= yes | |
POST_PLIST+= split-package | |
.PHONY: split-package | |
# Move out some files into our own staging area that will be packaged up | |
# after the entire build is done. | |
split-package: | |
@${ECHO_CMD} "===> Splitting out files" | |
@${SETENV} ${CO_ENV} SPLIT_PACKAGES_DST=${SPLIT_PACKAGES_DST:Q} \ | |
${SH} ${USES_LOCAL_DIR}/split-package.sh | |
.endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment