aboutsummaryrefslogtreecommitdiffstats
path: root/platforms/rpi-aarch64/second_stage_install.sh
blob: b66d01f749c4271dcbb47977fa0d5529015d052a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash

# Copyright (C) 2017-2018 Daniel Tartavel-jeannot   <contact@librepc.com>
# Copyright (C) 2019-2020 Jean-Baptiste Biernacki   <j.biernacki@free.fr>
#

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

export ARCH=arm64
if [[ -e /toSource.bash ]] ; then
    source /toSource.bash
    rm -f /toSource.bash
fi

# remove the warning:
#   186/194: lockdev               warning: group lock does not exist - using root
# #############################################
groupadd -r lock
groupadd -r shadow

/usr/bin/chown :shadow /etc/shadow /etc/gshadow /etc/login.defs /etc/pam.d/chage-chfn-chsh /etc/pam.d/chpasswd-newusers /etc/pam.d/system-auth /etc/pam.d/user-group-mod /bin/passwd /bin/chage

/usr/bin/chown :systemd-journal -R /var/log/journal

# Force include of libmount
# mkdir -p /etc/dracut.conf.d/
# cat <<EOT >/etc/dracut.conf.d/00-fix-libmount.conf
# add_drivers+=" brcmutil brcmfmac brcmfmac_wcc i2c_brcmstb reset_raspberrypi clk_bcm2711_dvp bcm2711_thermal gpio_raspberrypi_exp clk_raspberrypi raspberrypi_hwmon bcm2835_dma pcie_brcmstb sdhci_iproc configfs autofs4 "
# hostonly="no"
# omit_dracutmodules+=" network systemd "
# add_dracutmodules+=" fs-lib virtfs virtiofs rootfs-block "
# install_items+=" /usr/lib64/libmount.so /usr/lib64/libmount.so.1 /usr/lib64/libmount.so.1.1.0 "
# EOT
# cat <<EOT >/etc/dracut.conf.d/50-mageia.conf
# # Configuration for 10i18n module. See /usr/share/dracut/10i18n/README
# i18n_vars="/etc/sysconfig/i18n:SYSFONT-FONT,SYSFONTACM-FONT_MAP,UNIMAP-FONT_UNIMAP,LANG,LC_ALL /etc/sysconfig/keyboard:KEYTABLE,KEYMAP,GRP_TOGGLE"
# 
# # build initrd only to boot current hardware
# hostonly="no"
# 
# # Do not include the network module by default which saves about 10megs
# # Users can still generate a network friendly initrd by editing this file
# # or overriding omit_dracutmodules from another config file
# omit_dracutmodules+=" network systemd "
# EOT

# /sbin/urpmi.update "Core Updates Testing"

#Install all packages you need
<INSTALL_EXEC> basesystem grub2-efi efibootmgr chrony polkit lockdev rng-tools man openssh-server rfkill wireless-tools bluez wpa_supplicant make rsync binutils ldetect usbutils kernel-desktop-latest u-boot u-boot-tools

# rm -f /etc/dracut.conf.d/00-fix-libmount.conf

#For the wifi :
/sbin/urpmi.update "Nonfree Release"
/sbin/urpmi.update "Nonfree Updates"
<INSTALL_EXEC> --media "Nonfree Release,Nonfree Updates" -a --fuzzy kernel-firmware-nonfree
<INSTALL_EXEC> --media "Nonfree Release,Nonfree Updates" raspberrypi-firmware

/usr/bin/sed -i -e '/GRUB_CMDLINE_LINUX_DEFAULT/s|"[[:space:]]*$| audit=0"|' /etc/default/grub

echo \
"# Configuration file for fw_(printenv/setenv) utility.
# Up to two entries are valid, in this case the redundant
# environment sector is assumed present.
# MTD device name       Device offset   Env. size       Flash sector size
/boot/EFI/uboot.env            0x0000      0x4000" > /etc/fw_env.config

sed -e 's|preboot=.*$|preboot=|' \
    -e 's|kernel_addr_r=.*$|kernel_addr_r=0x00001000|' \
    /usr/lib/u-boot/rpi_arm64/default_env.txt \
    | mkenvimage -s $((0x4000)) -o /boot/EFI/uboot.env -

cp /usr/lib/u-boot/rpi_arm64/u-boot.bin /boot/EFI/u-boot.bin

/usr/bin/chown :chrony -R /etc/chrony.keys /var/log/chrony
/usr/bin/chown :daemon /etc/wpa_supplicant.conf
/usr/bin/chown :tty /bin/write /bin/wall
/usr/bin/chown :lock /sbin/lockdev
/usr/bin/chown :bin /sbin/traceroute
/usr/bin/chown polkitd /etc/polkit-1/rules.d

# /sbin/urpmi.update "Core Updates Testing"
# <INSTALL_EXEC> --media  "Core Updates Testing" kernel-desktop-latest

# permanently disable access to u-boot from grub, not working and not required.
chmod -x /etc/grub.d/30_uefi-firmware
# disable osprober because it finds and embedded the BuildSystem OS into the image.
chmod -x /etc/grub.d/30_os-prober 
/usr/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg
/usr/sbin/grub2-install --skip-fs-probe --target=arm64-efi --efi-directory=/boot/EFI --removable --no-nvram --force-file-id
chmod +x /etc/grub.d/30_os-prober

## DO NOT EXIT THE SCRIPT. A second part is automatically added in this script during the process in order to create the default user and set root password.