aboutsummaryrefslogtreecommitdiffstats
path: root/Dockerfile.debian
blob: 352df11d28d54d8ca3e370640dd7cf8fbd7f58f9 (plain) (blame)
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
FROM debian:bookworm-slim AS base-image

FROM base-image AS bitlbee-build

ARG BITLBEE_VERSION=3.6-1

ENV PYTHON=/usr/bin/python3

RUN apt-get update \
 && apt-get install -y --no-install-recommends \
    build-essential git python3 autoconf automake libtool intltool flex libglib2.0-dev \
    libssl-dev libpurple-dev libjson-glib-dev libgcrypt20-dev libotr5-dev \
 && cd /tmp \
 && git clone -n https://github.com/bitlbee/bitlbee.git \
 && cd bitlbee \
 && git checkout ${BITLBEE_VERSION} \
 && ./configure --purple=1 --otr=plugin --ssl=openssl --prefix=/usr --etcdir=/etc/bitlbee \
 && make -j$(nproc --ignore 2) \
 && make install-bin \
 && make install-doc \
 && make install-dev \
 && make install-etc \
 && strip /usr/sbin/bitlbee \
 && touch /nowhere

# ---

FROM bitlbee-build AS otr-install

ARG OTR=1

RUN echo OTR=${OTR} > /tmp/status \
 && if [ ${OTR} -eq 1 ]; \
     then cd /tmp/bitlbee \
       && make install-plugin-otr; \
     else mkdir -p /usr/lib/bitlbee \
       && ln -sf /nowhere /usr/lib/bitlbee/otr.so; \
    fi

# ---

FROM bitlbee-build AS facebook-build

ARG FACEBOOK=0
ARG FACEBOOK_VERSION

RUN echo FACEBOOK=${FACEBOOK} > /tmp/status \
 && if [ ${FACEBOOK} -eq 1 ]; \
     then cd /tmp \
       && git clone -n https://github.com/bitlbee/bitlbee-facebook.git \
       && cd bitlbee-facebook \
       && git checkout ${FACEBOOK_VERSION} \
       && ./autogen.sh \
       && make -j$(nproc --ignore 2) \
       && make install \
       && strip /usr/lib/bitlbee/facebook.so; \
     else mkdir -p /usr/lib/bitlbee \
        && ln -sf /nowhere /usr/lib/bitlbee/facebook.so \
       && ln -sf /nowhere /usr/lib/bitlbee/facebook.la; \
    fi

# ---

FROM bitlbee-build AS steam-build

ARG STEAM=0
ARG STEAM_VERSION

RUN echo STEAM=${STEAM} > /tmp/status \
 && if [ ${STEAM} -eq 1 ]; \
     then cd /tmp \
       && git clone -n https://github.com/bitlbee/bitlbee-steam.git \
       && cd bitlbee-steam \
       && git checkout ${STEAM_VERSION} \
       && ./autogen.sh \
       && make -j$(nproc --ignore 2) \
       && make install \
       && strip /usr/lib/bitlbee/steam.so; \
     else mkdir -p /usr/lib/bitlbee \
       && ln -sf /nowhere /usr/lib/bitlbee/steam.so \
       && ln -sf /nowhere /usr/lib/bitlbee/steam.la; \
    fi

# ---

FROM bitlbee-build AS skypeweb-build

ARG SKYPEWEB=1
ARG SKYPEWEB_VERSION

RUN echo SKYPEWEB=${SKYPEWEB} > /tmp/status \
 && if [ ${SKYPEWEB} -eq 1 ]; \
     then cd /tmp \
       && git clone -n https://github.com/EionRobb/skype4pidgin.git \
       && cd skype4pidgin \
       && git checkout ${SKYPEWEB_VERSION} \
       && cd skypeweb \
       && make -j$(nproc --ignore 2) \
       && make install \
       && strip /usr/lib/x86_64-linux-gnu/purple-2/libskypeweb.so; \
     else mkdir -p /usr/lib/x86_64-linux-gnu/purple-2 \
       && ln -sf /nowhere /usr/lib/x86_64-linux-gnu/purple-2/libskypeweb.so; \
    fi

# ---

FROM bitlbee-build AS telegram-build

ARG TELEGRAM=1
ARG TELEGRAM_VERSION=v0.4

