-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathnodejs.spec.in
1109 lines (959 loc) · 35.6 KB
/
nodejs.spec.in
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
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#
# spec file for package nodejs{{node_version_major}}
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
###########################################################
#
# WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!
#
# This spec file is generated from a template hosted at
# https://github.com/AdamMajer/nodejs-packaging
#
###########################################################
# Fedora doesn't have rpm-config-SUSE which provides
# ext_man in /usr/lib/rpm/macros.d/macros.obs
%if 0%{?fedora_version}
%define ext_man .gz
%endif
Name: nodejs{{node_version_major}}
Version: {{node_version}}
Release: 0
# Double DWZ memory limits
%define _dwz_low_mem_die_limit 20000000
%define _dwz_max_die_limit 100000000
%define node_version_number {{node_version_major}}
# openssl bsc#1192489 - fix released
%bcond_without openssl_RSA_get0_pss_params
%if 0%{?suse_version} > 1500 || 0%{?fedora_version}
%bcond_without libalternatives
%else
%bcond_with libalternatives
%endif
# nodejs20+ is not for SLE12
%if %{node_version_number} >= 20 && 0%{?suse_version} > 0 && 0%{?suse_version} < 1500
ExclusiveArch do_not_build
%endif
%if %node_version_number >= 12
%define openssl_req_ver 1.1.1
%else
%if %node_version_number >= 10
%define openssl_req_ver 1.1.0
%else
%define openssl_req_ver 1.0.2
%endif
%endif
%bcond_with valgrind_tests
%if %{node_version_number} >= 12
# turn on LTO only on non-32bit arches
%ifarch %{ix86} %{arm}
%bcond_with nodejs_lto
%else
%bcond_without nodejs_lto
%endif
%else
%bcond_with nodejs_lto
%endif
%if !0%{?with nodejs_lto}
%define _lto_cflags %{nil}
%endif
%if 0%{?suse_version} == 1110
%define _libexecdir %{_exec_prefix}/lib
%endif
%if {{intree_openssl}}
%bcond_with intree_openssl
%else
%bcond_without intree_openssl
%endif
%if {{intree_libcares2}}
%bcond_with intree_cares
%else
%bcond_without intree_cares
%endif
%if {{intree_icu}}
%bcond_with intree_icu
%else
%bcond_without intree_icu
%endif
%if {{intree_nghttp2}}
%bcond_with intree_nghttp2
%else
%bcond_without intree_nghttp2
%endif
%if {{intree_brotli}}
%bcond_with intree_brotli
%else
%bcond_without intree_brotli
%endif
%ifnarch x86_64 %{ix86}
%bcond_with gdb
%else
%bcond_without gdb
%endif
%define git_node {{git_node}}
Summary: Evented I/O for V8 JavaScript
License: MIT
Group: Development/Languages/NodeJS
{{URL}}
{{SOURCES}}
{{SOURCES_EXTRA}}
Source20: bash_output_helper.bash
## Patches not distribution specific
Patch1: cares_public_headers.patch # PATCH_FOR: 12, 14, 16, 18, 19, 20, 21, 22, master
Patch3: fix_ci_tests.patch
Patch4: cares_sle12_capabilities.patch # PATCH_FOR: 18, 20
Patch5: sle12_python3_compat.patch # PATCH_FOR: 13, 14, 15, 16, 18, 19, 20, 21, 22, master
Patch7: manual_configure.patch # PATCH_FOR: 14, 13, 12, 10, 8, 15, 16, 18, 19, 20, 21, 22, master
Patch8: icu_small_grouping.patch # PATCH_FOR: 9
Patch11: valgrind_fixes.patch # PATCH_FOR: 10
Patch12: openssl_1_1_1.patch # PATCH_FOR: 8
Patch13: openssl_binary_detection.patch # PATCH_FOR: 10, 12, 14, 15, 16, 18, 19, 20, 21, 22, master
Patch32: fix_build_with_openssl_1.1.1d.patch # PATCH_FOR: 8
Patch33: CVE-2019-15606.patch # PATCH_FOR: 8
Patch34: CVE-2019-15604.patch # PATCH_FOR: 8
Patch35: CVE-2019-15605.patch # PATCH_FOR: 8
Patch36: CVE-2020-8174.patch # PATCH_FOR: 8
Patch37: nghttp2_1.41.0.patch # PATCH_FOR: 8
Patch38: CVE-2020-11080.patch # PATCH_FOR: 8
Patch39: CVE-2020-8265.patch # PATCH_FOR: 8
Patch41: icu68.patch # PATCH_FOR: 10
Patch42: CVE-2020-8287.patch # PATCH_FOR: 8
Patch43: CVE-2021-22884.patch # PATCH_FOR: 8
Patch44: CVE-2021-22883.patch # PATCH_FOR: 8
Patch45: limit_worker_stdio_memsize.patch # PATCH_FOR: 10
Patch46: CVE-2021-22918.patch # PATCH_FOR: 10
Patch47: CVE-2021-22930.patch # PATCH_FOR: 8, 10
Patch48: CVE-2021-22939.patch # PATCH_FOR: 10
Patch49: CVE-2022-21824.patch # PATCH_FOR: 10
Patch50: CVE-2021-3807.patch # PATCH_FOR: 10, 8, 12
Patch51: CVE-2021-44906.patch # PATCH_FOR: 8, 10, 12
Patch52: CVE-2021-44907.patch # PATCH_FOR: 8, 10, 12
Patch53: CVE-2022-0235.patch # PATCH_FOR: 8, 10, 12, 14
Patch55: CVE-2022-32213.patch # PATCH_FOR: 12, 10, 8
Patch56: CVE-2022-32212.patch # PATCH_FOR: 12, 10, 8
Patch57: openssl_update.patch # PATCH_FOR: 12
Patch58: CVE-2022-35256.patch # PATCH_FOR: 12, 10, 8
Patch59: CVE-2022-43548.patch # PATCH_FOR: 12, 10, 8
Patch60: CVE-2023-23920.patch # PATCH_FOR: 12, 10, 8
Patch61: CVE-2022-25881.patch # PATCH_FOR: 14, 12, 10,
Patch62: CVE-2023-23918.patch # PATCH_FOR: 12
Patch63: CVE-2023-30581.patch # PATCH_FOR: 14, 12
Patch64: CVE-2023-30589.patch # PATCH_FOR: 14, 12
Patch65: CVE-2023-30590.patch # PATCH_FOR: 14, 12
Patch66: CVE-2023-32559.patch # PATCH_FOR: 14, 12
Patch67: CVE-2023-32002.patch # PATCH_FOR: 14, 12
Patch68: CVE-2023-44487.patch # PATCH_FOR: 16, 14, 12, 10
Patch69: CVE-2023-38552.patch # PATCH_FOR: 16, 14, 12
Patch70: CVE-2023-39333.patch # PATCH_FOR: 16
Patch71: CVE-2023-45143.patch # PATCH_FOR: 16
Patch72: CVE-2024-24806.patch # PATCH_FOR: 16, 14, 12, 10
Patch73: CVE-2024-24758.patch # PATCH_FOR: 16
Patch74: CVE-2024-22025.patch # PATCH_FOR: 16, 14, 12, 10
Patch75: CVE-2024-22019.patch # PATCH_FOR: 16, 14, 12, 10
Patch76: CVE-2023-46809.patch # PATCH_FOR: 16, 14, 12, 10
Patch77: CVE-2024-27983.patch # PATCH_FOR: 16, 14, 12, 10
Patch78: CVE-2024-27982.patch # PATCH_FOR: 16, 14, 12, 10
Patch79: CVE-2024-30261.patch # PATCH_FOR: 16
Patch80: openssl31.patch # PATCH_FOR: 12, 14, 16, 18
# Patch81: CVE-2024-22020.patch # PATCH_FOR: 16, 14, 12
Patch82: CVE-2024-21538.patch # PATCH_FOR: 18, 20
## Patches specific to SUSE and openSUSE
Patch100: linker_lto_jobs.patch # PATCH_FOR: 12, 13, 14, 15, 16, 18, 19, 20, 21, 22, master
# PATCH-FIX-OPENSUSE -- set correct path for dtrace if it is built
Patch101: nodejs-libpath.patch
# PATCH-FIX-UPSTREAM -- use custom addon.gypi by default instead of
# downloading node source
Patch102: node-gyp-addon-gypi.patch
Patch1020: sle12-node-gyp-addon-gypi.patch # PATCH_FOR: 18, 16
# PATCH-FIX-SLE -- configure script uses Python check_output method
# which isn't included in Python 2.6 (used in SLE 11).
Patch103: nodejs-sle11-python26-check_output.patch # PATCH_FOR: 8, 10, 12
# PATCH-FIX-OPENSUSE -- install user global npm packages to /usr/local
# instead of /usr
Patch104: npm_search_paths.patch
Patch105: skip_test_on_lowmem.patch # PATCH_FOR: 8, 10
Patch106: skip_no_console.patch # PATCH_FOR: 10, 12, 13, 14, 15, 16, 18
Patch109: python3.patch # PATCH_FOR: 12
Patch110: legacy_python.patch # PATCH_FOR: 16, 18, 19, 20, 21, 22, master
Patch120: flaky_test_rerun.patch
Patch125: cares_172.patch # PATCH_FOR: 10
Patch130: test_ssl_cert_fixups.patch # PATCH_FOR: 10, 8
Patch132: test-skip-y2038-on-32bit-time_t.patch # PATCH_FOR: 14, 16, 18, 19, 20, 21, 22, master
Patch133: rsa-pss-revert.patch # PATCH_FOR: 16, 18
# Use versioned binaries and paths
Patch200: versioned.patch
Patch305: qemu_timeouts_arches.patch # PATCH_FOR: 18, 19, 20, 21, 22, master
Patch307: v8-i586.patch # PATCH_FOR: 22, master
Patch308: node-gyp-config.patch # PATCH_FOR: 19, 20, 21
Patch309: gcc13.patch # PATCH_FOR: 20, 21, 22, master
Patch310: newicu_test_fixup.patch # PATCH_FOR: 14, 12, 10
Patch311: old_cares.patch # PATCH_FOR: 22
BuildRequires: pkg-config
BuildRequires: fdupes
BuildRequires: procps
BuildRequires: xz
BuildRequires: zlib-devel
%if 0%{?suse_version}
BuildRequires: config(netcfg)
%endif
# SLE-11 target only
# Node.js 6 requires GCC 4.8.5+.
#
# For Node.js 8.x, upstream requires GCC 4.9.4+, as GCC 4.8 may have
# slightly buggy C++11 support: https://github.com/nodejs/node/pull/13466
#
# If the default compiler is not supported, use the most recent compiler
# version available.
%if 0%{?suse_version} == 1110
# GCC 5 is only available in the SUSE:SLE-11:SP4:Update repository (SDK).
%if %node_version_number >= 8
BuildRequires: gcc5-c++
%define forced_gcc_version 5
%else
BuildRequires: gcc48-c++
%define forced_gcc_version 4.8
%endif
%endif
# sles == 11 block
# Pick and stick with "latest" compiler at time of LTS release
# for SLE-12:Update targets
%if 0%{?suse_version} == 1315
%if %node_version_number >= 17
BuildRequires: gcc12-c++
%define forced_gcc_version 12
%else
%if %node_version_number >= 14
BuildRequires: gcc9-c++
%define forced_gcc_version 9
%else
%if %node_version_number >= 8
BuildRequires: gcc7-c++
%define forced_gcc_version 7
%endif
%endif
%endif
%endif
%if 0%{?suse_version} == 1500
%if %node_version_number >= 17
BuildRequires: gcc12-c++
%define forced_gcc_version 12
%endif
%endif
# compiler selection
# No special version defined, use default.
%if ! 0%{?forced_gcc_version:1}
BuildRequires: gcc-c++
%endif
# Python dependencies
%if %node_version_number >= 14
%if 0%{?suse_version}
%if 0%{?suse_version} < 1500
BuildRequires: python36
%define forced_python_version 3.6m
%endif
%if %{?suse_version} == 1500
BuildRequires: python311
%define forced_python_version 3.11
%endif
%if %{?suse_version} > 1500
BuildRequires: python3
BuildRequires: python3-setuptools
%endif
%endif
%else
%if %node_version_number >= 12
BuildRequires: python3
%else
%if 0%{?suse_version} >= 1500
BuildRequires: python2
%else
BuildRequires: python
%endif
%endif
%endif
%if 0%{?suse_version} >= 1500 && %{node_version_number} >= 10
BuildRequires: user(nobody)
BuildRequires: group(nobody)
%endif
# shared openssl
%if ! 0%{with intree_openssl}
BuildRequires: pkgconfig(openssl) >= %{openssl_req_ver}
%if 0%{?suse_version}
%if 0%{?suse_version} >= 1500
BuildRequires: openssl >= %{openssl_req_ver}
BuildRequires: (libopenssl1_1-hmac if libopenssl-1_1-devel)
BuildRequires: (libopenssl3-hmac if libopenssl-3-devel)
%else
BuildRequires: openssl-1_1 >= %{openssl_req_ver}
BuildRequires: libopenssl1_1-hmac
%endif
# /suse_version
%endif
%if 0%{?fedora_version}
BuildRequires: openssl >= %{openssl_req_ver}
%endif
%else
# bundled openssl
%if %node_version_number <= 12 && 0%{?suse_version} == 1315 && 0%{?sle_version} < 120400
Provides: bundled(openssl) = {{bundled_openssl_version}}
%else
BuildRequires: bundled_openssl_should_not_be_required
%endif
# /bundled openssl
%endif
%if ! 0%{with intree_cares}
BuildRequires: pkgconfig(libcares) >= {{min_libcares2_version}}
%else
Provides: bundled(libcares2) = {{bundled_cares_version}}
%endif
%if %node_version_number >= 22 && 0%{?suse_version} > 1500
BuildRequires: sqlite3-devel
%endif
%if ! 0%{with intree_icu}
BuildRequires: pkgconfig(icu-i18n) >= {{min_icu_version}}
%else
Provides: bundled(icu) = {{bundled_icu-small_version}}
%endif
%if ! 0%{with intree_nghttp2}
BuildRequires: libnghttp2-devel >= {{min_nghttp2_version}}
%else
Provides: bundled(nghttp2) = {{bundled_nghttp2_version}}
%endif
%if 0%{with valgrind_tests}
BuildRequires: valgrind
%endif
%if %{with libalternatives}
Suggests: alts
%else
Requires(postun): %{_sbindir}/update-alternatives
%endif
# either for update-alternatives, or their removal
Requires(post): %{_sbindir}/update-alternatives
Recommends: npm{{node_version_major}}
#we need ABI virtual provides where SONAMEs aren't enough/not present so deps
#break when binary compatibility is broken
%global nodejs_abi {{node_version_major}}.0
Provides: nodejs(abi) = %{nodejs_abi}
#this corresponds to the "engine" requirement in package.json
Provides: nodejs(engine) = %{version}
# Multiple versions of NodeJS can be installed at a time, but
# to properly allow correct version execution from 3rd party
# npm software, `env node` requires further help than only
# update-alternatives can provide.
Provides: nodejs = %{version}
%if %{with libalternatives}
Requires: nodejs-common >= 5.0
%else
Requires: nodejs-common
%endif
# For SLE11, to be able to use the certificate store we need to have properly
# symlinked certificates. The compatability symlinks are provided by the
# openssl1 library in the Security Module
%if 0%{?suse_version} == 1110
Requires: openssl1
%endif
%if %node_version_number >= 12
%ifarch s390
ExclusiveArch: not_buildable
%endif
%endif
Provides: bundled(uvwasi) = {{bundled_uvwasi_version}}
Provides: bundled(libuv) = {{bundled_uv_version}}
Provides: bundled(v8) = {{bundled_v8_version}}
%if %{with intree_brotli}
Provides: bundled(brotli) = {{bundled_brotli_version}}
%else
BuildRequires: pkgconfig(libbrotlidec)
%endif
Provides: bundled(http-parser) = {{bundled_http_parser_version}}
Provides: bundled(nghttp3) = {{bundled_nghttp3_version}}
Provides: bundled(llhttp) = {{bundled_llhttp_version}}
Provides: bundled(ngtcp2) = {{bundled_ngtcp2_version}}
Provides: bundled(base64) = {{bundled_base64_version}}
Provides: bundled(simdutf) = {{bundled_simdutf_version}}
Provides: bundled(simdjson) = {{bundled_simdjson_version}}
# bundled url-ada parser, not ada
Provides: bundled(ada) = {{bundled_ada_version}}
{{node_npm_bundles}}
%description
Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. Node.js
uses an event-driven, non-blocking I/O model. Node.js has a package ecosystem
provided by npm.
%package devel
Summary: Development headers for NodeJS {{node_version_major}}.x
Group: Development/Languages/NodeJS
Provides: nodejs-devel = %{version}
Requires: npm{{node_version_major}} = %{version}
Requires: %{name} = %{version}
%description devel
This package provides development headers for Node.js needed for creation
of binary modules.
%package -n npm{{node_version_major}}
Summary: Package manager for Node.js
Group: Development/Languages/NodeJS
%if %{with libalternatives}
Requires: nodejs-common >= 5.0
%else
Requires: nodejs-common
%endif
Requires: nodejs{{node_version_major}} = %{version}
Provides: nodejs-npm = %{version}
Obsoletes: nodejs-npm < 4.0.0
Provides: npm(npm) = {{bundled_npm_version}}
Provides: npm = %{version}
%if 0%{?suse_version} >= 1500
%if %{node_version_number} >= 10
Requires: user(nobody)
Requires: group(nobody)
%endif
%endif
{{npm_npm_bundles}}
%description -n npm{{node_version_major}}
A package manager for Node.js that allows developers to install and
publish packages to a package registry.
%package -n corepack{{node_version_major}}
Summary: Helper bridge between NodeJS projects and their dependencies
Group: Development/Languages/NodeJS
Requires: nodejs-common >= 5.0
%description -n corepack{{node_version_major}}
Zero-runtime-dependency package acting as bridge between Node projects
and their package managers.
%package docs
Summary: Node.js API documentation
Group: Documentation/Other
%if 0%{?suse_version} >= 1200
# using noarch subpackage seems to break debuginfo on older releases
BuildArch: noarch
%endif
%description docs
The API documentation for the Node.js JavaScript runtime.
%prep
%if ! %{git_node}
echo "`grep node-v%{version}.tar.xz %{S:1} | head -n1 | cut -c1-64` %{S:0}" | sha256sum -c
%setup -q -n node-v%{version}
%else
%setup -q -n node-%{version}
%endif
%if %{node_version_number} == 16
tar zxf %{S:12}
%endif
%if %{node_version_number} <= 10
rm -r deps/npm/*
pushd deps/npm
tar zxf %{SOURCE9} --strip-components=1
tar Jxf %{SOURCE90}
popd
%endif
%if %{node_version_number} >= 10
tar Jxf %{SOURCE11}
%endif
# downgrade node-gyp to last version that supports python 3.4 for SLE12
%if 0%{?suse_version} && 0%{?suse_version} < 1500 && %{node_version_number} >= 16 && %{node_version_number} < 22
rm -r deps/npm/node_modules/node-gyp
mkdir deps/npm/node_modules/node-gyp
pushd deps/npm/node_modules/node-gyp
tar Jxf %{SOURCE5}
popd
%if %{node_version_number} >= 19
%patch -P 308 -p1
%else
%patch -P 1020 -p1
%endif
%endif
%patch -P 1 -p1
%patch -P 3 -p1
%if 0%{?suse_version} < 1500
%patch -P 4 -p1
%endif
%if %{node_version_number} <= 12 && 0%{?suse_version} < 1500
%patch -P 5 -p1
%endif
%patch -P 7 -p1
%patch -P 8 -p1
%if 0%{with valgrind_tests}
%patch -P 11 -p1
%endif
%patch -P 12 -p1
%patch -P 13 -p1
%patch -P 32 -p1
%patch -P 33 -p1
%patch -P 34 -p1
%patch -P 35 -p1
%patch -P 36 -p1
%patch -P 37 -p1
%patch -P 38 -p1
%patch -P 39 -p1
%patch -P 41 -p1
%patch -P 42 -p1
%patch -P 43 -p1
%patch -P 44 -p1
%patch -P 45 -p1
%patch -P 46 -p1
%patch -P 47 -p1
%patch -P 48 -p1
%patch -P 49 -p1
%patch -P 50 -p1
%patch -P 51 -p1
%patch -P 52 -p1
%patch -P 53 -p1
%patch -P 55 -p1
%patch -P 56 -p1
%patch -P 57 -p1
%patch -P 58 -p1
%patch -P 59 -p1
%patch -P 60 -p1
%patch -P 61 -p1
%patch -P 62 -p1
%patch -P 63 -p1
%patch -P 64 -p1
%patch -P 65 -p1
%patch -P 66 -p1
%patch -P 67 -p1
%patch -P 68 -p1
%patch -P 69 -p1
%patch -P 70 -p1
%patch -P 71 -p1
%patch -P 72 -p1
%patch -P 73 -p1
%patch -P 74 -p1
%patch -P 75 -p1
%patch -P 76 -p1
%patch -P 77 -p1
%patch -P 78 -p1
%patch -P 79 -p1
%patch -P 80 -p1
#%patch -P 81 -p1
%patch -P 82 -p1
%patch -P 100 -p1
%patch -P 101 -p1
%if 0%{?suse_version} >= 1500 || 0%{?suse_version} == 0
%patch -P 102 -p1
%endif
# Add check_output to configure script (not part of Python 2.6 in SLE11).
%if 0%{?suse_version} == 1110
%patch -P 103 -p1
%endif
%patch -P 104 -p1
%patch -P 105 -p1
%patch -P 106 -p1
%patch -P 109 -p1
%patch -P 110 -p1
%patch -P 120 -p1
%patch -P 125 -p1
%patch -P 130 -p1
%patch -P 132 -p1
%if ! 0%{with openssl_RSA_get0_pss_params}
%patch -P 133 -p1
%endif
%patch -P 200 -p1
%patch -P 305 -p1
%patch -P 307 -p1
%patch -P 309 -p1
%patch -P 310 -p1
%patch -P 311 -p1
%if %{node_version_number} == 12
# minimist security update - patch50
rm -r deps/npm/node_modules/mkdirp/node_modules/minimist
rmdir ./deps/npm/node_modules/mkdirp/node_modules
%endif
# remove backup files, if any
find -name \*~ -print0 -delete
# abnormalities from patching
find \( -name \*.js.orig -or -name \*.md.orig -or -name \*.1.orig \) -delete
%build
# normalize shebang
%if %{node_version_number} >= 12
find -type f -exec sed -i -e '1 s,^#!\s\?/usr/bin/env python\d*$,#!/usr/bin/python3,' -e '1 s,^#!\s\?/usr/bin/python$,#!/usr/bin/python3,' {} +
%else
find -type f -exec sed -i '1 s,^#!\s\?/usr/bin/env python$,#!/usr/bin/python,' {} +
%endif
find deps/npm -type f -exec sed -i '1 s,^#!\s\?/usr/bin/env node$,#!/usr/bin/node%{node_version_number},' {} +
find deps/npm -type f -exec sed -i '1 s,^#!\s\?/usr/bin/env \(bash\|sh\)\?$,#!/bin/bash,' {} +
. %{SOURCE20}
# Make sure nothing gets included from bundled deps:
# We only delete the source and header files, because
# the remaining build scripts are still used.
%if ! 0%{with intree_openssl}
find deps/openssl -name *.[ch] -delete
%endif
%if ! 0%{with intree_icu}
rm -rf deps/icu-small
%endif
%if ! 0%{with intree_cares}
find deps/cares -name *.[ch] -delete
%endif
find deps/zlib -name *.[ch] -delete
cat > spec.build.config <<EOF
export PREFIX=/usr
export CFLAGS="%{?build_cflags:%build_cflags}%{?!build_cflags:%optflags} -fno-strict-aliasing"
# -Wno-class-memaccess is not available in gcc < 8 (= system compiler on Leap until at least 15.3 is gcc7)
export CXXFLAGS="%{?build_cxxflags:%build_cxxflags}%{?!build_cxxflags:%optflags} -Wno-error=return-type -fno-strict-aliasing"
%if 0%{?forced_gcc_version} >= 8 || 0%{?suse_version} > 1500 || 0%{?fedora_version} >= 35
export CXXFLAGS="\${CXXFLAGS} -Wno-class-memaccess"
%endif
export LDFLAGS="%{?build_ldflags}"
%if !0%{?with nodejs_lto}
export LDFLAGS="\${LDFLAGS} -fno-lto"
%endif
# reduce disk space pressure
export CFLAGS="\${CFLAGS} -g1"
export CXXFLAGS="\${CXXFLAGS} -g1"
export LDFLAGS="\${LDFLAGS} -Wl,--reduce-memory-overhead"
%if 0%{?forced_gcc_version:1}
export CC=gcc-%{forced_gcc_version}
export CXX=g++-%{forced_gcc_version}
%endif
EOF
. ./spec.build.config
./configure \
--prefix=%{_prefix} \
%if 0%{?with nodejs_lto}
--enable-lto \
%endif
%if ! 0%{with intree_openssl}
--shared-openssl \
%endif
--shared-zlib \
%if ! 0%{with intree_cares}
--shared-cares \
%endif
%if ! 0%{with intree_icu}
--with-intl=system-icu \
%endif
%if ! 0%{with intree_nghttp2}
--shared-nghttp2 \
%endif
%if ! 0%{with intree_brotli}
--shared-brotli \
%endif
%if 0%{with gdb}
--gdb \
%endif
%if %{node_version_number} < 19
--without-dtrace \
%endif
%if %{node_version_number} >= 22 && 0%{?suse_version} > 1500
--shared-sqlite \
%endif
%if %{node_version_number} >= 16 && (0%{?suse_version} > 1550 || 0%{?sle_version} >= 150400)
--openssl-default-cipher-list=PROFILE=SYSTEM \
%endif
--openssl-use-def-ca-store
decoupled_cmd make %{?_smp_mflags}
# Fix documentation permissions
find doc/api -type f -exec chmod 0644 {} +
%install
. %{SOURCE20}
. ./spec.build.config
decoupled_cmd %make_install %{?_smp_mflags}
rm %{buildroot}%{_datadir}/doc/node/gdbinit
rm -f %{buildroot}%{_datadir}/doc/node/lldbinit
rm -f %{buildroot}%{_datadir}/doc/node/lldb_commands.py
# remove .bak files, if any
find %{buildroot} -name \*.bak -print -delete
# npm/npx man page
install -D -m 644 deps/npm/man/man1/npm.1 %{buildroot}%{_mandir}/man1/npm%{node_version_number}.1
install -D -m 644 deps/npm/man/man1/npx.1 %{buildroot}%{_mandir}/man1/npx%{node_version_number}.1
#node-gyp needs common.gypi too
install -D -m 644 common.gypi \
%{buildroot}%{_libdir}/node_modules/npm%{node_version_number}/node_modules/node-gyp/common.gypi
# %%{buildroot}%%{_datadir}/node/common.gypi
# install addon-rpm.gypi
install -D -m 644 addon-rpm.gypi \
%{buildroot}%{_libdir}/node_modules/npm%{node_version_number}/node_modules/node-gyp/addon-rpm.gypi
# clean
# hidden files and directories
find %{buildroot}%{_libdir}/node_modules/npm%{node_version_number} -name ".*" -exec rm -Rf -- {} +
# windows stuff
find %{buildroot}%{_libdir}/node_modules/npm%{node_version_number} -name "*.bat" -delete
find %{buildroot}%{_libdir}/node_modules/npm%{node_version_number} -name "*.cmd" -delete
# build stuff
find %{buildroot}%{_libdir}/node_modules/npm%{node_version_number} -name "Makefile" -delete
rm -rf %{buildroot}%{_libdir}/node_modules/npm%{node_version_number}/{test,scripts}
find %{buildroot}%{_libdir}/node_modules/npm%{node_version_number}/node_modules -name "*.sh" -delete
rm -rf %{buildroot}%{_libdir}/node_modules/npm%{node_version_number}/node_modules/node-gyp/src
# remove examples/tests/benchmark stuff
find %{buildroot}%{_libdir}/node_modules/npm%{node_version_number}/node_modules -name "example*" -exec rm -Rf -- {} +
find %{buildroot}%{_libdir}/node_modules/npm%{node_version_number}/node_modules -name "*_test.*" -delete
find %{buildroot}%{_libdir}/node_modules/npm%{node_version_number}/node_modules -type d -name "benchmark" -exec rm -Rf -- {} +
# fix permissions
chmod 0755 %{buildroot}%{_libdir}/node_modules/npm%{node_version_number}/bin/np*-cli.js
! test -f %{buildroot}%{_libdir}/node_modules/npm%{node_version_number}/bin/node-gyp-bin/node-gyp || \
chmod 0755 %{buildroot}%{_libdir}/node_modules/npm%{node_version_number}/bin/node-gyp-bin/node-gyp
chmod 0755 %{buildroot}%{_libdir}/node_modules/npm%{node_version_number}/node_modules/node-gyp/bin/node-gyp.js
! test -f %{buildroot}%{_libdir}/node_modules/npm%{node_version_number}/node_modules/npm-lifecycle/node-gyp-bin/node-gyp || \
chmod 0755 %{buildroot}%{_libdir}/node_modules/npm%{node_version_number}/node_modules/npm-lifecycle/node-gyp-bin/node-gyp
# browser.js is useless for npm cli
find %{buildroot}%{_libdir}/node_modules/npm%{node_version_number} -name "browser.js" -delete
# file duplicates
%fdupes %{buildroot}%{_libdir}/node_modules/npm%{node_version_number}
%fdupes %{buildroot}%{_includedir}/node%{node_version_number}
# Update alternatives
%if ! %{with libalternatives}
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
ln -s -f node-default %{buildroot}%{_sysconfdir}/alternatives/node-default
ln -s -f node.1%{ext_man} %{buildroot}%{_sysconfdir}/alternatives/node.1%{ext_man}
ln -s -f npm-default %{buildroot}%{_sysconfdir}/alternatives/npm-default
ln -s -f npm.1%{ext_man} %{buildroot}%{_sysconfdir}/alternatives/npm.1%{ext_man}
ln -s %{_sysconfdir}/alternatives/node-default %{buildroot}%{_bindir}/node-default
ln -s %{_sysconfdir}/alternatives/node.1%{ext_man} %{buildroot}%{_mandir}/man1/node.1%{ext_man}
ln -s %{_sysconfdir}/alternatives/npm-default %{buildroot}%{_bindir}/npm-default
ln -s %{_sysconfdir}/alternatives/npm.1%{ext_man} %{buildroot}%{_mandir}/man1/npm.1%{ext_man}
ln -s -f npx-default %{buildroot}%{_sysconfdir}/alternatives/npx-default
ln -s -f npx.1%{ext_man} %{buildroot}%{_sysconfdir}/alternatives/npx.1%{ext_man}
ln -s %{_sysconfdir}/alternatives/npx-default %{buildroot}%{_bindir}/npx-default
ln -s %{_sysconfdir}/alternatives/npx.1%{ext_man} %{buildroot}%{_mandir}/man1/npx.1%{ext_man}
%if %{node_version_number} >= 14
ln -s -f corepack-default %{buildroot}%{_sysconfdir}/alternatives/corepack-default
ln -s -f corepack.1%{ext_man} %{buildroot}%{_sysconfdir}/alternatives/corepack.1%{ext_man}
ln -s %{_sysconfdir}/alternatives/corepack-default %{buildroot}%{_bindir}/corepack-default
ln -s %{_sysconfdir}/alternatives/corepack.1%{ext_man} %{buildroot}%{_mandir}/man1/corepack.1%{ext_man}
%endif
%endif
# libalternatives - can always ship
mkdir -p %{buildroot}%{_datadir}/libalternatives/{node,npm,npx};
cat > %{buildroot}%{_datadir}/libalternatives/node/%{node_version_number}.conf <<EOF
binary=%{_bindir}/node%{node_version_number}
man=node%{node_version_number}.1
EOF
cat > %{buildroot}%{_datadir}/libalternatives/npm/%{node_version_number}.conf <<EOF
binary=%{_bindir}/npm%{node_version_number}
man=npm%{node_version_number}.1
group=npm,npx
EOF
cat > %{buildroot}%{_datadir}/libalternatives/npx/%{node_version_number}.conf <<EOF
binary=%{_bindir}/npx%{node_version_number}
man=npx%{node_version_number}.1
group=npm,npx
EOF
%if %{node_version_number} >= 14
mkdir -p %{buildroot}%{_datadir}/libalternatives/corepack;
cat > %{buildroot}%{_datadir}/libalternatives/corepack/%{node_version_number}.conf <<EOF
binary=%{_bindir}/corepack%{node_version_number}
man=corepack%{node_version_number}.1
EOF
%endif
# We need to own license directory on old versions of SLE
%if 0%{?suse_version} < 1500
mkdir -p %{buildroot}%{_defaultlicensedir}
%endif
%check
. ./spec.build.config
# Relax the crypto policies for the test-suite
export OPENSSL_SYSTEM_CIPHERS_OVERRIDE=xyz_nonexistent_file
export OPENSSL_CONF=''
export CI_JS_SUITES=default
export NODE_TEST_NO_INTERNET=1
%if %{node_version_number} >= 12
find test \( -name \*.out -or -name \*.js \) -exec sed -i 's,Use `node ,Use `node%{node_version_number} ,' {} \;
%endif
%if %{node_version_number} >= 20
rm test/parallel/test-strace-openat-openssl.js
%endif
# Update the python3 executable name to point at forced python version
# needed to fix build on SLE12 SP5
%if 0%{?forced_python_version:1}
sed -i -e "s,'python3','python%{forced_python_version}'," test/parallel/test-child-process-set-blocking.js
test -e tools/pseudo-tty.py && sed -i -e "s,^#!/usr/bin/env python3$,#!/usr/bin/python%{forced_python_version}," tools/pseudo-tty.py ||:
export PYTHON="/usr/bin/python%{forced_python_version}"
%endif
ln addon-rpm.gypi deps/npm/node_modules/node-gyp/addon-rpm.gypi
# Tarball doesn't have eslint package distributed, so disable some tests
find test -name \*-eslint-\* -print -delete
# No documentation is generated, don't bother checking it, and check broken on older nodejs
%if %{node_version_number} <= 10
rm test/doctool/test-make-doc.js
%endif
# DNS lookup doesn't work in build root
rm test/parallel/test-dns-cancel-reverse-lookup.js \
test/parallel/test-dns-resolveany.js
# multicast test fail since no socket?
rm test/parallel/test-dgram-membership.js
%if %{node_version_number} >= 22
# ::1 not defined in OBS on TW - https://github.com/openSUSE/obs-build/issues/848
rm test/report/test-report-exclude-network.js
# missing ICU test data for 15.6/15.7
ln test/fixtures/icu/localizationData-v74.2.json test/fixtures/icu/localizationData-v73.2.json
%endif
%if %{node_version_number} >= 18
# OBS broken /etc/hosts -- https://github.com/openSUSE/open-build-service/issues/13104
rm test/parallel/test-net-socket-connect-without-cb.js test/parallel/test-tcp-wrap-listen.js
%endif
%if 0%{?fedora_version}
# test/parallel/test-crypto-certificate.js requires OPENSSL_ENABLE_MD5_VERIFY=1
# as SPKAC required MD5 for verification
# https://src.fedoraproject.org/rpms/openssl/blob/rawhide/f/0006-Disable-signature-verification-with-totally-unsafe-h.patch
export OPENSSL_ENABLE_MD5_VERIFY=1
# test failures
# error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake
# failure:ssl/record/rec_layer_s3.c:1543:SSL alert number 40
rm test/parallel/test-tls-no-sslv3.js
%if %{node_version_number} >= 18
rm -r test/addons/openssl-providers
rm test/parallel/test-crypto-fips.js
%endif
%endif
# fedora
# qemu test failures
%if %{node_version_number} >= 18 && 0%{?qemu_user_space_build}
# sequential/test-debugger-*: timeout hit?
rm -v test/*/test-debugger-*.js
# parallel tests are not parallel under qemu
rm -v test/parallel/test-*.js test/parallel/test-*.mjs
# RuntimeError: memory access out of bounds
rm -v test/wasi/test-*.js
# ESM import hits assertion, timeout error?
rm -v test/es-module/test-esm-*.js
# AssertionError [ERR_ASSERTION]: Missing expected exception
rm -v test/js-native-api/test_constructor/test*.js
# Too slow for performance tests
rm -v test/sequential/test-perf-*.js test/sequential/test-diagnostic-*.js
%endif
# Run CI tests
%if 0%{with valgrind_tests}
# valgrind may have false positives, so do not fail on these by default
make test-valgrind ||:
%endif
make test-ci
%files
%defattr(-, root, root)
%license LICENSE
%doc doc/changelogs/CHANGELOG_V%{node_version_number}.md
%doc *.md
%doc deps/v8/tools/gdbinit
%dir %{_libdir}/node_modules
%dir %{_datadir}/libalternatives
%dir %{_datadir}/libalternatives/node
%{_datadir}/libalternatives/node/%{node_version_number}.conf
%{_bindir}/node%{node_version_number}
%{_mandir}/man1/node%{node_version_number}.1%{ext_man}
%if ! 0%{with libalternatives}
%ghost %{_bindir}/node-default
%ghost %{_mandir}/man1/node.1%{ext_man}
%ghost %{_sysconfdir}/alternatives/node-default
%ghost %{_sysconfdir}/alternatives/node.1%{ext_man}
%endif
%exclude %{_libdir}/node_modules/npm%{node_version_number}
# We need to own directory on old versions of SLE
%if 0%{?suse_version} < 1500
%dir %{_defaultlicensedir}
%endif
%files -n npm%{node_version_number}
%defattr(-, root, root)
%dir %{_datadir}/libalternatives
%dir %{_datadir}/libalternatives/npm
%dir %{_datadir}/libalternatives/npx
%{_datadir}/libalternatives/npm/%{node_version_number}.conf
%{_datadir}/libalternatives/npx/%{node_version_number}.conf
%{_bindir}/npm%{node_version_number}
%{_libdir}/node_modules/npm%{node_version_number}
%{_mandir}/man1/npm%{node_version_number}.1%{ext_man}
%if ! 0%{with libalternatives}
%ghost %{_bindir}/npm-default
%ghost %{_mandir}/man1/npm.1%{ext_man}
%ghost %{_sysconfdir}/alternatives/npm-default
%ghost %{_sysconfdir}/alternatives/npm.1%{ext_man}
%endif
%{_bindir}/npx%{node_version_number}
%{_mandir}/man1/npx%{node_version_number}.1%{ext_man}