Compare commits

...
Sign in to create a new pull request.

4 commits

Author SHA1 Message Date
Pavel Filipenský
0381883d73 Update to version 2.0.0 2021-08-26 10:55:07 +02:00
Andreas Schneider
1ff59e7322 Move yarn install --production to %install section 2021-08-08 11:36:42 +02:00
Andreas Schneider
e2f6852f8b Add missing prepare_vendor.sh 2021-08-08 11:36:40 +02:00
Andreas Schneider
5be31fb456 The big bang! 2021-08-08 11:36:37 +02:00
5 changed files with 190 additions and 0 deletions

4
.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
/bash-language-server-1.17.0-vendor.tar.xz
/bash-language-server-1.17.0.tar.gz
/bash-language-server-2.0.0.tar.gz
/bash-language-server-2.0.0-vendor.tar.xz

View file

@ -1,3 +1,12 @@
# nodejs-bash-language-server
The nodejs-bash-language-server package
## Updating the package
* Update the version in the spec file
* Run `bash prepare_vendor.sh` (This will download the tarball and create the
vendor package)
* Add a changelog entry to the spec file
* Upload new source tarballs with `fedpkg new-sources PACKAGE.tar.gz`
* Commit your stuff to git

View file

@ -0,0 +1,91 @@
%{?nodejs_default_filter}
%define pkg_name bash-language-server
Name: nodejs-bash-language-server
Version: 2.0.0
Release: 1%{?dist}
Summary: A language server for Bash
License: MIT
Url: https://github.com/bash-lsp/bash-language-server
Source0: %{url}/archive/server-%{version}/%{pkg_name}-%{version}.tar.gz
# Create with `bash prepare_vendor.sh`
Source1: %{pkg_name}-%{version}-vendor.tar.xz
BuildRequires: fdupes
BuildRequires: nodejs-typescript
BuildRequires: nodejs-packaging
BuildRequires: npm
BuildRequires: perl-interpreter
BuildRequires: rsync
BuildRequires: yarnpkg
BuildArch: noarch
ExclusiveArch: %{nodejs_arches} noarch
%description
Bash language server implementation based on Tree Sitter and its grammar for
Bash with explainshell integration.
%prep
%autosetup -n %{pkg_name}-server-%{version} -a1 -p1
%build
export YARN_CACHE_FOLDER="$(pwd)/.package-cache"
yarn install --offline
npm run compile
%install
export YARN_CACHE_FOLDER="$(pwd)/.package-cache"
# Only install production dependencies in node_modules
yarn install --production --offline
for S in $(grep -l '#!.*node' \
server/bin/* \
server/node_modules/acorn/bin/* \
server/node_modules/ajv/scripts/* \
server/node_modules/escodegen/bin/* \
server/node_modules/esprima/bin/* \
server/node_modules/performance-now/test/scripts/* \
server/node_modules/pn/scripts/* \
server/node_modules/sshpk/bin/* \
server/node_modules/uuid/bin/* \
server/node_modules/vscode-languageserver/bin/* \
) ; do
SB="${S}.backup"
cp ${S} ${SB}
perl -p -i -e 's|#!/usr/bin/env node|#!%{_bindir}/node|g' $S
diff -urN ${SB} ${S} || :
rm ${SB}
done
install -d -m 0755 %{buildroot}%{_bindir}
ln -s %{nodejs_sitelib}/%{pkg_name}/bin/main.js %{buildroot}%{_bindir}/%{pkg_name}
install -d -m 0755 %{buildroot}%{nodejs_sitelib}/%{pkg_name}/
rsync -av server/ %{buildroot}%{nodejs_sitelib}/%{pkg_name}/
rm -rf %{buildroot}%{nodejs_sitelib}/%{pkg_name}/node_modules/performance-now/test/
chmod 0644 %{buildroot}%{nodejs_sitelib}/%{pkg_name}/tree-sitter-bash.wasm \
%{buildroot}%{nodejs_sitelib}/%{pkg_name}/node_modules/web-tree-sitter/tree-sitter.wasm
find %{buildroot}%{nodejs_sitelib}/%{pkg_name} -name "*.bak" -delete
find %{buildroot}%{nodejs_sitelib}/%{pkg_name} -type f -name "\.*" -delete
%fdupes %{buildroot}%{nodejs_sitelib}/%{pkg_name}
%files
%license LICENSE
%doc README.md
%{_bindir}/%{pkg_name}
%dir %{nodejs_sitelib}
%{nodejs_sitelib}/%{pkg_name}/
%changelog
* Thu Aug 26 2021 Pavel Filipenský <pfilipen@redhat.com> - 2.0.0-1
- Update to version 2.0.0
* https://github.com/bash-lsp/bash-language-server/blob/server-2.0.0/server/CHANGELOG.md
- Fixed indentation for node shebang loop
* Thu Aug 05 2021 Andreas Schneider <asn@redhat.com> - 1.17.0-1
- Initial package

84
prepare_vendor.sh Normal file
View 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

2
sources Normal file
View file

@ -0,0 +1,2 @@
SHA512 (bash-language-server-2.0.0.tar.gz) = e72df6f13ed4b861b81329059d41cdfada2729e9523e619ef26d6ed0a2a5400a3dda659b4f4af923a2a9fb2054b99b9d6db082508f2ba06ac0f9a421516e2ce9
SHA512 (bash-language-server-2.0.0-vendor.tar.xz) = 2ce21b7296a5813afeb48b7cf27d2c19eb0b80d5355e3ef276e6da0c8710f6216a4bed498125956a6412ee670acafd0d25f55cdb7527a4b1c934d033a875b748