RUN echo TELEGRAM=${TELEGRAM} > /tmp/status \
 && if [ ${TELEGRAM} -eq 1 ]; \
     then cd /tmp \
       && apt-get update \
       && apt-get install -y --no-install-recommends cmake gperf libwebp-dev libpng-dev sudo \
       && git clone https://github.com/BenWiederhake/tdlib-purple/ \
       && cd tdlib-purple \
       && ./build_and_install.sh \
       # && cd tdlib-purple \
       # && git checkout ${TELEGRAM_VERSION} \
       # && TDLIB_REQ_VERSION=$(grep -o "tdlib version.*" CMakeLists.txt| tail -1 | awk '{print $3}') \
       # && cd /tmp \
       # && git clone -n https://github.com/tdlib/td.git tdlib \
       # && cd tdlib \
       # && TDLIB_VERSION=$(git log --pretty=format:"%h%x09%s" | grep "Update version to ${TDLIB_REQ_VERSION}" | awk '{print $1}') \
       # && git checkout ${TDLIB_VERSION} \
       # && mkdir build \
       # && cd build \
       # && cmake -DCMAKE_BUILD_TYPE=Release .. \
       # && make -j$(nproc --ignore 2) \
       # && make install \
       # && cd /tmp/tdlib-purple \
       # && mkdir build \
       # && cd build \
       # && cmake -DTd_DIR=/usr/local/lib/cmake/Td -DNoLottie=True -DNoVoip=True .. \
       # && make -j$(nproc --ignore 2)\
       # && make install \
       && strip /usr/lib/x86_64-linux-gnu/purple-2/libtelegram-tdlib.so; \
     else mkdir -p /usr/lib/x86_64-linux-gnu/purple-2 \
       && ln -sf /nowhere /usr/lib/x86_64-linux-gnu/purple-2/libtelegram-tdlib.so \
       && ln -sf /nowhere /usr/local/share/metainfo/tdlib-purple.metainfo.xml \
       && ln -sf /nowhere /usr/local/share/locale; \
    fi

# ---

FROM bitlbee-build AS hangouts-build

ARG HANGOUTS=0
ARG HANGOUTS_VERSION

RUN echo HANGOUTS=${HANGOUTS} > /tmp/status \
 && if [ ${HANGOUTS} -eq 1 ]; \
     then cd /tmp \
       && apt-get update \
       && apt-get install -y --no-install-recommends libprotobuf-c-dev protobuf-c-compiler \
       && git clone -n https://github.com/EionRobb/purple-hangouts.git \
       && cd purple-hangouts \
       && git checkout ${HANGOUTS_VERSION} \
       && make -j$(nproc --ignore 2) \
       && make install \
       && strip /usr/lib/x86_64-linux-gnu/purple-2/libhangouts.so; \
     else mkdir -p /usr/lib/x86_64-linux-gnu/purple-2 \
       && ln -sf /nowhere /usr/lib/x86_64-linux-gnu/purple-2/libhangouts.so; \
    fi

# ---

FROM bitlbee-build AS slack-build

ARG SLACK=1
ARG SLACK_VERSION

SHELL [ "/bin/bash", "-c" ]

RUN echo SLACK=${SLACK} > /tmp/status \
 && if [ ${SLACK} -eq 1 ]; \
     then cd /tmp \
       && git clone -n https://github.com/dylex/slack-libpurple.git \
       && cd slack-libpurple \
       && git fetch origin pull/162/head:162 \
       && git checkout 162 \
       && make -j$(nproc --ignore 2) \
       && install -d /usr/share/pixmaps/pidgin/protocols/{16,22,48} \
       && make install \
       && strip /usr/lib/x86_64-linux-gnu/purple-2/libslack.so; \
     else mkdir -p /usr/lib/x86_64-linux-gnu/purple-2 \
       && ln -sf /nowhere /usr/lib/x86_64-linux-gnu/purple-2/libslack.so; \
    fi

# ---

FROM bitlbee-build AS sipe-build

ARG SIPE=0
ARG SIPE_VERSION

