OBS-URL: https://build.opensuse.org/package/show/home:gladiac/nodejs-pyright?expand=0&rev=13
106 lines
2.9 KiB
Bash
106 lines
2.9 KiB
Bash
#!/bin/bash
|
|
|
|
PYRIGHT_URL=$(rpmspec -P *.spec | grep Source0 | sed -e 's/Source0:[ ]*//g')
|
|
PYRIGHT_TARBALL=$(basename ${PYRIGHT_URL})
|
|
PYRIGHT_PKGVERSION=$(rpmspec -P *.spec | grep ^Version | sed -e 's/Version:[ ]*//g')
|
|
PYRIGHT_PKGNAME="pyright"
|
|
PYRIGHT_PKGDIR="$(pwd)"
|
|
PYRIGHT_TMPDIR=$(mktemp --tmpdir -d pyright-XXXXXXXX)
|
|
PYRIGHT_PATH="${PYRIGHT_TMPDIR}/${PYRIGHT_PKGNAME}-${PYRIGHT_PKGVERSION}"
|
|
|
|
echo "URL: ${PYRIGHT_URL}"
|
|
echo "TARBALL: ${PYRIGHT_TARBALL}"
|
|
echo "NAME: ${PYRIGHT_PKGNAME}"
|
|
echo "VERSION: ${PYRIGHT_PKGVERSION}"
|
|
echo "PATH: ${PYRIGHT_PATH}"
|
|
|
|
cleanup_tmpdir() {
|
|
popd 2>/dev/null || true
|
|
rm -rf "${PYRIGHT_TMPDIR}"
|
|
}
|
|
trap cleanup_tmpdir SIGINT
|
|
|
|
cleanup_and_exit() {
|
|
cleanup_tmpdir
|
|
if test "$1" = 0 -o -z "$1" ; then
|
|
exit 0
|
|
else
|
|
exit "$1"
|
|
fi
|
|
}
|
|
|
|
if [ ! -w "${PYRIGHT_TARBALL}" ]; then
|
|
wget "${PYRIGHT_URL}"
|
|
fi
|
|
|
|
|
|
tar -xf "${PYRIGHT_TARBALL}" -C "${PYRIGHT_TMPDIR}"
|
|
|
|
|
|
pushd "$PYRIGHT_PATH" || cleanup_and_exit 1
|
|
|
|
NODEJS_VERSION="$(node -v | sed 's/v//')"
|
|
NODEJS_MAJOR_VERSION="${NODEJS_VERSION/\.*/}"
|
|
|
|
export npm_config_nodedir="/usr/include/node${NODEJS_MAJOR_VERSION}"
|
|
export npm_config_build_from_source=true
|
|
export CFLAGS="-I${npm_config_nodedir}"
|
|
export CXXFLAGS="-I${npm_config_nodedir}"
|
|
|
|
echo ">>>>>> Install npm modules"
|
|
npm run install:all
|
|
ret=$?
|
|
if [ ${ret} -ne 0 ]; then
|
|
echo "ERROR: npm install failed"
|
|
cleanup_and_exit 1
|
|
fi
|
|
|
|
# echo ">>>>>> Audit npm modules"
|
|
npm audit
|
|
|
|
# echo ">>>>>> Fix npm modules"
|
|
npm audit fix
|
|
ret=$?
|
|
if [ ${ret} -ne 0 ]; then
|
|
echo "ERROR: npm audit failed"
|
|
cleanup_and_exit 1
|
|
fi
|
|
|
|
|
|
echo ">>>>>> Cleanup object dirs"
|
|
find node_modules/ -type d -name "*.o.d" -print0 | xargs -0 rm -rf
|
|
find node_modules/ -type d -name "__pycache__" -print0 | xargs -0 rm -rf
|
|
|
|
|
|
echo ">>>>>> Cleanup object files"
|
|
# find node_modules/ -name "*.node" -print0 | xargs -0 rm -rf
|
|
|
|
find node_modules/ -name "*.dll" | grep -v signal-client | xargs rm -f
|
|
find node_modules/ -name "*.dylib" -delete
|
|
find node_modules/ -name "*.so" -delete
|
|
find node_modules/ -name "*.o" -delete
|
|
find node_modules/ -name "*.a" -delete
|
|
find node_modules/ -name "*.snyk-*.flag" -delete
|
|
find node_modules/ -name "builderror.log" -delete
|
|
find node_modules/ -name ".deps" -type d -print0 | xargs -0 rm -rf
|
|
|
|
|
|
echo ">>>>>> Cleanup build info"
|
|
find node_modules/ -name "Makefile" -delete
|
|
find node_modules/ -name "*.target.mk" -delete
|
|
find node_modules/ -name "config.gypi" -delete
|
|
find node_modules/ -name "package.json" -exec sed -i "s#$PYRIGHT_PATH#/tmp#g" {} \;
|
|
|
|
|
|
echo ">>>>>> Package vendor files"
|
|
rm -f "${PYRIGHT_PKGDIR}/${PYRIGHT_PKGNAME}-${PYRIGHT_PKGVERSION}-vendor.tar.zst"
|
|
XZ_OPT="-T$(nproc)" tar --zstd -cf "${PYRIGHT_PKGDIR}/${PYRIGHT_PKGNAME}-${PYRIGHT_PKGVERSION}-vendor.tar.zst" node_modules packages/pyright/node_modules packages/pyright-internal/node_modules packages/vscode-pyright/node_modules
|
|
ret=$?
|
|
if [ $ret -ne 0 ]; then
|
|
cleanup_and_exit 1
|
|
fi
|
|
|
|
popd || cleanup_and_exit 1
|
|
|
|
cleanup_and_exit 0
|