File preppare.sh of Package notion-electron

#!/bin/bash 

set -ex

version=$1
sed -i -e "s/^\(Version: *\)[^ ]*$/\1${version}/" notion-electron.spec

oldwd="$(pwd)"

# cleanup old stuff
(find -maxdepth 1 -type d -name 'notion-electron-*' | xargs rm -r) ||:

version=$(grep "Version:" notion-electron.spec | awk '{print $2}')
# last_packaged_version=$(osc cat devel:languages:nodejs/notion-electron/notion-electron.spec | grep "^Version:" | awk '{print $NF}')

osc rm --force notion-electron-*.tar.gz || :
wget -c https://github.com/anechunaev/notion-electron/archive/refs/tags/v${version}.tar.gz -O notion-electron-${version}.tar.gz
#wget https://meet.element.io/libs/external_api.min.js -O jitsi_external_api.min.js
osc add notion-electron-*.tar.gz

#zypper install npm

rm -rf "notion-electron-${version}"
tar xzvf notion-electron-${version}.tar.gz
cd notion-electron-${version}
#changes=$(grep "^Changes in \[$last_packaged_version\]" -B10000 CHANGELOG.md |  head -n -2 | sed -e '/^==*$/d' -e 's/Changes in \[\([^\[]*\)\].*/Version \1/' -e 's/^\([^-].*\)$/  \1/' -e 's/\[.*\](\(.*\))/\1/g' -e 's/^ *Version /Version /g')

tmpdir="$(mktemp -d)"
mkdir -pv "$tmpdir/home"
oldhome="$HOME"
export HOME="$tmpdir/home"

patch -i ${oldwd}/remove-builder.patch


npm cache verify
rm -rf node_modules/
#cp "$oldwd/npm.lock" ./
npm install  --frozen-lockfile --ignore-engines --ignore-platform  --ignore-scripts --link-duplicates || : # this will download the packages

#Remove non-free binaries, starting with a few common file extensions
find . -name '*.node' -print -delete
find . -name '*.jar' -print -delete
find . -name '*.dll' -print -delete
find . -name '*.exe' -print -delete
find . -name '*.dylib' -print -delete
find . -name '*.so' -print -delete
find . -name '*.o' -print -delete
find . -name '*.a' -print -delete

rm -rfv ./node_modules/electron-winstaller

# now detect the rest. This should catch all ELFs that may be executed. 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'

rm -f "${oldwd}/vendor.tar.zst"
ZSTD_CLEVEL=19 ZSTD_NBTHREADS=$(nproc) tar --zstd --sort=name -Scf "${oldwd}/vendor.tar.zst" node_modules
export HOME="$oldhome"

cd "$oldwd"
rm -rf "$tmpdir"
echo -e "\n\nDONE creating npm offline dependencies archive 'vendor.tar.zst'"

#read -p "Write changes?"
#osc vc -m "${changes}" notion-electron.changes
#dos2unix notion-electron.changes
openSUSE Build Service is sponsored by