RUN echo SIPE=${SIPE} > /tmp/status \
 && if [ ${SIPE} -eq 1 ]; \
     then cd /tmp \
       && apt-get update \
       && apt-get install -y --no-install-recommends libxml2-dev autopoint \
       && git clone -n https://repo.or.cz/siplcs.git \
       && cd siplcs \
       && git checkout ${SIPE_VERSION} \
       && ./autogen.sh \
       && ./configure --prefix=/usr \
       && make -j$(nproc --ignore 2) \
       && make install \
       && strip /usr/lib/x86_64-linux-gnu/purple-2/libsipe.so; \
     else mkdir -p /usr/lib/x86_64-linux-gnu/purple-2 \
       && ln -sf /nowhere /usr/lib/x86_64-linux-gnu/purple-2/libsipe.so \
       && ln -sf /nowhere /usr/lib/x86_64-linux-gnu/purple-2/libsipe.la \
       && ln -sf /nowhere /usr/share/locale; \
    fi

# ---

FROM bitlbee-build AS discord-build

ARG DISCORD=1
ARG DISCORD_VERSION

RUN echo DISCORD=${DISCORD} > /tmp/status \
 && if [ ${DISCORD} -eq 1 ]; \
     then cd /tmp \
       && git clone -n https://github.com/sm00th/bitlbee-discord.git \
       && cd bitlbee-discord \
       && git checkout ${DISCORD_VERSION} \
       && ./autogen.sh \
       && ./configure --prefix=/usr \
       && make -j$(nproc --ignore 2) \
       && make install \
       && strip /usr/lib/bitlbee/discord.so; \
     else mkdir -p /usr/lib/bitlbee \
       && ln -sf /nowhere /usr/lib/bitlbee/discord.so \
       && ln -sf /nowhere /usr/lib/bitlbee/discord.la \
       && ln -sf /nowhere /usr/share/bitlbee/discord-help.txt; \
    fi

# ---

FROM bitlbee-build AS rocketchat-build

ARG ROCKETCHAT=0
ARG ROCKETCHAT_VERSION

RUN echo ROCKETCHAT=${ROCKETCHAT} > /tmp/status \
 && if [ ${ROCKETCHAT} -eq 1 ]; \
     then cd /tmp \
       && apt-get update \
       && apt-get install -y --no-install-recommends libmarkdown2-dev \
       && git clone -n https://github.com/EionRobb/purple-rocketchat.git \
       && cd purple-rocketchat \
       && git checkout ${ROCKETCHAT_VERSION} \
       && make -j$(nproc --ignore 2) \
       && make install \
       && strip /usr/lib/x86_64-linux-gnu/purple-2/librocketchat.so; \
     else mkdir -p /usr/lib/x86_64-linux-gnu/purple-2 \
       && ln -sf /nowhere /usr/lib/x86_64-linux-gnu/purple-2/librocketchat.so; \
    fi

# ---

FROM bitlbee-build AS mastodon-build

ARG MASTODON=1
ARG MASTODON_VERSION

RUN echo MASTODON=${MASTODON} > /tmp/status \
 && if [ ${MASTODON} -eq 1 ]; \
     then cd /tmp \
       && git clone -n https://github.com/kensanata/bitlbee-mastodon \
       && cd bitlbee-mastodon \
       && git checkout ${MASTODON_VERSION} \
       && sh ./autogen.sh \
       && ./configure \
       && make -j$(nproc --ignore 2) \
       && make install \
       && strip /usr/lib/bitlbee/mastodon.so; \
     else mkdir -p /usr/lib/bitlbee \
       && ln -sf /nowhere /usr/lib/bitlbee/mastodon.so \
       && ln -sf /nowhere /usr/lib/bitlbee/mastodon.la \
       && ln -sf /nowhere /usr/share/bitlbee/mastodon-help.txt; \
    fi

# ---

FROM bitlbee-build AS matrix-build

ARG MATRIX=0
ARG MATRIX_VERSION

SHELL [ "/bin/bash", "-c" ]

COPY matrix-e2e.c.patch /tmp/matrix-e2e.c.patch

RUN echo MATRIX=${MATRIX} > /tmp/status \
 && if [ ${MATRIX} -eq 1 ]; \
     then cd /tmp \
       && apt-get update \
       && apt-get install -y --no-install-recommends libsqlite3-dev libhttp-parser-dev libolm-dev patch \
       && git clone -n https://github.com/matrix-org/purple-matrix \
       && cd purple-matrix \
       && git checkout ${MATRIX_VERSION} \
       && if [ $(uname -m) == "armv7l" ]; then patch < ../matrix-e2e.c.patch; fi \
       && make -j$(nproc --ignore 2) \
       && make install \
       && strip /usr/lib/x86_64-linux-gnu/purple-2/libmatrix.so; \
     else mkdir -p /usr/lib/x86_64-linux-gnu/purple-2 \
       && ln -sf /nowhere /usr/lib/x86_64-linux-gnu/purple-2/libmatrix.so; \
    fi

