Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
gh-131: Mocked uname to fake FreeBSD on Linux build systems
Browse files Browse the repository at this point in the history
  • Loading branch information
Vlastimil Holer committed Feb 4, 2019
1 parent 3533cf6 commit 27aa4c2
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,15 @@ fi

set -e

UNAME_PATH=$(mktemp -d)
BUILD_DIR=$(mktemp -d)

_POSTIN=$(mktemp)
_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##*##}
Expand Down Expand Up @@ -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 - <<EOF >"${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}"

Expand Down

0 comments on commit 27aa4c2

Please sign in to comment.