Files
nim/source.sh
T

67 lines
2.7 KiB
Bash

# This is the source.sh script. It is executed by BPM in a temporary directory when compiling a source package
# BPM Expects the source code to be extracted into the automatically created 'source' directory which can be accessed using $BPM_SOURCE
# BPM Expects the output files to be present in the automatically created 'output' directory which can be accessed using $BPM_OUTPUT
# The prepare function is executed in the root of the temp directory
# This function is used for putting downloaded files to the correct location or applying patches
prepare() {
cd "$BPM_SOURCE"
patch -Np1 -i "$BPM_WORKDIR"/build-docs.patch
patch -Np1 -i "$BPM_WORKDIR"/migrate-to-pcre2.patch
}
# The build function is executed in the source directory
# This function is used to compile the source code
build() {
export SOURCE_DATE_EPOCH=$(git log -n 1 --format=%at)
./build_all.sh
# Generate man pages
local h2m_args=(
--section=1
--no-info
--version-string="$BPM_PKG_VERSION"
)
help2man --name='Nim Language Compiler' "${h2m_args[@]}" -o nim.1 ./bin/nim
help2man --name='Nimsuggest' "${h2m_args[@]}" -o nimsuggest.1 ./bin/nimsuggest
help2man --name='Nimgrep' "${h2m_args[@]}" -o nimgrep.1 ./bin/nimgrep
help2man --name='Nimpretty' "${h2m_args[@]}" -o nimpretty.1 ./bin/nimpretty
help2man --name='Nim Package Installer' "${h2m_args[@]}" -o nimble.1 ./bin/nimble
# Generate install.sh
./koch distrohelper
}
# The package function is executed in the source directory
# This function is used to move the compiled files into the output directory
package() {
DESTDIR="$BPM_OUTPUT" ./install.sh /usr/bin
# Install documentation
install -d "$BPM_OUTPUT"/usr/share/doc/nim
cp -r doc/html "$BPM_OUTPUT"/usr/share/doc/nim
find "$BPM_OUTPUT"/usr/share/doc/nim -name '*.idx' -delete
# Install man pages
install -Dm644 ./*.1 -t "$BPM_OUTPUT"/usr/share/man/man1
# Install tools
for fn in nimble nimsuggest nimgrep nim-gdb; do cp ./bin/$fn "$BPM_OUTPUT"/usr/bin/; done
install -Dm644 doc/nimdoc.{css,cls} -t "$BPM_OUTPUT"/usr/lib/nim/doc
install -Dm644 tools/debug/nim-gdb.py -t "$BPM_OUTPUT"/usr/lib/nim/tools
install -Dm644 tools/dochack/{dochack.js,fuzzysearch.nim} -t "$BPM_OUTPUT"/usr/lib/nim/tools/dochack
# Install shell completions
for comp in {tools,dist/nimble}/*.bash-completion; do
install -Dm644 "${comp}" "$BPM_OUTPUT"/usr/share/bash-completion/completions/$(basename "${comp/.bash-completion}")
done
for comp in {tools,dist/nimble}/*.zsh-completion; do
install -Dm644 "${comp}" "$BPM_OUTPUT"/usr/share/zsh/site-functions/_$(basename "${comp/.zsh-completion}")
done
# Install package license
install -Dm644 "$BPM_SOURCE"/copying.txt "$BPM_OUTPUT"/usr/share/licenses/nim/copying.txt
}