# ---

# FROM bitlbee-build AS signald-build

# ARG SIGNAL=0
# ARG SIGNAL_VERSION=master

# RUN echo SIGNAL=${SIGNAL} > /tmp/status \
#  && if [ ${SIGNAL} -eq 1 ]; \
#      then cd /tmp \
#        && apt-get update \
#        && apt-get install -y --no-install-recommends cmake \
#        && git clone -n https://github.com/hoehermann/purple-signald \
#        && cd purple-signald \
#        && git checkout ${SIGNAL_VERSION} \
#        && git submodule init \
#        && git submodule update \
#        && mkdir -p build \
#        && cd build \
#        && cmake .. \
#        && make -j$(nproc --ignore 2) \
#        && make install \
#        && strip /usr/lib/x86_64-linux-gnu/purple-2/libsignald.so; \
#      else mkdir -p /usr/lib/x86_64-linux-gnu/purple-2 \
#        && ln -sf /nowhere /usr/lib/x86_64-linux-gnu/purple-2/libsignald.so; \
#     fi

# ---

FROM bitlbee-build AS signal-presage

ARG SIGNAL=0
ARG SIGNAL_VERSION=master

RUN echo SIGNAL=${SIGNAL} > /tmp/status \
  && if [ ${SIGNAL} -eq 1 ]; \
    then cd /tmp \
      && apt-get update \
      && apt-get install -y --no-install-recommends cmake libqrencode-dev protobuf-compiler curl \
      && curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
      && git clone --recurse-submodules https://github.com/hoehermann/purple-presage \
      && mkdir purple-presage/build \
      && cd purple-presage/build \
      && cmake .. \
      && cmake --build . \
      && cmake --install . \
      && strip /usr/lib/x86_64-linux-gnu/purple-2/libpresage.so; \
    else mkdir -p /usr/lib/x86_64-linux-gnu/purple-2 \
      && ln -sf /nowhere /usr/lib/x86_64-linux-gnu/purple-2/libpresage.so; \
    fi

# ---

FROM bitlbee-build AS mattermost-build

ARG MATTERMOST=0
ARG MATTERMOST_VERSION=v2.1

RUN echo MATTERMOST=${MATTERMOST} > /tmp/status \
 && if [ ${MATTERMOST} -eq 1 ]; \
     then cd /tmp \
       && apt-get update \
       && apt-get install -y libjson-glib-dev libglib2.0-dev git make libmarkdown2-dev build-essential \
       && git clone https://github.com/EionRobb/purple-mattermost.git \
       && cd purple-mattermost \
       && git checkout ${MATTERMOST_VERSION} \
       && make -j$(nproc --ignore 2) \
       && make install \
       && strip /usr/lib/x86_64-linux-gnu/purple-2/libmattermost.so; \
     else mkdir -p /usr/lib/x86_64-linux-gnu/purple-2 \
       && ln -sf /nowhere /usr/lib/x86_64-linux-gnu/purple-2/libmattermost.so; \
    fi

# ---

FROM bitlbee-build AS icyque-build

ARG ICYQUE=0
ARG ICYQUE_VERSION

RUN echo ICYQUE=${ICYQUE} > /tmp/status \
 && if [ ${ICYQUE} -eq 1 ]; \
     then cd /tmp \
       && git clone -n https://github.com/EionRobb/icyque.git \
       && cd icyque \
       && git checkout ${ICYQUE_VERSION} \
       && make -j$(nproc --ignore 2) \
       && make install \
       && strip /usr/lib/x86_64-linux-gnu/purple-2/libicyque.so; \
     else mkdir -p /usr/lib/x86_64-linux-gnu/purple-2 \
       && ln -sf /nowhere /usr/lib/x86_64-linux-gnu/purple-2/libicyque.so; \
    fi

# ---

FROM bitlbee-build AS whatsapp-build

ARG WHATSAPP=1
ARG WHATSAPP_VERSION=v1.15.0

