Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports
Path: blob/main/net-im/deltachat-desktop/scripts/make_node_tarball.sh
20806 views
1
#!/bin/sh
2
# Script for assembling the node dependencies required for FreeBSD packaging
3
#
4
# This is what I run to get the node_modules dirs needed to build the port
5
#
6
# Clone the https://github.com/deltachat/deltachat-desktop repo
7
# Then start with something like the following:
8
# git checkout -b v2.22.0 tags/v2.22.0
9
#
10
# Finally you can run this script.
11
#
12
# Requirements: electron37, node, npm, deltachat-rpc-server
13
14
set -eu
15
16
VERSION=$(git branch --show-current)
17
18
export ELECTRON_OVERRIDE_DIST_PATH=/usr/local/share/electron37
19
export ELECTRON_SKIP_BINARY_DOWNLOAD=1
20
21
# Cleanup
22
rm -rf node_modules pnpm packages/target-electron/node_modules deltachat-desktop-2.15.0-node-deps.tgz
23
git reset --hard
24
25
# Install pnpm in temp dir to avoid package.json parsing issues
26
# It would throw an error on the "catalog:"
27
CWD=$(pwd)
28
TMP=$(mktemp -d)
29
cd $TMP
30
npm i pnpm
31
mv node_modules $CWD
32
cd $CWD
33
rm -r $TMP
34
35
# Install all dependencies
36
echo "Installing dependencies..."
37
pnpm install
38
39
# Build workspace packages that have build steps
40
echo "Building workspace packages..."
41
# shared and runtime are just TypeScript source, no build needed
42
pnpm --filter @deltachat-desktop/frontend build
43
44
# Test the main build to ensure everything works
45
echo "Testing main build..."
46
cd packages/target-electron
47
pnpm build
48
cd ../..
49
50
echo "Build test successful! All dependencies are working."
51
52
# Remove platform-specific modules/binaries we don't need for FreeBSD
53
# TODO: there are possibly more that could be excluded
54
echo "Cleaning platform-specific binaries..."
55
rm -rf node_modules/.pnpm/*linux*
56
rm -rf node_modules/.pnpm/*darwin*
57
rm -rf node_modules/.pnpm/*win32*
58
rm -rf node_modules/.pnpm/*android*
59
rm -rf node_modules/.pnpm/@tauri-apps*
60
rm -rf node_modules/.pnpm/app-builder*
61
rm -rf node_modules/.pnpm/7zip-bin*
62
find node_modules -type f -name '*.exe' -delete
63
64
# Remove duplicates which will make it harder to select the right path by
65
# globbing in Makefile during packaging
66
find node_modules/.pnpm -name "@deltachat+stdio-rpc-server@*" -type d | tail -n+2 | xargs rm -r
67
68
echo "Creating tarball..."
69
tar -czvpf deltachat-desktop-${VERSION}-node-deps.tgz \
70
node_modules \
71
packages/target-electron/node_modules \
72
packages/frontend/node_modules \
73
packages/runtime/node_modules \
74
packages/shared/node_modules
75
76
echo ""
77
echo "Tarball created successfully!"
78
echo "You can now upload this distfile"
79
80