FirstRun.pm 16 KB
Newer Older
1
2
3
4
5
6
package ksb::FirstRun 0.10;

use 5.014;
use strict;
use warnings;
use File::Spec qw(splitpath);
7
use List::Util qw(min max first);
8

9
use ksb::BuildException;
10
11
use ksb::Debug qw(colorize);
use ksb::OSSupport;
12
use ksb::Util;
13
14
15
16
17
18
19
20
21

=head1 NAME

ksb::FirstRun

=head1 DESCRIPTION

Performs initial-install setup, implementing the C<--initial-setup> option.

22
23
24
B<NOTE> This module is supposed to be loadable even under minimal Perl
environments as fielded in "minimal Docker container" forms of popular distros.

25
26
27
28
29
30
31
=head1 SYNOPSIS

    my $exitcode = ksb::FirstRun::setupUserSystem();
    exit $exitcode;

=cut

Luis Kao's avatar
Luis Kao committed
32
use constant {
Luis Kao's avatar
Luis Kao committed
33
    SHELL_RC_SNIPPET => <<'RC'
Sebastian Engel's avatar
Sebastian Engel committed
34
# kdesrc-build #################################################################
Luis Kao's avatar
Luis Kao committed
35
36
37
38

## Add kdesrc-build to PATH
export PATH="$HOME/kde/src/kdesrc-build:$PATH"

Sebastian Engel's avatar
Sebastian Engel committed
39
40
41
42
43
44
45
46
47
48
49
50
51
## Autocomplete for kdesrc-run
function _comp-kdesrc-run
{
  local cur
  COMPREPLY=()
  cur="${COMP_WORDS[COMP_CWORD]}"

  # Complete only the first argument
  if [[ $COMP_CWORD != 1 ]]; then
    return 0
  fi

  # Filter cache to get build modules
Luis Kao's avatar
Luis Kao committed
52
  local modules=$(kdesrc-run --list-installed)
Sebastian Engel's avatar
Sebastian Engel committed
53
54
55
56
57
58
59
60
61
62

  # intersect lists
  COMPREPLY=($(compgen -W "${modules}" $cur))

  return 0
}
## register autocomplete function
complete -o nospace -F _comp-kdesrc-run kdesrc-run

################################################################################
Luis Kao's avatar
Luis Kao committed
63
64
65
RC
};

66
67
sub setupUserSystem
{
68
    my $baseDir = shift;
69
    my $os = ksb::OSSupport->new;
70
71
    my $envShell = $ENV{'SHELL'} // 'undefined';
    my $shellName = (split '/', $envShell)[-1];
Luis Kao's avatar
Luis Kao committed
72

73
74
    eval {
        _installSystemPackages($os);
75
        _setupBaseConfiguration($baseDir);
Luis Kao's avatar
Luis Kao committed
76
        _setupShellRcFile($shellName);
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
    };

    if (had_an_exception($@)) {
        my $msg = $@->{message};
        say colorize ("  b[r[*] r[$msg]");
        return 1;
    }

    return 0;
}

# Internal functions