RUN echo WHATSAPP=${WHATSAPP} > /tmp/status \
 && if [ ${WHATSAPP} -eq 1 ]; \
     then cd /tmp \
      && apt-get install -y wget \
      && wget -q https://go.dev/dl/go1.22.4.linux-amd64.tar.gz \
      && tar -C /usr/local -xzf go1.22.4.linux-amd64.tar.gz \
       && echo "deb http://deb.debian.org/debian bookworm-backports main" | tee -a /etc/apt/sources.list \
       && apt-get update \
      && apt-get install -y -t bookworm-backports \
       && apt-get install -y --no-install-recommends cmake pkg-config libgdk-pixbuf2.0-dev libopusfile-dev \
       && git clone -n https://github.com/hoehermann/purple-gowhatsapp.git \
       && cd purple-gowhatsapp \
       && git checkout ${WHATSAPP_VERSION} \
       && export PATH=$PATH:/usr/local/go/bin \
       && git submodule update --init \
       && mkdir build \
       && cd build \
       && cmake .. \
       && cmake --build . \
      # && cmake -DCMAKE_Go_COMPILER=/usr/lib/go-1.22/bin/go -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON --build \
       && make install/strip \
       && strip /usr/lib/x86_64-linux-gnu/purple-2/libwhatsmeow.so; \
     else mkdir -p /usr/lib/x86_64-linux-gnu/purple-2 \
       && ln -sf /nowhere /usr/lib/x86_64-linux-gnu/purple-2/libwhatsmeow.so; \
    fi

# ---

FROM bitlbee-build AS lurch-build

ARG LURCH=0
ARG LURCH_VERSION=master

RUN echo LURCH=${LURCH} > /tmp/status \
 && if [ ${LURCH} -eq 1 ]; \
     then cd /tmp \
       && echo "deb http://deb.debian.org/debian bookworm-backports main" | tee -a /etc/apt/sources.list \
       && apt-get update \
       && apt-get install -y git cmake libpurple-dev libmxml-dev libxml2-dev libsqlite3-dev libgcrypt20-dev build-essential \
       && git clone -n https://github.com/gkdr/lurch \
       && cd lurch \
       && git checkout ${LURCH_VERSION} \
       && git submodule update --init --recursive \
       && make \
       && cp /tmp/lurch/build/lurch.so /usr/lib/x86_64-linux-gnu/purple-2/lurch.so ; \
     else mkdir -p /usr/lib/x86_64-linux-gnu/purple-2 \
       && ln -sf /nowhere /usr/lib/x86_64-linux-gnu/purple-2/liblurch.so; \
    fi

# ---

FROM base-image AS bitlbee-plugins

COPY --from=bitlbee-build /usr/sbin/bitlbee /tmp/usr/sbin/bitlbee
COPY --from=bitlbee-build /usr/share/man/man8/bitlbee.8 /tmp/usr/share/man/man8/bitlbee.8
COPY --from=bitlbee-build /usr/share/man/man5/bitlbee.conf.5 /tmp/usr/share/man/man5/bitlbee.conf.5
COPY --from=bitlbee-build /usr/share/bitlbee /tmp/usr/share/bitlbee
COPY --from=bitlbee-build /usr/lib/pkgconfig/bitlbee.pc /tmp/usr/lib/pkgconfig/bitlbee.pc
COPY --from=bitlbee-build /etc/bitlbee /tmp/etc/bitlbee

COPY --from=otr-install /usr/lib/bitlbee/otr.so /tmp/usr/lib/bitlbee/otr.so
COPY --from=otr-install /tmp/status /tmp/plugin/otr

# COPY --from=facebook-build /usr/lib/bitlbee/facebook.so /tmp/usr/lib/bitlbee/facebook.so
# COPY --from=facebook-build /usr/lib/bitlbee/facebook.la /tmp/usr/lib/bitlbee/facebook.la
# COPY --from=facebook-build /tmp/status /tmp/plugin/facebook

# COPY --from=steam-build /usr/lib/bitlbee/steam.so /tmp/usr/lib/bitlbee/steam.so
# COPY --from=steam-build /usr/lib/bitlbee/steam.la /tmp/usr/lib/bitlbee/steam.la
# COPY --from=steam-build /tmp/status /tmp/plugin/steam

