forked from mattbillenstein/kiss-setup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stage2.sh
executable file
·621 lines (565 loc) · 32.5 KB
/
stage2.sh
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
#!/bin/sh
# Modified for gkiss linux: https://github.com/gkisslinux/grepo
LOOP="/dev/loop7"
set -eo pipefail
# Set KISS_PATH and clone main repo
cd /root
cat > .profile <<EOF
export KISS_PATH="\$HOME/repos/grepo/core:\$HOME/repos/grepo/extra:\$HOME/repos/grepo/wayland:\$HOME/repos/community/community:\$HOME/repos/kiss-bloat/community"
export KISS_SU="su"
EOF
# Modify KISS_PATH such that the bin repository takes priority over other repositories:
export KISS_PATH=$HOME/repos/grepo/bin:$KISS_PATH
# Modify KISS_PATH such that the nvidia repository takes priority over other repositories since some Wayland packages like wlroots are forked here to add NVIDIA support:
export KISS_PATH=$HOME/repos/grepo/nvidia:$KISS_PATH
# Reload env
. ~/.profile
mkdir repos
cd repos
git clone https://github.com/F1r3Hydr4nt/grepo
git clone https://github.com/kiss-community/community
git clone https://github.com/gkisslinux/kiss-bloat
# See if the packages were picked up
echo | kiss search \*
cd /root
#+---------------------------------------------------------------+
#| |
#| ENABLE REPOSITORY SIGNING |
#| |
#| * This step is _entirely optional_ and can also be done |
#| after the installation. |
#| |
#| * Repository signing ensures that all updates have been |
#| signed by (Dylan Araps) and further prevents any unsigned |
#| updates from reaching your system. |
#| |
#| |
#| BUILD AND INSTALL GNUPG1 |
#| |
#| Welcome to the KISS package manager! These two commands |
#| are how individual packages are built and installed on |
#| a KISS system. |
#| |
#kiss build gnupg1
#kiss install gnupg1
#| |
#| |
#| IMPORT MY (DYLAN ARAPS) KEY |
#| |
#| If the GNU keyserver fails on your network, you can try |
#| an alternative mirror (pgp.mit.edu for example). |
#| |
#| # Import my public key. |
#gpg --keyserver keys.gnupg.net --recv-key 46D62DD9F1DE636E
#| |
#| # Trust my public key. |
#echo trusted-key 0x46d62dd9f1de636e >>/root/.gnupg/gpg.conf
#| |
#| |
#| ENABLE SIGNATURE VERIFICATION |
#| |
#| Repository signature verification uses a feature built |
#| into git itself (`merge.verifySignatures`)! |
#| |
#| This can be disabled at any time using the inverse of |
#| the git command below. |
#| |
#| The same steps can also be followed with 3rd-party |
#| repositories if the owner signs their commits. |
#| |
# cd $HOME/repos/grepo/repo
# git config merge.verifySignatures true
#| |
#| |
#+---------------------------------------------------------------+
#
#+---------------------------------------------------------------+
#| |
#| REBUILD KISS |
#| |
#| * This step is entirely optional and you can just use the |
#| supplied binaries from the downloaded chroot. This step |
#| can also be done after the installation. |
#| |
#| |
#| MODIFY COMPILER OPTIONS (optional) |
#| |
#| These options have been tested and work with every package |
#| in the repositories. If you'd like to play it safe, use |
#| -O2 or -Os instead of -O3. |
#| |
#| If your system has a low amount of memory, omit -pipe. |
#| This option speeds up compilation but may use more memory. |
#| |
#| If you intend to transfer packages between machines, omit |
#| -march=native. This option tells the compiler to use |
#| optimizations unique to your processor's architecture. |
#| |
#| The `-jX` option should match the number of CPU cores |
#| available. You can optionally omit this, however builds |
#| will then be limited to a single core. |
#| |
#| # NOTE: The 'O' in '-O3' is the letter O and NOT 0 (ZERO). |
export CFLAGS="-O3 -pipe -march=native"
export CXXFLAGS="-O3 -pipe -march=native"
#| |
#| # NOTE: 4 should be changed to match the number of cores. |
export MAKEFLAGS="-16"
#| |
#| |
#| UPDATE ALL BASE PACKAGES TO THE LATEST VERSION |
#| |
#| This is how updates are performed on a KISS system. This |
#| command uses git to pull down changes from all enabled |
#| repositories and will then optionally handle the |
#| build/install process. |
#| |
#$ kiss update |
# update kiss itself, then installed pkgs
echo | kiss update
echo | kiss update
#| |
#| REBUILD ALL PACKAGES |
#| |
#| Running `kiss build` without specifying packages will |
#| start a rebuild of all installed packages on the system. |
#| |
#| Note: The package manager will prompt for user input on |
#| completion before installing the build packages. |
#| |
#$ cd /var/db/kiss/installed && kiss build * |
echo | kiss build $(ls /var/db/kiss/installed)
#| |
#| |
#+---------------------------------------------------------------+
#
#+---------------------------------------------------------------+
#| |
#| USERSPACE TOOLS |
#| |
#| * Each kiss action (build, install, etc) has a shorthand |
#| alias. From now on, 'kiss b' and 'kiss i' will be used |
#| in place of 'kiss build' and 'kiss install'. |
#| |
#| * The software below is required unless otherwise stated. |
#| |
#| |
#| FILESYSTEMS |
#| |
#| # Ext2, Ext3 and Ext4. |
#$ kiss b e2fsprogs |
#$ kiss i e2fsprogs |
#| |
#| # fat, vfat and friends (Only needed for UEFI). |
#$ kiss b dosfstools |
#$ kiss i dosfstools |
#| |
#| # Open an issue for additional filesystem support. |
#| # Additional filesystems will go here. |
#| |
#| |
#| DEVICE MANAGEMENT |
#| |
#| # Needed blkid support in eudev. |
#$ kiss b util-linux |
#$ kiss i util-linux |
#| |
#$ kiss b eudev |
#$ kiss i eudev |
#| |
#| |
#| WIFI (optional) |
#| |
#$ kiss b wpa_supplicant |
#$ kiss i wpa_supplicant |
#| |
#| |
#| DYNAMIC IP ADDRESSING (optional) |
#| |
#$ kiss b dhcpcd |
#$ kiss i dhcpcd |
#| |
#| |
#+---------------------------------------------------------------+
for pkg in e2fsprogs dosfstools util-linux eudev dhcpcd; do
echo | kiss build $pkg
kiss install $pkg
done
#+---------------------------------------------------------------+
#| |
#| THE KERNEL |
#| |
#| * This step involves configuring and building your own Linux |
#| kernel. If you have not done this before, below are a few |
#| guides to get you started. |
#| |
#| - KernelNewbies |
#| - Gentoo Wiki |
#| - Linuxtopia |
#| |
#| |
#| * The Linux kernel is not managed by the package manager. |
#| The kernel is managed manually by the user. |
#| |
#| * KISS does not support booting using an initramfs. When |
#| configuring your kernel ensure that all required |
#| file-system, disk controller and USB drivers are built |
#| with [*] (Yes) and not [m] (Module). |
#| |
#| * NOTE: A patch may be required for some kernels when built |
#| with GCC 10.1.0. Please read the link below (and the |
#| patch itself for more information). |
#| |
#| https://k1ss.org/news/20200509a |
#| |
#| |
#| INSTALL REQUIRED PACKAGES |
#| |
#| libelf is required in most if not all cases. |
#| |
#$ kiss b libelf |
#$ kiss i libelf |
#| |
#| ncurses is needed for 'make menuconfig' and can be |
#| skipped if you will not be using it. |
#| |
#$ kiss b ncurses |
#$ kiss i ncurses |
#| |
#| Perl is needed by the build_OID_registry script which will |
#| be executed during your kernel build 99.9% of the time. |
#| What this means is that perl is *required*. |
#| |
#$ kiss b perl |
#$ kiss i perl |
#| |
for pkg in libelf ncurses perl; do
echo | kiss build $pkg
kiss install $pkg
done
#| Perl _can_ be avoided by applying the following patch to |
#| the kernel sources. The patch replaces the perl script with |
#| an implementation in POSIX shell (Thanks @E5ten). |
#| |
#| Apply: https://k1ss.org/dist/kernel-no-perl.patch |
#| |
#| |
#| DOWNLOAD THE KERNEL SOURCES |
#| |
#| Kernel releases: |
#| |
#| - https://kernel.org |
#| - https://www.fsfla.org/ |
#| |
#| A larger list of kernels can be found on the |
#| https://wiki.archlinux.org/index.php/Kernel |
#| |
#$ wget KERNEL_SOURCE_URL |
KERNEL_VERSION="5.16.8"
wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-${KERNEL_VERSION}.tar.xz
#| |
#| # Extract the kernel sources. |
#$ tar xvf KERNEL_SOURCE.tar.?? |
#$ cd linux-* |
tar xf linux-${KERNEL_VERSION}.tar.xz
cd linux-${KERNEL_VERSION}
#| |
#| |
#| DOWNLOAD FIRMWARE BLOBS (if required) |
#| |
#| To keep the KISS repositories entirely FOSS, the |
#| proprietary kernel firmware is omitted. This also |
#| makes sense as the kernel itself is manually managed |
#| by the user. |
#| |
#| Note: This step is only required if your hardware |
#| utilizes these drivers. |
#| |
#| Sources: kernel.org |
#| |
#| # Download and extract the firmware. |
wget https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/snapshot/linux-firmware-20220209.tar.gz
tar xvf linux-firmware-20220209.tar.gz
#| |
#| # Copy the required drivers to '/usr/lib/firmware'. |
mkdir -p /usr/lib/firmware
cp -R linux-firmware-20220209 /usr/lib/firmware
#| |
#| |
#| CONFIGURE THE KERNEL |
#| |
#| You can determine which drivers you need by searching |
#| the web for your hardware and the Linux kernel. |
#| |
#| If you require firmware blobs, the drivers you enable |
#| must be enabled as [m] (modules). You can also optionally |
#| include the firmware in the kernel itself. |
#| |
#| # Generate a default config with *most* drivers |
#| # compiled as `[*]` (not modules). |
#$ make defconfig |
make defconfig
# Now customise
echo "Now make the changes for NVIDIA e.g: For kernel configuration, refer to the Gentoo Wiki (https://archive.is/o/13HqT/https://wiki.gentoo.org/wiki/NVIDIA/nvidia-drivers%23Kernel_compatibility). The nouveau kernel module must either be blacklisted from being loaded or disabled in the kernel configuration."
kiss b ncurses
kiss i ncurses
make menuconfig
export KERNEL_UNAME=5.16.8 # Example
# Environment variables can't be used in `post-install`.
depmod "$KERNEL_UNAME"
#| |
#| # Open an interactive menu to edit the generated |
#| # config, enabling anything extra you may need. |
#$ make menuconfig |
#| |
#| # Store the generated config for reuse later. |
#$ cp .config /path/to/somewhere |
#| |
#| |
#| BUILD THE KERNEL |
#| |
#| This may take a while to complete. The compilation time |
#| depends on your hardware and kernel configuration. |
#| |
#| # '-j $(nproc)' does a parallel build using all cores. |
#$ make -j "$(nproc)" |
make -j $(nproc)
#| |
#| |
#| INSTALL THE KERNEL |
#| |
#| Ignore the LILO error, it's harmless. |
#| |
#| # Install the built modules. |
#| # This installs directly to /lib (symlink to /usr/lib). |
#$ make modules_install |
make INSTALL_MOD_STRIP=1 modules_install
#| |
#| # Install the built kernel. |
#| # This installs directly to /boot. |
#$ make install |
make install
#| |
#| # Rename the kernel. |
#| # Substitute VERSION for the kernel version you have built. |
#| # Example: 'vmlinuz-5.4' |
#$ mv /boot/vmlinuz /boot/vmlinuz-VERSION |
#$ mv /boot/System.map /boot/System.map-VERSION |
mv /boot/vmlinuz /boot/vmlinuz-${KERNEL_VERSION}
mv /boot/System.map /boot/System-map-${KERNEL_VERSION}
cd ..
rm -fR linux-${KERNEL_VERSION}*
# Build libglvnd, and then mesa since NVIDIA drivers require libglvnd.
# Install the nvidia drivers by building the nvidia package.
echo | kiss build libglvnd
kiss install libglvnd
echo | kiss build mesa
kiss install mesa
echo | kiss build nvidia
kiss install nvidia
#| |
#| |
#+---------------------------------------------------------------+
#
#+---------------------------------------------------------------+
#| |
#| THE BOOTLOADER |
#| |
#| * The default bootloader is grub (*though nothing prevents |
#| you from using whatever bootloader you desire*). |
#| |
#| * This bootloader was chosen as most people are familiar |
#| with it, both BIOS and UEFI are supported and vast |
#| amounts of documentation for it exists |
#| |
#| |
#| RECOMMENDED |
#| |
#| Create an /etc/fstab by UUID and additionally pass the |
#| PARTUUID as a kernel parameter. |
#| |
#| |
#| BUILD AND INSTALL GRUB |
#| |
#$ kiss b grub |
#$ kiss i grub |
echo | kiss build grub
kiss install grub
#| |
#| # Required for UEFI. |
kiss b efibootmgr
kiss i efibootmgr
#| |
#| |
#| SETUP GRUB |
#| |
#| # BIOS. |
#$ grub-install /dev/sdX |
#$ grub-mkconfig -o /boot/grub/grub.cfg |
# grub-install $LOOP
# grub-mkconfig -o /boot/grub/grub.cfg
# sed -i -e 's:/dev/loop[^ ]*:/dev/sda1:g' /boot/grub/grub.cfg
#| |
#| # UEFI (replace 'esp' with the EFI mount point). |
grub-install --target=x86_64-efi \
--efi-directory=esp \
--bootloader-id=kiss $LOOP
grub-mkconfig -o /boot/grub/grub.cfg
sed -i -e 's:/dev/loop[^ ]*:/dev/sda1:g' /boot/grub/grub.cfg
#| |
#| |
#+---------------------------------------------------------------+
#
#+---------------------------------------------------------------+
#| |
#| INSTALL INIT SCRIPTS |
#| |
#| * The default init is busybox init (*though nothing ties |
#| you to it*). The below commands install the bootup and |
#| shutdown scripts as well as the default inittab config. |
#| |
#| * Source code: https://github.com/kisslinux/kiss-init |
#| |
#$ kiss b baseinit |
#$ kiss i baseinit |
echo | kiss build baseinit
kiss install baseinit
#| |
#| |
#+---------------------------------------------------------------+
#
#+---------------------------------------------------------------+
#| |
#| ADD A NORMAL USER (recommended) |
#| |
#| |
#$ adduser USERNAME |
#| |
#| |
#+---------------------------------------------------------------+
#
#+---------------------------------------------------------------+
#| |
#| ENABLE THE COMMUNITY REPOSITORY |
#| |
#| * The KISS community repository is maintained by users of the |
#| distribution and contains packages which aren't in the main |
#| repositories. This repository is disabled by default. |
#| |
#| # Clone the repository to a location of your choosing. |
#$ git clone https://github.com/kisslinux/community.git |
#| |
#| # Add the repository to the system-wide 'KISS_PATH'. |
#| # The 'KISS_PATH' variable works exactly like 'PATH'. |
#| # Each repository is split by ':' and is checked in |
#| # the order they're written. |
#| # |
#| # Add the full path to the repository you cloned |
#| # above to the existing KISS_PATH. |
#| # |
#| # NOTE: The subdirectory must also be added. |
#$ vi /etc/profile.d/kiss_path.sh |
#| |
#| # Spawn a new login shell to access this repository |
#| # immediately. |
#$ sh -l |
#| |
#| |
#+---------------------------------------------------------------+
#
#+---------------------------------------------------------------+
#| |
#| INSTALL XORG (optional) |
#| |
#| * To install Xorg, the input drivers and a basic default set |
#| of fonts, run the following commands |
#| |
#$ kiss b xorg-server xinit xf86-input-libinput |
#| |
#| # Installing a base font is recommended as Xorg |
#| # and applications require fonts to function. |
kiss b liberation-fonts
kiss i liberation-fonts
#| |
#| |
#+---------------------------------------------------------------+
#+---------------------------------------------------------------+
#| |
#| ADD YOUR USER TO THE RELEVANT GROUPS |
#| |
#| * This groups based permissions model may not be suitable if |
#| KISS will be used as a multi-seat system. Further |
#| configuration can be done at your own discretion. |
#| |
#| # Replace 'USERNAME' with the name of the |
#| # user created above. |
#$ addgroup USERNAME video |
#$ addgroup USERNAME audio |
#| |
#| |
#+---------------------------------------------------------------+
#
#+---------------------------------------------------------------+
#| |
#| FURTHER STEPS |
#| |
#| * You should now be able to reboot into your KISS |
#| installation. Typical configuration should follow |
#| (hostname, creation of users, service configuration, |
#| installing a window manager, terminal etc). |
#| |
#| * If you encountered any issues, don't hesitate to open |
#| an issue on one of our GitHub repositories, post on |
#| https://reddit.com/r/kisslinux or join the IRC server. |
#| |
#| See: https://k1ss.org/contact |
#| |
#| |
#+---------------------------------------------------------------+
# cleanup
rm /stage2.sh
rm -r /root/.cache
#
# Generate locales by running locale-gen as root after modifying the /etc/locale.gen file with the appropriate locales separated by newlines (en_US.UTF8 UTF-8 for most users) and add export LANG=en_US.UTF8 to /etc/profile.
echo "en_US.UTF8 UTF-8" >> /etc/locale.gen
cat /etc/locale.gen
locale-gen
echo "export LANG=en_US.UTF8" >> /etc/profile
cat /etc/profile
# For Wayland compositors to work properly, the NVIDIA kernel module MUST be loaded with the modeset parameter set to 1, append the following to /etc/inittab:
# Run a one-shot command during boot.
echo "::once:/bin/modprobe nvidia-drm modeset=1" >> /etc/inittab
# --[038] Install Graphical Session (Wayland) (Optional) -------------------------
# Refer to the documentation for each package.
# * Wayland Compositor @/wiki/pkg/sway
kiss b sway
kiss i sway
# * Terminal Emulator @/wiki/pkg/foot
kiss b foot
kiss i foot
# * Web Browser @/wiki/pkg/firefox
kiss b firefox
kiss i firefox
# * Media Player @/wiki/pkg/mpv
kiss b mpv
kiss i mpv
# * Desktop Background @/wiki/pkg/wbg
kiss b wlsunset
kiss i wlsunset
# * Color Temperature @/wiki/pkg/wlsunset
kiss b wl-clipboard
kiss i wl-clipboard
# * Clipboard Management @/wiki/pkg/wl-clipboard
kiss b sway
kiss i sway
# * Screenshots @/wiki/pkg/grim
kiss b grim
kiss i grim
# * Region Selection @/wiki/pkg/slurp
kiss b slurp
kiss i slurp
echo "YOU NEED TO RUN adduser USERNAME && passwd USERNAME && passwd for root"
# zero unused disk blocks so we compress well...
dd if=/dev/zero of=foo bs=1M 2>/dev/null || true
rm foo
echo "Stage2 complete, please exit this chroot..."