# Reads from the __DATA__ section below and dumps the contents in a hash keyed
# by filename (the @@ part between each resource).
my %packages;
sub _readPackages
{
    return \%packages if %packages;

    my $cur_file;
    my $cur_value;
    my $commit = sub {
        return unless $cur_file;
        $packages{$cur_file} = ($cur_value =~ s/ *$//r);
        $cur_value = '';
    };

    while(my $line = <DATA>) {
106
        next if $line =~ /^\s*#/ and $cur_file !~ /sample-rc/;
107
108
109
110
111
112
113
114
        chomp $line;

        my ($fname) = ($line =~ /^@@ *([^ ]+)$/);
        if ($fname) {
            $commit->();
            $cur_file = $fname;
        }
        else {
115
            $cur_value .= "$line\n";
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
        }
    }

    $commit->();
    return \%packages;
}

sub _throw
{
    my $msg = shift;
    die (make_exception('Setup', $msg));
}

sub _installSystemPackages
{
    my $os = shift;
    my $vendor = $os->vendorID;
    my $osVersion = $os->vendorVersion;

135
    print colorize(<<DONE);
136
 b[-] Installing b[system packages] for b[$vendor]...
137
138
DONE

139
140
    my @packages = _findBestVendorPackageList($os);
    if (@packages) {
141
142
143
144
        my @installCmd = _findBestInstallCmd($os);
        say colorize (" b[*] Running b[" . join(' ', @installCmd) . "]");
        my $result = system (@installCmd, @packages);
        if ($result >> 8 == 0) {
145
            say colorize (" b[*] b[g[Looks like the necessary packages were successfully installed!]");
146
147
148
        } else {
            say colorize (" r[b[*] Ran into an error with the installer!");
        }
149
    } else {
150
        say colorize (" r[b[*] Packages could not be installed, because kdesrc-build does not know your distribution (" . $vendor .")");
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
# Return the highest number of cores we can use based on available memory. Requires
# the number of cores we have available
sub _getNumCoresForLowMemory
{
    my $num_cores = shift;

    # Try to detect the amount of total memory for a corresponding option for
    # heavyweight modules (sorry ade, not sure what's needed for FreeBSD!)
    my $mem_total;
    my $total_mem_line = first { /MemTotal/ } (`cat /proc/meminfo`);

    if ($total_mem_line && $? == 0) {
        ($mem_total) = ($total_mem_line =~ /^MemTotal:\s*([0-9]+) /); # Value in KiB
        $mem_total = int $mem_total;
    }

    # 4 GiB is assumed if no info on memory is available, as this will
    # calculate to 2 cores. sprintf is used since there's no Perl round function
    my $rounded_mem = $mem_total ? (int sprintf("%.0f", $mem_total / 1024000.0)) : 4;
    my $max_cores_for_mem = max(1, int $rounded_mem / 2); # Assume 2 GiB per core
    my $num_cores_low = min($max_cores_for_mem, $num_cores);

    return $num_cores_low;
}

179
180
sub _setupBaseConfiguration
{
181
    my $baseDir = shift;
182
183
    my @knownLocations = ("$ENV{PWD}/kdesrc-buildrc", "$ENV{HOME}/.kdesrc-buildrc");
    my $locatedFile = first { -e $_ } @knownLocations;
184

185
    if (defined $locatedFile) {
186
        print colorize(<<DONE);
187
 b[*] You already have a configuration file: b[y[$locatedFile].
188
DONE
189
190
191
192
        return;
    }

    print colorize(<<DONE);
Luis Kao's avatar
Luis Kao committed
193
 b[*] Creating b[sample configuration file]: b[y["$ENV{HOME}/.kdesrc-buildrc"]...
194
DONE
195

196
197
    my $sampleRc = $packages{'sample-rc'} or
        _throw("Embedded sample file missing!");
198

199
200
    my $numCores = `nproc 2>/dev/null` || 4;
    my $numCoresLow = _getNumCoresForLowMemory($numCores);
201

202
203
204
    $sampleRc =~ s/%\{num_cores}/$numCores/g;
    $sampleRc =~ s/%\{num_cores_low}/$numCoresLow/g;
    $sampleRc =~ s/%\{base_dir}/$baseDir/g;
205

206
207
    open my $sampleFh, '>', "$ENV{HOME}/.kdesrc-buildrc"
        or _throw("Couldn't open new ~/.kdesrc-buildrc: $!");
208

209
210
    print $sampleFh $sampleRc
        or _throw("Couldn't write to ~/.kdesrc-buildrc: $!");
211

212
213
    close $sampleFh
        or _throw("Error closing ~/.kdesrc-buildrc: $!");
214
215
}

Luis Kao's avatar
Luis Kao committed
216
sub _setupShellRcFile
217
{
Luis Kao's avatar
Luis Kao committed
218
219
220
221
222
223
224
225
226
227
228
229
230
    my $shellName = shift;
    my $rcFilepath = undef;
    my $isAuto = 1;

    if ($shellName eq 'bash') {
        $rcFilepath = "$ENV{'HOME'}/.bashrc";
    } elsif ($shellName eq 'zsh') {
        if (defined $ENV{'ZDOTDIR'}) {
            $rcFilepath = "$ENV{'ZDOTDIR'}/.zshrc";
        } else {
            $rcFilepath = "$ENV{'HOME'}/.zshrc";
        }
    } else {
231
        say colorize(" b[*] Updating rc-file for shell 'y[b[$shellName]' is not supported.");
Luis Kao's avatar
Luis Kao committed
232
233
234
235
        $isAuto = 0;
    }

    if (defined $rcFilepath) {
236
        $isAuto = ksb::Util::yesNoPrompt(colorize(" b[*] Update your b[y[$rcFilepath]?"));
237
238
    }

Luis Kao's avatar
Luis Kao committed
239
240
    if ($isAuto) {
        open(my $rcFh, '>>', "$rcFilepath") or _throw("Couldn't open $rcFilepath: $!");
Luis Kao's avatar
Luis Kao committed
241
        say $rcFh '';
Luis Kao's avatar
Luis Kao committed
242
243
        say $rcFh SHELL_RC_SNIPPET;
        close($rcFh);
244
        say colorize(<<DONE);
245
246
247
     - Added b[y[kdesrc-build] directory into PATH
     - Added b[y[kdesrc-run] shell function
 b[*] b[g[Shell rc-file is successfully setup].
248
249
DONE
    } else {
250
251
252
253
254
        say '';
        say colorize(<<DONE);
 b[*] You can manually configure your shell rc-file with the snippet below:
DONE
        say SHELL_RC_SNIPPET;
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
sub _findBestInstallCmd
{
    my $os = shift;
    my $pkgsRef = _readPackages();

    my @supportedDistros =
        map  { s{^cmd/install/([^/]+)/.*$}{$1}; $_ }
        grep { /^cmd\/install\// }
            keys %{$pkgsRef};

    my $bestVendor = $os->bestDistroMatch(@supportedDistros);
    say colorize ("    Using installer for b[$bestVendor]");

    my $version = $os->vendorVersion();
    my @cmd;

    for my $opt ("$bestVendor/$version", "$bestVendor/unknown") {
        my $key = "cmd/install/$opt";
        next unless exists $pkgsRef->{$key};
        @cmd = split(' ', $pkgsRef->{$key});
        last;
    }

    _throw("No installer for $bestVendor!")
        unless @cmd;

    # If not running as root already, add sudo
    unshift @cmd, 'sudo' if $> != 0;

    return @cmd;
}

292
293
294
295
296
297
298
299
300
301
302
sub _findBestVendorPackageList
{
    my $os = shift;

    # Debian handles Ubuntu also
    my @supportedDistros =
        map  { s{^pkg/([^/]+)/.*$}{$1}; $_ }
        grep { /^pkg\// }
            keys %{_readPackages()};

    my $bestVendor = $os->bestDistroMatch(@supportedDistros);
303
304
305
    my $version = $os->vendorVersion();
    say colorize ("    Installing packages for b[$bestVendor]/b[$version]");
    return _packagesForVendor($bestVendor, $version);
306
307
308
309
}

sub _packagesForVendor
{
310
    my ($vendor, $version) = @_;
311
312
    my $packagesRef = _readPackages();

313
314
315
316
    foreach my $opt ("pkg/$vendor/$version", "pkg/$vendor/unknown") {
        next unless exists $packagesRef->{$opt};
        my @packages = split(' ', $packagesRef->{$opt});
        return @packages;
317
318
    }

319
    return;
320
321
322
323
324
325
}

1;

__DATA__
@@ pkg/debian/unknown
326
# This is woefully incomplete and not very useful.
327
# Perl support
Luis Kao's avatar
Luis Kao committed
328
329
libyaml-libyaml-perl
libio-socket-ssl-perl
330
libjson-xs-perl
Luis Kao's avatar
Luis Kao committed
331
liburi-perl
332
# Basic build tools
Luis Kao's avatar
Luis Kao committed
333
334
335
336
bison
build-essential
cmake
flex
337
gettext
Luis Kao's avatar
Luis Kao committed
338
339
340
git
gperf
libssl-dev
341
intltool
Luis Kao's avatar
Luis Kao committed
342
shared-mime-info
343
344
# Qt-related
libdbusmenu-qt5-dev
345
346
347
348
349
# And others
liblmdb-dev
libsm-dev
libnm-dev
libqrencode-dev
350
351
352
353
354

@@ pkg/neon/unknown
# Neon is a lot like Debian, except we know Qt is sufficiently new
# to install Qt dev-tools.
# Perl support
Luis Kao's avatar
Luis Kao committed
355
356
libyaml-libyaml-perl
libio-socket-ssl-perl
357
libjson-xs-perl
Luis Kao's avatar
Luis Kao committed
358
liburi-perl
359
# Basic build tools
Luis Kao's avatar
Luis Kao committed
360
361
362
363
bison
build-essential
cmake
flex
364
gettext
Luis Kao's avatar
Luis Kao committed
365
366
367
git
gperf
libssl-dev
368
intltool
369
370
meson
ninja-build
Luis Kao's avatar
Luis Kao committed
371
shared-mime-info
372
# Qt-related
373
libdbusmenu-qt5-dev
374
libqt5svg5-dev
Luis Kao's avatar
Luis Kao committed
375
376
libqt5waylandclient5-dev
libqt5x11extras5-dev
377
qtbase5-private-dev
378
qtdeclarative5-dev
Luis Kao's avatar
Luis Kao committed
379
380
381
qtmultimedia5-dev
qtquickcontrols2-5-dev
qtscript5-dev
382
qttools5-dev
Luis Kao's avatar
Luis Kao committed
383
qtwayland5-dev-tools
384
385
386
qtxmlpatterns5-dev-tools
# Frameworks dependencies
# .. polkit-qt-1
Luis Kao's avatar
Luis Kao committed
387
388
libpolkit-gobject-1-dev
libpolkit-agent-1-dev
389
# .. kdoctools
Luis Kao's avatar
Luis Kao committed
390
libxml2-dev
391
392
393
libxslt-dev
# .. kwindowsystem
libwayland-dev
Luis Kao's avatar
Luis Kao committed
394
395
396
libxcb-icccm4-dev
libxcb-keysyms1-dev
libxcb-res0-dev
397
libxcb-xfixes0-dev
Luis Kao's avatar
Luis Kao committed
398
399
libxcb-xkb-dev
libxfixes-dev
400
libxrender-dev
Luis Kao's avatar
Luis Kao committed
401
wayland-protocols
402
# .. kwallet
Luis Kao's avatar
Luis Kao committed
403
404
libgcrypt-dev
libgpgme11-dev
405
406
407
408
409
410
411
libgpgmepp-dev
# .. kactivities
libboost-dev
# .. kfilemetadata
libattr1-dev
# .. kidletime
libxcb-sync-dev
412
libx11-xcb-dev
413
414
415
# And others
qt5keychain-dev
libopenal-dev
Luis Kao's avatar
Luis Kao committed
416
libopenjp2-7-dev
417
qtlocation5-dev
Luis Kao's avatar
Luis Kao committed
418
libraw-dev
419
libsane-dev
Luis Kao's avatar
Luis Kao committed
420
421
libsndfile1-dev
libxcb-glx0-dev
422
423
424
425
liblmdb-dev
libsm-dev
libnm-dev
libqrencode-dev
426

427
@@ pkg/opensuse/unknown
Janet Blackquill's avatar
Janet Blackquill committed
428
429
430
cmake
docbook-xsl-stylesheets
docbook_4
431
flex bison
Janet Blackquill's avatar
Janet Blackquill committed
432
433
434
435
436
437
gettext-runtime
gettext-tools
giflib-devel
git
gperf
intltool
438
libboost_headers-devel
439
libdbusmenu-qt5-devel
Janet Blackquill's avatar
Janet Blackquill committed
440
libqt5-qtbase-common-devel
441
libqt5-qtbase-private-headers-devel
Luis Kao's avatar
Luis Kao committed
442
libqt5-qtimageformats-devel
Janet Blackquill's avatar
Janet Blackquill committed
443
libQt5Core-private-headers-devel
Luis Kao's avatar
Luis Kao committed
444
libQt5DesignerComponents5
Janet Blackquill's avatar
Janet Blackquill committed
445
libxml2-tools
446
lmdb-devel
Janet Blackquill's avatar
Janet Blackquill committed
447
make
Luis Kao's avatar
Luis Kao committed
448
perl
Janet Blackquill's avatar
Janet Blackquill committed
449
450
451
452
453
454
perl(IO::Socket::SSL)
perl(JSON)
perl(URI)
perl(YAML::LibYAML)
pkgconfig(libattr)
pkgconfig(libical)
455
pkgconfig(libnm)
Janet Blackquill's avatar
Janet Blackquill committed
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
pkgconfig(libpng)
pkgconfig(libqrencode)
pkgconfig(libudev)
pkgconfig(libxml-2.0)
pkgconfig(libxslt)
pkgconfig(ModemManager)
pkgconfig(openssl)
pkgconfig(Qt5Core)
pkgconfig(Qt5Multimedia)
pkgconfig(Qt5Qml)
pkgconfig(Qt5QuickControls2)
pkgconfig(Qt5Script)
pkgconfig(Qt5Svg)
pkgconfig(Qt5UiTools)
pkgconfig(Qt5WebKit)
pkgconfig(Qt5WebKitWidgets)
pkgconfig(Qt5X11Extras)
pkgconfig(Qt5XmlPatterns)
pkgconfig(sm)
pkgconfig(wayland-server)
Luis Kao's avatar
Luis Kao committed
476
pkgconfig(xcb-keysyms)
Janet Blackquill's avatar
Janet Blackquill committed
477
478
479
pkgconfig(xrender)
polkit-devel
shared-mime-info
480
libXfixes-devel
481
482

@@ pkg/fedora/unknown
Janet Blackquill's avatar
Janet Blackquill committed
483
bison
484
boost-devel
Janet Blackquill's avatar
Janet Blackquill committed
485
cmake
486
dbusmenu-qt5-devel
Janet Blackquill's avatar
Janet Blackquill committed
487
488
docbook-style-xsl
docbook-utils
489
doxygen
Janet Blackquill's avatar
Janet Blackquill committed
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
flex
gcc
gcc-c++
gettext
gettext-devel
giflib-devel
git
gperf
intltool
libxml2
make
pam-devel
perl(IO::Socket::SSL)
perl(IPC::Cmd)
perl(JSON::PP)
perl(URI)
perl(YAML::LibYAML)
Luis Kao's avatar
Luis Kao committed
507
pkgconfig(dbus-1)
Janet Blackquill's avatar
Janet Blackquill committed
508
pkgconfig(gbm)
Luis Kao's avatar
Luis Kao committed
509
pkgconfig(gl)
Janet Blackquill's avatar
Janet Blackquill committed
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
pkgconfig(gstreamer-1.0)
pkgconfig(libassuan)
pkgconfig(libattr)
pkgconfig(libnm)
pkgconfig(libpng)
pkgconfig(libqrencode)
pkgconfig(libxml-2.0)
pkgconfig(libxslt)
pkgconfig(lmdb)
pkgconfig(ModemManager)
pkgconfig(openssl)
pkgconfig(polkit-gobject-1)
pkgconfig(sm)
pkgconfig(wayland-client)
pkgconfig(wayland-protocols)
pkgconfig(xapian-core)
pkgconfig(xcb-cursor)
pkgconfig(xcb-ewmh)
pkgconfig(xcb-keysyms)
pkgconfig(xcb-util)
pkgconfig(xfixes)
pkgconfig(xrender)
python
shared-mime-info
texinfo
535
systemd-devel
536

537
@@ pkg/mageia/unknown
Janet Blackquill's avatar
Janet Blackquill committed
538
bison
539
boost
Janet Blackquill's avatar
Janet Blackquill committed
540
541
542
543
544
545
546
547
548
549
550
551
552
cmake
docbook-style-xsl
docbook-utils
flex
gcc
gcc-c++
gettext
gettext-devel
giflib
git
gperf
intltool
lib64lmdb-devel
553
libdbusmenu-qt5-devel
Janet Blackquill's avatar
Janet Blackquill committed
554
make
Luis Kao's avatar
Luis Kao committed
555
perl(IO::Socket::SSL)
Janet Blackquill's avatar
Janet Blackquill committed
556
perl(IPC::Cmd)
Luis Kao's avatar
Luis Kao committed
557
perl(JSON::PP)
Janet Blackquill's avatar
Janet Blackquill committed
558
perl(URI)
Luis Kao's avatar
Luis Kao committed
559
perl(YAML::LibYAML)
Janet Blackquill's avatar
Janet Blackquill committed
560
pkgconfig(dbus-1)
Luis Kao's avatar
Luis Kao committed
561
pkgconfig(gl)
Janet Blackquill's avatar
Janet Blackquill committed
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
pkgconfig(gstreamer-1.0)
pkgconfig(libattr)
pkgconfig(libnm)
pkgconfig(libpng)
pkgconfig(libqrencode)
pkgconfig(libxml-2.0)
pkgconfig(libxslt)
pkgconfig(ModemManager)
pkgconfig(openssl)
pkgconfig(polkit-gobject-1)
pkgconfig(sm)
pkgconfig(wayland-client)
pkgconfig(xcb-keysyms)
pkgconfig(xrender)
python
shared-mime-info
578
579


580
581
582
@@ pkg/gentoo/unknown
dev-util/cmake
dev-lang/perl
583
dev-libs/libdbusmenu-qt
584
585

@@ pkg/arch/unknown
586
perl-json perl-yaml-libyaml perl-io-socket-ssl
587
cmake gcc make qt5-base
588
doxygen
Nicolas Fella's avatar
Nicolas Fella committed
589
590
boost
intltool
Nicolas Fella's avatar
Nicolas Fella committed
591
gperf
Nicolas Fella's avatar
Nicolas Fella committed
592
593
594
595
596
597
598
599
docbook-xsl
flex
bison
automake
autoconf
pkg-config
wayland-protocols
clang
Tomaz  Canabrava's avatar
Tomaz Canabrava committed
600
601
602
603
604
ninja
meson
qrencode
signond
libaccounts-qt
605
libdbusmenu-qt5
Tomaz  Canabrava's avatar
Tomaz Canabrava committed
606
607
608
609
610
611
612
613
614
615
616
617
xapian-core
qgpgme
poppler-qt5
kdsoap
xsd
xerces-c
qt5-webkit
vlc
ruby-sass
eigen
mlt
freecell-solver
618

619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
@@ pkg/alpine/unknown
alpine-sdk
attr-dev
autoconf
automake
bison
boost-dev
cmake
doxygen
eudev-dev
flex
giflib-dev
gperf
gpgme-dev
grantlee-dev
gstreamer-dev
gst-plugins-base-dev
636
libcanberra-dev
637
libdbusmenu-qt-dev
638
639
640
libdmtx-dev
libepoxy-dev
libgcrypt-dev
641
libical-dev
642
643
644
645
libinput-dev
libqrencode-dev
libxkbfile-dev
libxrender-dev
646
libxslt-dev
647
648
649
650
651
652
653
654
655
libxtst-dev
linux-pam-dev
lmdb-dev
networkmanager-dev
perl
perl-io-socket-ssl
perl-uri
perl-yaml-libyaml
polkit-elogind-dev
656
pulseaudio-dev
657
658
659
qt5-qtbase-dev
qt5-qtdeclarative-dev
qt5-qtquickcontrols2-dev
660
qt5-qtmultimedia-dev
661
662
663
664
665
666
667
668
669
670
671
672
673
674
qt5-qtscript-dev
qt5-qtsensors-dev
qt5-qtsvg-dev
qt5-qttools-dev
qt5-qtwayland-dev
qt5-qtx11extras-dev
texinfo
wayland-protocols
xapian-core-dev
xcb-util-cursor-dev
xcb-util-image-dev
xcb-util-keysyms-dev
xcb-util-wm-dev

675
676
677
@@ cmd/install/debian/unknown
apt-get -q -y --no-install-recommends install

678
@@ cmd/install/opensuse/unknown
679
zypper install -y --no-recommends
680

681
@@ cmd/install/arch/unknown
682
pacman -Syu --noconfirm --needed
683

684
685
686
@@ cmd/install/fedora/unknown
dnf -y install

687
@@ cmd/install/alpine/unknown
688
apk add --virtual makedeps-kdesrc-build
689

690
691
692
693
694
695
@@ sample-rc
# This file controls options to apply when configuring/building modules, and
# controls which modules are built in the first place.
# List of all options: https://go.kde.org/u/ksboptions

global
696
697
698
    # Paths

    kdedir ~/kde/usr # Where to install KF5-based software
699
#   qtdir  ~/kde/qt5 # Where to install Qt5 if kdesrc-build supplies it
700
701
702
703

    source-dir ~/kde/src   # Where sources are downloaded
    build-dir  ~/kde/build # Where the source build is run

704
    directory-layout invent # Use invent.kde.org structure
705
706
707
708
709
710

    # Will pull in KDE-based dependencies only, to save you the trouble of
    # listing them all below
    include-dependencies true

    cmake-options -DCMAKE_BUILD_TYPE=RelWithDebInfo
711
712
713
714
715
716
717
718
719
720
721
722
723

    # kdesrc-build sets 2 options which you can use in options like make-options or set-env
    # to help manage the number of compile jobs that # happen during a build:
    #
    # 1. num-cores, which is just the number of detected CPU cores, and can be passed
    #    to tools like make (needed for parallel build) or ninja (completely optional).
    #
    # 2. num-cores-low-mem, which is set to largest value that appears safe for
    #    particularly heavyweight modules based on total memory, intended for
    #    modules like qtwebengine
    num-cores %{num_cores}
    num-cores-low-mem %{num_cores_low}

724
    make-options  -j ${num-cores}
725
726
end global

727
# With base options set, the remainder of the file is used to define modules to build, in the
728
729
730
731
732
733
734
# desired order, and set any module-specific options.
#
# Modules may be grouped into sets, and this is the normal practice.
#
# You can include other files inline using the "include" command. We do this here
# to include files which are updated with kdesrc-build.

735
736
737
738
739
# Common options that should be set for some KDE modules no matter how
# kdesrc-build finds them. Do not comment these out unless you know
# what you are doing.
include %{base_dir}/kf5-common-options-build-include

740
741
742
743
# Qt and some Qt-using middleware libraries. Uncomment if your distribution's Qt
# tools are too old but be warned that Qt take a long time to build!
#include %{base_dir}/qt5-build-include
#include %{base_dir}/custom-qt5-libs-build-include
744
745

# KF5 and Plasma :)
746
747
748
include %{base_dir}/kf5-qt5-build-include

# To change options for modules that have already been defined, use an
749
# 'options' block. See kf5-common-options-build-include for an example