COPY --from=skypeweb-build /usr/lib/x86_64-linux-gnu/purple-2/libskypeweb.so /tmp/usr/lib/x86_64-linux-gnu/purple-2/libskypeweb.so
COPY --from=skypeweb-build /tmp/status /tmp/plugin/skypeweb

COPY --from=telegram-build /usr/lib/x86_64-linux-gnu/purple-2/libtelegram-tdlib.so /tmp/usr/lib/x86_64-linux-gnu/purple-2/libtelegram-tdlib.so
COPY --from=telegram-build /usr/local/share/metainfo/tdlib-purple.metainfo.xml /tmp/usr/local/share/metainfo/tdlib-purple.metainfo.xml
COPY --from=telegram-build /usr/local/share/locale /tmp/usr/local/share/locale
COPY --from=telegram-build /tmp/status /tmp/plugin/telegram

# COPY --from=hangouts-build /usr/lib/x86_64-linux-gnu/purple-2/libhangouts.so /tmp/usr/lib/x86_64-linux-gnu/purple-2/libhangouts.so
# COPY --from=hangouts-build /tmp/status /tmp/plugin/hangouts

COPY --from=slack-build /usr/lib/x86_64-linux-gnu/purple-2/libslack.so /tmp/usr/lib/x86_64-linux-gnu/purple-2/libslack.so
COPY --from=slack-build /tmp/status /tmp/plugin/slack

# COPY --from=sipe-build /usr/lib/x86_64-linux-gnu/purple-2/libsipe.so /tmp/usr/lib/x86_64-linux-gnu/purple-2/libsipe.so
# COPY --from=sipe-build /usr/lib/x86_64-linux-gnu/purple-2/libsipe.la /tmp/usr/lib/x86_64-linux-gnu/purple-2/libsipe.la
# COPY --from=sipe-build /usr/share/locale /tmp/usr/share/locale
# COPY --from=sipe-build /tmp/status /tmp/plugin/sipe

COPY --from=discord-build /usr/lib/bitlbee/discord.so /tmp/usr/lib/bitlbee/discord.so
COPY --from=discord-build /usr/lib/bitlbee/discord.la /tmp/usr/lib/bitlbee/discord.la
COPY --from=discord-build /usr/share/bitlbee/discord-help.txt /tmp/usr/share/bitlbee/discord-help.txt
COPY --from=discord-build /tmp/status /tmp/plugin/discord

# COPY --from=rocketchat-build /usr/lib/x86_64-linux-gnu/purple-2/librocketchat.so /tmp/usr/lib/x86_64-linux-gnu/purple-2/librocketchat.so
# COPY --from=rocketchat-build /tmp/status /tmp/plugin/rocketchat

COPY --from=mastodon-build /usr/lib/bitlbee/mastodon.so /tmp/usr/lib/bitlbee/mastodon.so
COPY --from=mastodon-build /usr/lib/bitlbee/mastodon.la /tmp/usr/lib/bitlbee/mastodon.la
COPY --from=mastodon-build /usr/share/bitlbee/mastodon-help.txt /tmp/usr/share/bitlbee/mastodon-help.txt
COPY --from=mastodon-build /tmp/status /tmp/plugin/mastodon

# COPY --from=matrix-build /usr/lib/x86_64-linux-gnu/purple-2/libmatrix.so /tmp/usr/lib/x86_64-linux-gnu/purple-2/libmatrix.so
# COPY --from=matrix-build /tmp/status /tmp/plugin/matrix

# COPY --from=signald-build /usr/lib/x86_64-linux-gnu/purple-2/libsignald.so /tmp/usr/lib/x86_64-linux-gnu/purple-2/libsignald.so
# COPY --from=signald-build /tmp/status /tmp/plugin/signald

COPY --from=signal-presage /usr/lib/x86_64-linux-gnu/purple-2/libpresage.so /tmp/usr/lib/bitlbee/libpresage.so
# COPY --from=signal-presage /usr/lib/x86_64-linux-gnu/purple-2/libpurple_presage_backend.a /tmp/usr/lib/bitlbee/libpurple_presage_backend.a

# COPY --from=icyque-build /usr/lib/x86_64-linux-gnu/purple-2/libicyque.so /tmp/usr/lib/x86_64-linux-gnu/purple-2/libicyque.so
# COPY --from=icyque-build /tmp/status /tmp/plugin/icyque

