File of Package code

#!/bin/bash -eux

# dnf install gzip jq nodejs16 moreutils yarn

TMPDIR="$(mktemp --tmpdir -d vscode-XXXXXXXX)"

version=$(< ./*.spec grep ^Version: | sed -e 's/Version:\s*//g')

wget -nc${version}.tar.gz

tar --gzip -xvvf ${PKGDIR}/${version}.tar.gz

cd vscode-${version}

find -depth -name yarn.lock -type f -print0 |   sed -z 's[/yarn.lock$[[' | sponge | xargs -0  -I{} -n1 -t -- sh -c ' cd {} && yarn install --frozen-lockfile --ignore-engines --ignore-platform  --ignore-scripts --link-duplicates || exit 255'

echo ">>>>>> Remove vendored deps"
rm -v node_modules/@vscode/sqlite3/deps/*.gz
rm -rf {remote/,}node_modules/@vscode/spdlog/deps

echo ">>>>>> Remove non-free binaries"
find . -type f -name "*.jar" -print -delete
find . -type f -name "*.wasm" -print -delete
find . -type f -name "*.pyc" -print -delete
find . -type f -name "*.pyd" -print -delete
find . -type f -name "*.exe" -print -delete
find . -type f -name "*.node" -print -delete
find . -type f -name "*.dll" -print -delete
find . -type f -name "*.dylib" -print -delete
find . -type f -name "*.so" -print -delete
find . -type f -name "*.o" -print -delete
find . -type f -name "*.a" -print -delete

#We use sponge to avoid a race condition between find and rm
find -type f | sponge | xargs -P$(nproc) -- sh -c 'file -S "$@" | grep -v '\'' .*script'\'' | grep '\'' .*executable'\'' | tee /dev/stderr | sed '\''s/: .*//'\'' | xargs rm -fv'

#echo ">>>>>> Hardlink duplicate files to reduce extraction time"
#Disabled this — it fails to link sometimes causing tarball nondeterminism
#/usr/lib/rpm/fdupes_wrapper src

export ZSTD_CLEVEL=19
export ZSTD_NBTHREADS=$(nproc)
find -name node_modules -print0 | sed -z '/node_modules\/.*\/node_modules/d' | sed -z '/css-language-features\/server\/test\/linksTestFixtures/d' | sort -z | xargs -0 -x -t tar --zstd --sort=name -vvScf ${PKGDIR}/vendor.tar.zst

cd ..

cd /tmp
rm -rf "${TMPDIR}"
openSUSE Build Service is sponsored by