diff --git a/generate.sh b/generate.sh index e15fbdb..996697c 100755 --- a/generate.sh +++ b/generate.sh @@ -79,6 +79,7 @@ fi set -e +UNAME_PATH=$(mktemp -d) BUILD_DIR=$(mktemp -d) _POSTIN=$(mktemp) @@ -86,7 +87,7 @@ _PREUN=$(mktemp) _POSTUN=$(mktemp) _POSTUP=$(mktemp) -trap "rm -rf ${BUILD_DIR} ${_POSTIN} ${_PREUN} ${_POSTUN} ${_POSTUP}" EXIT +trap "rm -rf ${UNAME_PATH} ${BUILD_DIR} ${_POSTIN} ${_PREUN} ${_POSTUN} ${_POSTUP}" EXIT while IFS= read -r -d $'\0' SRC; do F_TAGS=${SRC##*##} @@ -123,6 +124,19 @@ if [ -z "${OUT}" ]; then rm -rf "${OUT}" fi +# Mocked 'uname' to fake FreeBSD on Linux build systems. +# Otherwise FPM places Linux identification into TXZ packages. +if [ "${TYPE}" = 'freebsd' ] && [ ! -x /bin/freebsd-version ]; then + cat - <"${UNAME_PATH}/uname" +#!/bin/sh +[ "\$1" = '-s' ] && echo 'FreeBSD' +[ "\$1" = '-r' ] && echo '12.0-RELEASE' +EOF + + chmod +x "${UNAME_PATH}/uname" + export PATH="${UNAME_PATH}:${PATH}" +fi + if [ "${TYPE}" = 'dir' ]; then cp -rT "${BUILD_DIR}" "${OUT}"