COPY --from=whatsapp-build /usr/lib/x86_64-linux-gnu/purple-2/libwhatsmeow.so /tmp/usr/lib/x86_64-linux-gnu/purple-2/libwhatsmeow.so
COPY --from=whatsapp-build /tmp/status /tmp/plugin/whatsapp

# COPY --from=lurch-build /usr/lib/x86_64-linux-gnu/purple-2/lurch.so /tmp/usr/lib/x86_64-linux-gnu/purple-2/lurch.so
# COPY --from=lurch-build /tmp/status /tmp/plugin/lurch

COPY --from=mattermost-build /usr/lib/x86_64-linux-gnu/purple-2/libmattermost.so /tmp/usr/lib/x86_64-linux-gnu/purple-2/libmattermost.so
COPY --from=mattermost-build /tmp/status /tmp/plugin/mattermost

RUN apt-get update \
 && apt-get install -y --no-install-recommends findutils \
 && find /tmp/ -type f -empty -delete \
 && find /tmp/ -type d -empty -delete \
 && cat /tmp/plugin/* > /tmp/plugins \
 && rm -rf /tmp/plugin

# ---

FROM base-image AS bitlbee-libpurple

COPY --from=bitlbee-plugins /tmp/ /

ARG PKGS="tzdata libglib2.0-0 libssl3 libpurple0 libtcl8.6 libtk8.6"

SHELL [ "/bin/bash", "-c" ]

RUN groupadd -g 101 -r bitlbee \
  && useradd -u 101 -r -g bitlbee -m -d /var/lib/bitlbee bitlbee \
  && install -d -m 750 -o bitlbee -g bitlbee /var/lib/bitlbee \
  && groupadd -g 102 -r signald \
  && usermod -aG signald bitlbee \
  && source /plugins \
  && if [ ${OTR} -eq 1 ]; then PKGS="${PKGS} libotr5"; fi \
  && if [ ${FACEBOOK} -eq 1 ] || [ ${SKYPEWEB} -eq 1 ] || [ ${HANGOUTS} -eq 1 ] \
  || [ ${ROCKETCHAT} -eq 1 ] || [ ${MATRIX} -eq 1 ] || [ ${SIGNAL} -eq 1 ] \
  || [ ${ICYQUE} -eq 1 ]; then PKGS="${PKGS} libjson-glib-1.0-0"; fi \
  && if [ ${STEAM} -eq 1 ] || [ ${TELEGRAM} -eq 1 ] || [ ${MATRIX} -eq 1 ]; then PKGS="${PKGS} libgcrypt20"; fi \
  && if [ ${TELEGRAM} -eq 1 ]; then PKGS="${PKGS} zlib1g libwebp7 libpng16-16 libstdc++6"; fi \
  && if [ ${HANGOUTS} -eq 1 ] || [ ${SIGNAL} -eq 1 ]; then PKGS="${PKGS} libprotobuf-c1"; fi \
  && if [ ${SIGNAL} -eq 1 ]; then PKGS="${PKGS} libqrencode4"; fi \
  && if [ ${WHATSAPP} -eq 1 ]; then PKGS="${PKGS} libopusfile-dev libgdk-pixbuf2.0-dev"; fi \
  && if [ ${SIPE} -eq 1 ]; then PKGS="${PKGS} libxml2"; fi \
  && if [ ${ROCKETCHAT} -eq 1 ]; then PKGS="${PKGS} libmarkdown2"; fi \
  && if [ ${MATRIX} -eq 1 ]; then PKGS="${PKGS} libsqlite3-0 libhttp-parser2.9 libolm2"; fi \
  && if [ ${WHATSAPP} -eq 1 ]; then PKGS="${PKGS} libgdk-pixbuf2.0-dev libopusfile-dev"; fi \
  && if [ ${LURCH} -eq 1 ]; then PKGS="${PKGS} libxml2 libmxml1 libsqlite3-0 libgcrypt20"; fi \
  && PKGS="${PKGS} vim libqrencode4" \
  && apt-get update \
  && apt-get install -y --no-install-recommends ${PKGS} \
  && apt-get clean \
  && rm /plugins

EXPOSE 6667

# CMD [ "/usr/sbin/bitlbee", "-F", "-n", "-u", "bitlbee" ]