Add missing prepare_vendor.sh
This commit is contained in:
parent
e25f9b05ed
commit
3e7f27175e
1 changed files with 84 additions and 0 deletions
84
prepare_vendor.sh
Normal file
84
prepare_vendor.sh
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
#!/bin/bash
|
||||
|
||||
BASHLS_URL=$(rpmspec -P *.spec | grep Source0 | sed -e 's/Source0:[ ]*//g')
|
||||
BASHLS_TARBALL=$(basename $BASHLS_URL)
|
||||
BASHLS_PKGVERSION=$(rpmspec -P *.spec | grep ^Version | sed -e 's/Version:[ ]*//g')
|
||||
BASHLS_PKGNAME="bash-language-server"
|
||||
BASHLS_PKGDIR="$(pwd)"
|
||||
BASHLS_TMPDIR=$(mktemp --tmpdir -d bashls-XXXXXXXX)
|
||||
BASHLS_PATH="$BASHLS_TMPDIR/$BASHLS_PKGNAME-server-$BASHLS_PKGVERSION"
|
||||
|
||||
echo "URL: $BASHLS_URL"
|
||||
echo "TARBALL: $BASHLS_TARBALL"
|
||||
echo "NAME: $BASHLS_PKGNAME"
|
||||
echo "VERSION: $BASHLS_PKGVERSION"
|
||||
echo "PATH: $BASHLS_PATH"
|
||||
|
||||
cleanup_tmpdir() {
|
||||
popd 2>/dev/null
|
||||
rm -rf $BASHLS_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 "$BASHLS_TARBALL" ]; then
|
||||
wget "$BASHLS_URL"
|
||||
fi
|
||||
|
||||
|
||||
tar -xf $BASHLS_TARBALL -C $BASHLS_TMPDIR
|
||||
|
||||
|
||||
pushd $BASHLS_PATH
|
||||
|
||||
export YARN_CACHE_FOLDER="$(pwd)/.package-cache"
|
||||
echo ">>>>>> Install npm modules"
|
||||
yarn install --frozen-lockfile
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "ERROR: yarn install failed"
|
||||
cleanup_and_exit 1
|
||||
fi
|
||||
|
||||
echo ">>>>>> Cleanup object dirs"
|
||||
find node_modules/ -type d -name "*.o.d" | xargs rm -rf
|
||||
find node_modules/ -type d -name "__pycache__" | xargs rm -rf
|
||||
|
||||
|
||||
echo ">>>>>> Cleanup object files"
|
||||
find node_modules/ -name "*.node" | xargs 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 | xargs 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#$BASHLS_PATH#/tmp#g" {} \;
|
||||
|
||||
|
||||
echo ">>>>>> Package vendor files"
|
||||
rm -f $BASHLS_PKGDIR/${BASHLS_PKGNAME}-${BASHLS_PKGVERSION}-vendor.tar.xz
|
||||
XZ_OPT="-T$(nproc)" tar cJf $BASHLS_PKGDIR/${BASHLS_PKGNAME}-${BASHLS_PKGVERSION}-vendor.tar.xz .package-cache
|
||||
if [ $? -ne 0 ]; then
|
||||
cleanup_and_exit 1
|
||||
fi
|
||||
|
||||
popd
|
||||
|
||||
cleanup_and_exit 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue