blob: 052aa24414d3825da7e83bb30f9ae0c69fdffdae (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
# Maintainer: Cedric Roijakkers <cedric [the at sign goes here] roijakkers [the dot sign goes here] be>.
# Inspired from the PKGBUILD for ferdi-git.
_pkgname='ferdium'
pkgname="ferdium"
pkgver=6.0.0.nightly.90
pkgrel=1
pkgdesc='A messaging browser that allows you to combine your favorite messaging services into one application (git build from latest release).'
arch=('x86_64' 'i686' 'armv7h' 'aarch64')
url="https://ferdium.org/"
license=('Apache')
depends=('nss' 'atk' 'at-spi2-atk' 'libcups' 'libdrm' 'gdk-pixbuf2' 'gtk3' 'alsa-lib' 'c-ares' 'ffmpeg' 'libevent' 'libxkbfile' 'libxslt' 'minizip' 're2' 'snappy')
apptag='v6.0.0-nightly.90'
makedepends=('nvm' 'git' 'python')
provides=("$_pkgname")
conflicts=("$_pkgname")
source=(
"$pkgname::git+https://github.com/ferdium/ferdium-app#tag=${apptag}"
)
sha512sums=('SKIP')
_sourcedirectory="$pkgname"
case "$CARCH" in
i686)
_electronbuilderarch='ia32'
;;
armv7h)
_electronbuilderarch='armv7l'
;;
aarch64)
_electronbuilderarch='arm64'
;;
*)
_electronbuilderarch='x64'
;;
esac
prepare() {
# Due to patches and sed's, reset the code to upstream before starting
cd "$srcdir/$_sourcedirectory/"
git reset --hard "refs/tags/${apptag}"
# Initialise the recipes submodule
git submodule init
cd "$srcdir/$_sourcedirectory/recipes"
git reset --hard
cd "$srcdir/$_sourcedirectory/"
git submodule update --init --recursive --remote --rebase --force
# Specify path for autostart file
sed -i -e "s#^const executablePath =.*#const executablePath = '/usr/bin/ferdium';#g" src/stores/AppStore.ts
# Set noUnusedLocals to false to avoid compilation error in AppStore.ts
sed -i -e 's#"noUnusedLocals": true#"noUnusedLocals": false#g' tsconfig.json
}
pkgver() {
cd "$srcdir/$_sourcedirectory/"
printf "%s" "$(git describe --tags | sed 's/\([^-]*-\)g/r\1/;s/-/./g' | sed 's/^v//')"
}
build() {
# Prepare recipes
cd "$srcdir/$_sourcedirectory/"
# Set environment variables needed for NodeJS/Electron
export CI=true
# Deactivate any pre-loaded nvm, and make sure we use our own in the current source directory
which nvm >/dev/null 2>&1 && nvm deactivate && nvm unload
export NVM_DIR="${srcdir}/.nvm"
source /usr/share/nvm/init-nvm.sh || [[ $? != 1 ]]
# Install the correct version of NodeJS (read from .nvmrc)
nvm install $(cat .nvmrc)
nvm use
# Check if the correct version of node is being used
if [[ "$(node --version)" != "v$(cat .nvmrc)" ]]
then
echo "Using the wrong version of NodeJS! Expected [v"$(cat .nvmrc)"] but using ["$(node --version)"]."
exit 1
fi
# Extract the correct versions of npm and pnpm from the package.json files
EXPECTED_NPM_VERSION=$(node -p 'require("./package.json").engines.npm')
EXPECTED_PNPM_VERSION=$(node -p 'require("./recipes/package.json").engines.pnpm')
# Empty the cache before building to avoid issues with packages not being found
npm cache clean --force
# Install the correct versions of npm and pnpm
npm i -gf npm@${EXPECTED_NPM_VERSION}
npm i -gf pnpm@${EXPECTED_PNPM_VERSION}
# This is useful if we move from 'npm' to 'pnpm' for the main repo as well
if [[ -s 'pnpm-lock.yaml' ]]; then
BASE_CMD=pnpm
else
BASE_CMD=npm
fi
# Build recipe archives
$BASE_CMD i
$BASE_CMD run prepare-code || true
# Run the package script
pushd recipes
pnpm i
pnpm run package
popd
# Make sure the internal version of electron-builder is being used by prefixing it to the $PATH
export PATH=./node_modules/.bin/:$PATH
# Run the electron build script
NODE_ENV='production' $BASE_CMD run build -- --dir
}
package() {
cd "$srcdir/$_sourcedirectory/"
# Determine where the unpacked output directory is located
local _outpath='out/linux'
if [ "$_electronbuilderarch" != 'x64' ]; then
_outpath="$_outpath-$_electronbuilderarch"
fi
_outpath="$_outpath-unpacked"
# Copy the linux-unpacked directory to the system
install -d -m755 "${pkgdir}/opt/$pkgname/"
cp -pr "$_outpath"/* "${pkgdir}/opt/$pkgname/"
# Create a symlink in the default $PATH
install -d -m755 "${pkgdir}/usr/bin/"
ln -s "/opt/$pkgname/$_pkgname" ${pkgdir}/usr/bin/$_pkgname
# Fix permissions of chrome-sandbox for those running the hardened kernel
chmod 4755 "${pkgdir}/opt/$pkgname/chrome-sandbox"
# Create a .desktop file
install -dm755 "$pkgdir/usr/share/applications/"
cat << EOF > "$pkgdir/usr/share/applications/$_pkgname.desktop"
[Desktop Entry]
Name=${_pkgname^}
Exec=/usr/bin/$_pkgname %U
Terminal=false
Type=Application
Icon=ferdium
StartupWMClass=Ferdium
Comment=Ferdium is your messaging app / former heir to the throne of Austria-Hungary and combines chat & messaging services into one application. Ferdium currently supports Slack, WhatsApp, Gmail, Facebook Messenger, Telegram, Google Hangouts, GroupMe, Skype and many more. You can download Ferdium for free for Mac, Windows, and Linux.
MimeType=x-scheme-handler/ferdium;
Categories=Network;InstantMessaging;
EOF
# Install the icons
for _size in 16 24 32 48 64 96 128 256 512 1024; do
install -Dm644 "build-helpers/images/icons/${_size}x${_size}.png" "$pkgdir/usr/share/icons/hicolor/${_size}x${_size}/apps/$_pkgname.png"
done
}
|