73 lines
2.5 KiB
Bash
73 lines
2.5 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
|
|
|
|
#
|
|
# Source script mostly copied from Arch Linux
|
|
#
|
|
|
|
REPO="https://github.com/npm/cli.git"
|
|
|
|
# The prepare function is executed in the root of the temp directory
|
|
# This function is used for downloading files and putting them into the correct location
|
|
prepare() {
|
|
git clone --depth 1 --branch "v${BPM_PKG_VERSION}" "$REPO" "$BPM_SOURCE"
|
|
}
|
|
|
|
# The build function is executed in the source directory
|
|
# This function is used to compile the source code
|
|
build() {
|
|
node scripts/resetdeps.js
|
|
}
|
|
|
|
# The check function is executed in the source directory
|
|
# This function is used to run tests to verify the package has been compiled correctly
|
|
check() {
|
|
# Windows shims test failure
|
|
mv test/bin/windows-shims.js{,.bak}
|
|
node . run test --ignore-scripts -- --no-coverage
|
|
mv test/bin/windows-shims.js{.bak,}
|
|
}
|
|
|
|
# The package function is executed in the source directory
|
|
# This function is used to move the compiled files into the output directory
|
|
package() {
|
|
mod_dir=/usr/lib/node_modules/npm
|
|
|
|
install -d "$BPM_OUTPUT"/usr/share/{bash-completion/completions,licenses/npm}
|
|
ln -s "$mod_dir"/LICENSE "$BPM_OUTPUT"/usr/share/licenses/npm/LICENSE
|
|
|
|
node . install -g --prefix="${BPM_OUTPUT}/usr" "$(node . pack --ignore-scripts | tail -1)"
|
|
node . completion > "$BPM_OUTPUT"/usr/share/bash-completion/completions/npm
|
|
echo 'globalconfig=/etc/npmrc' > "$BPM_OUTPUT"/$mod_dir/npmrc
|
|
|
|
cd "$BPM_OUTPUT"/"$mod_dir"
|
|
# Remove superfluous scripts
|
|
rm -r {bin/{node-gyp-bin,np{m,x}{,.{cmd,ps1}}},node_modules/.bin}
|
|
|
|
# Experimental dedup
|
|
rm -r node_modules/{node-gyp,nopt,semver}
|
|
|
|
#cd man
|
|
## Workaround for https://github.com/npm/cli/issues/780
|
|
#local name page sec title
|
|
#for page in man5/folders.5 man5/install.5 man7/*.7; do
|
|
# sec=${page##*.}
|
|
# name=$(basename "$page" ."$sec")
|
|
# title=${name@U}
|
|
|
|
# sed -Ei "s/^\.TH \"$title\"/.TH \"NPM-$title\"/" "$page"
|
|
# mv "$page" "${page/\///npm-}"
|
|
#done
|
|
|
|
#gzip man?/*
|
|
|
|
# Support both `man` and `npm help`
|
|
#local dest sec_dir
|
|
#for sec_dir in man?; do
|
|
# dest="$BPM_OUTPUT"/usr/share/man/$sec_dir
|
|
# install -d "$dest"
|
|
# ln -r -s "$sec_dir"/* "$dest"
|
|
#done
|
|
}
|