├── .github └── FUNDING.yml ├── COPYING ├── Makefile ├── README.md ├── defconfig └── README.md ├── files ├── firmware │ ├── UPDATE.mem │ └── fw-0a5c_21e8.hcd ├── inits │ ├── bthelper.init │ ├── credentials.init │ ├── firstboot.init │ ├── governor.init │ ├── leds.init │ └── zramswap.init ├── misc │ ├── 10-local-rpi.rules │ ├── 60-rpi.gpio-common.rules │ ├── 99-com.rules │ ├── profile │ └── rpi-vc.conf ├── patches │ ├── raspberrypi-sys-mods-control.patch │ ├── rpi-eeprom-control │ ├── rpi-eeprom-update.patch │ └── userland-remove-hi-pi.patch ├── scripts │ ├── 00-header │ ├── 15-brand │ ├── 20-sysinfo │ ├── 90-dynamic-motd │ ├── firstboot.sh │ ├── growpart │ ├── ifupdown.credentials │ ├── leds.sh │ ├── networkmanager.credentials │ ├── setup │ ├── smon │ ├── sysinfo │ ├── systemd-binfmt-fixups │ └── transfer ├── useracct │ ├── useraccount │ ├── useraccount.init │ ├── useraccount.service │ └── useraccount.txt ├── users │ ├── darkgreen.ini │ ├── darkred.ini │ ├── nanorc-root │ ├── nanorc-user │ ├── root-ini │ └── user-ini └── userscripts │ └── README.md ├── install.sh ├── lib ├── boards │ ├── bcm2708 │ ├── bcm2709 │ ├── bcm2710 │ ├── bcm2711 │ ├── bcm2711v7 │ └── bcm2712 ├── dialog │ ├── config │ ├── dialogrc │ ├── general │ └── menu ├── function │ ├── compilers │ ├── config │ ├── defconfig │ ├── echoes │ ├── miscellaneous │ ├── networking │ ├── patching │ ├── release │ ├── rootfs │ ├── rpi-commit │ ├── rpi-linux │ ├── rpi-pkgs │ ├── services │ ├── shrink │ ├── staging │ └── wireless └── source ├── packaging ├── builddeb ├── dtclist.txt ├── headers-byteshift.patch ├── initrd ├── logo │ ├── devuan_clut224.ppm │ ├── linux_clut224.ppm │ ├── raspberrypi_clut224.ppm │ └── skull_clut224.ppm ├── mkdebian └── pkgvars ├── patches ├── all │ ├── 6.10.y │ │ └── 001-scripts-Makefile.package-PHONY-intdeb-pkg.patch │ ├── 6.11.y │ │ └── 001-scripts-Makefile.package-PHONY-intdeb-pkg.patch │ ├── 6.12.y │ │ └── 001-scripts-Makefile.package-PHONY-intdeb-pkg.patch │ ├── 6.13.y │ │ └── 001-scripts-Makefile.package-PHONY-intdeb-pkg.patch │ ├── 6.14.y │ │ └── 001-scripts-Makefile.package-PHONY-intdeb-pkg.patch │ ├── 6.15.y │ │ └── 001-scripts-Makefile.package-PHONY-intdeb-pkg.patch │ ├── 6.16.y │ │ └── 001-scripts-Makefile.package-PHONY-intdeb-pkg.patch │ ├── 6.6.y │ │ ├── 001-scripts-Makefile.package-PHONY-intdeb-pkg.patch │ │ └── 002-arm64-swiotlb-Reduce-the-default-size-if-no-ZONE_DMA-bouncing-needed.patch │ ├── 6.7.y │ │ └── 001-scripts-Makefile.package-PHONY-intdeb-pkg.patch │ ├── 6.8.y │ │ └── 001-scripts-Makefile.package-PHONY-intdeb-pkg.patch │ └── 6.9.y │ │ └── 001-scripts-Makefile.package-PHONY-intdeb-pkg.patch ├── userpatches │ └── README.md └── wireless │ └── rtw88 │ ├── Kconfig │ ├── Makefile │ └── hack │ ├── 001-rtw88-usb-make-work-queues-high-priority.disable │ └── 002-rtw88-decrease-the-log-level-of-tx-report.patch └── scripts ├── .aarch64 ├── .ccompile ├── .header ├── .ncompile ├── check ├── clean ├── rootfs ├── rootfs-extra ├── rpi-commit ├── rpi-linux ├── stage1 └── stage2 /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [pyavitz]# Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: pyavitz # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: ['https://www.paypal.me/pyavitz'] 13 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | The rpi-img-builder is provided under: 2 | 3 | SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note 4 | 5 | Being under the terms of the GNU General Public License version 2 only, 6 | according with: 7 | 8 | LICENSES/preferred/GPL-2.0 9 | https://github.com/torvalds/linux/blob/master/LICENSES/preferred/GPL-2.0 10 | 11 | With an explicit syscall exception, as stated at: 12 | 13 | LICENSES/exceptions/Linux-syscall-note 14 | https://github.com/torvalds/linux/blob/master/LICENSES/exceptions/Linux-syscall-note 15 | 16 | In addition, other licenses may also apply. Please see: 17 | 18 | Documentation/process/license-rules.rst 19 | https://www.kernel.org/doc/Documentation/process/license-rules.rst 20 | 21 | for more details. 22 | 23 | All contributions to the rpi-img-builder are subject to this COPYING file. 24 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .ONESHELL: 2 | .SILENT: 3 | .PHONY: clean list 4 | 5 | # header 6 | HEADER=./scripts/.header 7 | 8 | # menu 9 | MENU=./lib/dialog/menu 10 | CONF=./lib/dialog/config 11 | DIALOGRC=$(shell cp -f lib/dialog/dialogrc ~/.dialogrc) 12 | 13 | # rootfs 14 | RFS=./scripts/rootfs 15 | ROOTFS=sudo ./scripts/rootfs 16 | 17 | # kernel 18 | XLINUX=./scripts/rpi-linux 19 | LINUX=sudo ./scripts/rpi-linux 20 | 21 | # commit 22 | XCOMMIT=./scripts/rpi-commit 23 | COMMIT=sudo ./scripts/rpi-commit 24 | 25 | # stages 26 | STG1=./scripts/stage1 27 | STG2=./scripts/stage2 28 | IMAGE=sudo ./scripts/stage1 29 | 30 | # clean 31 | CLN=./scripts/clean 32 | CLEAN=sudo ./scripts/clean 33 | 34 | # purge 35 | PURGE=$(shell sudo rm -fdr source; if [ -d .cache ]; then sudo rm -f .cache/git_fast.*; fi) 36 | PURGEALL=$(shell sudo rm -fdr source output; if [ -d .cache ]; then sudo rm -f .cache/git_fast.*; fi) 37 | 38 | # miscellaneous 39 | XCHECK=./scripts/check 40 | CHECK=./scripts/check 41 | 42 | # dependencies 43 | CCOMPILE=./scripts/.ccompile 44 | NCOMPILE=./scripts/.ncompile 45 | 46 | # boards 47 | BOARDS=$(shell sudo rm -f board.txt; if [ -f lib/boards/${board} ]; then sudo cp lib/boards/${board} board.txt; fi) 48 | 49 | ifdef board 50 | include lib/boards/${board} 51 | endif 52 | 53 | define create_config 54 | @chmod go=rx files/inits/* 55 | @chmod go=rx files/scripts/* 56 | @chmod go=r files/misc/* 57 | @chmod go=r files/users/* 58 | @chmod +x ${CONF} 59 | @${CONF} 60 | endef 61 | 62 | define build_kernel 63 | @${BOARDS} 64 | @chmod +x ${XLINUX} 65 | @${LINUX} 66 | endef 67 | 68 | define build_commit 69 | @${BOARDS} 70 | @chmod +x ${XCOMMIT} 71 | @${COMMIT} 72 | endef 73 | 74 | define build_image 75 | @${BOARDS} 76 | @chmod +x ${STG1} 77 | @chmod +x ${STG2} 78 | @${IMAGE} 79 | endef 80 | 81 | define create_rootfs 82 | @${BOARDS} 83 | @chmod +x ${RFS} 84 | @${ROOTFS} 85 | endef 86 | 87 | help: 88 | @echo "" 89 | @${HEADER} 90 | @echo "" 91 | @echo "\e[1;37mCommands:\e[0m" 92 | @echo " make ccompile\t\tInstall x86-64 dependencies" 93 | @echo " make ncompile\t\tInstall Aarch64 dependencies" 94 | @echo " make config\t\t\tCreate user data file" 95 | @echo " make menu\t\t\tUser menu interface" 96 | @echo " make clean\t\t\tClean up rootfs and image errors" 97 | @echo " make purge\t\t\tRemove source directory" 98 | @echo " make purge-all\t\tRemove source and output directory" 99 | @echo " make dialogrc\t\tSet builder theme" 100 | @echo " make check\t\t\tLatest revision of selected branch" 101 | @echo "" 102 | @echo " make list\t\t\tList boards" 103 | @echo " make all board=xxx\t\tKernel > rootfs > image" 104 | @echo " make kernel board=xxx\tBuilds linux kernel package" 105 | @echo " make commit board=xxx\tBuilds linux kernel package" 106 | @echo " make rootfs board=xxx\tCreate rootfs tarball" 107 | @echo " make image board=xxx\t\tMake bootable image" 108 | @echo "" 109 | 110 | # make commands 111 | ccompile: 112 | # X86_64 dependencies: 113 | @chmod +x ${CCOMPILE} 114 | @${CCOMPILE} 115 | 116 | ncompile: 117 | # Aarch64 dependencies: 118 | @chmod +x ${NCOMPILE} 119 | @${NCOMPILE} 120 | 121 | # USER DATA 122 | config: 123 | ifdef edit 124 | @if [ -f ${edit}.txt ]; then nano ${edit}.txt; else echo "${edit}.txt: file not found"; fi 125 | exit 126 | endif 127 | $(call create_config) 128 | 129 | # MENU 130 | menu: 131 | @chmod +x ${MENU} 132 | @${MENU} 133 | 134 | # LINUX 135 | kernel: 136 | # edit user data file 137 | ifdef build 138 | @$(shell sed -i "s/^BUILD_VERSION=.*/BUILD_VERSION="'"${build}"'"/" userdata.txt) 139 | endif 140 | ifdef compiler 141 | @$(shell sed -i "s/^COMPILER=.*/COMPILER="'"${compiler}"'"/" userdata.txt) 142 | endif 143 | ifdef menuconfig 144 | @$(shell sed -i "s/^MENUCONFIG=.*/MENUCONFIG="'"${menuconfig}"'"/" userdata.txt) 145 | endif 146 | ifdef myconfig 147 | @$(shell sed -i "s/^CUSTOM_DEFCONFIG=.*/CUSTOM_DEFCONFIG="'"1"'"/" userdata.txt) 148 | @$(shell sed -i "s/^MYCONFIG=.*/MYCONFIG="'"${myconfig}_defconfig"'"/" userdata.txt) 149 | endif 150 | ifdef verbose 151 | @$(shell sed -i "s/^VERBOSE=.*/VERBOSE="'"${verbose}"'"/" userdata.txt) 152 | endif 153 | ifdef version 154 | @$(shell sed -i "s/^VERSION=.*/VERSION="'"${version}"'"/" userdata.txt) 155 | endif 156 | $(call build_kernel) 157 | 158 | commit: 159 | $(call build_commit) 160 | 161 | # ROOT FILESYSTEM 162 | rootfs: 163 | # edit user data file 164 | ifdef distro 165 | @$(shell sed -i "s/^DISTRO=.*/DISTRO="'"${distro}"'"/" userdata.txt) 166 | endif 167 | ifdef release 168 | @$(shell sed -i "s/^DISTRO_VERSION=.*/DISTRO_VERSION="'"${release}"'"/" userdata.txt) 169 | endif 170 | ifdef verbose 171 | @$(shell sed -i "s/^VERBOSE=.*/VERBOSE="'"${verbose}"'"/" userdata.txt) 172 | endif 173 | $(call create_rootfs) 174 | 175 | # IMAGE 176 | image: 177 | # edit user data file 178 | ifdef distro 179 | @$(shell sed -i "s/^DISTRO=.*/DISTRO="'"${distro}"'"/" userdata.txt) 180 | endif 181 | ifdef release 182 | @$(shell sed -i "s/^DISTRO_VERSION=.*/DISTRO_VERSION="'"${release}"'"/" userdata.txt) 183 | endif 184 | ifdef verbose 185 | @$(shell sed -i "s/^VERBOSE=.*/VERBOSE="'"${verbose}"'"/" userdata.txt) 186 | endif 187 | $(call build_image) 188 | 189 | all: 190 | $(call build_kernel) 191 | $(call create_rootfs) 192 | $(call build_image) 193 | 194 | list: 195 | # Boards 196 | @cat lib/boards/* | grep -w "PRETTY_BOARD=" | sed 's/PRETTY_BOARD=//g' | sed 's/"//g' | sed 's/BCM/bcm/g' | sed 's/bcm2711 \/ ARMHF/bcm2711v7 \/ ARMHF/g' 197 | 198 | clean: 199 | @chmod +x ${CLN} 200 | @${CLEAN} 201 | 202 | purge: 203 | # Removing source directory 204 | @${PURGE} 205 | 206 | purge-all: 207 | # Removing source and output directory 208 | @${PURGEALL} 209 | 210 | dialogrc: 211 | @${DIALOGRC} 212 | 213 | check: 214 | @chmod +x ${XCHECK} 215 | @${CHECK} 216 | 217 | reset: 218 | @$(shell sed -i "s/^BUILD_VERSION=.*/BUILD_VERSION="'"1"'"/" userdata.txt) 219 | @$(shell sed -i "s/^MENUCONFIG=.*/MENUCONFIG="'"0"'"/" userdata.txt) 220 | @$(shell sed -i "s/^CUSTOM_DEFCONFIG=.*/CUSTOM_DEFCONFIG="'"0"'"/" userdata.txt) 221 | @$(shell sed -i "s/^MYCONFIG=.*/MYCONFIG="'"_defconfig"'"/" userdata.txt) 222 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 |

Boards

3 | 4 | ```py 5 | Raspberry Pi Zero/W/1 bcm2708 / ARMEL 6 | Raspberry Pi ZeroW2/2/3 bcm2709 / ARMHF 7 | Raspberry Pi ZeroW2/3 bcm2710 / ARM64 8 | Raspberry Pi ZeroW2/3/4/400/5 bcm2711 / ARM64 9 | Raspberry Pi 4/400 bcm2711v7 / ARMHF 10 | Raspberry Pi 5 bcm2712 / ARM64 11 | ``` 12 |
13 | 14 | * [Raspberry Pi Hardware](https://www.raspberrypi.org/documentation/hardware/raspberrypi) 15 | * [The config dot txt](https://www.raspberrypi.com/documentation/computers/config_txt.html#what-is-config-txt) 16 | 17 | ### Host dependencies for Debian Bookworm and Ubuntu Jammy Jellyfish / Noble Numbat 18 | * **Debian Bookworm** (testing) 19 | * **Ubuntu Jammy Jellyfish** (recommended) 20 | * **Ubuntu Noble Numbat** (recommended) 21 | 22 | **Install options:** 23 | * Run the `./install.sh` script ***(recommended)*** 24 | * Run builder [make commands](https://github.com/pyavitz/rpi-img-builder#install-dependencies) (dependency: make) 25 | 26 | --- 27 | 28 | ### Instructions 29 | #### Install dependencies 30 | 31 | ```sh 32 | make ccompile # Install x86-64 dependencies 33 | make ncompile # Install Aarch64 dependencies 34 | ``` 35 | 36 | #### Menu interface 37 | 38 | ```sh 39 | make config # Create user data file 40 | make menu # Open menu interface 41 | make dialogrc # Set builder theme (optional) 42 | ``` 43 | 44 | #### Command list 45 | 46 | ```sh 47 | make list # List boards 48 | make all board=xxx # Kernel > rootfs > image 49 | make kernel board=xxx # Builds linux kernel package 50 | make commit board=xxx # Builds linux kernel package 51 | make rootfs board=xxx # Create rootfs tarball 52 | make image board=xxx # Make bootable image 53 | ``` 54 | 55 | #### Miscellaneous 56 | 57 | ```sh 58 | make clean # Clean up rootfs and image errors 59 | make purge # Remove source directory 60 | make purge-all # Remove source and output directory 61 | make commands # List more commands 62 | make check # Shows latest revision of selected branch 63 | ``` 64 | 65 | #### Config Menu 66 | * Review the userdata.txt file for further options: locales, timezone, nameserver(s) and extra wireless support 67 | * 1 active | 0 inactive 68 | ```sh 69 | Name: # Your name 70 | Username: # Your username 71 | Password: # Your password 72 | Enable root: # Set root password to `toor` 73 | 74 | Linux kernel 75 | Branch: # Supported: 6.1.y and above 76 | Build: # Kernel build version number 77 | Menuconfig: # Kernel menuconfig 78 | Compiler: # GNU Compiler Collection / Clang 79 | Ccache: # Compiler cache 80 | 81 | Distribution 82 | Distro: # Supported: debian, devuan and ubuntu 83 | Release: # Debian: bullseye, bookworm, testing, unstable and sid 84 | # Devuan: chimaera, daedalus, excalibur, testing, unstable and ceres 85 | # https://www.devuan.org/os/announce/excalibur-usrmerge-announce-2024-02-20.html 86 | # Ubuntu: focal, jammy and noble 87 | NetworkManager # 1 networkmanager | 0 ifupdown 88 | 89 | Customize 90 | Defconfig: # User defconfig 91 | Name: # Name of _defconfig (Must be placed in defconfig dir.) 92 | 93 | User options 94 | Verbosity: # Verbose 95 | Devel Rootfs: # Developer rootfs tarball 96 | Compress img: # Auto compress img > img.xz 97 | User scripts: # Review the README in the files/userscripts directory 98 | User service: # Create user during first boot (bypass the user information above) 99 | ``` 100 | 101 | #### Customize image 102 | * custom.txt 103 | ```sh 104 | # Image Size 105 | IMGSIZE="4096MB" 106 | 107 | # Root Filesystem Types: ext4 btrfs xfs 108 | FSTYPE="ext4" 109 | 110 | # Shrink Image 111 | SHRINK="true" 112 | 113 | # Hostname 114 | HOSTNAME="raspberrypi" 115 | 116 | # Branding: true false 117 | BRANDING="false" 118 | MOTD="Raspberry Pi" 119 | ``` 120 | 121 | #### User defconfig 122 | ```sh 123 | # Config placement: defconfig/$NAME_defconfig 124 | The config menu will append _defconfig to the end of the name 125 | in the userdata.txt file. 126 | ``` 127 | 128 | #### User patches 129 | 130 | ```sh 131 | Patches "-p1" placed in userpatches are applied during compilation. 132 | ``` 133 | 134 | #### Preferred commit 135 | ```sh 136 | # Example 137 | ENABLE_COMMIT="1" 138 | COMMIT="9ed4f05ba2e2bcd9065831674e97b2b1283e866d" 139 | ``` 140 | 141 | ### Usage 142 | * Review the [Wiki](https://github.com/pyavitz/rpi-img-builder/wiki/Options-&-Scripts) 143 | * The boot partition is labelled BOOT 144 | #### BOOT: useraccount.txt 145 | * Input your user information 146 | ```sh 147 | NAME="" # Your name 148 | USERNAME="" # Username 149 | PASSWORD="" # Password 150 | ``` 151 | 152 | #### BOOT: credentials.txt 153 | ```sh 154 | Set to ENABLE="true" and input your wifi information. 155 | ENABLE="false" # Enable service 156 | 157 | SSID="" # Service set identifier 158 | PASSKEY="" # Wifi password 159 | COUNTRYCODE="" # Your country code 160 | 161 | # set static ip (ifupdown) 162 | MANUAL="false" # Set to true to enable a static ip 163 | IPADDR="" # Static ip address 164 | NETMASK="" # Your Netmask 165 | GATEWAY="" # Your Gateway 166 | NAMESERVERS="" # Your preferred dns 167 | 168 | # set static ip (network-manager) 169 | MANUAL="false" # Set to true to enable a static ip 170 | IPADDR="" # Static ip address 171 | GATEWAY="" # Your Gateway 172 | DNS="" # Your preferred dns 173 | 174 | # change hostname 175 | HOSTNAME="raspberrypi" # Hostname 176 | 177 | For headless use: ssh user@ipaddress 178 | ``` 179 | #### System Menu: `menu-config` 180 | Main Menu 181 | 182 | --- 183 | 184 | ## Support 185 | 186 | Should you come across any bugs, feel free to either open an issue on GitHub or talk with us directly by joining our channel on Libera; [`#arm-img-builder`](irc://irc.libera.chat/#arm-img-builder) or [Discord](https://discord.gg/mypJ7NW8BG) 187 | -------------------------------------------------------------------------------- /defconfig/README.md: -------------------------------------------------------------------------------- 1 | Place your custom defconfig(s) in this directory 2 | -------------------------------------------------------------------------------- /files/firmware/UPDATE.mem: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pyavitz/rpi-img-builder/75cb958a7f6f1a95fb464a6c4bcc9d014875b51b/files/firmware/UPDATE.mem -------------------------------------------------------------------------------- /files/firmware/fw-0a5c_21e8.hcd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pyavitz/rpi-img-builder/75cb958a7f6f1a95fb464a6c4bcc9d014875b51b/files/firmware/fw-0a5c_21e8.hcd -------------------------------------------------------------------------------- /files/inits/bthelper.init: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ### BEGIN INIT INFO 3 | # Provides: bthelper 4 | # Required-Start: 5 | # Required-Stop: 6 | # Default-Start: 2 7 | # Default-Stop: 8 | # Short-Description: Raspberry Pi bluetooth helper 9 | # Description: 10 | ### END INIT INFO 11 | 12 | # chmod +x /etc/init.d/bthelper 13 | # update-rc.d bthelper defaults 2 14 | 15 | . /lib/lsb/init-functions 16 | 17 | case "$1" in 18 | start) 19 | log_daemon_msg "Raspberry Pi bluetooth helper" 20 | /usr/bin/btuart 2>/dev/null 21 | log_end_msg $? 22 | ;; 23 | *) 24 | echo "Usage: $0 start" >&2 25 | exit 3 26 | ;; 27 | esac 28 | -------------------------------------------------------------------------------- /files/inits/credentials.init: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ### BEGIN INIT INFO 3 | # Provides: credentials 4 | # Required-Start: 5 | # Required-Stop: 6 | # Default-Start: 2 7 | # Default-Stop: 0 6 8 | # Short-Description: Input wifi information on firstboot 9 | # Description: 10 | ### END INIT INFO 11 | 12 | # chmod +x /etc/init.d/credentials 13 | # update-rc.d credentials defaults 2 14 | 15 | . /lib/lsb/init-functions 16 | 17 | case "$1" in 18 | start) 19 | log_daemon_msg "Checking credentials" 20 | /usr/local/bin/credentials 2>/dev/null 21 | log_end_msg $? 22 | ;; 23 | *) 24 | echo "Usage: $0 start" >&2 25 | exit 3 26 | ;; 27 | esac -------------------------------------------------------------------------------- /files/inits/firstboot.init: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ### BEGIN INIT INFO 3 | # Provides: firstboot 4 | # Required-Start: checkfs checkroot-bootclean mountall $local_fs 5 | # Required-Stop: 6 | # Default-Start: S 7 | # Default-Stop: 8 | # Short-Description: Expands the root partition 9 | # Description: 10 | ### END INIT INFO 11 | 12 | PATH=/sbin:/usr/sbin:/bin:/usr/bin 13 | 14 | # chmod +x /etc/init.d/firstboot 15 | # update-rc.d firstboot defaults S 16 | 17 | . /lib/lsb/init-functions 18 | 19 | case "$1" in 20 | start) 21 | log_daemon_msg "Starting firstboot" 22 | /usr/local/sbin/firstboot 2>/dev/null 23 | log_end_msg $? 24 | ;; 25 | *) 26 | echo "Usage: $0 start" >&2 27 | exit 3 28 | ;; 29 | esac -------------------------------------------------------------------------------- /files/inits/governor.init: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ### BEGIN INIT INFO 3 | # Provides: governor 4 | # Required-Start: 5 | # Required-Stop: 6 | # Default-Start: 2 7 | # Default-Stop: 8 | # Short-Description: CPU frequency scaling 9 | # Description: 10 | ### END INIT INFO 11 | 12 | # chmod +x /etc/init.d/governor 13 | # update-rc.d governor defaults 2 14 | 15 | . /lib/lsb/init-functions 16 | 17 | case "$1" in 18 | start) 19 | log_daemon_msg "Governor" 20 | /usr/local/bin/governor -r 2>/dev/null 21 | log_end_msg $? 22 | ;; 23 | *) 24 | echo "Usage: $0 start" >&2 25 | exit 3 26 | ;; 27 | esac 28 | -------------------------------------------------------------------------------- /files/inits/leds.init: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ### BEGIN INIT INFO 3 | # Provides: leds 4 | # Required-Start: 5 | # Required-Stop: 6 | # Default-Start: 2 7 | # Default-Stop: 8 | # Short-Description: LED Service 9 | # Description: 10 | ### END INIT INFO 11 | 12 | # chmod +x /etc/init.d/leds 13 | # update-rc.d leds defaults 2 14 | 15 | . /lib/lsb/init-functions 16 | 17 | case "$1" in 18 | start) 19 | log_daemon_msg "LED Service" 20 | /usr/local/sbin/leds 2>/dev/null 21 | log_end_msg $? 22 | ;; 23 | *) 24 | echo "Usage: $0 start" >&2 25 | exit 3 26 | ;; 27 | esac 28 | -------------------------------------------------------------------------------- /files/inits/zramswap.init: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ### BEGIN INIT INFO 3 | # Provides: zramswap 4 | # Required-Start: 5 | # Required-Stop: 6 | # Default-Start: 2 7 | # Default-Stop: 0 6 8 | # Short-Description: Zramswap virtual memory 9 | # Description: 10 | ### END INIT INFO 11 | 12 | # chmod +x /etc/init.d/zramswap 13 | # update-rc.d zramswap defaults 2 14 | 15 | . /lib/lsb/init-functions 16 | 17 | case "$1" in 18 | start) 19 | log_daemon_msg "Mounting zramswap virtual memory" 20 | zramswap start 2>/dev/null 21 | log_end_msg $? 22 | exit 0 23 | ;; 24 | stop) 25 | log_daemon_msg "Unmounting zramswap virtual memory" 26 | zramswap stop 2>/dev/null 27 | log_end_msg $? 28 | exit 3 29 | ;; 30 | esac 31 | -------------------------------------------------------------------------------- /files/misc/10-local-rpi.rules: -------------------------------------------------------------------------------- 1 | KERNEL=="vcio", GROUP="video", MODE="0660" 2 | KERNEL=="vchiq", GROUP="video", MODE="0660" 3 | SUBSYSTEM=="vc-sm", GROUP="video", MODE="0660" 4 | KERNEL=="vcsm-cma", GROUP="video", MODE="0660" 5 | -------------------------------------------------------------------------------- /files/misc/60-rpi.gpio-common.rules: -------------------------------------------------------------------------------- 1 | SUBSYSTEM=="bcm2835-gpiomem", KERNEL=="gpiomem", GROUP="dialout", MODE="0660" 2 | SUBSYSTEM=="gpio", KERNEL=="gpiochip*", ACTION=="add", PROGRAM="/bin/sh -c 'chown root:dialout /sys/class/gpio/export /sys/class/gpio/unexport ; chmod 220 /sys/class/gpio/export /sys/class/gpio/unexport'" 3 | SUBSYSTEM=="gpio", KERNEL=="gpio*", ACTION=="add", PROGRAM="/bin/sh -c 'chown root:dialout /sys%p/active_low /sys%p/direction /sys%p/edge /sys%p/value ; chmod 660 /sys%p/active_low /sys%p/direction /sys%p/edge /sys%p/value'" 4 | -------------------------------------------------------------------------------- /files/misc/99-com.rules: -------------------------------------------------------------------------------- 1 | SUBSYSTEM=="input", GROUP="input", MODE="0660" 2 | SUBSYSTEM=="i2c-dev", GROUP="i2c", MODE="0660" 3 | SUBSYSTEM=="spidev", GROUP="spi", MODE="0660" 4 | SUBSYSTEM=="bcm2835-gpiomem", GROUP="gpio", MODE="0660" 5 | SUBSYSTEM=="rpivid-*", GROUP="video", MODE="0660" 6 | 7 | KERNEL=="vcsm-cma", GROUP="video", MODE="0660" 8 | SUBSYSTEM=="dma_heap", GROUP="video", MODE="0660" 9 | 10 | SUBSYSTEM=="gpio", GROUP="gpio", MODE="0660" 11 | SUBSYSTEM=="gpio", KERNEL=="gpiochip*", ACTION=="add", PROGRAM="/bin/sh -c 'chgrp -R gpio /sys/class/gpio && chmod -R g=u /sys/class/gpio'" 12 | SUBSYSTEM=="gpio", ACTION=="add", PROGRAM="/bin/sh -c 'chgrp -R gpio /sys%p && chmod -R g=u /sys%p'" 13 | 14 | # PWM export results in a "change" action on the pwmchip device (not "add" of a new device), so match actions other than "remove". 15 | SUBSYSTEM=="pwm", ACTION!="remove", PROGRAM="/bin/sh -c 'chgrp -R gpio /sys%p && chmod -R g=u /sys%p'" 16 | 17 | KERNEL=="ttyAMA0", PROGRAM="/bin/sh -c '\ 18 | ALIASES=/proc/device-tree/aliases; \ 19 | if cmp -s $$ALIASES/uart0 $$ALIASES/serial0; then \ 20 | echo 0;\ 21 | elif cmp -s $$ALIASES/uart0 $$ALIASES/serial1; then \ 22 | echo 1; \ 23 | else \ 24 | exit 1; \ 25 | fi\ 26 | '", SYMLINK+="serial%c" 27 | 28 | KERNEL=="ttyAMA1", PROGRAM="/bin/sh -c '\ 29 | ALIASES=/proc/device-tree/aliases; \ 30 | if [ -e /dev/ttyAMA0 ]; then \ 31 | exit 1; \ 32 | elif cmp -s $$ALIASES/uart0 $$ALIASES/serial0; then \ 33 | echo 0;\ 34 | elif cmp -s $$ALIASES/uart0 $$ALIASES/serial1; then \ 35 | echo 1; \ 36 | else \ 37 | exit 1; \ 38 | fi\ 39 | '", SYMLINK+="serial%c" 40 | 41 | KERNEL=="ttyS0", PROGRAM="/bin/sh -c '\ 42 | ALIASES=/proc/device-tree/aliases; \ 43 | if cmp -s $$ALIASES/uart1 $$ALIASES/serial0; then \ 44 | echo 0; \ 45 | elif cmp -s $$ALIASES/uart1 $$ALIASES/serial1; then \ 46 | echo 1; \ 47 | else \ 48 | exit 1; \ 49 | fi \ 50 | '", SYMLINK+="serial%c" 51 | 52 | ACTION=="add", SUBSYSTEM=="vtconsole", KERNEL=="vtcon1", RUN+="/bin/sh -c '\ 53 | if echo RPi-Sense FB | cmp -s /sys/class/graphics/fb0/name; then \ 54 | echo 0 > /sys$devpath/bind; \ 55 | fi; \ 56 | '" 57 | -------------------------------------------------------------------------------- /files/misc/profile: -------------------------------------------------------------------------------- 1 | # /etc/profile: system-wide .profile file for the Bourne shell (sh(1)) 2 | # and Bourne compatible shells (bash(1), ksh(1), ash(1), ...). 3 | 4 | if [ "`id -u`" -eq 0 ]; then 5 | PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/vc/bin" 6 | else 7 | PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/opt/vc/bin" 8 | fi 9 | export PATH 10 | 11 | if [ "${PS1-}" ]; then 12 | if [ "${BASH-}" ] && [ "$BASH" != "/bin/sh" ]; then 13 | # The file bash.bashrc already sets the default PS1. 14 | # PS1='\h:\w\$ ' 15 | if [ -f /etc/bash.bashrc ]; then 16 | . /etc/bash.bashrc 17 | fi 18 | else 19 | if [ "`id -u`" -eq 0 ]; then 20 | PS1='# ' 21 | else 22 | PS1='$ ' 23 | fi 24 | fi 25 | fi 26 | 27 | if [ -d /etc/profile.d ]; then 28 | for i in /etc/profile.d/*.sh; do 29 | if [ -r $i ]; then 30 | . $i 31 | fi 32 | done 33 | unset i 34 | fi 35 | -------------------------------------------------------------------------------- /files/misc/rpi-vc.conf: -------------------------------------------------------------------------------- 1 | # rpi userland 2 | /opt/vc/lib 3 | -------------------------------------------------------------------------------- /files/patches/raspberrypi-sys-mods-control.patch: -------------------------------------------------------------------------------- 1 | diff -Naur a/debian/control b/debian/control 2 | --- a/debian/control 2022-01-06 12:12:31.988631601 -0500 3 | +++ b/debian/control 2022-01-06 12:13:00.075783120 -0500 4 | @@ -10,7 +10,7 @@ 5 | 6 | Package: raspberrypi-sys-mods 7 | Architecture: any 8 | -Depends: ${shlibs:Depends}, ${misc:Depends}, systemd (>= 230), gettext-base 9 | +Depends: ${shlibs:Depends}, ${misc:Depends}, gettext-base 10 | Breaks: raspberrypi-ui-mods (<<1.20210706), dhcpcd5 (<<1:8.1.2-1+rpt2) 11 | Replaces: raspberrypi-ui-mods (<<1.20210706) 12 | Recommends: rfkill, rpi-eeprom 13 | -------------------------------------------------------------------------------- /files/patches/rpi-eeprom-control: -------------------------------------------------------------------------------- 1 | Source: rpi-eeprom 2 | Section: misc 3 | Priority: optional 4 | Maintainer: Serge Schneider 5 | Build-Depends: debhelper (>= 12), help2man, python3-minimal 6 | Standards-Version: 4.6.2 7 | Homepage: https://github.com/raspberrypi/rpi-eeprom/ 8 | Vcs-Browser: https://github.com/raspberrypi/rpi-eeprom/ 9 | Vcs-Git: https://github.com/raspberrypi/rpi-eeprom.git 10 | 11 | Package: rpi-eeprom 12 | Architecture: all 13 | Depends: ${shlibs:Depends}, ${misc:Depends}, python3, binutils, pciutils 14 | Breaks: rpi-eeprom-images (<<7.2) 15 | Replaces: rpi-eeprom-images (<<7.2) 16 | Recommends: flashrom 17 | Provides: rpi-eeprom-images 18 | Description: Raspberry Pi 4 boot EEPROM updater 19 | Checks whether the Raspberry Pi bootloader EEPROM is up-to-date and updates 20 | the EEPROM. 21 | 22 | Package: rpi-eeprom-images 23 | Architecture: all 24 | Depends: ${misc:Depends}, rpi-eeprom (>=7.2) 25 | Priority: optional 26 | Section: oldlibs 27 | Description: transitional package 28 | This is a transitional package. It can safely be removed. 29 | -------------------------------------------------------------------------------- /files/patches/rpi-eeprom-update.patch: -------------------------------------------------------------------------------- 1 | Description: 2 | TODO: Put a short summary on the line above and replace this paragraph 3 | with a longer explanation of this change. Complete the meta-information 4 | with other relevant fields (see below for details). To make it easier, the 5 | information below has been extracted from the changelog. Adjust it or drop 6 | it. 7 | . 8 | rpi-eeprom (5.2-1) buster; urgency=medium 9 | . 10 | [ andrum99 ] 11 | * release-notes.md - fix typos 12 | . 13 | [ Tim Gover ] 14 | * pieeprom-2020-03-16 - Minor fix for Option97 GUID 15 | * pieeprom-2020-03-19: Minor fixes for manufacture test 16 | Author: Serge Schneider 17 | 18 | --- 19 | The information above should follow the Patch Tagging Guidelines, please 20 | checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here 21 | are templates for supplementary fields that you might want to add: 22 | 23 | Origin: , 24 | Bug: 25 | Bug-Debian: https://bugs.debian.org/ 26 | Bug-Ubuntu: https://launchpad.net/bugs/ 27 | Forwarded: 28 | Reviewed-By: 29 | Last-Update: 2020-03-23 30 | 31 | --- rpi-eeprom-5.2.orig/rpi-eeprom-update 32 | +++ rpi-eeprom-5.2/rpi-eeprom-update 33 | @@ -1,5 +1,5 @@ 34 | #!/bin/sh 35 | - 36 | +PATH="$PATH:/opt/vc/bin" 37 | # Raspberry Pi4 boot EEPROM updater. 38 | 39 | set -e 40 | -------------------------------------------------------------------------------- /files/patches/userland-remove-hi-pi.patch: -------------------------------------------------------------------------------- 1 | diff -Naur a/makefiles/cmake/vmcs.cmake b/makefiles/cmake/vmcs.cmake 2 | --- a/makefiles/cmake/vmcs.cmake 2023-04-21 15:51:40.011830638 -0400 3 | +++ b/makefiles/cmake/vmcs.cmake 2023-04-21 15:53:51.268505442 -0400 4 | @@ -59,8 +59,8 @@ 5 | # PERMISSIONS OWNER_WRITE WORLD_READ) 6 | 7 | # provide hello_pi demos 8 | -install(DIRECTORY host_applications/linux/apps/hello_pi 9 | - DESTINATION ${VMCS_INSTALL_PREFIX}/src) 10 | +#install(DIRECTORY host_applications/linux/apps/hello_pi 11 | +# DESTINATION ${VMCS_INSTALL_PREFIX}/src) 12 | 13 | # provide header files 14 | #install(DIRECTORY host_applications/linux/libs/bcm_host/include 15 | -------------------------------------------------------------------------------- /files/scripts/00-header: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source /etc/default/dynamic-motd 3 | UNAME_R=$(uname -r) 4 | UNAME_V=$(uname -v | sed 's/ SMP//g' | sed 's/ PREEMPT//g') 5 | UNAME_M=$(uname -m) 6 | # Ubuntu 7 | if [[ -f "/etc/lsb-release" ]]; then 8 | [ -r /etc/lsb-release ] && . /etc/lsb-release 9 | if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then 10 | # Fall back to using the very slow lsb_release utility 11 | DISTRIB_DESCRIPTION=$(lsb_release -s -d) 12 | fi 13 | HEADER=$(printf "%s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$UNAME_R" "$UNAME_V" "$UNAME_M") 14 | figlet ${H_POS} -f term $HEADER 15 | else 16 | # Debian / Devuan 17 | if [[ -f "/etc/os-release" ]]; then 18 | [ -r /etc/os-release ] && . /etc/os-release 19 | if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then 20 | # Fall back to using the very slow lsb_release utility 21 | DISTRIB_DESCRIPTION=$(lsb_release -s -d) 22 | fi 23 | HEADER=$(printf "%s %s %s %s\n" "$DISTRIB_DESCRIPTION" "$UNAME_R" "$UNAME_V" "$UNAME_M") 24 | figlet ${H_POS} -f term $HEADER 25 | else 26 | uname -snrvm 27 | fi 28 | fi 29 | -------------------------------------------------------------------------------- /files/scripts/15-brand: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source /etc/opt/board.txt 3 | source /etc/default/dynamic-motd 4 | 5 | if [[ "$BRANDING" == "true" ]]; then 6 | echo ""; 7 | toilet -f ${T_FONT} --filter ${T_FILTER} $MOTD; 8 | echo ""; 9 | else 10 | if [[ -f "/proc/device-tree/model" ]]; then 11 | MODEL=$(tr -d '\0' /dev/null 2>&1; then 22 | if [[ `ls /sys/class/hwmon/hwmon*[0-9]*/fan1_input` ]] > /dev/null 2>&1 || \ 23 | [[ `ls /sys/class/hwmon/hwmon*[0-9]*/pwm1_enable` ]] > /dev/null 2>&1; then 24 | FAN="true" 25 | HWMON=`ls /sys/class/hwmon/hwmon*[0-9]*/pwm1 | grep -ohE 'hwmon[0-9][^ ]' | sed 's/.$//'` 26 | fi 27 | else 28 | FAN="false" 29 | fi 30 | if [[ `ls /sys/class/nvme/nvme[0-9]/hwmon[0-9]/temp[0-9]_input` ]] > /dev/null 2>&1; then 31 | NVME="true" 32 | NVMET=$(cat /sys/class/nvme/nvme[0-9]/hwmon[0-9]/temp[0-9]_input | cut -c1-2 | sed s/$/°C/ | tr '\n' ' ') 33 | else 34 | NVME="false" 35 | fi 36 | if [[ `ls /sys/class/scsi_device/[0-9]:[0-9]:[0-9]:[0-9]/device/hwmon/hwmon[0-9]/temp1_input` ]] > /dev/null 2>&1; then 37 | SSD="true" 38 | SSDT=$(cat /sys/class/scsi_device/[0-9]:[0-9]:[0-9]:[0-9]/device/hwmon/hwmon[0-9]/temp1_input | cut -c1-2 | sed s/$/°C/ | tr '\n' ' ') 39 | else 40 | SSD="false" 41 | fi 42 | 43 | NETWORK=$(ip -o -4 -br a | grep -v '^lo'| sed 's/^/ /' | sed 's/\/..//' | sed -r '1s/\s+/ /g' | sed -r '2s/\s+/ /g') 44 | DOCKER=`echo -e Docker:` 45 | ETH=`echo -e Wired:` 46 | HA=`echo -e Hassio:` 47 | HCI=$(hcitool dev | sed "s/^[ \t]*//" | sed '1d' | sed 's/[[:blank:]]/ /g') 48 | USB=`echo -e Tether:` 49 | WLAN=`echo -e Wireless:` 50 | 51 | # functions 52 | count_high (){ 53 | echo -en "Processors: "$CPU0; echo -en " @ $CPU0M"; echo -en "MHz $CPU0T°C"; 54 | echo -en "," $CPU1; echo -en " @ $CPU1M"; echo -e "MHz $CPU1T°C"; 55 | echo -en "Frequencies: "$CPU0C; echo -en "MHz $CPU1C"; echo -e "MHz" 56 | } 57 | 58 | count_low (){ 59 | echo -en "Processor: "$CPU0; echo -en " @ $CPU0M"; echo -e "MHz $CPU0T°C"; 60 | echo -en "Frequency: "$CPU0C; echo -e "MHz"; 61 | } 62 | 63 | cpu_hwinfo (){ 64 | if [[ "$PRESENT" == "0-7" || "$PRESENT" == "0-5" ]]; then 65 | count_high; 66 | fi 67 | if [[ "$PRESENT" == "0-3" || "$PRESENT" == "0-1" || "$PRESENT" == "0" ]]; then 68 | count_low; 69 | fi 70 | } 71 | 72 | fan_pwr (){ 73 | MODEL=$(tr -d '\0' /dev/null 2>&1; then 76 | RPM=`cat /sys/class/hwmon/${HWMON}/fan1_input` 77 | echo -e "Fan: RPM ${RPM}, PWR ${PWM}" 78 | else 79 | if [[ "$PWM" == "0" ]]; then 80 | echo -e "Fan: OFF, PWR ${PWM}" 81 | else 82 | echo -e "Fan: ON, PWR ${PWM}" 83 | fi 84 | fi 85 | } 86 | 87 | # display 88 | echo -e "── \e[1mDISK\e[0m" 89 | df -h | egrep '(Filesystem)|(/dev/mmc)|(/dev/root)|(/dev/sd)|(/dev/nvme)' 90 | echo "" 91 | echo -e "── \e[1mNETWORK\e[0m" 92 | echo -e "Hostname: $(hostname)" 93 | echo -e "$NETWORK" | sed "s/^[ \t]*//" | \ 94 | sed "s/eth0/$ETH eth0/g" | sed "s/eth1/$ETH eth1/g" | sed "s/eth2/$ETH eth2/g" | \ 95 | sed "s/wlan0/$WLAN wlan0/g" | sed "s/wlan1/$WLAN wlan1/g" | sed "s/wlan2/$WLAN wlan2/g" | \ 96 | sed "s/usb0/$USB usb0/g" | sed "s/usb1/$USB usb1/g" | \ 97 | sed "s/hassio/$HA hassio/g" | sed "s/docker0/$DOCKER docker0/g" 98 | if [[ `command -v hcitool` ]] && [[ ! -z "$HCI" ]]; then echo -en "Bluetooth: "; echo "$HCI"; fi 99 | echo "" 100 | echo -e "── \e[1mSYSTEM\e[0m" 101 | if [[ -f "/sys/devices/system/cpu/present" ]]; then cpu_hwinfo; fi 102 | echo -e "Online: " $(lscpu | grep -w "On-line CPU(s) list:" | sed "s/On-line CPU(s) list:/ /g" | sed -e "s/\s\{3,\}//g") 103 | if [[ "$FAN" == "true" ]]; then fan_pwr; fi 104 | if [[ "$NVME" == "true" ]]; then echo -e "NVMe: ${NVMET}"; fi 105 | if [[ "$SSD" == "true" ]]; then echo -e "SSD: ${SSDT}"; fi 106 | echo -e "Governor: " $(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor) 107 | echo -e "Memory: " $(free -h | sed 's/i//g' | sed 's/Mem://g' | awk '{print $1" "$2}' | sed -n 'n;p') 108 | echo -e "Entropy: " $(cat /proc/sys/kernel/random/entropy_avail) 109 | echo -e "Uptime: " $(uptime) 110 | -------------------------------------------------------------------------------- /files/scripts/90-dynamic-motd: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -f /etc/default/dynamic-motd ]; then 4 | source /etc/default/dynamic-motd; 5 | if [[ "$MENUCONFIG" == "true" ]]; then 6 | # menu-config 7 | echo ""; 8 | echo -e "To configure your Raspberry Pi run 'menu-config'"; 9 | # run once and disable 10 | sed -i 's/MENUCONFIG="true"/MENUCONFIG="false"/g' /etc/default/dynamic-motd; 11 | fi 12 | fi 13 | -------------------------------------------------------------------------------- /files/scripts/firstboot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin 4 | 5 | if [[ -f "/etc/opt/board.txt" ]]; then . /etc/opt/board.txt; fi 6 | 7 | DISTRO=`cat /etc/os-release | grep -w NAME | sed 's/NAME=//g' | sed 's/"//g' | sed 's/ GNU\/Linux//g'` 8 | BOOT=`findmnt -v -n -o SOURCE /boot/broadcom` 9 | ROOTFS=`findmnt -v -n -o SOURCE /` 10 | GROW=`findmnt -v -n -o SOURCE / | sed 's/p/ /'` 11 | GROW_SD=`findmnt -v -n -o SOURCE / | sed 's/./& /8'` 12 | 13 | disable_bthelper(){ 14 | RPI_REV=`cat /proc/cpuinfo | grep Raspberry | sed 's/[^ ]* //' | sed 's/://g' | sed -e 's/^[ \t]*//'` 15 | if [[ "$RPI_REV" == "Raspberry Pi Model B Rev 1" || "$RPI_REV" == "Raspberry Pi Model B Rev 2" || \ 16 | "$RPI_REV" == "Raspberry Pi 2 Model B" || "$RPI_REV" == "Raspberry Pi 2 Model B rev 1.2" ]]; then 17 | update-rc.d -f bthelper remove 18 | fi 19 | } 20 | 21 | # expand root filesystem 22 | if [[ "$DISTRO" == "Devuan" ]]; then 23 | echo "" 24 | echo -e " \033[1mExpanding root filesystem\033[0m ..." 25 | fi 26 | if [[ `findmnt -v -n -o SOURCE / | grep "mmc"` ]] || [[ `findmnt -v -n -o SOURCE / | grep "nvme"` ]]; then 27 | bash growpart $GROW > /dev/null 2>&1 28 | fi 29 | if [[ `findmnt -v -n -o SOURCE / | grep "sd"` ]]; then 30 | bash growpart $GROW_SD > /dev/null 2>&1 31 | fi 32 | sleep .50 33 | if [[ `findmnt -v -n -o FSTYPE / | grep -w "ext4"` ]]; then 34 | resize2fs $ROOTFS > /dev/null 2>&1 35 | fi 36 | if [[ `findmnt -v -n -o FSTYPE / | grep -w "btrfs"` ]]; then 37 | btrfs filesystem resize max / > /dev/null 2>&1 38 | fi 39 | if [[ `findmnt -v -n -o FSTYPE / | grep -w "xfs"` ]]; then 40 | xfs_growfs -d / > /dev/null 2>&1 41 | fi 42 | 43 | # boot partition 44 | if [[ -d "/boot/broadcom" ]]; then 45 | if [[ "$DISTRO" == "Devuan" ]]; then echo -e " \033[1mRunning fsck on boot partition\033[0m ..."; fi 46 | umount /boot/broadcom 47 | sleep .75 48 | bash fsck.fat -trawl $BOOT > /dev/null 2>&1 49 | sleep .75 50 | mount /boot/broadcom 51 | sleep .75 52 | fi 53 | if [[ "$ARCH" == "arm" ]]; then 54 | ROOT_PARTUUID=`blkid -o export -- $ROOTFS | sed -ne 's/^PARTUUID=//p'` 55 | if [[ `findmnt -v -n -o FSTYPE / | grep -w "ext4"` ]]; then ROOTFSTYPE="rootfstype=ext4"; fi 56 | if [[ `findmnt -v -n -o FSTYPE / | grep -w "btrfs"` ]]; then ROOTFSTYPE="rootfstype=btrfs rootflags=subvol=@"; fi 57 | if [[ `findmnt -v -n -o FSTYPE / | grep -w "xfs"` ]]; then ROOTFSTYPE="rootfstype=xfs"; fi 58 | rm -f /boot/broadcom/cmdline.txt 59 | tee /boot/broadcom/cmdline.txt < /etc/modprobe.d/cfg80211.conf 15 | iw reg set ${COUNTRYCODE} 16 | sleep 2 17 | ifdown wlan0 18 | sleep .75 19 | ifconfig wlan0 up 20 | ifup wlan0 21 | } 22 | 23 | static (){ 24 | sed -i '22s/.*/iface wlan0 inet static/' /etc/network/interfaces 25 | sed -i "24s/.*/ address ${IPADDR}/" /etc/network/interfaces 26 | sed -i "25s/.*/ netmask ${NETMASK}/g" /etc/network/interfaces 27 | sed -i "26s/.*/ gateway ${GATEWAY}/g" /etc/network/interfaces 28 | sed -i "27s/.*/ dns-nameservers ${NAMESERVERS}/g" /etc/network/interfaces 29 | if [[ -f "/etc/default/crda" ]]; then sed -i "s/REGDOMAIN=/REGDOMAIN=${COUNTRYCODE}/g" /etc/default/crda; fi 30 | sed -i "s/country=US/country=${COUNTRYCODE}/g" /etc/wpa_supplicant/wpa_supplicant.conf 31 | sed -i 's/ssid="mywifissid"/ssid="'"${SSID}"'"/g' /etc/wpa_supplicant/wpa_supplicant.conf 32 | sed -i 's/psk="wifipasskey"/psk="'"${PASSKEY}"'"/g' /etc/wpa_supplicant/wpa_supplicant.conf 33 | echo "options cfg80211 ieee80211_regdom=${COUNTRYCODE}" > /etc/modprobe.d/cfg80211.conf 34 | iw reg set ${COUNTRYCODE} 35 | sleep 2 36 | ifdown wlan0 37 | sleep .75 38 | ifconfig wlan0 up 39 | ifup wlan0 40 | } 41 | 42 | # generate new ssh keys and machine-id 43 | sleep .50 44 | rm -f /etc/ssh/ssh_host_* 45 | dpkg-reconfigure openssh-server 46 | service ssh restart 47 | sleep .50 48 | rm -f /etc/machine-id 49 | rm -f /var/lib/dbus/machine-id 50 | dbus-uuidgen --ensure=/etc/machine-id 51 | dbus-uuidgen --ensure 52 | 53 | # change hostname 54 | if ! [[ "$CURRENT_HOSTNAME" == "$HOSTNAME" ]]; then 55 | sed -i "s/${CURRENT_HOSTNAME}/${HOSTNAME}/g" /etc/hostname 56 | sed -i "s/${CURRENT_HOSTNAME}/${HOSTNAME}/g" /etc/hosts 57 | sleep .75 58 | if [[ "$DISTRO" == "Devuan" ]]; then 59 | service hostname.sh --full-restart 60 | else 61 | hostnamectl set-hostname ${HOSTNAME} 62 | fi 63 | service avahi-daemon restart 64 | fi 65 | 66 | # check credentials 67 | if [[ "$ENABLE" =~ ^(true|yes)$ ]]; then 68 | if [[ "$MANUAL" =~ ^(true|yes)$ ]]; then static; else dhcp; fi 69 | fi 70 | 71 | # Restart ifup@wlan0 systemd service 72 | if [[ `systemctl status ifup@wlan0.service | grep -w "failed"` ]]; then systemctl restart ifup@wlan0.service; fi 73 | 74 | # fixup resolv on Ubuntu Focal 75 | if [[ "$DISTRO_CODENAME" == "focal" ]] && [[ ! -f "/etc/resolv.conf" ]]; then 76 | if [[ -f "/run/systemd/resolve/stub-resolv.conf" ]]; then ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf; fi 77 | fi 78 | 79 | # clean 80 | if [[ -f "/etc/init.d/credentials" ]]; then update-rc.d -f credentials remove; fi 81 | if [[ -f "/etc/systemd/system/credentials.service" ]]; then systemctl disable credentials; fi 82 | rm -f /boot/broadcom/credentials.txt 83 | rm -f /usr/local/bin/credentials 84 | 85 | exit 0 86 | -------------------------------------------------------------------------------- /files/scripts/leds.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Bind root activity to green LED 3 | # Turn off power LED 4 | 5 | # foundation kernel 6 | if [ -f /sys/class/leds/led0/trigger ]; then 7 | ACT="led0" 8 | fi 9 | if [ -f /sys/class/leds/led1/brightness ]; then 10 | PWR="led1" 11 | fi 12 | # mainline kernel 13 | if [ -f /sys/class/leds/ACT/trigger ]; then 14 | ACT="ACT" 15 | fi 16 | if [ -f /sys/class/leds/PWR/brightness ]; then 17 | PWR="PWR" 18 | fi 19 | 20 | if [ -f /sys/class/leds/$ACT/trigger ]; then 21 | ROOT_DEVICE=`findmnt -v -n -o SOURCE /` 22 | ROOT_DEVICE=${ROOT_DEVICE/\/dev\//} 23 | ROOT_DEVICE=${ROOT_DEVICE/mmcblk/mmc} 24 | ROOT_DEVICE=${ROOT_DEVICE/p[0-9]/} 25 | echo -n "$ROOT_DEVICE" > /sys/class/leds/$ACT/trigger 26 | fi 27 | 28 | if [ -f /sys/class/leds/$PWR/brightness ]; then 29 | echo "0" > /sys/class/leds/$PWR/brightness 30 | fi 31 | -------------------------------------------------------------------------------- /files/scripts/networkmanager.credentials: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DISTRO=`cat /etc/os-release | grep -w NAME | sed 's/NAME=//g' | sed 's/"//g' | sed 's/ GNU\/Linux//g'` 4 | DISTRO_CODENAME=`cat /etc/os-release | grep -w "VERSION_CODENAME" | sed 's/VERSION_CODENAME=//g'` 5 | CURRENT_HOSTNAME=`cat /etc/hostname | sed -n '1p'` 6 | if [[ -f "/boot/broadcom/credentials.txt" ]]; then . /boot/broadcom/credentials.txt; fi 7 | 8 | # functions 9 | dhcp(){ 10 | if [[ -f "/etc/default/crda" ]]; then sed -i "s/REGDOMAIN=/REGDOMAIN=${COUNTRYCODE}/g" /etc/default/crda; fi 11 | echo "options cfg80211 ieee80211_regdom=${COUNTRYCODE}" > /etc/modprobe.d/cfg80211.conf 12 | iw reg set ${COUNTRYCODE} 13 | nmcli c add type wifi con-name ${SSID} ifname wlan0 ssid ${SSID} 14 | nmcli c modify ${SSID} wifi-sec.key-mgmt wpa-psk wifi-sec.psk ${PASSKEY} 15 | nmcli c up ${SSID} 16 | } 17 | 18 | static(){ 19 | if [[ -f "/etc/default/crda" ]]; then sed -i "s/REGDOMAIN=/REGDOMAIN=${COUNTRYCODE}/g" /etc/default/crda; fi 20 | echo "options cfg80211 ieee80211_regdom=${COUNTRYCODE}" > /etc/modprobe.d/cfg80211.conf 21 | iw reg set ${COUNTRYCODE} 22 | nmcli c add type wifi con-name ${SSID} ifname wlan0 ssid ${SSID} 23 | nmcli c modify ${SSID} wifi-sec.key-mgmt wpa-psk wifi-sec.psk ${PASSKEY} 24 | nmcli con mod ${SSID} ipv4.addresses ${IPADDR}/24 25 | nmcli con mod ${SSID} ipv4.gateway ${GATEWAY} 26 | nmcli con mod ${SSID} ipv4.method manual 27 | nmcli con mod ${SSID} ipv4.dns "${DNS}" 28 | nmcli c up ${SSID} 29 | } 30 | 31 | # generate new ssh keys and machine-id 32 | sleep 1s 33 | rm -f /etc/ssh/ssh_host_* 34 | dpkg-reconfigure openssh-server 35 | service ssh restart 36 | rm -f /etc/machine-id 37 | rm -f /var/lib/dbus/machine-id 38 | dbus-uuidgen --ensure=/etc/machine-id 39 | dbus-uuidgen --ensure 40 | 41 | # change hostname 42 | if ! [[ "$CURRENT_HOSTNAME" == "$HOSTNAME" ]]; then 43 | sed -i "s/${CURRENT_HOSTNAME}/${HOSTNAME}/g" /etc/hostname 44 | sed -i "s/${CURRENT_HOSTNAME}/${HOSTNAME}/g" /etc/hosts 45 | sleep .75 46 | if [[ "$DISTRO" == "Devuan" ]]; then 47 | service hostname.sh --full-restart 48 | else 49 | hostnamectl set-hostname ${HOSTNAME} 50 | fi 51 | service avahi-daemon restart 52 | fi 53 | 54 | # check credentials 55 | if [[ "$ENABLE" =~ ^(true|yes)$ ]]; then 56 | if [[ "$MANUAL" =~ ^(true|yes)$ ]]; then static; else dhcp; fi 57 | fi 58 | 59 | # fixup resolv on Ubuntu Focal 60 | if [[ "$DISTRO_CODENAME" == "focal" ]] && [[ ! -f "/etc/resolv.conf" ]]; then 61 | if [[ -f "/run/systemd/resolve/stub-resolv.conf" ]]; then ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf; fi 62 | fi 63 | 64 | # clean 65 | if [[ -f "/etc/init.d/credentials" ]]; then update-rc.d -f credentials remove; fi 66 | if [[ -f "/etc/systemd/system/credentials.service" ]]; then systemctl disable credentials; fi 67 | rm -f /boot/broadcom/credentials.txt 68 | rm -f /usr/local/bin/credentials 69 | 70 | exit 0 71 | -------------------------------------------------------------------------------- /files/scripts/setup: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [[ -f "/etc/opt/board.txt" ]]; then 4 | . /etc/opt/board.txt 5 | fi 6 | DISTRO=`cat /etc/os-release | grep -w NAME | sed 's/NAME=//g' | sed 's/"//g' | sed 's/ GNU\/Linux//g'` 7 | 8 | if [ $# -eq 0 ]; then 9 | echo -e "Missing options!" 10 | echo "(run $0 -h for help)" 11 | echo "" 12 | exit 0 13 | fi 14 | 15 | while getopts "rh" OPTION; do 16 | case $OPTION in 17 | r) 18 | echo "" 19 | echo -e "Running System Setup ..." 20 | sleep .75 21 | sudo dpkg-reconfigure locales tzdata keyboard-configuration console-setup 22 | if [[ "$DISTRO" == "Devuan" ]]; then 23 | sudo service console-setup.sh restart 24 | else 25 | sudo service console-setup restart 26 | fi 27 | sleep .50 28 | if [[ `curl -I https://github.com 2>&1 | grep 'HTTP/2 200'` ]]; then 29 | if [[ "$DISTRO" == "Ubuntu" ]]; then echo ""; fi 30 | echo "Reconfiguring debconf ..." 31 | if [[ `command -v tasksel` ]]; then 32 | :; 33 | else 34 | sudo apt update 35 | sudo apt install -y tasksel 36 | fi 37 | sleep .75 38 | sudo apt-get update 39 | sudo apt-get install --reinstall debconf 40 | sudo dpkg-reconfigure tasksel 41 | echo "Done." 42 | echo "" 43 | fi 44 | sleep .50 45 | sudo update-ca-certificates -f 46 | echo "" 47 | echo -e "Setup complete." 48 | exit 0 49 | ;; 50 | h) 51 | echo "" 52 | echo -e " -r Run setup" 53 | echo "" 54 | exit 0 55 | ;; 56 | esac 57 | done 58 | 59 | exit 0 60 | -------------------------------------------------------------------------------- /files/scripts/smon: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | sudo watch -n1 /usr/local/bin/sysinfo -r 3 | -------------------------------------------------------------------------------- /files/scripts/systemd-binfmt-fixups: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Description: Systemd binfmt fixups 3 | # Destination: /usr/local/sbin/systemd-binfmt-fixups 4 | 5 | DISTRO=`cat /etc/os-release | grep -w NAME | sed 's/NAME=//g' | sed 's/"//g' | sed 's/ GNU\/Linux//g'` 6 | DISTRO_CODENAME=`cat /etc/os-release | grep -w "VERSION_CODENAME" | sed 's/VERSION_CODENAME=//g'` 7 | KERNEL_RELEASE=`ls /boot/config-* | sed 's/\/boot\/config-//g' | sed -e 's/^\(.\{4\}\).*/\1/' | sed 's/-//g' | sed -r 's/\.$//'` 8 | 9 | if [[ "$KERNEL_RELEASE" == "5.10" || "$KERNEL_RELEASE" == "5.15" || "$KERNEL_RELEASE" == "6.1" ]] > /dev/null 2>&1; then 10 | # if LTS before 6.6 exit script 11 | exit 0 12 | fi 13 | 14 | if [[ "$DISTRO_CODENAME" == "bookworm" ]]; then 15 | /usr/sbin/update-binfmts --enable python3.11 > /dev/null 2>&1 16 | sleep .75 17 | systemctl restart systemd-binfmt.service > /dev/null 2>&1 18 | fi 19 | 20 | exit 0 21 | -------------------------------------------------------------------------------- /files/useracct/useraccount: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [[ -f "/etc/opt/board.txt" ]]; then . /etc/opt/board.txt; fi 4 | if [[ -f "/boot/broadcom/useraccount.txt" ]]; then . /boot/broadcom/useraccount.txt; fi 5 | DISTRO=`cat /etc/os-release | grep -w NAME | sed 's/NAME=//g' | sed 's/"//g' | sed 's/ GNU\/Linux//g'` 6 | 7 | create_user (){ 8 | if [[ ! -z "$NAME" ]]; then NAME=`echo $NAME | sed 's/ //g'`; else NAME=`echo ${BOARD} | sed 's/ //g'`; fi 9 | if [[ ! -z "$USERNAME" ]]; then :; else USERNAME="pi"; fi 10 | if [[ ! -z "$PASSWORD" ]]; then :; else PASSWORD="board"; fi 11 | adduser ${USERNAME} --gecos ${NAME} --disabled-password 12 | echo "${USERNAME}:${PASSWORD}" | chpasswd 13 | adduser ${USERNAME} sudo 14 | adduser ${USERNAME} audio 15 | adduser ${USERNAME} dialout 16 | adduser ${USERNAME} video 17 | adduser ${USERNAME} disk 18 | adduser ${USERNAME} plugdev 19 | adduser ${USERNAME} netdev 20 | adduser ${USERNAME} bluetooth 21 | adduser ${USERNAME} input 22 | adduser ${USERNAME} render 23 | adduser ${USERNAME} tty 24 | adduser ${USERNAME} i2c 25 | if [[ `grep -w "gpio" "/etc/group"` ]]; then 26 | adduser ${USERNAME} gpio 27 | else 28 | groupadd gpio; 29 | adduser ${USERNAME} gpio 30 | fi 31 | if [[ `grep -w "spi" "/etc/group"` ]]; then 32 | adduser ${USERNAME} spi 33 | else 34 | groupadd spi; 35 | adduser ${USERNAME} spi 36 | fi 37 | } 38 | 39 | create_sudoers(){ 40 | rm -f /etc/sudoers.d/010_pi-nopasswd 41 | tee /etc/sudoers.d/010_${USERNAME}-nopasswd < /dev/null 2>&1 58 | else 59 | systemctl disable useraccount > /dev/null 2>&1 60 | fi 61 | sleep .75 62 | if [[ -d "/home/${USERNAME}" ]]; then 63 | sleep 1s 64 | mkdir -p /home/${USERNAME}/.config/mc/ 65 | mv -f /etc/opt/user-ini /home/${USERNAME}/.config/mc/ini 66 | mv -f /etc/opt/nanorc-user /home/${USERNAME}/.nanorc 67 | chown -R ${USERNAME}:${USERNAME} /home/${USERNAME} 68 | rm -f /etc/opt/{nanorc-user,user-ini} 69 | fi 70 | if [[ "$DISTRO" == "Devuan" ]]; then clear -x; fi 71 | 72 | exit 0 73 | -------------------------------------------------------------------------------- /files/useracct/useraccount.init: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ### BEGIN INIT INFO 3 | # Provides: User Account 4 | # Required-Start: $all 5 | # Required-Stop: 6 | # Default-Start: 2 3 4 5 7 | # Default-Stop: 0 6 8 | # Short-Description: Creates a user account on firstboot 9 | # Description: 10 | ### END INIT INFO 11 | 12 | # chmod +x /etc/init.d/useraccount 13 | # update-rc.d useraccount defaults 5 14 | 15 | . /lib/lsb/init-functions 16 | . /boot/broadcom/useraccount.txt 17 | 18 | case "$1" in 19 | start) 20 | /usr/local/sbin/useraccount 21 | exit 0 22 | ;; 23 | *) 24 | echo "Usage: $0 start" >&2 25 | exit 3 26 | ;; 27 | esac 28 | -------------------------------------------------------------------------------- /files/useracct/useraccount.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=User Account 3 | After=firstboot.service network.target 4 | Before=sshd.service systemd-logind.service getty@tty1.service credentials.service 5 | 6 | [Service] 7 | Type=oneshot 8 | ExecStart=/usr/local/sbin/useraccount 9 | TimeoutSec=0 10 | #RemainAfterExit=yes 11 | StandardOutput=journal+console 12 | StandardError=journal+console 13 | 14 | [Install] 15 | WantedBy=default.target 16 | RequiredBy=sshd.service systemd-logind.service getty@tty1.service 17 | -------------------------------------------------------------------------------- /files/useracct/useraccount.txt: -------------------------------------------------------------------------------- 1 | # Input user information 2 | 3 | NAME="" 4 | USERNAME="" 5 | PASSWORD="" 6 | -------------------------------------------------------------------------------- /files/users/darkgreen.ini: -------------------------------------------------------------------------------- 1 | [skin] 2 | description=darkcourses green by bohoomil 3 | 4 | [Lines] 5 | horiz=─ 6 | vert=│ 7 | lefttop=┌ 8 | righttop=┐ 9 | leftbottom=└ 10 | rightbottom=┘ 11 | topmiddle=─ 12 | bottommiddle=─ 13 | leftmiddle=├ 14 | rightmiddle=┤ 15 | cross=┼ 16 | dhoriz=─ 17 | dvert=│ 18 | dlefttop=┌ 19 | drighttop=┐ 20 | dleftbottom=└ 21 | drightbottom=┘ 22 | dtopmiddle=─ 23 | dbottommiddle=─ 24 | dleftmiddle=├ 25 | drightmiddle=┤ 26 | 27 | [core] 28 | _default_=gray;default 29 | selected=black;green 30 | marked=default;red 31 | markselect=default;magenta 32 | gauge=black;lightgray 33 | input=default;black 34 | inputunchanged=black;green 35 | inputmark=cyan;black 36 | disabled=gray;black 37 | reverse=brightgreen;default 38 | commandlinemark=black;lightgray 39 | header=green;black 40 | inputhistory=blue;default 41 | commandhistory=cyan;default 42 | 43 | [dialog] 44 | _default_=lightgray;black 45 | dfocus=white;green 46 | dhotnormal=blue;black 47 | dhotfocus=black;green 48 | dtitle=green;black 49 | 50 | [error] 51 | _default_=white;red 52 | errdfocus=black;lightgray 53 | errdhotnormal=yellow;red 54 | errdhotfocus=yellow;lightgray 55 | errdtitle=yellow;red 56 | 57 | [filehighlight] 58 | directory=lightgray; 59 | executable=brightgreen; 60 | symlink=brightcyan; 61 | stalelink=brightred; 62 | device=brightmagenta; 63 | special=gray; 64 | core=red; 65 | temp=gray; 66 | archive=brightred; 67 | doc=green; 68 | source=brightcyan; 69 | media=cyan; 70 | audio1=blue; 71 | audio2=brightblue; 72 | vid1=green; 73 | vid2=brightgreen; 74 | graph=brightmagenta; 75 | database=brightred; 76 | text=lightgray; 77 | markup=cyan; 78 | html=brown; 79 | ebook=magenta; 80 | ebook2=brown; 81 | ps=yellow; 82 | 83 | [menu] 84 | _default_=lightgray;black 85 | menuhot=blue;black 86 | menusel=black;green 87 | menuhotsel=black;green 88 | menuinactive=lightgray;black 89 | 90 | [buttonbar] 91 | hotkey=black;green 92 | button=lightgray;black 93 | 94 | [statusbar] 95 | _default_=green;black 96 | 97 | [help] 98 | _default_=default;default 99 | helpitalic=red;default 100 | helpbold=brightgreen;default 101 | helplink=green;default 102 | helpslink=black;green 103 | helptitle=green;default 104 | 105 | [editor] 106 | _default_=lightgray;default 107 | editbold=brown;default 108 | editmarked=cyan;default 109 | editwhitespace=brightblue;default 110 | editlinestate=brightcyan 111 | editrightmargin=brightblue 112 | bookmark=red 113 | bookmarkfound=black;green 114 | 115 | [diffviewer] 116 | added=brightgreen;default 117 | changedline=blue;default 118 | changednew=red;default 119 | changed=cyan;default 120 | removed=magenta;default 121 | folder=brightblue;default 122 | error=brightred;default 123 | 124 | [viewer] 125 | viewunderline=gray;default 126 | viewbold=yellow;black 127 | viewselected=yellow;cyan 128 | 129 | [popupmenu] 130 | _default_=lightgray;black 131 | menusel=black;green 132 | menutitle=green;black 133 | 134 | [widget-common] 135 | sort-sign-down=↑ 136 | sort-sign-up=↓ 137 | 138 | [widget-panel] 139 | hiddenfiles-sign-show = • 140 | hiddenfiles-sign-hide = ○ 141 | history-prev-item-sign = « 142 | history-next-item-sign = » 143 | history-show-list-sign = ^ 144 | 145 | [widget-scollbar] 146 | first-vert-char=↑ 147 | last-vert-char=↓ 148 | first-horiz-char=« 149 | last-horiz-char=» 150 | current-char=■ 151 | background-char=▒ 152 | 153 | -------------------------------------------------------------------------------- /files/users/darkred.ini: -------------------------------------------------------------------------------- 1 | [skin] 2 | description=dark red 3 | 4 | [Lines] 5 | horiz=─ 6 | vert=│ 7 | lefttop=┌ 8 | righttop=┐ 9 | leftbottom=└ 10 | rightbottom=┘ 11 | topmiddle=─ 12 | bottommiddle=─ 13 | leftmiddle=├ 14 | rightmiddle=┤ 15 | cross=┼ 16 | dhoriz=─ 17 | dvert=│ 18 | dlefttop=┌ 19 | drighttop=┐ 20 | dleftbottom=└ 21 | drightbottom=┘ 22 | dtopmiddle=─ 23 | dbottommiddle=─ 24 | dleftmiddle=├ 25 | drightmiddle=┤ 26 | 27 | [core] 28 | _default_=gray;default 29 | selected=black;red 30 | marked=default;red 31 | markselect=default;magenta 32 | gauge=black;lightgray 33 | input=default;black 34 | inputunchanged=black;red 35 | inputmark=cyan;black 36 | disabled=gray;black 37 | reverse=brightred;default 38 | commandlinemark=black;lightgray 39 | header=red;black 40 | inputhistory=blue;default 41 | commandhistory=cyan;default 42 | 43 | [dialog] 44 | _default_=lightgray;black 45 | dfocus=white;red 46 | dhotnormal=blue;black 47 | dhotfocus=black;red 48 | dtitle=red;black 49 | 50 | [error] 51 | _default_=white;red 52 | errdfocus=black;lightgray 53 | errdhotnormal=yellow;red 54 | errdhotfocus=yellow;lightgray 55 | errdtitle=yellow;red 56 | 57 | [filehighlight] 58 | directory=lightgray; 59 | executable=brightred; 60 | symlink=brightcyan; 61 | stalelink=brightred; 62 | device=brightmagenta; 63 | special=gray; 64 | core=red; 65 | temp=gray; 66 | archive=brightred; 67 | doc=red; 68 | source=brightcyan; 69 | media=cyan; 70 | audio1=blue; 71 | audio2=brightblue; 72 | vid1=red; 73 | vid2=brightred; 74 | graph=brightmagenta; 75 | database=brightred; 76 | text=lightgray; 77 | markup=cyan; 78 | html=brown; 79 | ebook=magenta; 80 | ebook2=brown; 81 | ps=yellow; 82 | 83 | [menu] 84 | _default_=lightgray;black 85 | menuhot=blue;black 86 | menusel=black;red 87 | menuhotsel=black;red 88 | menuinactive=lightgray;black 89 | 90 | [buttonbar] 91 | hotkey=black;red 92 | button=lightgray;black 93 | 94 | [statusbar] 95 | _default_=red;black 96 | 97 | [help] 98 | _default_=default;default 99 | helpitalic=red;default 100 | helpbold=brightred;default 101 | helplink=red;default 102 | helpslink=black;red 103 | helptitle=red;default 104 | 105 | [editor] 106 | _default_=lightgray;default 107 | editbold=brown;default 108 | editmarked=cyan;default 109 | editwhitespace=brightblue;default 110 | editlinestate=brightcyan 111 | editrightmargin=brightblue 112 | bookmark=red 113 | bookmarkfound=black;red 114 | 115 | [diffviewer] 116 | added=brightred;default 117 | changedline=blue;default 118 | changednew=red;default 119 | changed=cyan;default 120 | removed=magenta;default 121 | folder=brightblue;default 122 | error=brightred;default 123 | 124 | [viewer] 125 | viewunderline=gray;default 126 | viewbold=yellow;black 127 | viewselected=yellow;cyan 128 | 129 | [popupmenu] 130 | _default_=lightgray;black 131 | menusel=black;red 132 | menutitle=red;black 133 | 134 | [widget-common] 135 | sort-sign-down=↑ 136 | sort-sign-up=↓ 137 | 138 | [widget-panel] 139 | hiddenfiles-sign-show = • 140 | hiddenfiles-sign-hide = ○ 141 | history-prev-item-sign = « 142 | history-next-item-sign = » 143 | history-show-list-sign = ^ 144 | 145 | [widget-scollbar] 146 | first-vert-char=↑ 147 | last-vert-char=↓ 148 | first-horiz-char=« 149 | last-horiz-char=» 150 | current-char=■ 151 | background-char=▒ 152 | -------------------------------------------------------------------------------- /files/users/nanorc-root: -------------------------------------------------------------------------------- 1 | # ROOT 2 | # set element fgcolor,bgcolor 3 | set titlecolor brightred,black 4 | set statuscolor brightred,black 5 | set errorcolor brightwhite,red 6 | set selectedcolor brightwhite,magenta 7 | set numbercolor yellow 8 | set keycolor yellow 9 | set functioncolor red 10 | 11 | include "/usr/share/nano/*.nanorc" 12 | -------------------------------------------------------------------------------- /files/users/nanorc-user: -------------------------------------------------------------------------------- 1 | # USER 2 | # set element fgcolor,bgcolor 3 | set titlecolor brightgreen,black 4 | set statuscolor brightgreen,black 5 | set errorcolor brightblack,red 6 | set selectedcolor brightwhite,magenta 7 | #set stripecolor ,yellow 8 | set numbercolor yellow 9 | set keycolor yellow 10 | set functioncolor green 11 | 12 | include "/usr/share/nano/*.nanorc" 13 | -------------------------------------------------------------------------------- /files/users/root-ini: -------------------------------------------------------------------------------- 1 | [Midnight-Commander] 2 | verbose=1 3 | pause_after_run=1 4 | shell_patterns=1 5 | auto_save_setup=1 6 | preallocate_space=0 7 | auto_menu=0 8 | use_internal_view=1 9 | use_internal_edit=0 10 | clear_before_exec=1 11 | confirm_delete=1 12 | confirm_overwrite=1 13 | confirm_execute=0 14 | confirm_history_cleanup=1 15 | confirm_exit=0 16 | confirm_directory_hotlist_delete=1 17 | safe_delete=0 18 | mouse_repeat_rate=100 19 | double_click_speed=250 20 | use_8th_bit_as_meta=0 21 | confirm_view_dir=0 22 | mouse_move_pages_viewer=1 23 | mouse_close_dialog=0 24 | fast_refresh=0 25 | drop_menus=0 26 | wrap_mode=1 27 | old_esc_mode=0 28 | old_esc_mode_timeout=1000000 29 | cd_symlinks=1 30 | show_all_if_ambiguous=0 31 | max_dirt_limit=10 32 | use_file_to_guess_type=1 33 | alternate_plus_minus=0 34 | only_leading_plus_minus=1 35 | show_output_starts_shell=0 36 | xtree_mode=0 37 | num_history_items_recorded=60 38 | file_op_compute_totals=1 39 | classic_progressbar=1 40 | vfs_timeout=60 41 | ftpfs_directory_timeout=900 42 | use_netrc=1 43 | ftpfs_retry_seconds=30 44 | ftpfs_always_use_proxy=0 45 | ftpfs_use_passive_connections=1 46 | ftpfs_use_passive_connections_over_proxy=0 47 | ftpfs_use_unix_list_options=1 48 | ftpfs_first_cd_then_ls=1 49 | fish_directory_timeout=900 50 | editor_tab_spacing=8 51 | editor_word_wrap_line_length=72 52 | editor_fill_tabs_with_spaces=0 53 | editor_return_does_auto_indent=0 54 | editor_backspace_through_tabs=0 55 | editor_fake_half_tabs=1 56 | editor_option_save_mode=0 57 | editor_option_save_position=1 58 | editor_option_auto_para_formatting=0 59 | editor_option_typewriter_wrap=0 60 | editor_edit_confirm_save=1 61 | editor_syntax_highlighting=1 62 | editor_persistent_selections=1 63 | editor_drop_selection_on_copy=1 64 | editor_cursor_beyond_eol=0 65 | editor_cursor_after_inserted_block=0 66 | editor_visible_tabs=1 67 | editor_visible_spaces=1 68 | editor_line_state=0 69 | editor_simple_statusbar=0 70 | editor_check_new_line=0 71 | editor_show_right_margin=0 72 | editor_group_undo=1 73 | editor_state_full_filename=1 74 | editor_ask_filename_before_edit=0 75 | nice_rotating_dash=1 76 | mcview_remember_file_position=0 77 | auto_fill_mkdir_name=1 78 | copymove_persistent_attr=1 79 | editor_backup_extension=~ 80 | editor_filesize_threshold=64M 81 | editor_stop_format_chars=-+*\\,.;:&> 82 | mcview_eof= 83 | ignore_ftp_chattr_errors=true 84 | skin=darkred 85 | 86 | filepos_max_saved_entries=1024 87 | 88 | [Layout] 89 | message_visible=1 90 | keybar_visible=1 91 | xterm_title=1 92 | output_lines=0 93 | command_prompt=1 94 | menubar_visible=1 95 | free_space=1 96 | horizontal_split=0 97 | vertical_equal=1 98 | left_panel_size=40 99 | horizontal_equal=1 100 | top_panel_size=1 101 | 102 | [Misc] 103 | timeformat_recent=%b %e %H:%M 104 | timeformat_old=%b %e %Y 105 | ftp_proxy_host=gate 106 | ftpfs_password=anonymous@ 107 | display_codepage=UTF-8 108 | source_codepage=Other_8_bit 109 | autodetect_codeset= 110 | spell_language=en 111 | clipboard_store= 112 | clipboard_paste= 113 | 114 | [Colors] 115 | base_color= 116 | xterm-256color= 117 | color_terminals= 118 | #base_color=linux:normal=white,black:marked=yellow,black:input=,green:menu=black:menusel=white:menuhot=red,:menuhotsel=black,red:dfocus=white,black:dhotnormal=white,black:dhotfocus=white,black:executable=,black:directory=white,black:link=white,black:device=white,black:special=white,black:core=,black:stalelink=red,black:editnormal=white,black 119 | 120 | 121 | linux= 122 | 123 | xterm-256color= 124 | color_terminals= 125 | 126 | [Panels] 127 | show_mini_info=true 128 | kilobyte_si=false 129 | mix_all_files=false 130 | show_backups=true 131 | show_dot_files=true 132 | fast_reload=false 133 | fast_reload_msg_shown=false 134 | mark_moves_down=true 135 | reverse_files_only=true 136 | auto_save_setup_panels=false 137 | navigate_with_arrows=false 138 | panel_scroll_pages=true 139 | panel_scroll_center=false 140 | mouse_move_pages=true 141 | filetype_mode=true 142 | permission_mode=false 143 | torben_fj_mode=false 144 | quick_search_mode=2 145 | select_flags=6 146 | 147 | [Panelize] 148 | Find *.orig after patching=find . -name \\*.orig -print 149 | Find SUID and SGID programs=find . \\( \\( -perm -04000 -a -perm /011 \\) -o \\( -perm -02000 -a -perm /01 \\) \\) -print 150 | Find rejects after patching=find . -name \\*.rej -print 151 | Modified git files=git ls-files --modified 152 | -------------------------------------------------------------------------------- /files/users/user-ini: -------------------------------------------------------------------------------- 1 | [Midnight-Commander] 2 | verbose=1 3 | pause_after_run=1 4 | shell_patterns=1 5 | auto_save_setup=1 6 | preallocate_space=0 7 | auto_menu=0 8 | use_internal_view=1 9 | use_internal_edit=0 10 | clear_before_exec=1 11 | confirm_delete=1 12 | confirm_overwrite=1 13 | confirm_execute=0 14 | confirm_history_cleanup=1 15 | confirm_exit=0 16 | confirm_directory_hotlist_delete=1 17 | safe_delete=0 18 | mouse_repeat_rate=100 19 | double_click_speed=250 20 | use_8th_bit_as_meta=0 21 | confirm_view_dir=0 22 | mouse_move_pages_viewer=1 23 | mouse_close_dialog=0 24 | fast_refresh=0 25 | drop_menus=0 26 | wrap_mode=1 27 | old_esc_mode=0 28 | old_esc_mode_timeout=1000000 29 | cd_symlinks=1 30 | show_all_if_ambiguous=0 31 | max_dirt_limit=10 32 | use_file_to_guess_type=1 33 | alternate_plus_minus=0 34 | only_leading_plus_minus=1 35 | show_output_starts_shell=0 36 | xtree_mode=0 37 | num_history_items_recorded=60 38 | file_op_compute_totals=1 39 | classic_progressbar=1 40 | vfs_timeout=60 41 | ftpfs_directory_timeout=900 42 | use_netrc=1 43 | ftpfs_retry_seconds=30 44 | ftpfs_always_use_proxy=0 45 | ftpfs_use_passive_connections=1 46 | ftpfs_use_passive_connections_over_proxy=0 47 | ftpfs_use_unix_list_options=1 48 | ftpfs_first_cd_then_ls=1 49 | fish_directory_timeout=900 50 | editor_tab_spacing=8 51 | editor_word_wrap_line_length=72 52 | editor_fill_tabs_with_spaces=0 53 | editor_return_does_auto_indent=0 54 | editor_backspace_through_tabs=0 55 | editor_fake_half_tabs=1 56 | editor_option_save_mode=0 57 | editor_option_save_position=1 58 | editor_option_auto_para_formatting=0 59 | editor_option_typewriter_wrap=0 60 | editor_edit_confirm_save=1 61 | editor_syntax_highlighting=1 62 | editor_persistent_selections=1 63 | editor_drop_selection_on_copy=1 64 | editor_cursor_beyond_eol=0 65 | editor_cursor_after_inserted_block=0 66 | editor_visible_tabs=1 67 | editor_visible_spaces=1 68 | editor_line_state=0 69 | editor_simple_statusbar=0 70 | editor_check_new_line=0 71 | editor_show_right_margin=0 72 | editor_group_undo=1 73 | editor_state_full_filename=1 74 | editor_ask_filename_before_edit=0 75 | nice_rotating_dash=1 76 | mcview_remember_file_position=0 77 | auto_fill_mkdir_name=1 78 | copymove_persistent_attr=1 79 | editor_backup_extension=~ 80 | editor_filesize_threshold=64M 81 | editor_stop_format_chars=-+*\\,.;:&> 82 | mcview_eof= 83 | ignore_ftp_chattr_errors=true 84 | skin=darkgreen 85 | 86 | filepos_max_saved_entries=1024 87 | 88 | [Layout] 89 | message_visible=1 90 | keybar_visible=1 91 | xterm_title=1 92 | output_lines=0 93 | command_prompt=1 94 | menubar_visible=1 95 | free_space=1 96 | horizontal_split=0 97 | vertical_equal=1 98 | left_panel_size=40 99 | horizontal_equal=1 100 | top_panel_size=1 101 | 102 | [Misc] 103 | timeformat_recent=%b %e %H:%M 104 | timeformat_old=%b %e %Y 105 | ftp_proxy_host=gate 106 | ftpfs_password=anonymous@ 107 | display_codepage=UTF-8 108 | source_codepage=Other_8_bit 109 | autodetect_codeset= 110 | spell_language=en 111 | clipboard_store= 112 | clipboard_paste= 113 | 114 | [Colors] 115 | base_color= 116 | xterm-256color= 117 | color_terminals= 118 | #base_color=linux:normal=white,black:marked=yellow,black:input=,green:menu=black:menusel=white:menuhot=red,:menuhotsel=black,red:dfocus=white,black:dhotnormal=white,black:dhotfocus=white,black:executable=,black:directory=white,black:link=white,black:device=white,black:special=white,black:core=,black:stalelink=red,black:editnormal=white,black 119 | 120 | 121 | linux= 122 | 123 | xterm-256color= 124 | color_terminals= 125 | 126 | [Panels] 127 | show_mini_info=true 128 | kilobyte_si=false 129 | mix_all_files=false 130 | show_backups=true 131 | show_dot_files=true 132 | fast_reload=false 133 | fast_reload_msg_shown=false 134 | mark_moves_down=true 135 | reverse_files_only=true 136 | auto_save_setup_panels=false 137 | navigate_with_arrows=false 138 | panel_scroll_pages=true 139 | panel_scroll_center=false 140 | mouse_move_pages=true 141 | filetype_mode=true 142 | permission_mode=false 143 | torben_fj_mode=false 144 | quick_search_mode=2 145 | select_flags=6 146 | 147 | [Panelize] 148 | Find *.orig after patching=find . -name \\*.orig -print 149 | Find SUID and SGID programs=find . \\( \\( -perm -04000 -a -perm /011 \\) -o \\( -perm -02000 -a -perm /01 \\) \\) -print 150 | Find rejects after patching=find . -name \\*.rej -print 151 | Modified git files=git ls-files --modified 152 | -------------------------------------------------------------------------------- /files/userscripts/README.md: -------------------------------------------------------------------------------- 1 | ### How it works (files/userscripts/uscripts) 2 | * run_function0 3 | ```sh 4 | Runs at the start of stage1. 5 | ``` 6 | 7 | * run_function1 8 | ```sh 9 | Runs in the middle of stage1 and can be used to make edits to the p2 directory before chroot. 10 | ``` 11 | 12 | * run_function2 13 | ```sh 14 | Runs in stage2 during chroot. 15 | ``` 16 | * run_function3 17 | ```sh 18 | Runs at the end of stage1 before the loop(s) get unmounted and the image is finalized. 19 | ``` 20 | 21 | Examples: [here](https://github.com/pyavitz/debian-image-builder/tree/userscripts). 22 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #set -x 4 | source lib/source 5 | RED="\e[0;31m" 6 | GRN="\e[0;32m" 7 | PNK="\e[0;35m" 8 | TXT="\033[0m" 9 | YLW="\e[0;33m" 10 | FIN="\e[0m" 11 | GIT_BRANCH=`git branch` 12 | 13 | echo "" 14 | echo -en "${TXT}Raspberry Pi Image Builder:${FIN}" 15 | echo -e " ${PNK}[${FIN}${GRN}${GIT_BRANCH}${FIN}${PNK}]${FIN}" 16 | echo -en "${TXT}Checking Internet Connection:${FIN} " 17 | if [[ `curl -I https://github.com 2>&1 | grep 'HTTP/2 200'` ]]; then 18 | echo -en "${PNK}[${FIN}${GRN}OK${FIN}${PNK}]${FIN}" 19 | echo "" 20 | else 21 | echo -en "${PNK}[${FIN}${RED}failed${FIN}${PNK}]${FIN}" 22 | echo "" 23 | echo -e "${TXT}Please check your internet connection and try again${FIN}." 24 | exit 1 25 | fi 26 | if [[ `command -v sudo` ]]; then 27 | :; 28 | else 29 | echo "" 30 | echo -e "Missing dependency: sudo" 31 | echo -e "https://wiki.debian.org/sudo" 32 | exit 1 33 | fi 34 | if [[ `command -v curl` ]]; then 35 | :; 36 | else 37 | echo "" 38 | echo -e "Missing dependency: curl" 39 | sudo apt install -y curl 40 | exit 1 41 | fi 42 | if [[ `command -v make` ]]; then 43 | :; 44 | else 45 | echo "" 46 | echo -e "Missing dependency: make" 47 | sudo apt install -y make 48 | exit 1 49 | fi 50 | echo -en "${TXT}Checking Host Machine:${FIN} " 51 | sleep .50 52 | if [[ "$HOST_CODENAME" =~ ^(bullseye|bookworm|jammy|noble)$ ]]; then 53 | echo -en "${PNK}[${FIN}${GRN}${HOST_PRETTY}${FIN}${PNK}]${FIN}" 54 | echo "" 55 | else 56 | echo -ne "${PNK}[${FIN}${RED}failed${FIN}${PNK}]${FIN}" 57 | echo "" 58 | echo -e "${TXT}The OS you are running is not supported${FIN}." 59 | exit 1 60 | fi 61 | echo "" 62 | if [[ "$HOST_ARCH" =~ ^(aarch64|x86_64)$ ]]; then 63 | if [[ "$HOST_ARCH" == "aarch64" ]]; then CMD="ncompile"; else CMD="ccompile"; fi 64 | echo -e "${TXT}Starting install ...${FIN}" 65 | sudo apt update; sudo apt upgrade -y; make ${CMD} 66 | else 67 | echo -e "ARCH: $HOST_ARCH is not supported by this script." 68 | exit 1 69 | fi 70 | 71 | # install builder theme 72 | make dialogrc 73 | 74 | # clear 75 | clear -x 76 | 77 | # builder options 78 | make help 79 | 80 | exit 0 81 | -------------------------------------------------------------------------------- /lib/boards/bcm2708: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # architecture 4 | ARCH="arm" 5 | ARCH_EXT="armel" 6 | DEBARCH="${ARCH_EXT}" 7 | KERNEL_VAR="kernel" 8 | CROSS_COMPILE="arm-linux-gnueabi-" 9 | ROOTFS_ARCH="rootfs-${ARCH_EXT}" 10 | STATIC="qemu-arm-static" 11 | 12 | # menu 13 | PRETTY_BOARD="Raspberry Pi Zero/W/1 BCM2708 / ARMEL" 14 | 15 | # misc 16 | FAMILY="broadcom" 17 | FAMILY_EXT="" 18 | 19 | # default config 20 | LINUX_DEFCONFIG="bcmrpi_defconfig" 21 | 22 | # partitions 23 | IMG_OFFSET="4MiB" 24 | P_VALUE="p2" 25 | 26 | # output 27 | BOARD="bcm2708" 28 | BOARD_EXT="rpi" 29 | OUTPUT="output/${BOARD}" 30 | IMG_EXP="${BOARD_EXT}-*.img*" 31 | 32 | # cmdline 33 | CONSOLE="console=serial0,115200 console=tty1" 34 | EXTRA="loglevel=5 net.ifnames=0 firmware_class.path=/lib/firmware/updates/brcm" 35 | 36 | # packaging 37 | KERNEL_IMG="kernel.img" 38 | SERIES="bcm2708-${BOARD_EXT}" 39 | -------------------------------------------------------------------------------- /lib/boards/bcm2709: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # architecture 4 | ARCH="arm" 5 | ARCH_EXT="armhf" 6 | DEBARCH="" 7 | KERNEL_VAR="kernel7" 8 | CROSS_COMPILE="arm-linux-gnueabihf-" 9 | ROOTFS_ARCH="rootfs-${ARCH_EXT}" 10 | STATIC="qemu-arm-static" 11 | 12 | # menu 13 | PRETTY_BOARD="Raspberry Pi ZeroW2/2/3 BCM2709 / ARMHF" 14 | 15 | # misc 16 | FAMILY="broadcom" 17 | FAMILY_EXT="" 18 | 19 | # default config 20 | LINUX_DEFCONFIG="bcm2709_defconfig" 21 | 22 | # partitions 23 | IMG_OFFSET="4MiB" 24 | P_VALUE="p2" 25 | 26 | # output 27 | BOARD="bcm2709" 28 | BOARD_EXT="rpi-2+3" 29 | OUTPUT="output/${BOARD}" 30 | IMG_EXP="${BOARD_EXT}-*.img*" 31 | 32 | # cmdline 33 | CONSOLE="console=serial0,115200 console=tty1" 34 | EXTRA="loglevel=5 net.ifnames=0 firmware_class.path=/lib/firmware/updates/brcm" 35 | 36 | # packaging 37 | KERNEL_IMG="kernel7.img" 38 | SERIES="bcm2709-rpi" 39 | -------------------------------------------------------------------------------- /lib/boards/bcm2710: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # architecture 4 | ARCH="arm64" 5 | ARCH_EXT="arm64" 6 | DEBARCH="" 7 | CROSS_COMPILE="aarch64-linux-gnu-" 8 | ROOTFS_ARCH="rootfs-${ARCH_EXT}" 9 | STATIC="qemu-aarch64-static" 10 | 11 | # menu 12 | PRETTY_BOARD="Raspberry Pi ZeroW2/3 BCM2710 / ARM64" 13 | 14 | # misc 15 | FAMILY="broadcom" 16 | FAMILY_EXT="" 17 | 18 | # default config 19 | LINUX_DEFCONFIG="bcmrpi3_defconfig" 20 | 21 | # partitions 22 | IMG_OFFSET="4MiB" 23 | P_VALUE="p2" 24 | 25 | # output 26 | BOARD="bcm2710" 27 | BOARD_EXT="rpi-3" 28 | OUTPUT="output/${BOARD}" 29 | IMG_EXP="${BOARD_EXT}-*.img*" 30 | 31 | # cmdline 32 | CONSOLE="console=serial0,115200 console=tty1" 33 | EXTRA="loglevel=5 net.ifnames=0 firmware_class.path=/lib/firmware/updates/brcm" 34 | 35 | # packaging 36 | KERNEL_IMG="kernel8.img" 37 | SERIES="bcm2710-rpi" 38 | -------------------------------------------------------------------------------- /lib/boards/bcm2711: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # architecture 4 | ARCH="arm64" 5 | ARCH_EXT="arm64" 6 | DEBARCH="" 7 | CROSS_COMPILE="aarch64-linux-gnu-" 8 | ROOTFS_ARCH="rootfs-${ARCH_EXT}" 9 | STATIC="qemu-aarch64-static" 10 | 11 | # menu 12 | PRETTY_BOARD="Raspberry Pi ZeroW2/3/4/400/5 BCM2711 / ARM64" 13 | 14 | # misc 15 | FAMILY="broadcom" 16 | FAMILY_EXT="" 17 | 18 | # default config 19 | LINUX_DEFCONFIG="bcm2711_defconfig" 20 | 21 | # partitions 22 | IMG_OFFSET="4MiB" 23 | P_VALUE="p2" 24 | 25 | # output 26 | BOARD="bcm2711" 27 | BOARD_EXT="rpi-4" 28 | OUTPUT="output/${BOARD}" 29 | IMG_EXP="${BOARD_EXT}-*.img*" 30 | 31 | # cmdline 32 | CONSOLE="console=serial0,115200 console=tty1" 33 | EXTRA="loglevel=5 net.ifnames=0 firmware_class.path=/lib/firmware/updates/brcm" 34 | 35 | # packaging 36 | KERNEL_IMG="kernel8.img" 37 | SERIES="bcm2711-rpi" 38 | -------------------------------------------------------------------------------- /lib/boards/bcm2711v7: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # architecture 4 | ARCH="arm" 5 | ARCH_EXT="armhf" 6 | DEBARCH="" 7 | KERNEL_VAR="kernel7l" 8 | CROSS_COMPILE="arm-linux-gnueabihf-" 9 | ROOTFS_ARCH="rootfs-${ARCH_EXT}" 10 | STATIC="qemu-arm-static" 11 | 12 | # menu 13 | PRETTY_BOARD="Raspberry Pi 4/400 BCM2711 / ARMHF" 14 | 15 | # misc 16 | FAMILY="broadcom" 17 | FAMILY_EXT="" 18 | 19 | # default config 20 | LINUX_DEFCONFIG="bcm2711_defconfig" 21 | 22 | # partitions 23 | IMG_OFFSET="4MiB" 24 | P_VALUE="p2" 25 | 26 | # output 27 | BOARD="bcm2711v7" 28 | BOARD_EXT="rpi-4" 29 | OUTPUT="output/${BOARD}" 30 | IMG_EXP="${BOARD_EXT}-*.img*" 31 | 32 | # cmdline 33 | CONSOLE="console=serial0,115200 console=tty1" 34 | EXTRA="loglevel=5 net.ifnames=0 firmware_class.path=/lib/firmware/updates/brcm" 35 | 36 | # packaging 37 | KERNEL_IMG="kernel7l.img" 38 | SERIES="bcm2711-rpi" 39 | -------------------------------------------------------------------------------- /lib/boards/bcm2712: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # architecture 4 | ARCH="arm64" 5 | ARCH_EXT="arm64" 6 | DEBARCH="" 7 | CROSS_COMPILE="aarch64-linux-gnu-" 8 | ROOTFS_ARCH="rootfs-${ARCH_EXT}" 9 | STATIC="qemu-aarch64-static" 10 | 11 | # menu 12 | PRETTY_BOARD="Raspberry Pi 5 BCM2712 / ARM64" 13 | 14 | # misc 15 | FAMILY="broadcom" 16 | FAMILY_EXT="" 17 | 18 | # default config 19 | LINUX_DEFCONFIG="bcm2712_defconfig" 20 | 21 | # partitions 22 | IMG_OFFSET="4MiB" 23 | P_VALUE="p2" 24 | 25 | # output 26 | BOARD="bcm2712" 27 | BOARD_EXT="rpi-5" 28 | OUTPUT="output/${BOARD}" 29 | IMG_EXP="${BOARD_EXT}-*.img*" 30 | 31 | # cmdline 32 | CONSOLE="console=serial0,115200 console=tty1" 33 | EXTRA="loglevel=5 net.ifnames=0 firmware_class.path=/lib/firmware/updates/brcm" 34 | 35 | # packaging 36 | KERNEL_IMG="kernel_2712.img" 37 | SERIES="bcm2712-rpi" 38 | -------------------------------------------------------------------------------- /lib/dialog/config: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source lib/function/config 4 | # builder and profile versions 5 | BUILDER="6.10" 6 | PROFILE="1.2" 7 | 8 | if [[ `command -v dialog` ]]; then :; else sudo apt install dialog; fi 9 | ARCH=`uname -m` 10 | MYNAME=`echo $USER | sed -e "s/\b\(.\)/\u\1/g"` 11 | 12 | # userdata dot txt 13 | NAME="$MYNAME" 14 | USERNAME="$USER" 15 | PASSWORD="board" 16 | COMPILER="gcc" 17 | CCACHE="1" 18 | NETWORKMANAGER="1" 19 | RTW88="0" 20 | USERACCT="0" 21 | USER_PKGS="htop libsensors-dev rsyslog" 22 | LOCALE="en_US.UTF-8" 23 | LOCALE_LC_ALL="C.UTF-8" 24 | TIMEZONE="America/New_York" 25 | NAMESERVER1="8.8.8.8" 26 | NAMESERVER2="8.8.4.4" 27 | # profile dot txt 28 | if [[ -f "profile.txt" ]]; then 29 | . profile.txt 30 | if [[ -n "$USER_PROFILE" ]]; then :; else rm -f profile.txt; fi 31 | if [[ "$PROFILE" == "$USER_PROFILE" ]]; then :; else profile_txt; fi 32 | else 33 | profile_txt 34 | fi 35 | ROOTPASSWD="0" 36 | VERSION="6.12.y" 37 | BUILD_VERSION="1" 38 | MENUCONFIG="0" 39 | DISTRO="debian" 40 | DISTRO_VERSION="bookworm" 41 | CUSTOM_DEFCONFIG="0" 42 | MYCONFIG="" 43 | VERBOSE="0" 44 | DEVROOTFS="1" 45 | COMPRESS_IMG="0" 46 | USCRIPTS="0" 47 | 48 | # open fd 49 | exec 3>&1 50 | 51 | # store data to $VALUES variable 52 | VALUES=$(dialog --ok-label "Submit" --no-cancel \ 53 | --backtitle "RASPBERRY PI IMAGE BUILDER: CONFIG MENU" \ 54 | --title "" --form "" 0 36 0 \ 55 | "Name:" 1 1 "$NAME" 1 7 23 0 \ 56 | "Username:" 2 1 "$USERNAME" 2 11 19 0 \ 57 | "Password:" 3 1 "$PASSWORD" 3 11 19 0 \ 58 | "Enable root:" 4 1 "$ROOTPASSWD" 4 14 3 0 \ 59 | "" 5 1 "" 5 14 0 0 \ 60 | "Distribution" 6 1 "" 6 14 0 0 \ 61 | "Distro:" 7 1 "$DISTRO" 7 9 21 0 \ 62 | "Release:" 8 1 "$DISTRO_VERSION" 8 10 20 0 \ 63 | "Network Manager:" 9 1 "$NETWORKMANAGER" 9 18 3 0 \ 64 | "" 10 1 "" 10 14 0 0 \ 65 | "Linux kernel" 11 1 "" 11 14 0 0 \ 66 | "Branch:" 12 1 "$VERSION" 12 9 8 0 \ 67 | "Build:" 13 1 "$BUILD_VERSION" 13 8 5 0 \ 68 | "Menuconfig:" 14 1 "$MENUCONFIG" 14 13 3 0 \ 69 | "Compiler:" 15 1 "$COMPILER" 15 11 10 0 \ 70 | "Ccache:" 16 1 "$CCACHE" 16 9 3 0 \ 71 | "" 17 1 "" 17 14 0 0 \ 72 | "Customize" 18 1 "" 18 14 0 0 \ 73 | "Defconfig:" 19 1 "$CUSTOM_DEFCONFIG" 19 12 3 0 \ 74 | "Name:" 20 1 "$MYCONFIG" 20 7 23 0 \ 75 | "" 21 1 "" 21 14 0 0 \ 76 | "User options" 22 1 "" 22 14 0 0 \ 77 | "Verbosity:" 23 1 "$VERBOSE" 23 12 3 0 \ 78 | "Compress img:" 24 1 "$COMPRESS_IMG" 24 15 3 0 \ 79 | "User scripts:" 25 1 "$USCRIPTS" 25 15 3 0 \ 80 | "User service:" 26 1 "$USERACCT" 26 15 3 0 \ 81 | 2>&1 1>&3) 82 | 83 | # close fd 84 | exec 3>&- 85 | 86 | # convert into variables 87 | echo "$VALUES" > tmp1 88 | echo NAME='"' > tmp0 89 | echo USERNAME='"' >> tmp0 90 | echo PASSWORD='"' >> tmp0 91 | echo ROOTPASSWD= >> tmp0 92 | echo DISTRO='"' >> tmp0 93 | echo DISTRO_VERSION='"' >> tmp0 94 | echo NETWORKMANAGER= >> tmp0 95 | echo VERSION='"' >> tmp0 96 | echo BUILD_VERSION='"' >> tmp0 97 | echo MENUCONFIG= >> tmp0 98 | echo COMPILER='"' >> tmp0 99 | echo CCACHE= >> tmp0 100 | echo CUSTOM_DEFCONFIG= >> tmp0 101 | echo MYCONFIG='"' >> tmp0 102 | echo VERBOSE= >> tmp0 103 | echo COMPRESS_IMG= >> tmp0 104 | echo USCRIPTS= >> tmp0 105 | echo USERACCT= >> tmp0 106 | echo 'DEVROOTFS="1"' >> tmp0 107 | echo USER_PKGS='"'${USER_PKGS}'"' >> tmp0 108 | echo 'ENABLE_COMMIT="0"' >> tmp0 109 | echo 'COMMIT=""' >> tmp0 110 | echo CORES=\`nproc\` >> tmp0 111 | echo 'CFLAGS=""' >> tmp0 112 | echo 'KBUSER="playboy"' >> tmp0 113 | echo 'KBHOST="penguin"' >> tmp0 114 | echo LOCALE='"'${LOCALE}'"' >> tmp0 115 | echo LOCALE_LC_ALL='"'${LOCALE_LC_ALL}'"' >> tmp0 116 | echo TIMEZONE='"'${TIMEZONE}'"' >> tmp0 117 | echo NAMESERVER1='"'${NAMESERVER1}'"' >> tmp0 118 | echo NAMESERVER2='"'${NAMESERVER2}'"' >> tmp0 119 | echo "RTW88=${RTW88}" >> tmp0 120 | echo BUILDER=${BUILDER} >> tmp0 121 | echo '"' > tmp2 122 | echo '"' >> tmp2 123 | echo '"' >> tmp2 124 | echo >> tmp2 125 | echo '"' >> tmp2 126 | echo '"' >> tmp2 127 | echo >> tmp2 128 | echo '"' >> tmp2 129 | echo '"' >> tmp2 130 | echo >> tmp2 131 | echo '"' >> tmp2 132 | echo >> tmp2 133 | echo >> tmp2 134 | echo _defconfig'"' >> tmp2 135 | paste -d '\0' tmp0 tmp1 tmp2 > userdata.txt 136 | rm -f tmp0 tmp1 tmp2 137 | 138 | # categories 139 | sed -i '5i### DISTRIBUTION' userdata.txt 140 | sed -i '9i### LINUX KERNEL' userdata.txt 141 | sed -i '15i### CUSTOM' userdata.txt 142 | sed -i '24i### CUSTOM LINUX KERNEL' userdata.txt 143 | sed -i '27i### COMPILER TUNING' userdata.txt 144 | sed -i '30i### WHOAMI AND HOST' userdata.txt 145 | sed -i '33i### LOCALES TIMEZONE AND NAMESERVERS' userdata.txt 146 | sed -i '39i### EXTRA WIRELESS' userdata.txt 147 | sed -i '41i### DO NOT EDIT BELOW THIS LINE' userdata.txt 148 | 149 | # custom dot txt 150 | if [[ -f "custom.txt" ]]; then 151 | . custom.txt 152 | if [[ "$CUSTOM" == "$BUILDER" ]]; then :; else custom_txt; fi 153 | else 154 | custom_txt 155 | fi 156 | 157 | # kernel preferences 158 | if [[ -f "kernel.txt" ]]; then 159 | . kernel.txt 160 | if [[ "$KERNEL_PREFERENCES" == "$BUILDER" ]]; then :; else kernel_txt; fi 161 | else 162 | kernel_txt 163 | fi 164 | 165 | # rootfs / image mirrors 166 | if [[ -f "mirror.txt" ]]; then 167 | . mirror.txt 168 | if [[ "$MIRROR_LIST" == "$BUILDER" ]]; then :; else mirror_txt; fi 169 | else 170 | mirror_txt 171 | fi 172 | 173 | # clear screen 174 | clear -x 175 | 176 | # userdata-txt 177 | if [[ -f "userdata.txt" ]]; then 178 | sed -i 's/=0/="0"/g' userdata.txt 179 | sed -i 's/=1/="1"/g' userdata.txt 180 | sed -i '4G;8G;14G;23G;26G;29G;32G;38G;40G' userdata.txt 181 | echo -e "userdata file created." 182 | exit 0 183 | fi 184 | 185 | exit 0 186 | -------------------------------------------------------------------------------- /lib/dialog/dialogrc: -------------------------------------------------------------------------------- 1 | # 2 | # Run-time configuration file for dialog 3 | # 4 | # Automatically generated by "dialog --create-rc " 5 | # 6 | # 7 | # Types of values: 8 | # 9 | # Number - 10 | # String - "string" 11 | # Boolean - 12 | # Attribute - (foreground,background,highlight?) 13 | 14 | # Set aspect-ration. 15 | aspect = 0 16 | 17 | # Set separator (for multiple widgets output). 18 | separate_widget = "" 19 | 20 | # Set tab-length (for textbox tab-conversion). 21 | tab_len = 0 22 | 23 | # Make tab-traversal for checklist, etc., include the list. 24 | visit_items = OFF 25 | 26 | # Shadow dialog boxes? This also turns on color. 27 | use_shadow = OFF 28 | 29 | # Turn color support ON or OFF 30 | use_colors = ON 31 | 32 | # Screen color 33 | screen_color = (WHITE,DEFAULT,OFF) 34 | 35 | # Shadow color 36 | shadow_color = (BLACK,BLACK,ON) 37 | 38 | # Dialog box color 39 | dialog_color = (BLACK,WHITE,OFF) 40 | 41 | # Dialog box title color 42 | title_color = (BLACK,WHITE,OFF) 43 | 44 | # Dialog box border color 45 | border_color = (WHITE,WHITE,ON) 46 | 47 | # Active button color 48 | button_active_color = (WHITE,RED,ON) 49 | 50 | # Inactive button color 51 | button_inactive_color = dialog_color 52 | 53 | # Active button key color 54 | button_key_active_color = button_active_color 55 | 56 | # Inactive button key color 57 | button_key_inactive_color = (RED,WHITE,OFF) 58 | 59 | # Active button label color 60 | button_label_active_color = (WHITE,RED,ON) 61 | 62 | # Inactive button label color 63 | button_label_inactive_color = (BLACK,WHITE,OFF) 64 | 65 | # Input box color 66 | inputbox_color = dialog_color 67 | 68 | # Input box border color 69 | inputbox_border_color = dialog_color 70 | 71 | # Search box color 72 | searchbox_color = dialog_color 73 | 74 | # Search box title color 75 | searchbox_title_color = title_color 76 | 77 | # Search box border color 78 | searchbox_border_color = border_color 79 | 80 | # File position indicator color 81 | position_indicator_color = title_color 82 | 83 | # Menu box color 84 | menubox_color = dialog_color 85 | 86 | # Menu box border color 87 | menubox_border_color = border_color 88 | 89 | # Item color 90 | item_color = dialog_color 91 | 92 | # Selected item color 93 | item_selected_color = button_active_color 94 | 95 | # Tag color 96 | tag_color = title_color 97 | 98 | # Selected tag color 99 | tag_selected_color = button_label_active_color 100 | 101 | # Tag key color 102 | tag_key_color = button_key_inactive_color 103 | 104 | # Selected tag key color 105 | tag_key_selected_color = (WHITE,RED,ON) 106 | 107 | # Check box color 108 | check_color = dialog_color 109 | 110 | # Selected check box color 111 | check_selected_color = button_active_color 112 | 113 | # Up arrow color 114 | uarrow_color = (GREEN,WHITE,ON) 115 | 116 | # Down arrow color 117 | darrow_color = uarrow_color 118 | 119 | # Item help-text color 120 | itemhelp_color = (WHITE,BLACK,OFF) 121 | 122 | # Active form text color 123 | #form_active_text_color = button_active_color 124 | form_active_text_color = (WHITE,RED,ON) 125 | 126 | # Form text color 127 | form_text_color = (BLACK,WHITE,OFF) 128 | 129 | # Readonly form item color 130 | form_item_readonly_color = (CYAN,WHITE,ON) 131 | 132 | # Dialog box gauge color 133 | gauge_color = title_color 134 | 135 | # Dialog box border2 color 136 | border2_color = dialog_color 137 | 138 | # Input box border2 color 139 | inputbox_border2_color = dialog_color 140 | 141 | # Search box border2 color 142 | searchbox_border2_color = dialog_color 143 | 144 | # Menu box border2 color 145 | menubox_border2_color = dialog_color 146 | -------------------------------------------------------------------------------- /lib/dialog/general: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source lib/boards/$1 4 | source userdata.txt 5 | source custom.txt 6 | MAKE_OUTPUT="output/$1" 7 | BTITLE=`echo $FAMILY: $MOTD: $BOARD: $ARCH_EXT | sed 's/bcm2711v7/bcm2711/g' | sed -e 's/\(.*\)/\U\1/'` 8 | if [[ "$BOARD" == "bcm2708" ]]; then 9 | TITLE=`echo $MOTD $BOARD | sed 's/bcm2708/Zero\/W\/1/g'`; 10 | fi 11 | if [[ "$BOARD" == "bcm2709" ]]; then 12 | TITLE=`echo $MOTD $BOARD | sed 's/bcm2709/ZeroW2\/2\/3/g'`; 13 | fi 14 | if [[ "$BOARD" == "bcm2710" ]]; then 15 | TITLE=`echo $MOTD $BOARD | sed 's/bcm2710/ZeroW2\/3/g'`; 16 | fi 17 | if [[ "$BOARD" == "bcm2711" ]]; then 18 | TITLE=`echo $MOTD $BOARD | sed 's/bcm2711/ZeroW2\/3\/4\/400\/5/g'`; 19 | fi 20 | if [[ "$BOARD" == "bcm2711v7" ]]; then 21 | TITLE=`echo $MOTD $BOARD | sed 's/bcm2711v7/4\/400/g'`; 22 | fi 23 | if [[ "$BOARD" == "bcm2712" ]]; then 24 | TITLE=`echo $MOTD $BOARD | sed 's/bcm2712/5/g'`; 25 | fi 26 | DIALOG_CANCEL=1 27 | DIALOG_ESC=255 28 | HEIGHT=0 29 | WIDTH=0 30 | 31 | while true; do 32 | exec 3>&1 33 | selection=$(dialog \ 34 | --backtitle "$BTITLE" \ 35 | --title "$TITLE" \ 36 | --clear \ 37 | --cancel-label "Exit" \ 38 | --menu "Select:" $HEIGHT $WIDTH 0 \ 39 | "1" "Make All ..."\ 40 | "2" "Make Linux Kernel" \ 41 | "3" "Make Root Filesystem" \ 42 | "4" "Make Flashable Image" \ 43 | 2>&1 1>&3) 44 | exit_status=$? 45 | exec 3>&-; 46 | case $exit_status in 47 | $DIALOG_CANCEL) 48 | clear -x 49 | echo "Program terminated." 50 | exit 51 | ;; 52 | $DIALOG_ESC) 53 | clear -x 54 | echo "Program aborted." >&2 55 | exit 1 56 | ;; 57 | esac 58 | case $selection in 59 | 0 ) 60 | clear -x 61 | echo "Program terminated." 62 | ;; 63 | 1 ) 64 | make "all" "board=$1" 65 | dialog --prgbox "Results:" "ls $IMG_EXP ${DISTRO}-${DISTRO_VERSION}-${ROOTFS_ARCH}* $MAKE_OUTPUT/" 30 75 66 | exit 0 67 | ;; 68 | 2 ) 69 | make "kernel" "board=$1" 70 | dialog --prgbox "Results:" "ls $MAKE_OUTPUT/*.deb" 30 75 71 | ;; 72 | 3 ) 73 | make "rootfs" "board=$1" 74 | dialog --prgbox "Results:" "ls ${DISTRO}-${DISTRO_VERSION}-${ROOTFS_ARCH}*" 30 75 75 | ;; 76 | 4 ) 77 | make "image" "board=$1" 78 | dialog --prgbox "Results:" "ls $IMG_EXP" 30 75 79 | ;; 80 | esac 81 | done 82 | -------------------------------------------------------------------------------- /lib/dialog/menu: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source lib/source 4 | validation 5 | COUNT=0 6 | 7 | # create menu 8 | mkdir -p .cache 9 | cat lib/boards/* | grep -w "PRETTY_BOARD" | sed 's/PRETTY_BOARD="//g' | sed 's/"//g' | sudo tee .cache/menu >/dev/null 10 | 11 | # menu list 12 | while IFS=$'\n' read -r opt; do 13 | COUNT=$(( COUNT+1 )) 14 | OPTIONS+=($COUNT "$opt" off) 15 | done < .cache/menu 16 | 17 | # dialog menu 18 | CMD=(dialog --backtitle "RASPBERRY PI IMAGE BUILDER" --title "B O A R D S" --cancel-label "Exit" --radiolist "" 0 0 0) 19 | CHOICES=($("${CMD[@]}" "${OPTIONS[@]}" 2>&1 1>/dev/tty)) 20 | 21 | # selection 22 | for choice in "${CHOICES[@]}"; do 23 | BOARD=`ls lib/boards | head -n $choice | tail -n 1` 24 | chmod +x lib/dialog/general 25 | ./lib/dialog/general $BOARD 26 | done 27 | 28 | # finish 29 | if [[ -f ".cache/menu" ]]; then sudo rm -f .cache/menu; fi 30 | clear -x 31 | echo -e "Program terminated." 32 | exit 0 33 | -------------------------------------------------------------------------------- /lib/function/compilers: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | linux_compilers (){ 4 | # install and setup compilers 5 | DEB_CLANG_DEPENDS="clang clang-14 clang-15 clang-16 lld lld-14 lld-15 lld-16 llvm" 6 | UBU_JAMMY_CLANG_DEPENDS="clang clang-14 clang-15 lld lld-14 lld-15 llvm" 7 | UBU_NOBLE_CLANG_DEPENDS="clang clang-14 clang-15 clang-16 clang-17 clang-18 clang-19 lld lld-14 lld-15 lld-16 lld-17 lld-18 lld-19 llvm" 8 | COMPILER_CLANG=`echo ${COMPILER} | sed 's/[0-9]//g' | sed 's/-//g'` 9 | if [[ "$COMPILER_CLANG" == "clang" ]]; then 10 | if [[ "$HOST_CODENAME" == "bookworm" ]]; then 11 | if [[ `command -v clang-14` ]] && [[ `command -v clang-15` ]] \ 12 | && [[ `command -v clang-16` ]]; then :; else apt install -y ${DEB_CLANG_DEPENDS}; fi 13 | fi 14 | if [[ "$HOST_CODENAME" == "jammy" ]]; then 15 | if [[ `command -v clang-14` ]] && [[ `command -v clang-15` ]]; then :; else apt install -y ${UBU_JAMMY_CLANG_DEPENDS}; fi 16 | fi 17 | if [[ "$HOST_CODENAME" == "noble" ]]; then 18 | if [[ `command -v clang-14` ]] && [[ `command -v clang-15` ]] \ 19 | && [[ `command -v clang-16` ]] && [[ `command -v clang-17` ]] \ 20 | && [[ `command -v clang-18` ]] && [[ `command -v clang-19` ]]; then :; else apt install -y ${UBU_NOBLE_CLANG_DEPENDS}; fi 21 | fi 22 | # builder doesn't support compiling armel with clang 23 | if [[ "$ARCH_EXT" == "armel" ]]; then COMPILER_CLANG="gcc"; COMPILER="gcc"; fi 24 | fi 25 | if [ $CCACHE -eq 1 ]; then 26 | if [[ `command -v ccache` ]]; then :; else apt install -y ccache; fi 27 | fi 28 | # find compiler version 29 | if [[ "$COMPILER" =~ ^(clang|gcc)$ ]]; then 30 | CVER=`readlink /usr/bin/${COMPILER} | sed "s/[^0-9.]*//g" | sed 's/\.//g'` 31 | COMPILER="${COMPILER}-${CVER}" 32 | fi 33 | if [[ "$COMPILER_CLANG" == "clang" ]]; then 34 | CLANG="1" 35 | CLANG_LLVM=`echo LLVM=${COMPILER} LLVM_IAS=1 | sed 's/clang//g'` 36 | else 37 | CLANG="0" 38 | fi 39 | # compiler 40 | if [ $CCACHE -eq 1 ]; then 41 | NATIVE="ccache ${COMPILER}" 42 | if [ $CLANG -eq 1 ]; then CROSS="ccache ${COMPILER}"; else CROSS="ccache ${CROSS_COMPILE}${COMPILER}"; fi 43 | else 44 | NATIVE="${COMPILER}" 45 | if [ $CLANG -eq 1 ]; then CROSS="${COMPILER}"; else CROSS="${CROSS_COMPILE}${COMPILER}"; fi 46 | fi 47 | } 48 | 49 | kbuild (){ 50 | if [ $CLANG -eq 1 ]; then CLANG_FLAGS="${CLANG_LLVM}"; fi 51 | if [ $CROSSCOMPILE -eq 1 ]; then 52 | make -j${CORES} KBUILD_DEBARCH=${DEBARCH} ARCH=${ARCH} CC="${CROSS}" CFLAGS="${CFLAGS}" CROSS_COMPILE=${CROSS_COMPILE} ${CLANG_FLAGS} $1 53 | else 54 | make -j${CORES} KBUILD_DEBARCH=${DEBARCH} ARCH=${ARCH} CC="${NATIVE}" CFLAGS="${CFLAGS}" ${CLANG_FLAGS} $1 55 | fi 56 | } 57 | -------------------------------------------------------------------------------- /lib/function/config: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | custom_txt (){ 4 | cat < "custom.txt" 5 | # Bootstrap: if false use debootstrap 6 | MMDEBSTRAP="true" 7 | 8 | # Image Size: 3584MB 4096MB 9 | IMGSIZE="4096MB" 10 | 11 | # Root Filesystem Types: ext4 btrfs xfs 12 | FSTYPE="ext4" 13 | 14 | # Shrink Image 15 | SHRINK="true" 16 | 17 | # Hostname 18 | HOSTNAME="raspberrypi" 19 | 20 | # Branding: true false 21 | BRANDING="false" 22 | MOTD="Raspberry Pi" 23 | 24 | ### DO NOT EDIT BELOW THIS LINE 25 | CUSTOM="${BUILDER}" 26 | EOF 27 | } 28 | 29 | kernel_txt (){ 30 | cat < "kernel.txt" 31 | ### ADVANCED KERNEL PREFERENCES 32 | 33 | # Custom linux logo 34 | LINUX_LOGO="linux_clut224.ppm" 35 | 36 | # Enable additional modules 37 | MODULES="CONFIG_MODULE_SIG=y CONFIG_CIFS_POSIX=y CONFIG_EFI=y CONFIG_DMI=y CONFIG_SYSFB_SIMPLEFB=y \n 38 | CONFIG_EFI_ARMSTUB_DTB_LOADER=y CONFIG_EFI_BOOTLOADER_CONTROL=y CONFIG_RESET_ATTACK_MITIGATION=y \n 39 | CONFIG_NVME_HWMON=y CONFIG_ZRAM_BACKEND_LZ4=y CONFIG_ZRAM_BACKEND_LZ4HC=y CONFIG_ZRAM_BACKEND_ZSTD=y \n 40 | CONFIG_ZRAM_BACKEND_DEFLATE=y CONFIG_ZRAM_BACKEND_LZO=y" 41 | 42 | ### DO NOT EDIT BELOW THIS LINE 43 | KERNEL_PREFERENCES="$BUILDER" 44 | EOF 45 | sed -i 's/[\][n]/\\/g' kernel.txt 46 | } 47 | 48 | mirror_txt (){ 49 | cat < "mirror.txt" 50 | DEBIAN_MIRROR="http://deb.debian.org/debian" 51 | DEVUAN_MIRROR="http://deb.devuan.org/merged" 52 | KALI_MIRROR="http://http.kali.org/kali" 53 | UBUNTU_MIRROR="http://ports.ubuntu.com/ubuntu-ports/" 54 | 55 | ### DO NOT EDIT BELOW THIS LINE 56 | MIRROR_LIST="$BUILDER" 57 | EOF 58 | } 59 | 60 | profile_txt (){ 61 | cat < "profile.txt" 62 | # User data defaults 63 | #NAME="$MYNAME" 64 | #USERNAME="$USER" 65 | #PASSWORD="board" 66 | #COMPILER="gcc" 67 | #CCACHE="$CCACHE" 68 | #NETWORKMANAGER="$NETWORKMANAGER" 69 | #RTW88="$RTW88" 70 | #USERACCT="$USERACCT" 71 | #USER_PKGS="$USER_PKGS" 72 | #LOCALE="$LOCALE" 73 | #LOCALE_LC_ALL="$LOCALE_LC_ALL" 74 | #TIMEZONE="$TIMEZONE" 75 | #NAMESERVER1="$NAMESERVER1" 76 | #NAMESERVER2="$NAMESERVER2" 77 | 78 | ### DO NOT EDIT BELOW THIS LINE 79 | USER_PROFILE="$PROFILE" 80 | EOF 81 | } 82 | -------------------------------------------------------------------------------- /lib/function/defconfig: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | linux_configs (){ 4 | if [[ -f "arch/${ARCH}/configs/${LINUX_DEFCONFIG}" ]]; then 5 | # remove localversion 6 | if [[ `grep -w "CONFIG_LOCALVERSION=" "arch/${ARCH}/configs/${LINUX_DEFCONFIG}"` ]]; then sed -i 's/CONFIG_LOCALVERSION=/# CONFIG_LOCALVERSION=/g' arch/${ARCH}/configs/${LINUX_DEFCONFIG}; fi 7 | # hardcode i2c-dev 8 | if [[ `grep -w "CONFIG_I2C_CHARDEV=m" "arch/${ARCH}/configs/${LINUX_DEFCONFIG}"` ]]; then sed -i 's/CONFIG_I2C_CHARDEV=m/CONFIG_I2C_CHARDEV=y/g' arch/${ARCH}/configs/${LINUX_DEFCONFIG}; fi 9 | fi 10 | if [[ -v "MODULES" ]] && [[ ! -z "$MODULES" ]]; then 11 | # insert additional modules 12 | echo -e ${MODULES} | tr ' ' '\n' | tee -a modlist.txt > /dev/null 2>&1 13 | for MODLIST in `cat modlist.txt`; do 14 | if [[ `grep -w "${MODLIST}" "arch/${ARCH}/configs/${LINUX_DEFCONFIG}"` ]]; then :; else echo "${MODLIST}" >> "arch/${ARCH}/configs/${LINUX_DEFCONFIG}"; fi 15 | rm -f modlist.txt 16 | done 17 | fi 18 | if [ $CLANG -eq 1 ] && [[ "$ARCH" == "arm64" ]] && [[ -f "arch/${ARCH}/configs/${LINUX_DEFCONFIG}" ]]; then 19 | if [[ `grep -w "CONFIG_LTO_CLANG_THIN=y" "arch/${ARCH}/configs/${LINUX_DEFCONFIG}"` ]]; then :; else echo "CONFIG_LTO_CLANG_THIN=y" >> arch/${ARCH}/configs/${LINUX_DEFCONFIG}; fi 20 | fi 21 | } 22 | -------------------------------------------------------------------------------- /lib/function/echoes: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # COLORS 4 | RED="\e[0;31m" 5 | GRN="\e[0;32m" 6 | PNK="\e[0;35m" 7 | YLW="\e[0;36m" 8 | WHT="\033[0m" 9 | FIN="\e[0m" 10 | 11 | # ECHOES 12 | echo_extract(){ 13 | echo -e "${WHT}Extracting archive${FIN} ..." 14 | } 15 | 16 | echo_compress(){ 17 | echo -e "${WHT}== Compressing image${FIN}" 18 | } 19 | 20 | echo_shrink(){ 21 | echo -e "${WHT}== Shrinking image${FIN}" 22 | } 23 | 24 | echo_patch(){ 25 | echo -e "${WHT}Applying patches${FIN} ..." 26 | } 27 | 28 | echo_done(){ 29 | echo -e "${WHT}Done${FIN}." 30 | } 31 | 32 | echo_ok(){ 33 | echo -e "${PNK}[${FIN}${GRN}ok${FIN}${PNK}]${FIN}" 34 | } 35 | 36 | echo_nok(){ 37 | echo -e -n "${PNK}[${FIN}${GRN}ok${FIN}${PNK}]${FIN}" 38 | } 39 | 40 | echo_fail(){ 41 | echo -n -e "${PNK}[${FIN}${RED}failed${FIN}${PNK}]${FIN}" 42 | } 43 | 44 | echo_bdone(){ 45 | echo -e "${PNK}[${FIN}${GRN}done${FIN}${PNK}]${FIN}" 46 | } 47 | 48 | echo_kernel(){ 49 | echo -e "${WHT}Downloading ${KERNEL}-${VERSION}${FIN} ..." 50 | } 51 | 52 | echo_firm(){ 53 | echo -e "${WHT}Downloading firmware${FIN} ..." 54 | } 55 | 56 | echo_stable(){ 57 | echo -e "${WHT}Downloading stable linux${FIN} ..." 58 | } 59 | 60 | echo_mainline(){ 61 | echo -e "${WHT}Downloading mainline linux${FIN} ..." 62 | } 63 | 64 | echo_cconfig(){ 65 | echo -e "${WHT}Making ${MYCONFIG}${FIN} ..." 66 | } 67 | 68 | echo_fconfig(){ 69 | echo -e "${WHT}Making foundation defconfig${FIN} ..." 70 | } 71 | 72 | echo_bconfig(){ 73 | echo -e "${WHT}Making builder defconfig${FIN} ..." 74 | } 75 | 76 | echo_menuconfig(){ 77 | echo -e "${WHT}Opening menuconfig${FIN} ..." 78 | } 79 | 80 | echo_build(){ 81 | echo -e "${WHT}--- Building deb packages${FIN} ..." 82 | } 83 | -------------------------------------------------------------------------------- /lib/function/miscellaneous: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # ubuntu apt preferences 4 | apt_preferences (){ 5 | CAP_DISTRO=`echo "${DISTRO}" | sed -e "s/\b\(.\)/\u\1/g"` 6 | echo "" 7 | echo "Blacking listing packages ..." 8 | tee /etc/apt/preferences < "/etc/newt/palette.dark" 20 | root=,black 21 | checkbox=,black 22 | entry=,black 23 | label=black, 24 | actlistbox=,black 25 | helpline=,black 26 | roottext=lightgray,black 27 | emptyscale=black 28 | disabledentry=black, 29 | EOF 30 | ln -sf /etc/newt/palette.dark /etc/alternatives/newt-palette 31 | } 32 | 33 | xorg_confs (){ 34 | mkdir -p /etc/X11/xorg.conf.d 35 | cat < "/etc/X11/xorg.conf.d/99-v3d.conf" 36 | Section "OutputClass" 37 | Identifier "vc4" 38 | MatchDriver "vc4" 39 | Driver "modesetting" 40 | Option "PrimaryGPU" "true" 41 | EndSection 42 | EOF 43 | } 44 | 45 | # user scripts 46 | uscripts_pre-stage1 (){ 47 | if [[ -f "files/userscripts/uscripts" ]]; then 48 | source files/userscripts/uscripts 49 | if [[ `type run_function0` ]] &>/dev/null; then run_function0; fi 50 | fi 51 | } 52 | 53 | uscripts_stage1 (){ 54 | if [[ -f "files/userscripts/uscripts" ]]; then 55 | mkdir -p p2/root/userscripts 56 | cp -fr files/userscripts/* p2/root/userscripts/ 57 | if [[ -f "p2/root/userscripts/README.md" ]]; then rm -f p2/root/userscripts/README.md; fi 58 | if [[ `type run_function1` ]] &>/dev/null; then run_function1; fi 59 | fi 60 | } 61 | 62 | uscripts_stage2 (){ 63 | if [[ -f "/root/userscripts/uscripts" ]]; then 64 | source /root/userscripts/uscripts 65 | if [[ `type run_function2` ]] &>/dev/null; then 66 | echo "" 67 | echo -e "\033[1mRunning user scripts\e[0m ..." 68 | run_function2 69 | echo -e "\033[1mDone\e[0m." 70 | fi 71 | fi 72 | if [[ -e "/root/userscripts" ]]; then rm -fdr /root/userscripts; fi 73 | } 74 | 75 | uscripts_fin-stage1 (){ 76 | if [[ -f "files/userscripts/uscripts" ]]; then 77 | source files/userscripts/uscripts 78 | if [[ `type run_function3` ]] &>/dev/null; then run_function3; fi 79 | fi 80 | } 81 | 82 | # fin and compress 83 | finish_image (){ 84 | IMAGE_TIME="$(date +%T | sed 's/://g' | sed 's/..$//')" 85 | IMAGE_FIN_NAME="${BOARD_EXT}-${DISTRO}-${DISTRO_VERSION}-${INSTALLED_KERNEL}-${ARCH_EXT}-${FSTYPE}-${IMAGE_DATE}-${IMAGE_TIME}.img" 86 | if [[ -f "${IMAGE_FILE_NAME}" ]]; then 87 | mv -f ${IMAGE_FILE_NAME} ${IMAGE_FIN_NAME} 88 | else 89 | echo -e "Build error: ${IMAGE_FILE_NAME}" 90 | exit 1 91 | fi 92 | if [ $COMPRESS_IMG -eq 1 ]; then 93 | if [[ -f "${IMAGE_FIN_NAME}" ]]; then 94 | echo -e "" 95 | echo_compress 96 | xz -zev --threads=${CORES} ${IMAGE_FIN_NAME} 97 | if [[ -f "${IMAGE_FIN_NAME}.xz" ]]; then 98 | sha256sum ${IMAGE_FIN_NAME}.xz > ${IMAGE_FIN_NAME}.xz.sha256 99 | sha256sum --check ${IMAGE_FIN_NAME}.xz.sha256 100 | fi 101 | else 102 | echo -e "" 103 | echo -e "${IMAGE_FIN_NAME} not found?" 104 | fi 105 | fi 106 | } 107 | -------------------------------------------------------------------------------- /lib/function/patching: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # boot firmware 4 | firmware (){ 5 | FIRMWARE="https://github.com/raspberrypi/firmware.git" 6 | echo -en "Firmware" 7 | echo -en " ${PNK}[${FIN}${WHT}downloading${FIN}${PNK}]${FIN}" 8 | rm -fdr firmware 9 | git clone -q -n --filter=tree:0 --sparse ${FIRMWARE} tmp &> /dev/null 10 | cd tmp 11 | git sparse-checkout set --no-cone --quiet boot &> /dev/null 12 | git checkout --quiet &> /dev/null 13 | rm -fdr boot/{overlays,*.dtb,kernel*} 14 | mv boot ../firmware 15 | cd .. 16 | rm -fdr tmp 17 | echo -en " ${PNK}[${FIN}${WHT}checking${FIN}${PNK}]${FIN}" 18 | if [[ `ls firmware/{fixup4.dat,fixup4cd.dat,fixup4db.dat,fixup4x.dat,start4.elf,start4cd.elf,start4db.elf,start4x.elf}` ]] > /dev/null 2>&1; then 19 | :; 20 | else 21 | echo -en " ${YLW}[${FIN}${RED}failed${FIN}${YLW}]${FIN}"; echo "" 22 | exit 1 23 | fi 24 | if [[ `ls firmware/{bootcode.bin,fixup.dat,fixup_cd.dat,fixup_db.dat,fixup_x.dat,start.elf,start_cd.elf,start_db.elf,start_x.elf}` ]] > /dev/null 2>&1; then 25 | echo -e " ${PNK}[${FIN}${GRN}done${FIN}${PNK}]${FIN}" 26 | else 27 | echo -en " ${YLW}[${FIN}${RED}failed${FIN}${YLW}]${FIN}"; echo "" 28 | exit 1 29 | fi 30 | } 31 | 32 | # check log and report 33 | check_log (){ 34 | if [[ -f "${LOG_FILE}" ]]; then 35 | PATHTOFILE=`echo ${LOG_FILE} | sed 's/..\/..\///g'` 36 | if [[ `grep "Skipping patch" "${LOG_FILE}"` ]]; then 37 | SKIPPING="true" 38 | grep "Skipping patch" "${LOG_FILE}" | echo -en " ${PNK}[${FIN}"${WHT}skipping${FIN} ${WHT}`wc -l`${FIN}"${PNK}]${FIN}" 39 | else 40 | SKIPPING="false" 41 | fi 42 | if [[ `grep "FAILED" "${LOG_FILE}"` ]]; then 43 | FAILED="true" 44 | grep "FAILED" "${LOG_FILE}" | echo -en " ${PNK}[${FIN}"${RED}fails${FIN} ${WHT}`wc -l`${FIN}"${PNK}]${FIN}" 45 | if [ $VERBOSE -eq 1 ]; then 46 | echo -en " ${WHT}log: ${PATHTOFILE}${FIN}" 47 | exit 1 48 | fi 49 | else 50 | FAILED="false" 51 | fi 52 | if [[ "$SKIPPING" == "true" ]] && [[ "$FAILED" == "false" ]]; then 53 | echo -en " ${PNK}[${FIN}${YLW}done${FIN}${PNK}]${FIN}" 54 | fi 55 | if [[ "$SKIPPING" == "false" ]] && [[ "$FAILED" == "false" ]]; then 56 | echo -en " ${PNK}[${FIN}${GRN}done${FIN}${PNK}]${FIN}" 57 | fi 58 | echo -en " ${WHT}log: ${PATHTOFILE}${FIN}" 59 | echo -e "" 60 | fi 61 | } 62 | 63 | # linux patch log 64 | linux_log (){ 65 | LOG_DIR="../../output/logs" 66 | LOG_FILE="${LOG_DIR}/${BOARD}-patch.log" 67 | if [[ -f "${LOG_FILE}" ]]; then 68 | mv -f ${LOG_FILE} ${LOG_FILE}.1 69 | echo "Linux ${VERSION}" > ${LOG_FILE} 70 | echo `date` >> ${LOG_FILE} 71 | else 72 | mkdir -p ${LOG_DIR} 73 | echo "Linux ${VERSION}" > ${LOG_FILE} 74 | echo `date` >> ${LOG_FILE} 75 | fi 76 | } 77 | 78 | # linux user patch log 79 | linux_user_log (){ 80 | LOG_DIR="../../output/logs" 81 | LOG_FILE="${LOG_DIR}/${BOARD}-user-patch.log" 82 | if [[ -f "${LOG_FILE}" ]]; then 83 | mv -f ${LOG_FILE} ${LOG_FILE}.1 84 | echo "Linux ${VERSION}" > ${LOG_FILE} 85 | echo `date` >> ${LOG_FILE} 86 | else 87 | mkdir -p ${LOG_DIR} 88 | echo "Linux ${VERSION}" > ${LOG_FILE} 89 | echo `date` >> ${LOG_FILE} 90 | fi 91 | } 92 | 93 | # linux apply patches 94 | linux_patches (){ 95 | linux_log 96 | echo "" >> ${LOG_FILE} 97 | echo "# APPLYING PATCHES" >> ${LOG_FILE} 98 | echo -en "${WHT}Patches${FIN} ${PNK}[${FIN}${WHT}applying${FIN}${PNK}]${FIN}" 99 | if [[ -d "../../patches/all/${VERSION}" ]]; then 100 | if [[ `ls ../../patches/all/${VERSION}/*.patch` ]] > /dev/null 2>&1; then 101 | for i in ../../patches/all/${VERSION}/*.patch; do patch -N -p1 < $i; done >> ${LOG_FILE} 102 | fi 103 | fi 104 | # wireless 105 | if [ $RTW88 -eq 1 ] && [[ -d "../../patches/wireless/rtw88" ]]; then 106 | if [[ `ls ../../patches/wireless/rtw88/{Kconfig,Makefile}` ]] > /dev/null 2>&1; then 107 | cp -fr ../../patches/wireless/rtw88/{Kconfig,Makefile} drivers/net/wireless/realtek/${DRIVER}/ 108 | fi 109 | if [[ `ls ../../patches/wireless/rtw88/hack/*.patch` ]] > /dev/null 2>&1; then 110 | echo "# wireless/rtw88/hack" | sed -e 's/\(.*\)/\U\1/' >> ${LOG_FILE} 111 | for i in ../../patches/wireless/rtw88/hack/*.patch; do patch -N -p1 < $i; done >> ${LOG_FILE} 112 | fi 113 | fi 114 | check_log 115 | } 116 | 117 | # user patches 118 | user_patches (){ 119 | if [[ `ls ../../patches/userpatches/*.patch` ]] > /dev/null 2>&1; then 120 | linux_user_log 121 | echo "" >> ${LOG_FILE} 122 | echo "# APPLYING USER PATCHES" >> ${LOG_FILE} 123 | echo -en "${WHT}User Patches${FIN} ${PNK}[${FIN}${WHT}applying${FIN}${PNK}]${FIN}" 124 | for i in ../../patches/userpatches/*.patch; do patch -N -p1 < $i; done >> ${LOG_FILE} 125 | check_log 126 | fi 127 | } 128 | 129 | # patching and packaging 130 | linux_patching (){ 131 | rm -f scripts/package/{builddeb,mkdebian} 132 | cp -fr ../../packaging/{builddeb,mkdebian} scripts/package/ 133 | chmod +x scripts/package/{builddeb,mkdebian} 134 | if [[ -f "../../packaging/dtclist.txt" ]] && [[ -f "../../packaging/initrd" ]] && [[ -f "../../packaging/headers-byteshift.patch" ]]; then 135 | cp -fr ../../packaging/{dtclist.txt,initrd,headers-byteshift.patch} . 136 | else 137 | echo -e "An essential builddeb file is missing." 138 | exit 1 139 | fi 140 | if [[ -v "LINUX_LOGO" ]] && [[ ! -z "$LINUX_LOGO" ]]; then 141 | if [[ -f "../../packaging/logo/${LINUX_LOGO}" ]]; then cp -f "../../packaging/logo/${LINUX_LOGO}" "drivers/video/logo/logo_linux_clut224.ppm"; fi 142 | fi 143 | if [[ -f "arch/${ARCH}/Kconfig" ]] && [[ "$ARCH" == "arm64" ]]; then 144 | # REVERT: arm64/Kconfig: Don't set DMA_BOUNCE_UNALIGNED_KMALLOC 145 | # If enabled, DMA_BOUNCE_UNALIGNED_KMALLOC causes the swiotlb buffers (64MB, by default) to be allocated, even on systems 146 | # where the DMA controller can reach all of RAM. 147 | sed -i 's/ # select DMA_BOUNCE_UNALIGNED_KMALLOC/ select DMA_BOUNCE_UNALIGNED_KMALLOC/g' arch/arm64/Kconfig 148 | fi 149 | linux_patches 150 | user_patches 151 | linux_packaging 152 | echo -e "" 153 | } 154 | -------------------------------------------------------------------------------- /lib/function/release: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mirrors (){ 4 | source mirror.txt 5 | if [[ "$DISTRO" == "debian" ]]; then MIRROR="${DEBIAN_MIRROR}"; else 6 | if [[ "$DISTRO" == "devuan" ]]; then MIRROR="${DEVUAN_MIRROR}"; else 7 | if [[ "$DISTRO" == "kali" ]]; then MIRROR="${KALI_MIRROR}"; else 8 | if [[ "$DISTRO" == "raspbian" ]]; then MIRROR="http://raspbian.raspberrypi.org/raspbian"; else 9 | if [[ "$DISTRO" == "ubuntu" ]]; then MIRROR="${UBUNTU_MIRROR}"; fi; fi; fi; fi; fi 10 | } 11 | 12 | # DEBIAN 13 | debian_sources_list (){ 14 | SOURCES_LIST="${P_VALUE}/etc/apt/sources.list.d/${DISTRO}.sources" 15 | } 16 | 17 | debian_release (){ 18 | if [[ "$DISTRO_VERSION" == "bullseye" ]]; then POOL="main contrib non-free"; else POOL="main contrib non-free non-free-firmware"; fi 19 | if [[ "$DISTRO_VERSION" =~ ^(bullseye|bookworm|trixie|testing)$ ]]; then 20 | tee ${SOURCES_LIST} < "${P_VALUE}/etc/dpkg/dpkg.cfg.d/dpkg-unsafe-io" 23 | if [ $VERBOSE -eq 1 ]; then choose_release; else choose_release > /dev/null 2>&1; fi 24 | } 25 | 26 | devuan_keyring (){ 27 | URL="https://pkgmaster.devuan.org/devuan/pool/main/d/devuan-keyring/" 28 | FILE="devuan-keyring_2023.10.07_all.deb" 29 | if [[ `dpkg -l | grep "devuan-keyring"` ]]; then 30 | if [[ `dpkg -l | grep "devuan-keyring" | tr -d -c 0-9` == "20231007" ]]; then 31 | :; 32 | else 33 | apt purge -y devuan-keyring 34 | wget -cq --show-progress ${URL}${FILE}; dpkg -i ${FILE}; rm -f ${FILE} 35 | fi 36 | else 37 | wget -cq --show-progress ${URL}${FILE}; dpkg -i ${FILE}; rm -f ${FILE} 38 | fi 39 | } 40 | 41 | kali_keyring (){ 42 | URL="http://http.kali.org/pool/main/k/kali-archive-keyring/" 43 | FILE="kali-archive-keyring_2024.1_all.deb" 44 | if [[ `dpkg -l | grep "kali-archive-keyring"` ]]; then 45 | if [[ `dpkg -l | grep "kali-archive-keyring" | tr -d -c 0-9` == "20241" ]]; then 46 | :; 47 | else 48 | apt purge -y kali-archive-keyring 49 | wget -cq --show-progress ${URL}${FILE}; dpkg -i ${FILE}; rm -f ${FILE} 50 | fi 51 | else 52 | wget -cq --show-progress ${URL}${FILE}; dpkg -i ${FILE}; rm -f ${FILE} 53 | fi 54 | } 55 | 56 | raspbian_keyring (){ 57 | if [[ -f "/usr/share/keyrings/raspbian-archive-keyring.gpg" ]]; then 58 | :; 59 | else 60 | curl -sS http://archive.raspbian.org/raspbian.public.key | gpg --dearmor | tee /usr/share/keyrings/raspbian-archive-keyring.gpg > /dev/null 2>&1 61 | fi 62 | } 63 | 64 | ubuntu_keyring (){ 65 | URL="https://github.com/pyavitz/debian-image-builder/releases/download/dpkg/" 66 | FILE1="ubuntu-keyring_2023.11.28.1-0.2_all.deb" 67 | FILE2="ubuntu-archive-keyring_2023.11.28.1-0.2_all.deb" 68 | if [[ `dpkg -l | grep "ubuntu-keyring"` ]]; then 69 | if [[ `dpkg -l | grep "ubuntu-keyring" | tr -d -c 0-9` == "20231128102" ]]; then 70 | :; 71 | else 72 | apt purge -y ubuntu-keyring 73 | if [[ `dpkg -l | grep "ubuntu-archive-keyring"` ]]; then apt purge -y ubuntu-archive-keyring; fi 74 | if [[ `dpkg -l | grep "ubuntu-dbgsym-keyring"` ]]; then apt purge -y ubuntu-dbgsym-keyring; fi 75 | if [[ `dpkg -l | grep "ubuntu-cloud-keyring"` ]]; then apt purge -y ubuntu-cloud-keyring; fi 76 | wget -cq --show-progress ${URL}${FILE1}; wget -cq --show-progress ${URL}${FILE2} 77 | dpkg -i *.deb; rm -f *.deb 78 | fi 79 | else 80 | wget -cq --show-progress ${URL}${FILE1}; wget -cq --show-progress ${URL}${FILE2} 81 | dpkg -i *.deb; rm -f *.deb 82 | fi 83 | } 84 | 85 | debootstrap_script (){ 86 | DEBOOTSTRAP_DIR="/usr/share/debootstrap/scripts" 87 | if [[ -f "${DEBOOTSTRAP_DIR}/${DISTRO_VERSION}" ]]; then 88 | SPOOF_SCRIPT="false" 89 | else 90 | ln -sr ${DEBOOTSTRAP_DIR}/${DEBOOTSTRAP_SCRIPT} ${DEBOOTSTRAP_DIR}/${DISTRO_VERSION} 91 | SPOOF_SCRIPT="true" 92 | sleep .50 93 | fi 94 | } 95 | 96 | run_debootstrap (){ 97 | KEY="/usr/share/keyrings/${DISTRO}-archive-keyring.gpg" 98 | if [[ "$DISTRO" =~ ^(debian|devuan)$ ]]; then DEBOOTSTRAP_SCRIPT="sid"; debootstrap_script; fi 99 | if [[ "$DISTRO" == "ubuntu" ]]; then DEBOOTSTRAP_SCRIPT="gutsy"; debootstrap_script; fi 100 | if [[ "$MMDEBSTRAP" == "true" ]]; then 101 | mkdir -p ${P_VALUE}/etc/apt/sources.list.d/ 102 | touch ${P_VALUE}/etc/apt/sources.list # prevent duplicates 103 | if [ $VERBOSE -eq 1 ]; then choose_release; else choose_release > /dev/null 2>&1; fi 104 | mmdebstrap --skip=check/empty --arch=${ARCH_EXT} --keyring=${KEY} ${DISTRO_VERSION} ${P_VALUE} 105 | else 106 | debootstrap --arch ${ARCH_EXT} --foreign --force-check-gpg --keyring=${KEY} ${DISTRO_VERSION} ${P_VALUE} ${MIRROR} 107 | chroot ${P_VALUE} /debootstrap/debootstrap --second-stage 108 | echo "" > ${P_VALUE}/etc/apt/sources.list # clear file 109 | fi 110 | } 111 | -------------------------------------------------------------------------------- /lib/function/rpi-commit: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | DOWNLOAD="aria2c -c --download-result=hide --console-log-level=error --disable-ipv6=true --summary-interval=0 --show-files=false" 3 | 4 | source_dir (){ 5 | mkdir -p ${SRC} 6 | cp -f board.txt ${SRC}/ 7 | cd ${SRC} 8 | } 9 | 10 | download (){ 11 | RPIURL="https://github.com/raspberrypi/linux/archive/" 12 | echo "" 13 | if [[ -f "${CKERNEL}-${COMMIT}.tar.gz" ]]; then 14 | :; 15 | else 16 | echo -e "${WHT}Downloading ${CKERNEL}-${COMMIT}${FIN} ..." 17 | ${DOWNLOAD} ${RPIURL}${COMMIT}.tar.gz 18 | echo -e " ${PNK}[${FIN}${GRN}done${FIN}${PNK}]${FIN}" 19 | fi 20 | } 21 | 22 | report_tarball_error (){ 23 | echo "NOTICE: Tarball ${CKERNEL}-${COMMIT} is MIA. Please make a report." 24 | echo "" 25 | exit 0 26 | } 27 | 28 | extract (){ 29 | echo "" 30 | if [[ -f "${CKERNEL}-${COMMIT}.tar.gz" ]]; then 31 | echo_extract 32 | pv ${CKERNEL}-${COMMIT}.tar.gz | tar -xzf - -C . 33 | else 34 | report_tarball_error 35 | fi 36 | } 37 | 38 | report_dir_error (){ 39 | echo "NOTICE: Directory ${CKERNEL}-${COMMIT} is MIA. Please make a report." 40 | echo "" 41 | exit 0 42 | } 43 | 44 | setup (){ 45 | if [[ -d "${CKERNEL}-${COMMIT}" ]]; then 46 | cd ${CKERNEL}-${COMMIT} 47 | export ARCH=${ARCH} 48 | if [[ "ARCH" == "arm" ]]; then KERNEL=${KERNEL_VAR}; fi 49 | else 50 | report_dir_error 51 | fi 52 | } 53 | 54 | cconfig (){ 55 | echo_cconfig 56 | if [[ -f "../../defconfig/${MYCONFIG}" ]]; then 57 | cp -f ../../defconfig/${MYCONFIG} arch/${ARCH}/configs/ 58 | else 59 | echo "" 60 | echo -e "${MYCONFIG} was not found." 61 | echo -e "Check that the name is correct and in the correct location." 62 | echo -e "If you believe you are receiving this in error, please report it." 63 | read -p "Press enter to continue." 64 | exit 1 65 | fi 66 | kbuild "${MYCONFIG}" 67 | echo "" 68 | } 69 | 70 | fconfig (){ 71 | echo -e "${WHT}Making ${LINUX_DEFCONFIG}${FIN}." 72 | linux_configs 73 | kbuild "${LINUX_DEFCONFIG}" 74 | echo "" 75 | } 76 | 77 | save_defconfig (){ 78 | if [[ -f "defconfig" ]]; then 79 | echo "" 80 | mkdir -p ../../$OUTPUT/ 81 | # minimal 82 | cp -f defconfig ../../$OUTPUT/${BOARD}_defconfig 83 | # full 84 | cp -f .config ../../$OUTPUT/${BOARD}-config_defconfig 85 | # path to files 86 | ls -ls ../../$OUTPUT/${BOARD}_defconfig | sed 's/..\/..\///g' 87 | ls -ls ../../$OUTPUT/${BOARD}-config_defconfig | sed 's/..\/..\///g' 88 | fi 89 | } 90 | 91 | menuconfig (){ 92 | echo "" 93 | echo_menuconfig 94 | sleep .50 95 | kbuild "menuconfig" 96 | sleep .25 97 | kbuild "savedefconfig" 98 | echo "# ${BOARD} defconfig saved." 99 | options=("Continue" "Quit") 100 | select opt in "${options[@]}" 101 | do 102 | case $opt in 103 | "Continue") 104 | save_defconfig 105 | break 106 | ;; 107 | "Quit") 108 | save_defconfig 109 | exit 0 110 | ;; 111 | *) echo "invalid option $REPLY";; 112 | esac 113 | done 114 | } 115 | 116 | builddeb (){ 117 | if [ $CROSSCOMPILE -eq 1 ]; then echo -e "${GRN} CC${FIN} ${CROSS_COMPILE}${COMPILER}"; else echo -e "${GRN} NC${FIN} ${COMPILER}"; fi 118 | echo ${BUILD_VERSION} > .version 119 | echo 'y' | kbuild "LOCALVERSION= KBUILD_BUILD_USER=${KBUSER} KBUILD_BUILD_HOST=${KBHOST} bindeb-pkg" 120 | } 121 | -------------------------------------------------------------------------------- /lib/function/rpi-linux: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | GIT_URL="https://github.com/raspberrypi/linux" 3 | ITL="\033[3m" 4 | 5 | source_dir (){ 6 | mkdir -p ${SRC} 7 | cp -f board.txt ${SRC}/ 8 | cd ${SRC} 9 | } 10 | 11 | noinitrd (){ # no longer used 12 | sed -i 's/export INITRD=$want_initrd/export INITRD=No/g' scripts/package/builddeb 13 | sed -i 's/export INITRD=$(if_enabled_echo CONFIG_BLK_DEV_INITRD Yes No)/export INITRD=No/g' scripts/package/builddeb 14 | } 15 | 16 | download (){ 17 | if [[ `wget -S --spider ${GIT_URL}/blob/rpi-${VERSION}/Makefile 2>&1 | grep 'HTTP/1.1 200 OK'` ]]; then 18 | download_options 19 | if [[ "$GIT_SHALLOW" == "true" ]]; then verify_commit; fi 20 | if [[ -d "${KERNEL}-${VERSION}" ]] && [[ -d "${KERNEL}-${VERSION}.backup" ]]; then 21 | echo -en "${KERNEL}-${VERSION}" 22 | echo -en " ${PNK}[${FIN}${YLW}restoring${FIN}${PNK}]${FIN}" 23 | rm -fdr ${KERNEL}-${VERSION} 24 | echo -en " ${WHT}...${FIN}" 25 | mv -f ${KERNEL}-${VERSION}.backup ${KERNEL}-${VERSION} 26 | if [[ "$GIT_SHALLOW" == "false" ]]; then 27 | cd ${KERNEL}-${VERSION}; git pull -q; make clean; cd .. 28 | else 29 | cd ${KERNEL}-${VERSION}; make clean; cd .. 30 | fi 31 | cp -r ${KERNEL}-${VERSION} ${KERNEL}-${VERSION}.backup 32 | echo -e " ${PNK}[${FIN}${GRN}done${FIN}${PNK}]${FIN}" 33 | else 34 | echo -e "This may take a while ..." 35 | echo "" 36 | git clone ${GIT_OPT} -b rpi-${VERSION} ${GIT_URL}.git ${KERNEL}-${VERSION} 37 | sleep .50 38 | if [[ -d "${KERNEL}-${VERSION}" ]] && [[ -f "${KERNEL}-${VERSION}/Makefile" ]]; then 39 | cd ${KERNEL}-${VERSION}; make clean; cd .. 40 | echo -en "${KERNEL}-${VERSION}" 41 | echo -en " ${PNK}[${FIN}${WHT}creating backup${FIN}${PNK}]${FIN}" 42 | cp -r ${KERNEL}-${VERSION} ${KERNEL}-${VERSION}.backup 43 | echo -e " ${PNK}[${FIN}${GRN}done${FIN}${PNK}]${FIN}" 44 | else 45 | echo -en "${KERNEL}-${VERSION}" 46 | echo -en " ${PNK}[${FIN}${WHT}download${FIN}${PNK}]${FIN}" 47 | echo -e " ${PNK}[${FIN}${RED}failed${FIN}${PNK}]${FIN}" 48 | exit 0 49 | fi 50 | fi 51 | else 52 | echo "" 53 | echo -e "Git branch ${VERSION} is not available?" 54 | exit 0 55 | fi 56 | } 57 | 58 | download_options (){ 59 | GIT_HASH=`git ls-remote --heads ${GIT_URL}.git | grep -w "refs/heads/rpi-${VERSION}" | sed -n '1p' | sed "s/refs\/heads\/rpi-${VERSION}//g" | sed s/'\s'//g` 60 | if [[ -f "../.cache/git_shallow.${KERNEL}-${VERSION}" ]] && [[ -d "${KERNEL}-${VERSION}" ]]; then 61 | :; 62 | else 63 | rm -f ../.cache/git_shallow.${KERNEL}-${VERSION} 64 | rm -fdr ${KERNEL}-${VERSION} 65 | fi 66 | if [[ -f "../.cache/git_shallow.${KERNEL}-${VERSION}" ]]; then 67 | source ../.cache/git_shallow.${KERNEL}-${VERSION} 68 | if [[ "$GIT_SHALLOW" == "true" ]]; then GIT_OPT="--depth 1"; else GIT_OPT=""; fi 69 | else 70 | mkdir -p ../.cache 71 | echo 'GIT_SHALLOW="true"' > ../.cache/git_shallow.${KERNEL}-${VERSION} 72 | echo GIT_COMMIT='"'${GIT_HASH}'"' >> ../.cache/git_shallow.${KERNEL}-${VERSION} 73 | GIT_OPT="--depth 1" 74 | echo -e "" 75 | fi 76 | GIT_HASH_SHORT=`echo "${GIT_HASH}" | sed 's/^\(.\{7\}\).*/\1/'` 77 | GIT_COMMIT_SHORT=`echo "${GIT_COMMIT}" | sed 's/^\(.\{7\}\).*/\1/'` 78 | } 79 | 80 | verify_commit (){ 81 | echo "" 82 | echo -en "Commit:" 83 | if [[ "$GIT_COMMIT" == "$GIT_HASH" ]]; then 84 | echo -en " ${GIT_COMMIT_SHORT}" 85 | sleep .50 86 | echo -e " ${PNK}[${FIN}${GRN}ok${FIN}${PNK}]${FIN}" 87 | else 88 | 89 | echo -en " ${GIT_HASH_SHORT}" 90 | sleep .50 91 | echo -e " ${ITL}NEW!${FIN}" 92 | sed -i 's/^GIT_COMMIT=.*/GIT_COMMIT="'"${GIT_HASH}"'"/' ../.cache/git_shallow.${KERNEL}-${VERSION} 93 | echo -en "Removing: ${GIT_COMMIT_SHORT}" 94 | rm -fdr ${KERNEL}-${VERSION} ${KERNEL}-${VERSION}.backup 95 | echo -e " ${PNK}[${FIN}${GRN}done${FIN}${PNK}]${FIN}" 96 | echo "" 97 | fi 98 | } 99 | 100 | setup (){ 101 | if [[ -d "${KERNEL}-${VERSION}" ]]; then 102 | cd ${KERNEL}-${VERSION} 103 | export ARCH=${ARCH} 104 | if [[ "ARCH" == "arm" ]]; then KERNEL=${KERNEL_VAR}; fi 105 | else 106 | report_dir_error 107 | fi 108 | } 109 | 110 | cconfig (){ 111 | echo_cconfig 112 | if [[ -f "../../defconfig/${MYCONFIG}" ]]; then 113 | cp -f ../../defconfig/${MYCONFIG} arch/${ARCH}/configs/ 114 | else 115 | echo "" 116 | echo -e "${MYCONFIG} was not found." 117 | echo -e "Check that the name is correct and in the correct location." 118 | echo -e "If you believe you are receiving this in error, please report it." 119 | read -p "Press enter to continue." 120 | exit 1 121 | fi 122 | kbuild "${MYCONFIG}" 123 | echo "" 124 | } 125 | 126 | fconfig (){ 127 | echo -e "${WHT}Making ${LINUX_DEFCONFIG}${FIN}." 128 | linux_configs 129 | kbuild "${LINUX_DEFCONFIG}" 130 | echo "" 131 | } 132 | 133 | save_defconfig (){ 134 | if [[ -f "defconfig" ]]; then 135 | echo "" 136 | mkdir -p ../../$OUTPUT/ 137 | # minimal 138 | cp -f defconfig ../../$OUTPUT/${BOARD}_defconfig 139 | # full 140 | cp -f .config ../../$OUTPUT/${BOARD}-config_defconfig 141 | # path to files 142 | ls -ls ../../$OUTPUT/${BOARD}_defconfig | sed 's/..\/..\///g' 143 | ls -ls ../../$OUTPUT/${BOARD}-config_defconfig | sed 's/..\/..\///g' 144 | fi 145 | } 146 | 147 | menuconfig (){ 148 | echo "" 149 | echo_menuconfig 150 | sleep .50 151 | kbuild "menuconfig" 152 | sleep .25 153 | kbuild "savedefconfig" 154 | echo "# ${BOARD} defconfig saved." 155 | options=("Continue" "Quit") 156 | select opt in "${options[@]}" 157 | do 158 | case $opt in 159 | "Continue") 160 | save_defconfig 161 | break 162 | ;; 163 | "Quit") 164 | save_defconfig 165 | exit 0 166 | ;; 167 | *) echo "invalid option $REPLY";; 168 | esac 169 | done 170 | } 171 | 172 | builddeb (){ 173 | if [ $CROSSCOMPILE -eq 1 ]; then echo -e "${GRN} CC${FIN} ${CROSS_COMPILE}${COMPILER}"; else echo -e "${GRN} NC${FIN} ${COMPILER}"; fi 174 | echo ${BUILD_VERSION} > .version 175 | echo 'y' | kbuild "LOCALVERSION= KBUILD_BUILD_USER=${KBUSER} KBUILD_BUILD_HOST=${KBHOST} bindeb-pkg" 176 | } 177 | -------------------------------------------------------------------------------- /lib/function/rpi-pkgs: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # stage 1 4 | stage1_kernel (){ 5 | if [[ `ls ${OUTPUT}/{linux-image-*.deb,linux-headers-*.deb}` ]] > /dev/null 2>&1; then 6 | cp ${OUTPUT}/*.deb p2/root 7 | else 8 | echo "" 9 | echo -en "${BOARD}" 10 | echo -e ": Compile a kernel before building an image." 11 | make cleanup 12 | exit 1 13 | fi 14 | } 15 | 16 | # stage 2 17 | raspberrypi_sys_mods (){ 18 | echo "" 19 | git clone https://github.com/RPi-Distro/raspberrypi-sys-mods.git 20 | if [[ "$DISTRO" == "devuan" ]]; then 21 | mv -f raspberrypi-sys-mods-control.patch raspberrypi-sys-mods/ 22 | cd raspberrypi-sys-mods 23 | git checkout -q 46ae4208397d662fc4f5d0cc9acc85395f852af1 24 | patch -p1 < raspberrypi-sys-mods-control.patch 25 | rm -f raspberrypi-sys-mods-control.patch 26 | else 27 | rm -f raspberrypi-sys-mods-control.patch 28 | cd raspberrypi-sys-mods 29 | git checkout -q 46ae4208397d662fc4f5d0cc9acc85395f852af1 30 | fi 31 | dpkg-buildpackage -us -uc 32 | cd ~ 33 | dpkg -i raspberrypi-sys-mods*.deb 34 | rm -fdr raspberrypi-sys-mods* 35 | rm -f /etc/apt/sources.list.d/vscode.list 36 | rm -f /etc/apt/trusted.gpg.d/microsoft.gpg 37 | rm -f /etc/apt/preferences.d/3rd_parties.pref 38 | } 39 | 40 | pi_bluetooth (){ 41 | echo "" 42 | if [[ "$DISTRO" == "ubuntu" ]]; then 43 | git clone --depth=1 https://github.com/pyavitz/pi-bluetooth.git -b ubuntu 44 | else 45 | git clone --depth=1 https://github.com/pyavitz/pi-bluetooth.git 46 | fi 47 | cd pi-bluetooth 48 | chmod +x debian/rules 49 | dpkg-buildpackage -us -uc 50 | cd ~ 51 | dpkg -i pi-bluetooth_*.deb 52 | rm -fdR pi-bluetooth* 53 | } 54 | 55 | # userland 56 | rpi_userland (){ 57 | echo "" 58 | rm -f /etc/profile 59 | mv -f profile /etc/profile 60 | mv rpi-vc.conf /etc/ld.so.conf.d/rpi-vc.conf 61 | chown root:root /etc/profile 62 | chown root:root /etc/ld.so.conf.d/rpi-vc.conf 63 | mkdir -p /opt 64 | git clone --depth=1 https://github.com/raspberrypi/userland.git 65 | mv -f userland-remove-hi-pi.patch /root/userland/ 66 | cd userland 67 | patch -p1 < userland-remove-hi-pi.patch 68 | rm -f userland-remove-hi-pi.patch 69 | if [[ "$ARCH" == "arm64" ]]; then 70 | echo -e "\e[1;37m== ARM64\e[0m" 71 | sleep .50 72 | ./buildme --aarch64 73 | else 74 | echo -e "\e[1;37m== ARM\e[0m" 75 | sleep .50 76 | ./buildme 77 | fi 78 | cd ~ 79 | rm -fdr userland 80 | ldconfig 81 | } 82 | 83 | # rpi-eeprom 84 | find_eeprom (){ 85 | EEPROM_VERSION=$(curl --silent -L ${CHANGELOG} | awk '{if (NR==1) {print substr($2, 1, length($2)-3)}}' | sed 's/[()]//g') 86 | if [[ `wget -S --spider ${ERURL}rpi-eeprom_${EEPROM_VERSION}.orig.tar.gz 2>&1 | grep 'HTTP/1.1 200 OK'` ]]; then 87 | wget -cq --show-progress ${ERURL}rpi-eeprom_${EEPROM_VERSION}-1.debian.tar.xz 88 | wget -cq --show-progress ${ERURL}rpi-eeprom_${EEPROM_VERSION}.orig.tar.gz 89 | else 90 | EEPROM_VERSION=$(curl --silent -L ${CHANGELOG} | awk '{if (NR==10) {print substr($2, 1, length($2)-3)}}' | sed 's/[()]//g') 91 | if [[ `wget -S --spider ${ERURL}rpi-eeprom_${EEPROM_VERSION}.orig.tar.gz 2>&1 | grep 'HTTP/1.1 200 OK'` ]]; then 92 | wget -cq --show-progress ${ERURL}rpi-eeprom_${EEPROM_VERSION}-1.debian.tar.xz 93 | wget -cq --show-progress ${ERURL}rpi-eeprom_${EEPROM_VERSION}.orig.tar.gz 94 | else 95 | EEPROM_VERSION="26.9" 96 | wget -cq --show-progress ${ERURL}rpi-eeprom_${EEPROM_VERSION}-1.debian.tar.xz 97 | wget -cq --show-progress ${ERURL}rpi-eeprom_${EEPROM_VERSION}.orig.tar.gz 98 | fi 99 | fi 100 | } 101 | 102 | eeprom_support (){ 103 | ERURL="https://archive.raspberrypi.org/debian/pool/main/r/rpi-eeprom/" 104 | CHANGELOG="https://raw.githubusercontent.com/raspberrypi/rpi-eeprom/pios/bookworm/debian/changelog" 105 | export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin 106 | echo "" 107 | apt install help2man rsync pciutils -y 108 | mkdir -p ~/eeprom 109 | mv -f rpi-eeprom-update.patch /root/eeprom/ 110 | mv -f rpi-eeprom-control /root/eeprom/ 111 | cd ~/eeprom 112 | find_eeprom 113 | tar xf rpi-eeprom_${EEPROM_VERSION}.orig.tar.gz 114 | tar xf rpi-eeprom_${EEPROM_VERSION}-1.debian.tar.xz 115 | rm -f rpi-eeprom_${EEPROM_VERSION}-1.debian.tar.xz 116 | mkdir -p debian/patches 117 | mv rpi-eeprom-update.patch debian/patches/rpi-eeprom-update.patch 118 | echo rpi-eeprom-update.patch >> debian/patches/series 119 | rm -f debian/control; mv -f rpi-eeprom-control debian/control 120 | echo "12" > debian/compat 121 | mv -f debian rpi-eeprom-${EEPROM_VERSION}/ 122 | cd rpi-eeprom-${EEPROM_VERSION} 123 | rm -f rpi-eeprom-control.patch 124 | dpkg-buildpackage -us -nc -uc 125 | cd .. 126 | dpkg -i *.deb 127 | cd .. 128 | rm -fdr eeprom 129 | } 130 | 131 | # linux kernel 132 | stage2_kernel (){ 133 | echo "" 134 | apt update 135 | apt upgrade -y 136 | apt -y clean 137 | apt -y autoclean 138 | sleep 1s 139 | cd ~ 140 | dpkg -i *.deb 141 | rm -f *.deb 142 | sleep .75 143 | # take note of linux kernel release 144 | if [ -f /usr/src/linux-headers-*/include/config/kernel.release ]; then 145 | KERNEL_RELEASE=`cat /usr/src/linux-headers-*/include/config/kernel.release` 146 | else 147 | KERNEL_RELEASE=`ls /boot/config-* | sed 's/\/boot\/config-//g'` 148 | fi 149 | echo -e INSTALLED_KERNEL='"'$KERNEL_RELEASE'"' > /root/kernel.release 150 | # add fstype to the board.txt and kernel.release file 151 | echo FSTYPE='"'${FSTYPE}'"' >> /root/kernel.release 152 | echo "" >> /etc/opt/board.txt 153 | echo "# filesystem" >> /etc/opt/board.txt 154 | echo FSTYPE='"'${FSTYPE}'"' >> /etc/opt/board.txt 155 | } 156 | -------------------------------------------------------------------------------- /lib/function/services: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Systemd services 4 | binfmt_fixups_service (){ 5 | tee /etc/systemd/system/binfmt-fixups.service < /dev/null 2>&1 35 | Type=oneshot 36 | RemainAfterExit=yes 37 | 38 | [Install] 39 | WantedBy=multi-user.target 40 | EOF 41 | } 42 | 43 | firstboot_service (){ 44 | tee /etc/systemd/system/firstboot.service </dev/null 72 | Type=oneshot 73 | RemainAfterExit=yes 74 | 75 | [Install] 76 | WantedBy=multi-user.target 77 | EOF 78 | } 79 | 80 | kali_services (){ 81 | systemctl enable avahi-daemon 82 | systemctl enable bluetooth 83 | systemctl enable ntpsec 84 | systemctl enable ssh 85 | systemctl disable systemd-networkd 86 | systemctl mask systemd-networkd-wait-online 87 | } 88 | 89 | led_service (){ 90 | tee /etc/systemd/system/leds.service </dev/null 97 | Type=oneshot 98 | RemainAfterExit=yes 99 | 100 | [Install] 101 | WantedBy=multi-user.target 102 | EOF 103 | systemctl enable leds 104 | } 105 | 106 | rc-local_service (){ 107 | tee /etc/systemd/system/rc-local.service < /etc/systemd/system/haveged.service.d/fix.conf 153 | systemctl daemon-reload 154 | systemctl restart haveged 155 | fi 156 | if [[ -f "/etc/systemd/system/multi-user.target.wants/ondemand.service" ]]; then systemctl disable ondemand; fi 157 | if [[ -f "/etc/systemd/system/multi-user.target.wants/ua-auto-attach.service" ]]; then systemctl disable ua-auto-attach; fi 158 | if [[ "$DISTRO" =~ ^(debian|kali|raspbian)$ ]]; then systemctl enable resolvconf; fi 159 | #systemctl enable serial-getty@ttyUSB0.service 160 | } 161 | 162 | # devuan 163 | sysvinit_services (){ 164 | chmod +x /etc/init.d/governor 165 | chmod +x /etc/init.d/firstboot 166 | chmod +x /etc/init.d/leds 167 | chmod +x /etc/init.d/bthelper 168 | chmod +x /etc/init.d/zramswap 169 | chmod +x /etc/init.d/credentials 170 | update-rc.d -f hwclock.sh remove 171 | update-rc.d firstboot defaults S 172 | update-rc.d governor defaults 2 173 | update-rc.d leds defaults 2 174 | update-rc.d bthelper defaults 2 175 | update-rc.d zramswap defaults 2 176 | update-rc.d credentials defaults 2 177 | } 178 | -------------------------------------------------------------------------------- /lib/function/shrink: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # DU does not provide an accurate calculation of disk usage on ROOTFS. 4 | # This function adds space for the BOOT partition "512MB" and more or 5 | # less depending on the overall size of the ROOTFS partition. 6 | calculate (){ 7 | DU=`du -sh ROOTFS | sed 's/ROOTFS//g' | sed s/'\s'//g | sed 's/G//g'` 8 | CALC=$(echo $DU + 1.0 | bc | sed 's/\.//g') 9 | GB=$(echo $CALC | head -c 1) 10 | if [[ "$GB" == "1" ]]; then CALC=$(echo $DU + 0.9 | bc | sed 's/\.//g'); fi 11 | if [[ "$GB" == "2" ]]; then :; fi 12 | if [[ "$GB" == "3" ]]; then CALC=$(echo $DU + 1.2 | bc | sed 's/\.//g'); fi 13 | if [[ "$GB" == "4" ]]; then CALC=$(echo $DU + 1.3 | bc | sed 's/\.//g'); fi 14 | if [[ "$GB" == "5" ]]; then CALC=$(echo $DU + 1.4 | bc | sed 's/\.//g'); fi 15 | if [[ "$GB" == "6" ]]; then CALC=$(echo $DU + 1.5 | bc | sed 's/\.//g'); fi 16 | if [[ "$GB" == "7" ]]; then CALC=$(echo $DU + 1.6 | bc | sed 's/\.//g'); fi 17 | if [[ "$GB" == "8" ]]; then CALC=$(echo $DU + 1.7 | bc | sed 's/\.//g'); fi 18 | if [[ "$GB" == "9" ]]; then CALC=$(echo $DU + 1.8 | bc | sed 's/\.//g'); fi 19 | IMGSIZE="${CALC}00MB" 20 | } 21 | 22 | # shrink 23 | shrink (){ 24 | export LC_ALL=C.UTF-8 25 | IMAGE_FILE="${BOARD_EXT}-${DISTRO}-${DISTRO_VERSION}-${IMAGE_DATE}.img" 26 | if [[ -f "${IMAGE_FILE}" ]]; then mv -f ${IMAGE_FILE} shrink.img; else echo "Shrink failed! Missing file ${IMAGE_FILE}."; exit 0; fi 27 | KPARTX="$(kpartx -av shrink.img)" 28 | if [[ "$HOST_MACHINE" == "Ubuntu" ]]; then 29 | # snapd woes; grep for higher loop numbers. 30 | LOOP=`grep -o 'loop[0-9]\+p.' <<<"$KPARTX"` 31 | else 32 | LOOP=`grep -o 'loop.p.' <<<"$KPARTX"` 33 | fi 34 | B_LOOP=`echo "$LOOP" | sed -n '1p'` 35 | R_LOOP=`echo "$LOOP" | sed -n '2p'` 36 | BOOT_LOOP="/dev/mapper/$B_LOOP" 37 | ROOTFS_LOOP="/dev/mapper/$R_LOOP" 38 | BOOT="${BOOT_LOOP}" 39 | ROOTFS="${ROOTFS_LOOP}" 40 | if [[ "$FSTYPE" == "ext4" ]]; then fsck.${FSTYPE} -pf "$ROOTFS" > /dev/null 2>&1; fi 41 | mkdir -p BOOT; mkdir -p ROOTFS 42 | sleep .50 43 | mount "${BOOT}" BOOT; mount "${ROOTFS}" ROOTFS 44 | sleep .50 45 | calculate 46 | if [ $RAM -ne 0 ]; then IMAGE_FOLDER="ram/"; fi 47 | mkdir -p "$IMAGE_FOLDER" 48 | if [ $RAM -ne 0 ]; then mount -t tmpfs -o size=4G tmpfs $IMAGE_FOLDER; fi 49 | partition > /dev/null 2>&1; uuid 50 | echo "" 51 | echo -en "Shrink ${PNK}[${FIN}${WHT}enabled${FIN}${PNK}]${FIN}" 52 | sleep 1 53 | echo -en " ${PNK}[${FIN}${WHT}${IMGSIZE}${FIN}${PNK}]${FIN}" 54 | cp -ax BOOT/* p1/ 55 | if [ $VERBOSE -eq 1 ]; then 56 | if [[ "$FSTYPE" == "btrfs" ]]; then cp -axv ROOTFS/@/* p2/; else cp -axv ROOTFS/* p2/; fi 57 | else 58 | if [[ "$FSTYPE" == "btrfs" ]]; then cp -ax ROOTFS/@/* p2/; else cp -ax ROOTFS/* p2/; fi 59 | fi 60 | sleep .75 61 | echo -en " ${PNK}[${FIN}${YLW}finishing${FIN}${PNK}]${FIN}" 62 | umount BOOT; umount ROOTFS 63 | sleep .75 64 | rm -fdr BOOT; rm -fdr ROOTFS 65 | kpartx -d shrink.img 66 | rm -f shrink.img 67 | fstab > /dev/null 2>&1 68 | cmdline > /dev/null 2>&1 69 | umount p2; umount p1 70 | if [[ "$FSTYPE" == "ext4" ]]; then fsck.${FSTYPE} -pf "${IMAGE_LOOP_DEV_ROOTFS}" > /dev/null 2>&1; fi 71 | losetup -d "${IMAGE_LOOP_DEV}" 72 | mv "${IMAGE_FOLDER}${IMAGE_FILE_NAME}" "${IMAGE_FILE_NAME}" 73 | if [ $RAM -ne 0 ]; then umount "${IMAGE_FOLDER}"; fi 74 | rmdir "${IMAGE_FOLDER}" 75 | rmdir p1 p2 76 | echo -e " ${PNK}[${FIN}${GRN}done${FIN}${PNK}]${FIN}" 77 | } 78 | -------------------------------------------------------------------------------- /lib/function/staging: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | partition (){ 4 | truncate -s ${IMGSIZE} "${IMAGE_FOLDER}${IMAGE_FILE_NAME}" 5 | parted --script "${IMAGE_FOLDER}${IMAGE_FILE_NAME}" \ 6 | mklabel msdos \ 7 | mkpart primary fat32 ${IMG_OFFSET} 512MiB \ 8 | mkpart primary ext2 512MiB 100% 9 | parted --script "${IMAGE_FOLDER}${IMAGE_FILE_NAME}" set 1 boot on 10 | IMAGE_LOOP_DEV="$(losetup --show -P -f ${IMAGE_FOLDER}${IMAGE_FILE_NAME})" 11 | IMAGE_LOOP_DEV_BOOT="${IMAGE_LOOP_DEV}p1" 12 | IMAGE_LOOP_DEV_ROOTFS="${IMAGE_LOOP_DEV}p2" 13 | partprobe "${IMAGE_LOOP_DEV}" 14 | filesystem 15 | $MAKE_BOOTFS 16 | $MAKE_ROOTFS 17 | mkdir -p p1 p2 18 | mount "${IMAGE_LOOP_DEV_BOOT}" p1 19 | mount "${IMAGE_LOOP_DEV_ROOTFS}" p2 20 | if [[ "$FSTYPE" == "btrfs" ]]; then btrfs subvolume create p2/@; fi 21 | sync 22 | umount p2 23 | $MOUNT_ROOTFS 24 | } 25 | 26 | filesystem (){ 27 | MAKE_BOOTFS="mkfs -t vfat -n BOOT ${IMAGE_LOOP_DEV_BOOT}" 28 | BOOT_PATH="/boot/broadcom" 29 | if [[ "$FSTYPE" == "ext4" ]]; then 30 | MAKE_ROOTFS="mkfs.ext4 -L ROOTFS ${IMAGE_LOOP_DEV_ROOTFS}" 31 | MOUNT_ROOTFS="mount -o defaults,noatime ${IMAGE_LOOP_DEV_ROOTFS} p2" 32 | ROOTFS_TABLE="ext4 defaults,noatime,commit=600,errors=remount-ro 0 1" 33 | ROOTFSTYPE="rootfstype=ext4" 34 | fi 35 | if [[ "$FSTYPE" == "btrfs" ]]; then 36 | MAKE_ROOTFS="mkfs.btrfs -f -L ROOTFS ${IMAGE_LOOP_DEV_ROOTFS}" 37 | MOUNT_ROOTFS="mount -o compress=lzo,noatime,subvol=@ ${IMAGE_LOOP_DEV_ROOTFS} p2" 38 | ROOTFS_TABLE="btrfs defaults,compress=lzo,noatime,subvol=@ 0 1" 39 | ROOTFSTYPE="rootfstype=btrfs rootflags=subvol=@" 40 | fi 41 | if [[ "$FSTYPE" == "xfs" ]]; then 42 | MAKE_ROOTFS="mkfs.xfs -f -L ROOTFS ${IMAGE_LOOP_DEV_ROOTFS}" 43 | MOUNT_ROOTFS="mount -o defaults,noatime ${IMAGE_LOOP_DEV_ROOTFS} p2" 44 | ROOTFS_TABLE="xfs defaults,noatime 0 1" 45 | ROOTFSTYPE="rootfstype=xfs" 46 | fi 47 | } 48 | 49 | fstab (){ 50 | rm -f p2/etc/fstab 51 | tee p2/etc/fstab < 2 | Link: http://lkml.kernel.org/r/1330436245-24875-2-git-send-email-matt@console-pimps.org 3 | Signed-off-by: H. Peter Anvin 4 | Signed-off-by: Greg Kroah-Hartman 5 | 6 | --- 7 | tools/include/tools/be_byteshift.h | 70 +++++++++++++++++++++++++++++++++++++ 8 | tools/include/tools/le_byteshift.h | 70 +++++++++++++++++++++++++++++++++++++ 9 | 2 files changed, 140 insertions(+) 10 | 11 | --- /dev/null 12 | +++ b/tools/include/tools/be_byteshift.h 13 | @@ -0,0 +1,70 @@ 14 | +#ifndef _TOOLS_BE_BYTESHIFT_H 15 | +#define _TOOLS_BE_BYTESHIFT_H 16 | + 17 | +#include 18 | + 19 | +static inline __u16 __get_unaligned_be16(const __u8 *p) 20 | +{ 21 | + return p[0] << 8 | p[1]; 22 | +} 23 | + 24 | +static inline __u32 __get_unaligned_be32(const __u8 *p) 25 | +{ 26 | + return p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3]; 27 | +} 28 | + 29 | +static inline __u64 __get_unaligned_be64(const __u8 *p) 30 | +{ 31 | + return (__u64)__get_unaligned_be32(p) << 32 | 32 | + __get_unaligned_be32(p + 4); 33 | +} 34 | + 35 | +static inline void __put_unaligned_be16(__u16 val, __u8 *p) 36 | +{ 37 | + *p++ = val >> 8; 38 | + *p++ = val; 39 | +} 40 | + 41 | +static inline void __put_unaligned_be32(__u32 val, __u8 *p) 42 | +{ 43 | + __put_unaligned_be16(val >> 16, p); 44 | + __put_unaligned_be16(val, p + 2); 45 | +} 46 | + 47 | +static inline void __put_unaligned_be64(__u64 val, __u8 *p) 48 | +{ 49 | + __put_unaligned_be32(val >> 32, p); 50 | + __put_unaligned_be32(val, p + 4); 51 | +} 52 | + 53 | +static inline __u16 get_unaligned_be16(const void *p) 54 | +{ 55 | + return __get_unaligned_be16((const __u8 *)p); 56 | +} 57 | + 58 | +static inline __u32 get_unaligned_be32(const void *p) 59 | +{ 60 | + return __get_unaligned_be32((const __u8 *)p); 61 | +} 62 | + 63 | +static inline __u64 get_unaligned_be64(const void *p) 64 | +{ 65 | + return __get_unaligned_be64((const __u8 *)p); 66 | +} 67 | + 68 | +static inline void put_unaligned_be16(__u16 val, void *p) 69 | +{ 70 | + __put_unaligned_be16(val, p); 71 | +} 72 | + 73 | +static inline void put_unaligned_be32(__u32 val, void *p) 74 | +{ 75 | + __put_unaligned_be32(val, p); 76 | +} 77 | + 78 | +static inline void put_unaligned_be64(__u64 val, void *p) 79 | +{ 80 | + __put_unaligned_be64(val, p); 81 | +} 82 | + 83 | +#endif /* _TOOLS_BE_BYTESHIFT_H */ 84 | --- /dev/null 85 | +++ b/tools/include/tools/le_byteshift.h 86 | @@ -0,0 +1,70 @@ 87 | +#ifndef _TOOLS_LE_BYTESHIFT_H 88 | +#define _TOOLS_LE_BYTESHIFT_H 89 | + 90 | +#include 91 | + 92 | +static inline __u16 __get_unaligned_le16(const __u8 *p) 93 | +{ 94 | + return p[0] | p[1] << 8; 95 | +} 96 | + 97 | +static inline __u32 __get_unaligned_le32(const __u8 *p) 98 | +{ 99 | + return p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24; 100 | +} 101 | + 102 | +static inline __u64 __get_unaligned_le64(const __u8 *p) 103 | +{ 104 | + return (__u64)__get_unaligned_le32(p + 4) << 32 | 105 | + __get_unaligned_le32(p); 106 | +} 107 | + 108 | +static inline void __put_unaligned_le16(__u16 val, __u8 *p) 109 | +{ 110 | + *p++ = val; 111 | + *p++ = val >> 8; 112 | +} 113 | + 114 | +static inline void __put_unaligned_le32(__u32 val, __u8 *p) 115 | +{ 116 | + __put_unaligned_le16(val >> 16, p + 2); 117 | + __put_unaligned_le16(val, p); 118 | +} 119 | + 120 | +static inline void __put_unaligned_le64(__u64 val, __u8 *p) 121 | +{ 122 | + __put_unaligned_le32(val >> 32, p + 4); 123 | + __put_unaligned_le32(val, p); 124 | +} 125 | + 126 | +static inline __u16 get_unaligned_le16(const void *p) 127 | +{ 128 | + return __get_unaligned_le16((const __u8 *)p); 129 | +} 130 | + 131 | +static inline __u32 get_unaligned_le32(const void *p) 132 | +{ 133 | + return __get_unaligned_le32((const __u8 *)p); 134 | +} 135 | + 136 | +static inline __u64 get_unaligned_le64(const void *p) 137 | +{ 138 | + return __get_unaligned_le64((const __u8 *)p); 139 | +} 140 | + 141 | +static inline void put_unaligned_le16(__u16 val, void *p) 142 | +{ 143 | + __put_unaligned_le16(val, p); 144 | +} 145 | + 146 | +static inline void put_unaligned_le32(__u32 val, void *p) 147 | +{ 148 | + __put_unaligned_le32(val, p); 149 | +} 150 | + 151 | +static inline void put_unaligned_le64(__u64 val, void *p) 152 | +{ 153 | + __put_unaligned_le64(val, p); 154 | +} 155 | + 156 | +#endif /* _TOOLS_LE_BYTESHIFT_H */ 157 | -------------------------------------------------------------------------------- /packaging/initrd: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | INITRD_BRCM="/boot/broadcom/initrd.gz" 4 | 5 | if [[ -d "/boot" ]] && [[ `ls /boot/initrd.img-*` ]] > /dev/null 2>&1; then 6 | echo "update-initramfs: Generating ${INITRD_BRCM}" 7 | mkdir -p /boot/broadcom 8 | rm -fr /boot/{initrd.gz,initrd.img-*-bak} 9 | rm -f /boot/broadcom/initrd.gz 10 | cp -f /boot/initrd.img-* ${INITRD_BRCM} 11 | rm -f /boot/firmware 12 | ln -s /boot/broadcom /boot/firmware 13 | fi 14 | 15 | exit 0 16 | -------------------------------------------------------------------------------- /packaging/mkdebian: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | is_enabled() { 6 | grep -q "^$1=y" include/config/auto.conf 7 | } 8 | 9 | if_enabled_echo() { 10 | if is_enabled "$1"; then 11 | echo -n "$2" 12 | elif [ $# -ge 3 ]; then 13 | echo -n "$3" 14 | fi 15 | } 16 | 17 | set_debarch() { 18 | if [ -n "$KBUILD_DEBARCH" ] ; then 19 | debarch="$KBUILD_DEBARCH" 20 | return 21 | fi 22 | 23 | # Attempt to find the correct Debian architecture 24 | case "$UTS_MACHINE" in 25 | i386|ia64|alpha|m68k|riscv*) 26 | debarch="$UTS_MACHINE" ;; 27 | x86_64) 28 | debarch=amd64 ;; 29 | sparc*) 30 | debarch=sparc$(if_enabled_echo CONFIG_64BIT 64) ;; 31 | s390*) 32 | debarch=s390x ;; 33 | ppc*) 34 | if is_enabled CONFIG_64BIT; then 35 | debarch=ppc64$(if_enabled_echo CONFIG_CPU_LITTLE_ENDIAN el) 36 | else 37 | debarch=powerpc$(if_enabled_echo CONFIG_SPE spe) 38 | fi 39 | ;; 40 | parisc*) 41 | debarch=hppa ;; 42 | mips*) 43 | if is_enabled CONFIG_CPU_LITTLE_ENDIAN; then 44 | debarch=mips$(if_enabled_echo CONFIG_64BIT 64)$(if_enabled_echo CONFIG_CPU_MIPSR6 r6)el 45 | elif is_enabled CONFIG_CPU_MIPSR6; then 46 | debarch=mips$(if_enabled_echo CONFIG_64BIT 64)r6 47 | else 48 | debarch=mips 49 | fi 50 | ;; 51 | aarch64|arm64) 52 | debarch=arm64 ;; 53 | arm*) 54 | if is_enabled CONFIG_AEABI; then 55 | debarch=arm$(if_enabled_echo CONFIG_VFP hf el) 56 | else 57 | debarch=arm 58 | fi 59 | ;; 60 | openrisc) 61 | debarch=or1k ;; 62 | sh) 63 | if is_enabled CONFIG_CPU_SH3; then 64 | debarch=sh3$(if_enabled_echo CONFIG_CPU_BIG_ENDIAN eb) 65 | elif is_enabled CONFIG_CPU_SH4; then 66 | debarch=sh4$(if_enabled_echo CONFIG_CPU_BIG_ENDIAN eb) 67 | fi 68 | ;; 69 | esac 70 | if [ -z "$debarch" ]; then 71 | debarch=$(dpkg-architecture -qDEB_HOST_ARCH) 72 | echo "" >&2 73 | echo "** ** ** WARNING ** ** **" >&2 74 | echo "" >&2 75 | echo "Your architecture doesn't have its equivalent" >&2 76 | echo "Debian userspace architecture defined!" >&2 77 | echo "Falling back to the current host architecture ($debarch)." >&2 78 | echo "Please add support for $UTS_MACHINE to ${0} ..." >&2 79 | echo "" >&2 80 | fi 81 | } 82 | 83 | if [ -f scripts/package/pkgvars ]; then 84 | . scripts/package/pkgvars 85 | else 86 | echo "Missing: pkgvars" 87 | exit 0 88 | fi 89 | 90 | # Some variables and settings used throughout the script 91 | version=$KERNELRELEASE 92 | if [ -n "$KDEB_PKGVERSION" ]; then 93 | packageversion=$KDEB_PKGVERSION 94 | revision=${packageversion##*-} 95 | else 96 | revision=$(cat .version 2>/dev/null||echo 1) 97 | packageversion=$version-$revision 98 | fi 99 | sourcename="rpi-img-builder" 100 | # set by pkgvars 101 | packagename=$linux_name 102 | kernel_headers_packagename=$headers_name 103 | # end of pkgvars 104 | dbg_packagename=$packagename-dbg 105 | debarch= 106 | set_debarch 107 | 108 | if [ "$ARCH" = "um" ] ; then 109 | packagename=user-mode-linux-$version 110 | fi 111 | 112 | email=${DEBEMAIL-$EMAIL} 113 | 114 | # use email string directly if it contains 115 | if echo $email | grep -q '<.*>'; then 116 | maintainer=$email 117 | else 118 | # or construct the maintainer string 119 | user=${KBUILD_BUILD_USER-$(id -nu)} 120 | name=${DEBFULLNAME-$user} 121 | if [ -z "$email" ]; then 122 | buildhost=${KBUILD_BUILD_HOST-$(hostname -f 2>/dev/null || hostname)} 123 | email="$user@$buildhost" 124 | fi 125 | maintainer="$name <$email>" 126 | fi 127 | 128 | # Try to determine distribution 129 | if [ -n "$KDEB_CHANGELOG_DIST" ]; then 130 | distribution=$KDEB_CHANGELOG_DIST 131 | # In some cases lsb_release returns the codename as n/a, which breaks dpkg-parsechangelog 132 | elif distribution=$(lsb_release -cs 2>/dev/null) && [ -n "$distribution" ] && [ "$distribution" != "n/a" ]; then 133 | : # nothing to do in this case 134 | else 135 | distribution="unstable" 136 | echo >&2 "Using default distribution of 'unstable' in the changelog" 137 | echo >&2 "Install lsb-release or set \$KDEB_CHANGELOG_DIST explicitly" 138 | fi 139 | 140 | mkdir -p debian/source/ 141 | echo "2.0" > debian/source/format 142 | 143 | echo $debarch > debian/arch 144 | extra_build_depends=", $(if_enabled_echo CONFIG_UNWINDER_ORC libelf-dev:native)" 145 | extra_build_depends="$extra_build_depends, $(if_enabled_echo CONFIG_SYSTEM_TRUSTED_KEYRING libssl-dev:native)" 146 | 147 | # Generate a simple changelog template 148 | cat < debian/changelog 149 | $sourcename ($packageversion) $distribution; urgency=low 150 | 151 | * Oh, goodie! My Illudium Q-36 explosive space modulator. 152 | 153 | -- $maintainer $(date -R) 154 | EOF 155 | 156 | # Generate copyright file 157 | cat < debian/copyright 158 | This is a packacked upstream version of the Linux kernel. 159 | 160 | The sources may be found at most Linux archive sites, including: 161 | https://www.kernel.org/pub/linux/kernel 162 | 163 | Copyright: 1991 - 2018 Linus Torvalds and others. 164 | 165 | The git repository for mainline kernel development is at: 166 | git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 167 | 168 | This program is free software; you can redistribute it and/or modify 169 | it under the terms of the GNU General Public License as published by 170 | the Free Software Foundation; version 2 dated June, 1991. 171 | 172 | On Debian GNU/Linux systems, the complete text of the GNU General Public 173 | License version 2 can be found in \`/usr/share/common-licenses/GPL-2'. 174 | EOF 175 | 176 | # Generate a control file 177 | cat < debian/control 178 | Source: $sourcename 179 | Section: kernel 180 | Priority: optional 181 | Maintainer: $maintainer 182 | Build-Depends: bc, rsync, kmod, cpio, bison, flex | flex:native $extra_build_depends 183 | Homepage: http://www.kernel.org/ 184 | 185 | Package: $packagename 186 | Architecture: $debarch 187 | Description: Linux kernel, version $version 188 | This package contains the Linux kernel, modules and corresponding other 189 | files, version: $version. 190 | 191 | Package: $kernel_headers_packagename 192 | Architecture: $debarch 193 | Description: Linux kernel headers for $version on $debarch 194 | This package provides kernel header files for $version on $debarch 195 | . 196 | This is useful for people who need to build external modules 197 | 198 | Package: linux-libc-dev 199 | Section: devel 200 | Provides: linux-kernel-headers 201 | Architecture: $debarch 202 | Description: Linux support headers for userspace development 203 | This package provides userspaces headers from the Linux kernel. These headers 204 | are used by the installed headers for GNU glibc and other system libraries. 205 | Multi-Arch: same 206 | 207 | Package: $dbg_packagename 208 | Section: debug 209 | Architecture: $debarch 210 | Description: Linux kernel debugging symbols for $version 211 | This package will come in handy if you need to debug the kernel. It provides 212 | all the necessary debug symbols for the kernel and its modules. 213 | EOF 214 | 215 | cat < debian/rules 216 | #!$(command -v $MAKE) -f 217 | 218 | srctree ?= . 219 | 220 | build: 221 | \$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} \ 222 | KBUILD_BUILD_VERSION=${revision} -f \$(srctree)/Makefile 223 | 224 | binary-arch: 225 | \$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} \ 226 | KBUILD_BUILD_VERSION=${revision} -f \$(srctree)/Makefile intdeb-pkg 227 | 228 | clean: 229 | rm -rf debian/*tmp debian/files 230 | \$(MAKE) clean 231 | 232 | binary: binary-arch 233 | EOF 234 | chmod +x debian/rules 235 | 236 | exit 0 237 | -------------------------------------------------------------------------------- /packaging/pkgvars: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | COMPRESSION="xz" 4 | PLATFORM="broadcom" 5 | LINUX_IMAGE="linux-image-${SERIES}" 6 | LINUX_HEADERS="linux-headers-${SERIES}" 7 | OVERLAY_PATH="usr/lib/${LINUX_IMAGE}/overlays" 8 | INSTALL_PATH="boot/${PLATFORM}" 9 | 10 | linux_packaging(){ 11 | # install target 12 | if [[ "$ARCH" == "arm" ]]; then 13 | LINUX_PATH="usr/lib/${LINUX_IMAGE}" 14 | else 15 | LINUX_PATH="usr/lib/${LINUX_IMAGE}/${PLATFORM}" 16 | fi 17 | cat < "scripts/package/pkgvars" 18 | # packaging variables 19 | board_series="$SERIES" 20 | kernel_img="$KERNEL_IMG" 21 | linux_name="$LINUX_IMAGE" 22 | headers_name="$LINUX_HEADERS" 23 | compression="$COMPRESSION" 24 | linux_path="$LINUX_PATH" 25 | overlays_path="$OVERLAY_PATH" 26 | boot_path="$INSTALL_PATH" 27 | karch="$ARCH" 28 | EOF 29 | } 30 | -------------------------------------------------------------------------------- /patches/all/6.10.y/001-scripts-Makefile.package-PHONY-intdeb-pkg.patch: -------------------------------------------------------------------------------- 1 | From 5fc46d18b2674bcc54aed0034173f50bc5512b1e Mon Sep 17 00:00:00 2001 2 | From: Patrick Yavitz 3 | Date: Wed, 17 Apr 2024 13:53:25 -0400 4 | Subject: [PATCH] scripts: Makefile.package: PHONY += intdeb-pkg 5 | 6 | This is required by the builders builddeb kernel packaging script. 7 | 8 | Signed-off-by: Patrick Yavitz 9 | --- 10 | scripts/Makefile.package | 4 ++++ 11 | 1 file changed, 4 insertions(+) 12 | 13 | diff --git a/scripts/Makefile.package b/scripts/Makefile.package 14 | index a81dfb1f5181..070599cc25bb 100644 15 | --- a/scripts/Makefile.package 16 | +++ b/scripts/Makefile.package 17 | @@ -127,6 +127,10 @@ deb-pkg srcdeb-pkg bindeb-pkg: 18 | --no-check-builddeps) \ 19 | $(DPKG_FLAGS)) 20 | 21 | +PHONY += intdeb-pkg 22 | +intdeb-pkg: 23 | + +$(CONFIG_SHELL) $(srctree)/scripts/package/builddeb 24 | + 25 | # snap-pkg 26 | # --------------------------------------------------------------------------- 27 | PHONY += snap-pkg 28 | -- 29 | 2.39.2 30 | 31 | -------------------------------------------------------------------------------- /patches/all/6.11.y/001-scripts-Makefile.package-PHONY-intdeb-pkg.patch: -------------------------------------------------------------------------------- 1 | From 5fc46d18b2674bcc54aed0034173f50bc5512b1e Mon Sep 17 00:00:00 2001 2 | From: Patrick Yavitz 3 | Date: Wed, 17 Apr 2024 13:53:25 -0400 4 | Subject: [PATCH] scripts: Makefile.package: PHONY += intdeb-pkg 5 | 6 | This is required by the builders builddeb kernel packaging script. 7 | 8 | Signed-off-by: Patrick Yavitz 9 | --- 10 | scripts/Makefile.package | 4 ++++ 11 | 1 file changed, 4 insertions(+) 12 | 13 | diff --git a/scripts/Makefile.package b/scripts/Makefile.package 14 | index a81dfb1f5181..070599cc25bb 100644 15 | --- a/scripts/Makefile.package 16 | +++ b/scripts/Makefile.package 17 | @@ -127,6 +127,10 @@ deb-pkg srcdeb-pkg bindeb-pkg: 18 | --no-check-builddeps) \ 19 | $(DPKG_FLAGS)) 20 | 21 | +PHONY += intdeb-pkg 22 | +intdeb-pkg: 23 | + +$(CONFIG_SHELL) $(srctree)/scripts/package/builddeb 24 | + 25 | # snap-pkg 26 | # --------------------------------------------------------------------------- 27 | PHONY += snap-pkg 28 | -- 29 | 2.39.2 30 | 31 | -------------------------------------------------------------------------------- /patches/all/6.12.y/001-scripts-Makefile.package-PHONY-intdeb-pkg.patch: -------------------------------------------------------------------------------- 1 | From 5fc46d18b2674bcc54aed0034173f50bc5512b1e Mon Sep 17 00:00:00 2001 2 | From: Patrick Yavitz 3 | Date: Wed, 17 Apr 2024 13:53:25 -0400 4 | Subject: [PATCH] scripts: Makefile.package: PHONY += intdeb-pkg 5 | 6 | This is required by the builders builddeb kernel packaging script. 7 | 8 | Signed-off-by: Patrick Yavitz 9 | --- 10 | scripts/Makefile.package | 4 ++++ 11 | 1 file changed, 4 insertions(+) 12 | 13 | diff --git a/scripts/Makefile.package b/scripts/Makefile.package 14 | index a81dfb1f5181..070599cc25bb 100644 15 | --- a/scripts/Makefile.package 16 | +++ b/scripts/Makefile.package 17 | @@ -127,6 +127,10 @@ deb-pkg srcdeb-pkg bindeb-pkg: 18 | --no-check-builddeps) \ 19 | $(DPKG_FLAGS)) 20 | 21 | +PHONY += intdeb-pkg 22 | +intdeb-pkg: 23 | + +$(CONFIG_SHELL) $(srctree)/scripts/package/builddeb 24 | + 25 | # snap-pkg 26 | # --------------------------------------------------------------------------- 27 | PHONY += snap-pkg 28 | -- 29 | 2.39.2 30 | 31 | -------------------------------------------------------------------------------- /patches/all/6.13.y/001-scripts-Makefile.package-PHONY-intdeb-pkg.patch: -------------------------------------------------------------------------------- 1 | From 8f1359515e956f9beb30bc5fabc2bdb17e8bf28f Mon Sep 17 00:00:00 2001 2 | From: Patrick Yavitz 3 | Date: Mon, 13 Jan 2025 17:18:44 -0500 4 | Subject: [PATCH] scripts: Makefile.package: PHONY += intdeb-pkg 5 | 6 | This is required by the builders builddeb kernel packaging script. 7 | 8 | Signed-off-by: Patrick Yavitz 9 | --- 10 | scripts/Makefile.package | 4 ++++ 11 | 1 file changed, 4 insertions(+) 12 | 13 | diff --git a/scripts/Makefile.package b/scripts/Makefile.package 14 | index 74bcb9e7f7a4..5aaafd9ab4f5 100644 15 | --- a/scripts/Makefile.package 16 | +++ b/scripts/Makefile.package 17 | @@ -132,6 +132,10 @@ deb-pkg srcdeb-pkg bindeb-pkg: 18 | --no-check-builddeps) \ 19 | $(DPKG_FLAGS)) 20 | 21 | +PHONY += intdeb-pkg 22 | +intdeb-pkg: 23 | + +$(CONFIG_SHELL) $(srctree)/scripts/package/builddeb 24 | + 25 | # snap-pkg 26 | # --------------------------------------------------------------------------- 27 | PHONY += snap-pkg 28 | -- 29 | 2.39.5 30 | 31 | -------------------------------------------------------------------------------- /patches/all/6.14.y/001-scripts-Makefile.package-PHONY-intdeb-pkg.patch: -------------------------------------------------------------------------------- 1 | From 8f1359515e956f9beb30bc5fabc2bdb17e8bf28f Mon Sep 17 00:00:00 2001 2 | From: Patrick Yavitz 3 | Date: Mon, 13 Jan 2025 17:18:44 -0500 4 | Subject: [PATCH] scripts: Makefile.package: PHONY += intdeb-pkg 5 | 6 | This is required by the builders builddeb kernel packaging script. 7 | 8 | Signed-off-by: Patrick Yavitz 9 | --- 10 | scripts/Makefile.package | 4 ++++ 11 | 1 file changed, 4 insertions(+) 12 | 13 | diff --git a/scripts/Makefile.package b/scripts/Makefile.package 14 | index 74bcb9e7f7a4..5aaafd9ab4f5 100644 15 | --- a/scripts/Makefile.package 16 | +++ b/scripts/Makefile.package 17 | @@ -132,6 +132,10 @@ deb-pkg srcdeb-pkg bindeb-pkg: 18 | --no-check-builddeps) \ 19 | $(DPKG_FLAGS)) 20 | 21 | +PHONY += intdeb-pkg 22 | +intdeb-pkg: 23 | + +$(CONFIG_SHELL) $(srctree)/scripts/package/builddeb 24 | + 25 | # snap-pkg 26 | # --------------------------------------------------------------------------- 27 | PHONY += snap-pkg 28 | -- 29 | 2.39.5 30 | 31 | -------------------------------------------------------------------------------- /patches/all/6.15.y/001-scripts-Makefile.package-PHONY-intdeb-pkg.patch: -------------------------------------------------------------------------------- 1 | From 8f1359515e956f9beb30bc5fabc2bdb17e8bf28f Mon Sep 17 00:00:00 2001 2 | From: Patrick Yavitz 3 | Date: Mon, 13 Jan 2025 17:18:44 -0500 4 | Subject: [PATCH] scripts: Makefile.package: PHONY += intdeb-pkg 5 | 6 | This is required by the builders builddeb kernel packaging script. 7 | 8 | Signed-off-by: Patrick Yavitz 9 | --- 10 | scripts/Makefile.package | 4 ++++ 11 | 1 file changed, 4 insertions(+) 12 | 13 | diff --git a/scripts/Makefile.package b/scripts/Makefile.package 14 | index 74bcb9e7f7a4..5aaafd9ab4f5 100644 15 | --- a/scripts/Makefile.package 16 | +++ b/scripts/Makefile.package 17 | @@ -132,6 +132,10 @@ deb-pkg srcdeb-pkg bindeb-pkg: 18 | --no-check-builddeps) \ 19 | $(DPKG_FLAGS)) 20 | 21 | +PHONY += intdeb-pkg 22 | +intdeb-pkg: 23 | + +$(CONFIG_SHELL) $(srctree)/scripts/package/builddeb 24 | + 25 | # snap-pkg 26 | # --------------------------------------------------------------------------- 27 | PHONY += snap-pkg 28 | -- 29 | 2.39.5 30 | 31 | -------------------------------------------------------------------------------- /patches/all/6.16.y/001-scripts-Makefile.package-PHONY-intdeb-pkg.patch: -------------------------------------------------------------------------------- 1 | From 8f1359515e956f9beb30bc5fabc2bdb17e8bf28f Mon Sep 17 00:00:00 2001 2 | From: Patrick Yavitz 3 | Date: Mon, 13 Jan 2025 17:18:44 -0500 4 | Subject: [PATCH] scripts: Makefile.package: PHONY += intdeb-pkg 5 | 6 | This is required by the builders builddeb kernel packaging script. 7 | 8 | Signed-off-by: Patrick Yavitz 9 | --- 10 | scripts/Makefile.package | 4 ++++ 11 | 1 file changed, 4 insertions(+) 12 | 13 | diff --git a/scripts/Makefile.package b/scripts/Makefile.package 14 | index 74bcb9e7f7a4..5aaafd9ab4f5 100644 15 | --- a/scripts/Makefile.package 16 | +++ b/scripts/Makefile.package 17 | @@ -132,6 +132,10 @@ deb-pkg srcdeb-pkg bindeb-pkg: 18 | --no-check-builddeps) \ 19 | $(DPKG_FLAGS)) 20 | 21 | +PHONY += intdeb-pkg 22 | +intdeb-pkg: 23 | + +$(CONFIG_SHELL) $(srctree)/scripts/package/builddeb 24 | + 25 | # snap-pkg 26 | # --------------------------------------------------------------------------- 27 | PHONY += snap-pkg 28 | -- 29 | 2.39.5 30 | 31 | -------------------------------------------------------------------------------- /patches/all/6.6.y/001-scripts-Makefile.package-PHONY-intdeb-pkg.patch: -------------------------------------------------------------------------------- 1 | From 7eb5bc56252e488c43531b197ff093be14361c8a Mon Sep 17 00:00:00 2001 2 | From: Patrick Yavitz 3 | Date: Tue, 12 Sep 2023 01:42:16 -0400 4 | Subject: [PATCH] scripts: Makefile.package: PHONY += intdeb-pkg 5 | 6 | This is required by the builders builddeb kernel packaging script. 7 | 8 | Signed-off-by: Patrick Yavitz 9 | --- 10 | scripts/Makefile.package | 4 ++++ 11 | 1 file changed, 4 insertions(+) 12 | 13 | diff --git a/scripts/Makefile.package b/scripts/Makefile.package 14 | index 2bcab02da965..466a5ccedfc6 100644 15 | --- a/scripts/Makefile.package 16 | +++ b/scripts/Makefile.package 17 | @@ -152,6 +152,10 @@ deb-pkg srcdeb-pkg bindeb-pkg: 18 | --no-check-builddeps) \ 19 | $(DPKG_FLAGS)) 20 | 21 | +PHONY += intdeb-pkg 22 | +intdeb-pkg: 23 | + +$(CONFIG_SHELL) $(srctree)/scripts/package/builddeb 24 | + 25 | # snap-pkg 26 | # --------------------------------------------------------------------------- 27 | PHONY += snap-pkg 28 | -- 29 | 2.39.2 30 | 31 | -------------------------------------------------------------------------------- /patches/all/6.6.y/002-arm64-swiotlb-Reduce-the-default-size-if-no-ZONE_DMA-bouncing-needed.patch: -------------------------------------------------------------------------------- 1 | From 7648741002eeb851ceb394864253445b77ea3d25 Mon Sep 17 00:00:00 2001 2 | From: Catalin Marinas 3 | Date: Wed, 10 Apr 2024 08:25:37 -0400 4 | Subject: [PATCH] arm64: swiotlb: Reduce the default size if no ZONE_DMA 5 | bouncing needed 6 | 7 | With CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC enabled, the arm64 kernel still 8 | allocates the default SWIOTLB buffer (64MB) even if ZONE_DMA is disabled 9 | or all the RAM fits into this zone. However, this potentially wastes a 10 | non-negligible amount of memory on platforms with little RAM. 11 | 12 | Reduce the SWIOTLB size to 1MB per 1GB of RAM if only needed for 13 | kmalloc() buffer bouncing. 14 | 15 | Signed-off-by: Catalin Marinas 16 | Suggested-by: Ross Burton 17 | Cc: Ross Burton 18 | Cc: Will Deacon 19 | Reviewed-by: Robin Murphy 20 | --- 21 | arch/arm64/mm/init.c | 11 ++++++++++- 22 | 1 file changed, 10 insertions(+), 1 deletion(-) 23 | 24 | diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c 25 | index 8a0f8604348b..8deec68028ac 100644 26 | --- a/arch/arm64/mm/init.c 27 | +++ b/arch/arm64/mm/init.c 28 | @@ -16,6 +16,7 @@ 29 | #include 30 | #include 31 | #include 32 | +#include 33 | #include 34 | #include 35 | #include 36 | @@ -493,8 +494,16 @@ void __init mem_init(void) 37 | { 38 | bool swiotlb = max_pfn > PFN_DOWN(arm64_dma_phys_limit); 39 | 40 | - if (IS_ENABLED(CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC)) 41 | + if (IS_ENABLED(CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC) && !swiotlb) { 42 | + /* 43 | + * If no bouncing needed for ZONE_DMA, reduce the swiotlb 44 | + * buffer for kmalloc() bouncing to 1MB per 1GB of RAM. 45 | + */ 46 | + unsigned long size = 47 | + DIV_ROUND_UP(memblock_phys_mem_size(), 1024); 48 | + swiotlb_adjust_size(min(swiotlb_size_or_default(), size)); 49 | swiotlb = true; 50 | + } 51 | 52 | swiotlb_init(swiotlb, SWIOTLB_VERBOSE); 53 | 54 | -- 55 | 2.39.2 56 | 57 | -------------------------------------------------------------------------------- /patches/all/6.7.y/001-scripts-Makefile.package-PHONY-intdeb-pkg.patch: -------------------------------------------------------------------------------- 1 | From 7eb5bc56252e488c43531b197ff093be14361c8a Mon Sep 17 00:00:00 2001 2 | From: Patrick Yavitz 3 | Date: Tue, 12 Sep 2023 01:42:16 -0400 4 | Subject: [PATCH] scripts: Makefile.package: PHONY += intdeb-pkg 5 | 6 | This is required by the builders builddeb kernel packaging script. 7 | 8 | Signed-off-by: Patrick Yavitz 9 | --- 10 | scripts/Makefile.package | 4 ++++ 11 | 1 file changed, 4 insertions(+) 12 | 13 | diff --git a/scripts/Makefile.package b/scripts/Makefile.package 14 | index 2bcab02da965..466a5ccedfc6 100644 15 | --- a/scripts/Makefile.package 16 | +++ b/scripts/Makefile.package 17 | @@ -152,6 +152,10 @@ deb-pkg srcdeb-pkg bindeb-pkg: 18 | --no-check-builddeps) \ 19 | $(DPKG_FLAGS)) 20 | 21 | +PHONY += intdeb-pkg 22 | +intdeb-pkg: 23 | + +$(CONFIG_SHELL) $(srctree)/scripts/package/builddeb 24 | + 25 | # snap-pkg 26 | # --------------------------------------------------------------------------- 27 | PHONY += snap-pkg 28 | -- 29 | 2.39.2 30 | 31 | -------------------------------------------------------------------------------- /patches/all/6.8.y/001-scripts-Makefile.package-PHONY-intdeb-pkg.patch: -------------------------------------------------------------------------------- 1 | From 5fc46d18b2674bcc54aed0034173f50bc5512b1e Mon Sep 17 00:00:00 2001 2 | From: Patrick Yavitz 3 | Date: Wed, 17 Apr 2024 13:53:25 -0400 4 | Subject: [PATCH] scripts: Makefile.package: PHONY += intdeb-pkg 5 | 6 | This is required by the builders builddeb kernel packaging script. 7 | 8 | Signed-off-by: Patrick Yavitz 9 | --- 10 | scripts/Makefile.package | 4 ++++ 11 | 1 file changed, 4 insertions(+) 12 | 13 | diff --git a/scripts/Makefile.package b/scripts/Makefile.package 14 | index a81dfb1f5181..070599cc25bb 100644 15 | --- a/scripts/Makefile.package 16 | +++ b/scripts/Makefile.package 17 | @@ -127,6 +127,10 @@ deb-pkg srcdeb-pkg bindeb-pkg: 18 | --no-check-builddeps) \ 19 | $(DPKG_FLAGS)) 20 | 21 | +PHONY += intdeb-pkg 22 | +intdeb-pkg: 23 | + +$(CONFIG_SHELL) $(srctree)/scripts/package/builddeb 24 | + 25 | # snap-pkg 26 | # --------------------------------------------------------------------------- 27 | PHONY += snap-pkg 28 | -- 29 | 2.39.2 30 | 31 | -------------------------------------------------------------------------------- /patches/all/6.9.y/001-scripts-Makefile.package-PHONY-intdeb-pkg.patch: -------------------------------------------------------------------------------- 1 | From 5fc46d18b2674bcc54aed0034173f50bc5512b1e Mon Sep 17 00:00:00 2001 2 | From: Patrick Yavitz 3 | Date: Wed, 17 Apr 2024 13:53:25 -0400 4 | Subject: [PATCH] scripts: Makefile.package: PHONY += intdeb-pkg 5 | 6 | This is required by the builders builddeb kernel packaging script. 7 | 8 | Signed-off-by: Patrick Yavitz 9 | --- 10 | scripts/Makefile.package | 4 ++++ 11 | 1 file changed, 4 insertions(+) 12 | 13 | diff --git a/scripts/Makefile.package b/scripts/Makefile.package 14 | index a81dfb1f5181..070599cc25bb 100644 15 | --- a/scripts/Makefile.package 16 | +++ b/scripts/Makefile.package 17 | @@ -127,6 +127,10 @@ deb-pkg srcdeb-pkg bindeb-pkg: 18 | --no-check-builddeps) \ 19 | $(DPKG_FLAGS)) 20 | 21 | +PHONY += intdeb-pkg 22 | +intdeb-pkg: 23 | + +$(CONFIG_SHELL) $(srctree)/scripts/package/builddeb 24 | + 25 | # snap-pkg 26 | # --------------------------------------------------------------------------- 27 | PHONY += snap-pkg 28 | -- 29 | 2.39.2 30 | 31 | -------------------------------------------------------------------------------- /patches/userpatches/README.md: -------------------------------------------------------------------------------- 1 | ### User Patches 2 | ```sh 3 | Patches "-p1" placed in this directory are applied during compilation. 4 | ``` 5 | -------------------------------------------------------------------------------- /patches/wireless/rtw88/Kconfig: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: GPL-2.0-only 2 | menuconfig RTW88 3 | tristate "Realtek 802.11ac wireless chips support" 4 | depends on MAC80211 5 | default m 6 | help 7 | This module adds support for mac80211-based wireless drivers that 8 | enables Realtek IEEE 802.11ac wireless chipsets. 9 | 10 | If you choose to build a module, it'll be called rtw88. 11 | 12 | if RTW88 13 | 14 | config RTW88_CORE 15 | tristate 16 | select WANT_DEV_COREDUMP 17 | 18 | config RTW88_PCI 19 | tristate 20 | 21 | config RTW88_SDIO 22 | tristate 23 | 24 | config RTW88_USB 25 | tristate 26 | 27 | config RTW88_8822B 28 | tristate 29 | 30 | config RTW88_8822C 31 | tristate 32 | 33 | config RTW88_8723X 34 | tristate 35 | 36 | config RTW88_8703B 37 | tristate 38 | select RTW88_8723X 39 | 40 | config RTW88_8723D 41 | tristate 42 | select RTW88_8723X 43 | 44 | config RTW88_8821C 45 | tristate 46 | 47 | config RTW88_88XXA 48 | tristate 49 | 50 | config RTW88_8821A 51 | tristate 52 | select RTW88_88XXA 53 | 54 | config RTW88_8812A 55 | tristate 56 | select RTW88_88XXA 57 | 58 | config RTW88_8814A 59 | tristate 60 | 61 | config RTW88_8822BE 62 | tristate "Realtek 8822BE PCI wireless network adapter" 63 | depends on PCI 64 | select RTW88_CORE 65 | select RTW88_PCI 66 | select RTW88_8822B 67 | default m 68 | help 69 | Select this option will enable support for 8822BE chipset 70 | 71 | 802.11ac PCIe wireless network adapter 72 | 73 | config RTW88_8822BS 74 | tristate "Realtek 8822BS SDIO wireless network adapter" 75 | depends on MMC 76 | select RTW88_CORE 77 | select RTW88_SDIO 78 | select RTW88_8822B 79 | default m 80 | help 81 | Select this option will enable support for 8822BS chipset 82 | 83 | 802.11ac SDIO wireless network adapter 84 | 85 | config RTW88_8822BU 86 | tristate "Realtek 8822BU USB wireless network adapter" 87 | depends on USB 88 | select RTW88_CORE 89 | select RTW88_USB 90 | select RTW88_8822B 91 | default m 92 | help 93 | Select this option will enable support for 8822BU chipset 94 | 95 | 802.11ac USB wireless network adapter 96 | 97 | config RTW88_8822CE 98 | tristate "Realtek 8822CE PCI wireless network adapter" 99 | depends on PCI 100 | select RTW88_CORE 101 | select RTW88_PCI 102 | select RTW88_8822C 103 | default m 104 | help 105 | Select this option will enable support for 8822CE chipset 106 | 107 | 802.11ac PCIe wireless network adapter 108 | 109 | config RTW88_8822CS 110 | tristate "Realtek 8822CS SDIO wireless network adapter" 111 | depends on MMC 112 | select RTW88_CORE 113 | select RTW88_SDIO 114 | select RTW88_8822C 115 | default m 116 | help 117 | Select this option will enable support for 8822CS chipset 118 | 119 | 802.11ac SDIO wireless network adapter 120 | 121 | config RTW88_8822CU 122 | tristate "Realtek 8822CU USB wireless network adapter" 123 | depends on USB 124 | select RTW88_CORE 125 | select RTW88_USB 126 | select RTW88_8822C 127 | default m 128 | help 129 | Select this option will enable support for 8822CU chipset 130 | 131 | 802.11ac USB wireless network adapter 132 | 133 | config RTW88_8723DE 134 | tristate "Realtek 8723DE PCI wireless network adapter" 135 | depends on PCI 136 | select RTW88_CORE 137 | select RTW88_PCI 138 | select RTW88_8723D 139 | default m 140 | help 141 | Select this option will enable support for 8723DE chipset 142 | 143 | 802.11n PCIe wireless network adapter 144 | 145 | config RTW88_8723DS 146 | tristate "Realtek 8723DS SDIO wireless network adapter" 147 | depends on MMC 148 | select RTW88_CORE 149 | select RTW88_SDIO 150 | select RTW88_8723D 151 | default m 152 | help 153 | Select this option will enable support for 8723DS chipset 154 | 155 | 802.11n SDIO wireless network adapter 156 | 157 | config RTW88_8723CS 158 | tristate "Realtek 8723CS SDIO wireless network adapter" 159 | depends on MMC 160 | select RTW88_CORE 161 | select RTW88_SDIO 162 | select RTW88_8703B 163 | default m 164 | help 165 | Select this option to enable support for 8723CS chipset (EXPERIMENTAL) 166 | 167 | This module adds support for the 8723CS 802.11n SDIO 168 | wireless network adapter. 169 | 170 | If you choose to build a module, it'll be called rtw88_8723cs. 171 | 172 | config RTW88_8723DU 173 | tristate "Realtek 8723DU USB wireless network adapter" 174 | depends on USB 175 | select RTW88_CORE 176 | select RTW88_USB 177 | select RTW88_8723D 178 | default m 179 | help 180 | Select this option will enable support for 8723DU chipset 181 | 182 | 802.11n USB wireless network adapter 183 | 184 | config RTW88_8821CE 185 | tristate "Realtek 8821CE PCI wireless network adapter" 186 | depends on PCI 187 | select RTW88_CORE 188 | select RTW88_PCI 189 | select RTW88_8821C 190 | default m 191 | help 192 | Select this option will enable support for 8821CE chipset 193 | 194 | 802.11ac PCIe wireless network adapter 195 | 196 | config RTW88_8821CS 197 | tristate "Realtek 8821CS SDIO wireless network adapter" 198 | depends on MMC 199 | select RTW88_CORE 200 | select RTW88_SDIO 201 | select RTW88_8821C 202 | default m 203 | help 204 | Select this option will enable support for 8821CS chipset 205 | 206 | 802.11ac SDIO wireless network adapter 207 | 208 | config RTW88_8821CU 209 | tristate "Realtek 8821CU USB wireless network adapter" 210 | depends on USB 211 | select RTW88_CORE 212 | select RTW88_USB 213 | select RTW88_8821C 214 | default m 215 | help 216 | Select this option will enable support for 8821CU chipset 217 | 218 | 802.11ac USB wireless network adapter 219 | 220 | config RTW88_8821AU 221 | tristate "Realtek 8821AU/8811AU USB wireless network adapter" 222 | depends on USB 223 | select RTW88_CORE 224 | select RTW88_USB 225 | select RTW88_8821A 226 | default m 227 | help 228 | Select this option will enable support for 8821AU and 8811AU chipset 229 | 230 | 802.11ac USB wireless network adapter 231 | 232 | config RTW88_8812AU 233 | tristate "Realtek 8812AU USB wireless network adapter" 234 | depends on USB 235 | select RTW88_CORE 236 | select RTW88_USB 237 | select RTW88_8812A 238 | default m 239 | help 240 | Select this option will enable support for 8812AU chipset 241 | 242 | 802.11ac USB wireless network adapter 243 | 244 | config RTW88_8814AE 245 | tristate "Realtek 8814AE PCI wireless network adapter" 246 | depends on PCI 247 | select RTW88_CORE 248 | select RTW88_PCI 249 | select RTW88_8814A 250 | default m 251 | help 252 | Select this option will enable support for 8814AE chipset 253 | 254 | 802.11ac PCIe wireless network adapter 255 | 256 | config RTW88_8814AU 257 | tristate "Realtek 8814AU USB wireless network adapter" 258 | depends on USB 259 | select RTW88_CORE 260 | select RTW88_USB 261 | select RTW88_8814A 262 | default m 263 | help 264 | Select this option will enable support for 8814AU chipset 265 | 266 | 802.11ac USB wireless network adapter 267 | 268 | config RTW88_DEBUG 269 | bool "Realtek rtw88 debug support" 270 | depends on RTW88_CORE 271 | help 272 | Enable debug support 273 | 274 | If unsure, say Y to simplify debug problems 275 | 276 | config RTW88_DEBUGFS 277 | bool "Realtek rtw88 debugfs support" 278 | depends on RTW88_CORE 279 | help 280 | Enable debug support 281 | 282 | If unsure, say Y to simplify debug problems 283 | 284 | config RTW88_LEDS 285 | bool 286 | depends on LEDS_CLASS=y || LEDS_CLASS=MAC80211 287 | default y 288 | 289 | endif 290 | -------------------------------------------------------------------------------- /patches/wireless/rtw88/Makefile: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause 2 | 3 | obj-$(CONFIG_RTW88_CORE) += rtw88_core.o 4 | rtw88_core-y += main.o \ 5 | mac80211.o \ 6 | util.o \ 7 | debug.o \ 8 | tx.o \ 9 | rx.o \ 10 | mac.o \ 11 | phy.o \ 12 | coex.o \ 13 | efuse.o \ 14 | fw.o \ 15 | ps.o \ 16 | sec.o \ 17 | bf.o \ 18 | sar.o \ 19 | regd.o 20 | 21 | rtw88_core-$(CONFIG_PM) += wow.o 22 | 23 | rtw88_core-$(CONFIG_RTW88_LEDS) += led.o 24 | 25 | obj-$(CONFIG_RTW88_8822B) += rtw88_8822b.o 26 | rtw88_8822b-objs := rtw8822b.o rtw8822b_table.o 27 | 28 | obj-$(CONFIG_RTW88_8822BE) += rtw88_8822be.o 29 | rtw88_8822be-objs := rtw8822be.o 30 | 31 | obj-$(CONFIG_RTW88_8822BS) += rtw88_8822bs.o 32 | rtw88_8822bs-objs := rtw8822bs.o 33 | 34 | obj-$(CONFIG_RTW88_8822BU) += rtw88_8822bu.o 35 | rtw88_8822bu-objs := rtw8822bu.o 36 | 37 | obj-$(CONFIG_RTW88_8822C) += rtw88_8822c.o 38 | rtw88_8822c-objs := rtw8822c.o rtw8822c_table.o 39 | 40 | obj-$(CONFIG_RTW88_8822CE) += rtw88_8822ce.o 41 | rtw88_8822ce-objs := rtw8822ce.o 42 | 43 | obj-$(CONFIG_RTW88_8822CS) += rtw88_8822cs.o 44 | rtw88_8822cs-objs := rtw8822cs.o 45 | 46 | obj-$(CONFIG_RTW88_8822CU) += rtw88_8822cu.o 47 | rtw88_8822cu-objs := rtw8822cu.o 48 | 49 | obj-$(CONFIG_RTW88_8723X) += rtw88_8723x.o 50 | rtw88_8723x-objs := rtw8723x.o 51 | 52 | obj-$(CONFIG_RTW88_8703B) += rtw88_8703b.o 53 | rtw88_8703b-objs := rtw8703b.o rtw8703b_tables.o 54 | 55 | obj-$(CONFIG_RTW88_8723CS) += rtw88_8723cs.o 56 | rtw88_8723cs-objs := rtw8723cs.o 57 | 58 | obj-$(CONFIG_RTW88_8723D) += rtw88_8723d.o 59 | rtw88_8723d-objs := rtw8723d.o rtw8723d_table.o 60 | 61 | obj-$(CONFIG_RTW88_8723DE) += rtw88_8723de.o 62 | rtw88_8723de-objs := rtw8723de.o 63 | 64 | obj-$(CONFIG_RTW88_8723DS) += rtw88_8723ds.o 65 | rtw88_8723ds-objs := rtw8723ds.o 66 | 67 | obj-$(CONFIG_RTW88_8723DU) += rtw88_8723du.o 68 | rtw88_8723du-objs := rtw8723du.o 69 | 70 | obj-$(CONFIG_RTW88_8821C) += rtw88_8821c.o 71 | rtw88_8821c-objs := rtw8821c.o rtw8821c_table.o 72 | 73 | obj-$(CONFIG_RTW88_8821CE) += rtw88_8821ce.o 74 | rtw88_8821ce-objs := rtw8821ce.o 75 | 76 | obj-$(CONFIG_RTW88_8821CS) += rtw88_8821cs.o 77 | rtw88_8821cs-objs := rtw8821cs.o 78 | 79 | obj-$(CONFIG_RTW88_8821CU) += rtw88_8821cu.o 80 | rtw88_8821cu-objs := rtw8821cu.o 81 | 82 | obj-$(CONFIG_RTW88_88XXA) += rtw88_88xxa.o 83 | rtw88_88xxa-objs := rtw88xxa.o 84 | 85 | obj-$(CONFIG_RTW88_8821A) += rtw88_8821a.o 86 | rtw88_8821a-objs := rtw8821a.o rtw8821a_table.o 87 | 88 | obj-$(CONFIG_RTW88_8812A) += rtw88_8812a.o 89 | rtw88_8812a-objs := rtw8812a.o rtw8812a_table.o 90 | 91 | obj-$(CONFIG_RTW88_8821AU) += rtw88_8821au.o 92 | rtw88_8821au-objs := rtw8821au.o 93 | 94 | obj-$(CONFIG_RTW88_8812AU) += rtw88_8812au.o 95 | rtw88_8812au-objs := rtw8812au.o 96 | 97 | obj-$(CONFIG_RTW88_8814A) += rtw88_8814a.o 98 | rtw88_8814a-objs := rtw8814a.o rtw8814a_table.o 99 | 100 | obj-$(CONFIG_RTW88_8814AE) += rtw88_8814ae.o 101 | rtw88_8814ae-objs := rtw8814ae.o 102 | 103 | obj-$(CONFIG_RTW88_8814AU) += rtw88_8814au.o 104 | rtw88_8814au-objs := rtw8814au.o 105 | 106 | obj-$(CONFIG_RTW88_PCI) += rtw88_pci.o 107 | rtw88_pci-objs := pci.o 108 | 109 | obj-$(CONFIG_RTW88_SDIO) += rtw88_sdio.o 110 | rtw88_sdio-objs := sdio.o 111 | 112 | obj-$(CONFIG_RTW88_USB) += rtw88_usb.o 113 | rtw88_usb-objs := usb.o 114 | -------------------------------------------------------------------------------- /patches/wireless/rtw88/hack/001-rtw88-usb-make-work-queues-high-priority.disable: -------------------------------------------------------------------------------- 1 | From 3996a482cf8d679a4d4db89a3665d5980f0bb730 Mon Sep 17 00:00:00 2001 2 | From: Patrick Yavitz 3 | Date: Thu, 1 Aug 2024 06:03:40 -0400 4 | Subject: [PATCH] rtw88: usb: make work queues high priority 5 | 6 | The rtw8822/21cu driver has problems handling high rx or tx rates compared with high 7 | load (such as high I/O) on slower systems. 8 | 9 | Examples: i.MX6 SoloX, NanoPi M1 and similar platforms. 10 | https://lore.kernel.org/linux-wireless/20230612134048.321500-1-petter@technux.se/T/#t 11 | 12 | Signed-off-by: Patrick Yavitz 13 | --- 14 | drivers/net/wireless/realtek/rtw88/usb.c | 4 ++-- 15 | 1 file changed, 2 insertions(+), 2 deletions(-) 16 | 17 | diff --git a/drivers/net/wireless/realtek/rtw88/usb.c b/drivers/net/wireless/realtek/rtw88/usb.c 18 | index 3dd1bc53e316..b194ecfef7ca 100644 19 | --- a/drivers/net/wireless/realtek/rtw88/usb.c 20 | +++ b/drivers/net/wireless/realtek/rtw88/usb.c 21 | @@ -772,7 +772,7 @@ static int rtw_usb_init_rx(struct rtw_dev *rtwdev) 22 | { 23 | struct rtw_usb *rtwusb = rtw_get_usb_priv(rtwdev); 24 | 25 | - rtwusb->rxwq = create_singlethread_workqueue("rtw88_usb: rx wq"); 26 | + rtwusb->rxwq = alloc_workqueue("rtw88_usb: rx wq", WQ_UNBOUND | WQ_HIGHPRI, 0); 27 | if (!rtwusb->rxwq) { 28 | rtw_err(rtwdev, "failed to create RX work queue\n"); 29 | return -ENOMEM; 30 | @@ -812,7 +812,7 @@ static int rtw_usb_init_tx(struct rtw_dev *rtwdev) 31 | struct rtw_usb *rtwusb = rtw_get_usb_priv(rtwdev); 32 | int i; 33 | 34 | - rtwusb->txwq = create_singlethread_workqueue("rtw88_usb: tx wq"); 35 | + rtwusb->txwq = alloc_workqueue("rtw88_usb: tx wq", WQ_UNBOUND | WQ_HIGHPRI, 0); 36 | if (!rtwusb->txwq) { 37 | rtw_err(rtwdev, "failed to create TX work queue\n"); 38 | return -ENOMEM; 39 | -- 40 | 2.39.2 41 | 42 | -------------------------------------------------------------------------------- /patches/wireless/rtw88/hack/002-rtw88-decrease-the-log-level-of-tx-report.patch: -------------------------------------------------------------------------------- 1 | From 21e65dd7e309a476bcfa65c771ad07f768a03dc1 Mon Sep 17 00:00:00 2001 2 | From: Patrick Yavitz 3 | Date: Thu, 1 Aug 2024 06:04:26 -0400 4 | Subject: [PATCH] rtw88: decrease the log level of tx report 5 | 6 | Reduce 'failed to get tx report from firmware' dmesg spam. 7 | https://lore.kernel.org/linux-wireless/20210713104524.47101-1-pkshih@realtek.com/ 8 | https://cgit.freebsd.org/src/commit/?id=e140d551b78670fbf99c83a59438cb13de50420f 9 | 10 | Signed-off-by: Patrick Yavitz 11 | --- 12 | drivers/net/wireless/realtek/rtw88/tx.c | 12 +++++++----- 13 | 1 file changed, 7 insertions(+), 5 deletions(-) 14 | 15 | diff --git a/drivers/net/wireless/realtek/rtw88/tx.c b/drivers/net/wireless/realtek/rtw88/tx.c 16 | index 1d8af54a2739..39c0acd786d8 100644 17 | --- a/drivers/net/wireless/realtek/rtw88/tx.c 18 | +++ b/drivers/net/wireless/realtek/rtw88/tx.c 19 | @@ -205,14 +205,16 @@ void rtw_tx_report_purge_timer(void *cntx) 20 | struct rtw_tx_report *tx_report = &rtwdev->tx_report; 21 | unsigned long flags; 22 | 23 | - if (skb_queue_len(&tx_report->queue) == 0) 24 | - return; 25 | - 26 | - rtw_warn(rtwdev, "failed to get tx report from firmware\n"); 27 | + uint32_t qlen; 28 | 29 | spin_lock_irqsave(&tx_report->q_lock, flags); 30 | - skb_queue_purge(&tx_report->queue); 31 | + qlen = skb_queue_len(&tx_report->queue); 32 | + if (qlen > 0) 33 | + skb_queue_purge(&tx_report->queue); 34 | spin_unlock_irqrestore(&tx_report->q_lock, flags); 35 | + 36 | + rtw_dbg(rtwdev, RTW_DBG_TX, "failed to get tx report from firmware: " 37 | + "txreport qlen %u\n", qlen); 38 | } 39 | 40 | void rtw_tx_report_enqueue(struct rtw_dev *rtwdev, struct sk_buff *skb, u8 sn) 41 | -- 42 | 2.39.2 43 | 44 | -------------------------------------------------------------------------------- /scripts/.aarch64: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source lib/source 4 | 5 | bullseye-aarch64 (){ 6 | sudo debconf-apt-progress -- apt install -y \ 7 | build-essential bison bc git dialog patch fdisk jq mtools mmdebstrap \ 8 | dosfstools zip unzip qemu debootstrap qemu-user-static rsync \ 9 | kmod cpio flex libssl-dev libncurses5-dev parted fakeroot swig \ 10 | aria2 pv distro-info-data lsb-release xz-utils curl figlet \ 11 | e2fsprogs btrfs-progs xfsprogs kpartx make libelf-dev zstd gcc-9 gcc-10 \ 12 | gcc-9-plugin-dev gcc-10-plugin-dev ccache 13 | } 14 | 15 | bookworm-aarch64 (){ 16 | sudo debconf-apt-progress -- apt install -y \ 17 | build-essential bison bc git dialog patch fdisk mtools mmdebstrap \ 18 | dosfstools zip unzip debootstrap qemu-user-static rsync \ 19 | kmod cpio flex libssl-dev libncurses5-dev parted fakeroot swig \ 20 | aria2 pv distro-info-data lsb-release xz-utils curl jq figlet \ 21 | e2fsprogs btrfs-progs xfsprogs kpartx make libelf-dev zstd gcc-11 gcc-12 \ 22 | gcc-11-plugin-dev gcc-12-plugin-dev ccache 23 | } 24 | 25 | jammy-aarch64 (){ 26 | sudo debconf-apt-progress -- apt install -y \ 27 | build-essential bison bc git dialog patch jq mtools mmdebstrap \ 28 | dosfstools zip unzip qemu debootstrap qemu-user-static rsync \ 29 | kmod cpio flex libssl-dev libncurses5-dev parted fakeroot swig \ 30 | aria2 pv distro-info-data lsb-release xz-utils curl figlet \ 31 | e2fsprogs btrfs-progs kpartx xfsprogs fdisk debian-archive-keyring \ 32 | debian-keyring make libelf-dev gcc-9 gcc-10 gcc-11 gcc-12 \ 33 | gcc-9-plugin-dev gcc-10-plugin-dev gcc-11-plugin-dev gcc-12-plugin-dev \ 34 | ccache 35 | } 36 | 37 | noble-aarch64 (){ 38 | sudo debconf-apt-progress -- apt install -y \ 39 | build-essential bison bc git dialog patch jq mtools mmdebstrap \ 40 | dosfstools zip unzip debootstrap qemu-user-static rsync \ 41 | kmod cpio flex libssl-dev libncurses5-dev parted fakeroot swig \ 42 | aria2 pv distro-info-data lsb-release xz-utils curl figlet \ 43 | e2fsprogs btrfs-progs kpartx xfsprogs fdisk debian-archive-keyring \ 44 | debian-keyring make libelf-dev gcc-9 gcc-10 gcc-11 gcc-12 gcc-13 gcc-14 \ 45 | gcc-9-plugin-dev gcc-10-plugin-dev gcc-11-plugin-dev gcc-12-plugin-dev \ 46 | gcc-13-plugin-dev gcc-14-plugin-dev ccache 47 | } 48 | 49 | if [[ "$HOST_ARCH" == "x86_64" ]]; then 50 | echo "" 51 | echo -e "You are running: $HOST_ARCH" 52 | echo -e "Please run: make ccompile" 53 | exit 0 54 | fi 55 | 56 | if [[ "$HOST_CODENAME" =~ ^(bullseye|bookworm|jammy|noble)$ ]]; then 57 | echo "" 58 | ${HOST_CODENAME}-aarch64 59 | else 60 | echo -e "" 61 | echo -e "Something went wrong..?" 62 | exit 0 63 | fi 64 | 65 | exit 0 66 | -------------------------------------------------------------------------------- /scripts/.ccompile: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source lib/source 4 | 5 | bullseye-ccompile (){ 6 | sudo debconf-apt-progress -- apt install -y \ 7 | build-essential bison bc git dialog patch kpartx zstd aria2 pv jq mmdebstrap \ 8 | dosfstools zip unzip qemu debootstrap qemu-user-static rsync make figlet \ 9 | kmod cpio flex libssl-dev libncurses5-dev parted fakeroot swig libelf-dev \ 10 | crossbuild-essential-arm64 crossbuild-essential-armel crossbuild-essential-armhf \ 11 | distro-info-data lsb-release xz-utils curl e2fsprogs btrfs-progs xfsprogs \ 12 | fdisk gcc-9 gcc-10 gcc-9-arm-linux-gnueabihf gcc-10-arm-linux-gnueabihf \ 13 | gcc-9-arm-linux-gnueabi gcc-10-arm-linux-gnueabi gcc-9-aarch64-linux-gnu \ 14 | gcc-10-aarch64-linux-gnu mtools gcc-9-plugin-dev gcc-10-plugin-dev ccache 15 | } 16 | 17 | bookworm-ccompile (){ 18 | sudo debconf-apt-progress -- apt install -y \ 19 | build-essential bison bc git dialog patch dosfstools zip unzip parted mmdebstrap \ 20 | debootstrap qemu-user-static rsync kmod cpio flex libssl-dev libncurses5-dev \ 21 | device-tree-compiler libfdt-dev python3-distutils python3-dev swig fakeroot figlet \ 22 | lzop lz4 aria2 pv crossbuild-essential-arm64 crossbuild-essential-armhf u-boot-tools \ 23 | distro-info-data lsb-release libelf-dev fdisk kpartx ccache xz-utils gcc-11 gcc-12 \ 24 | python-is-python3 python-dev-is-python3 zstd gcc-arm-none-eabi gcc-11-arm-linux-gnueabihf \ 25 | gcc-11-aarch64-linux-gnu gcc-12-aarch64-linux-gnu gcc-12-arm-linux-gnueabihf \ 26 | colorized-logs gdisk jq wget btrfs-progs xfsprogs gcc-11-arm-linux-gnueabi \ 27 | gcc-12-arm-linux-gnueabi crossbuild-essential-armel python3-setuptools \ 28 | python3-pyelftools curl mtools gcc-11-plugin-dev gcc-12-plugin-dev ccache 29 | } 30 | 31 | jammy-ccompile (){ 32 | sudo debconf-apt-progress -- apt install -y \ 33 | build-essential bison bc git dialog patch fdisk distro-info-data mmdebstrap \ 34 | dosfstools zip unzip qemu debootstrap qemu-user-static rsync xfsprogs \ 35 | kmod cpio flex libssl-dev libncurses5-dev parted fakeroot swig kpartx \ 36 | aria2 pv lsb-release xz-utils curl e2fsprogs btrfs-progs jq mtools figlet \ 37 | crossbuild-essential-arm64 crossbuild-essential-armhf crossbuild-essential-armel \ 38 | gcc-9-arm-linux-gnueabi gcc-10-arm-linux-gnueabi gcc-11-arm-linux-gnueabi \ 39 | gcc-9-arm-linux-gnueabihf gcc-10-arm-linux-gnueabihf gcc-11-arm-linux-gnueabihf \ 40 | gcc-9-aarch64-linux-gnu gcc-10-aarch64-linux-gnu gcc-11-aarch64-linux-gnu \ 41 | gcc-9 gcc-10 gcc-11 gcc-12 debian-archive-keyring debian-keyring make libelf-dev \ 42 | gcc-12-arm-linux-gnueabi gcc-12-arm-linux-gnueabihf gcc-12-aarch64-linux-gnu \ 43 | gcc-9-plugin-dev gcc-10-plugin-dev gcc-11-plugin-dev gcc-12-plugin-dev ccache 44 | } 45 | 46 | noble-ccompile (){ 47 | sudo debconf-apt-progress -- apt install -y \ 48 | build-essential bison bc git dialog patch fdisk distro-info-data mmdebstrap \ 49 | dosfstools zip unzip debootstrap qemu-user-static rsync xfsprogs \ 50 | kmod cpio flex libssl-dev libncurses5-dev parted fakeroot swig kpartx \ 51 | aria2 pv lsb-release xz-utils curl e2fsprogs btrfs-progs jq mtools figlet \ 52 | crossbuild-essential-arm64 crossbuild-essential-armhf crossbuild-essential-armel \ 53 | gcc-9-arm-linux-gnueabi gcc-10-arm-linux-gnueabi gcc-11-arm-linux-gnueabi \ 54 | gcc-12-arm-linux-gnueabi gcc-13-arm-linux-gnueabi gcc-14-arm-linux-gnueabi \ 55 | gcc-9-arm-linux-gnueabihf gcc-10-arm-linux-gnueabihf gcc-11-arm-linux-gnueabihf \ 56 | gcc-12-arm-linux-gnueabihf gcc-13-arm-linux-gnueabihf gcc-14-arm-linux-gnueabihf \ 57 | gcc-9-aarch64-linux-gnu gcc-10-aarch64-linux-gnu gcc-11-aarch64-linux-gnu \ 58 | gcc-12-aarch64-linux-gnu gcc-13-aarch64-linux-gnu gcc-14-aarch64-linux-gnu \ 59 | gcc-9 gcc-10 gcc-11 gcc-12 gcc-13 gcc-14 debian-archive-keyring debian-keyring make \ 60 | libelf-dev gcc-9-plugin-dev gcc-10-plugin-dev gcc-11-plugin-dev gcc-12-plugin-dev \ 61 | gcc-13-plugin-dev gcc-14-plugin-dev ccache 62 | } 63 | 64 | if [[ "$HOST_ARCH" == "aarch64" ]]; then 65 | echo -e "" 66 | echo -e "You are running: $HOST_ARCH" 67 | echo -e "Please run: make ncompile" 68 | exit 1 69 | fi 70 | 71 | if [[ "$HOST_CODENAME" =~ ^(bullseye|bookworm|jammy|noble)$ ]]; then 72 | echo "" 73 | ${HOST_CODENAME}-ccompile 74 | else 75 | echo -e "" 76 | echo -e "Something went wrong..? Please report." 77 | exit 1 78 | fi 79 | 80 | exit 0 81 | -------------------------------------------------------------------------------- /scripts/.header: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [[ `command -v figlet` ]]; then :; else sudo apt install -y figlet; echo ""; fi 4 | 5 | GRN="\e[0;32m" 6 | PNK="\e[0;35m" 7 | TXT="\033[1m" 8 | FIN="\e[0m" 9 | 10 | BUILDER=`figlet -f term -l "Raspberry Pi Image Builder"` 11 | GIT_BRANCH=`git branch` 12 | 13 | if [[ -f "userdata.txt" ]]; then 14 | VERSION=`grep "BUILDER=" "userdata.txt" | sed 's/BUILDER=//g'` 15 | BUILDER_VER=" ${PNK}(${FIN}${GRN}${VERSION}${FIN}${PNK})${FIN}" 16 | else 17 | BUILDER_VER="" 18 | fi 19 | 20 | echo -en "${TXT}${BUILDER}${FIN} ${PNK}(${FIN}${GRN}${GIT_BRANCH}${FIN}${PNK})${FIN}${BUILDER_VER}" 21 | if [[ -f "/etc/os-release" ]] && [[ `command -v uname` ]]; then 22 | # host machine 23 | HOST_MACHINE=`cat /etc/os-release | grep -w NAME | sed 's/NAME=//g' | sed 's/"//g' | sed 's/ GNU\/Linux//g'` 24 | HOST_CODENAME=`cat /etc/os-release | grep -w "VERSION_CODENAME" | sed 's/VERSION_CODENAME=//g' | sed -e "s/\b\(.\)/\u\1/g"` 25 | HOST_ARCH=`uname -m` 26 | echo -e "" 27 | echo -en "${TXT}Host machine${FIN} ${PNK}(${FIN}${GRN}${HOST_MACHINE} ${HOST_CODENAME}${FIN}${PNK})${FIN} ${PNK}(${FIN}${GRN}${HOST_ARCH}${FIN}${PNK})${FIN}" 28 | fi 29 | echo -e "" 30 | 31 | exit 0 32 | -------------------------------------------------------------------------------- /scripts/.ncompile: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source lib/source 4 | 5 | bullseye-ncompile (){ 6 | sudo debconf-apt-progress -- apt install -y \ 7 | build-essential bison bc git dialog patch kpartx zstd mtools mmdebstrap \ 8 | dosfstools zip unzip qemu debootstrap qemu-user-static rsync make fdisk \ 9 | kmod cpio flex libssl-dev libncurses5-dev parted fakeroot swig libelf-dev \ 10 | crossbuild-essential-armel crossbuild-essential-armhf aria2 pv figlet \ 11 | distro-info-data lsb-release xz-utils curl e2fsprogs btrfs-progs xfsprogs \ 12 | gcc-9 gcc-10 gcc-9-arm-linux-gnueabihf gcc-10-arm-linux-gnueabihf \ 13 | gcc-9-arm-linux-gnueabi gcc-10-arm-linux-gnueabi gcc-9-plugin-dev gcc-10-plugin-dev \ 14 | ccache 15 | } 16 | 17 | bookworm-ncompile (){ 18 | sudo debconf-apt-progress -- apt install -y \ 19 | build-essential bison bc git dialog patch kpartx zstd mtools mmdebstrap \ 20 | dosfstools zip unzip debootstrap qemu-user-static rsync make fdisk \ 21 | kmod cpio flex libssl-dev libncurses5-dev parted fakeroot swig libelf-dev \ 22 | crossbuild-essential-armel crossbuild-essential-armhf aria2 pv jq figlet \ 23 | distro-info-data lsb-release xz-utils curl e2fsprogs btrfs-progs xfsprogs \ 24 | gcc-11 gcc-12 gcc-11-arm-linux-gnueabihf gcc-12-arm-linux-gnueabihf \ 25 | gcc-11-arm-linux-gnueabi gcc-12-arm-linux-gnueabi gcc-11-plugin-dev gcc-12-plugin-dev \ 26 | ccache 27 | } 28 | 29 | jammy-ncompile (){ 30 | sudo debconf-apt-progress -- apt install -y \ 31 | build-essential bison bc git dialog patch dosfstools mtools mmdebstrap \ 32 | zip unzip qemu debootstrap qemu-user-static rsync kmod cpio flex \ 33 | libssl-dev libncurses5-dev parted fakeroot swig aria2 pv figlet \ 34 | distro-info-data lsb-release xz-utils curl e2fsprogs btrfs-progs kpartx \ 35 | debian-archive-keyring crossbuild-essential-armel crossbuild-essential-armhf \ 36 | gcc-9-arm-linux-gnueabi gcc-10-arm-linux-gnueabi gcc-11-arm-linux-gnueabi \ 37 | gcc-9-arm-linux-gnueabihf gcc-10-arm-linux-gnueabihf gcc-11-arm-linux-gnueabihf \ 38 | gcc-12-arm-linux-gnueabi gcc-12-arm-linux-gnueabihf gcc-9 gcc-10 gcc-11 gcc-12 \ 39 | debian-keyring make libelf-dev xfsprogs fdisk gcc-9-plugin-dev gcc-10-plugin-dev \ 40 | gcc-11-plugin-dev gcc-12-plugin-dev ccache 41 | } 42 | 43 | noble-ncompile (){ 44 | sudo debconf-apt-progress -- apt install -y \ 45 | build-essential bison bc git dialog patch fdisk distro-info-data mmdebstrap \ 46 | dosfstools zip unzip debootstrap qemu-user-static rsync xfsprogs \ 47 | kmod cpio flex libssl-dev libncurses5-dev parted fakeroot swig kpartx \ 48 | aria2 pv lsb-release xz-utils curl e2fsprogs btrfs-progs jq mtools figlet \ 49 | crossbuild-essential-arm64 crossbuild-essential-armhf crossbuild-essential-armel \ 50 | gcc-9-arm-linux-gnueabi gcc-10-arm-linux-gnueabi gcc-11-arm-linux-gnueabi \ 51 | gcc-12-arm-linux-gnueabi gcc-13-arm-linux-gnueabi gcc-14-arm-linux-gnueabi \ 52 | gcc-9-arm-linux-gnueabihf gcc-10-arm-linux-gnueabihf gcc-11-arm-linux-gnueabihf \ 53 | gcc-12-arm-linux-gnueabihf gcc-13-arm-linux-gnueabihf gcc-14-arm-linux-gnueabihf \ 54 | gcc-9 gcc-10 gcc-11 gcc-12 gcc-13 gcc-14 debian-archive-keyring debian-keyring make \ 55 | libelf-dev gcc-9-plugin-dev gcc-10-plugin-dev gcc-11-plugin-dev gcc-12-plugin-dev \ 56 | gcc-13-plugin-dev gcc-14-plugin-dev ccache 57 | } 58 | 59 | if [[ "$HOST_ARCH" == "x86_64" ]]; then 60 | echo "" 61 | echo -e "You are running: $HOST_ARCH" 62 | echo -e "Please run: make ccompile" 63 | exit 0 64 | fi 65 | 66 | if [[ "$HOST_CODENAME" =~ ^(bullseye|bookworm|jammy|noble)$ ]]; then 67 | echo "" 68 | ${HOST_CODENAME}-ncompile 69 | else 70 | echo -e "" 71 | echo -e "Something went wrong..? Please report." 72 | exit 0 73 | fi 74 | 75 | exit 0 76 | -------------------------------------------------------------------------------- /scripts/check: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # depends: curl 3 | 4 | source lib/source 5 | echo "Example: 6.12.y" 6 | echo 7 | echo -en "BRANCH: " 8 | read BRANCH 9 | ITL="\033[3m" 10 | FIN="\033[0m" 11 | GIT_URL="https://github.com/raspberrypi/linux" 12 | GIT_HASH=`git ls-remote --heads ${GIT_URL}.git | grep -w "refs/heads/rpi-${BRANCH}" | sed -n '1p' | sed "s/refs\/heads\/rpi-${BRANCH}//g" | sed s/'\s'//g` 13 | if [[ `wget -S --spider https://raw.githubusercontent.com/raspberrypi/linux/rpi-$BRANCH/Makefile 2>&1 | grep 'HTTP/1.1 200 OK'` ]]; then 14 | curl --silent -L https://raw.githubusercontent.com/raspberrypi/linux/rpi-$BRANCH/Makefile | grep -m1 "VERSION" | \ 15 | sed 's/VERSION = //g' > revision.txt 16 | curl --silent -L https://raw.githubusercontent.com/raspberrypi/linux/rpi-$BRANCH/Makefile | grep -m1 "PATCHLEVEL" | \ 17 | sed 's/PATCHLEVEL = /./g' >> revision.txt 18 | curl --silent -L https://raw.githubusercontent.com/raspberrypi/linux/rpi-$BRANCH/Makefile | grep -m1 "SUBLEVEL" | \ 19 | sed 's/SUBLEVEL = /./g' >> revision.txt 20 | curl --silent -L https://raw.githubusercontent.com/raspberrypi/linux/rpi-$BRANCH/Makefile | grep -m1 "EXTRAVERSION" | \ 21 | sed 's/EXTRAVERSION =//g' | sed 's/ //g' >> revision.txt 22 | else 23 | echo "" 24 | echo -e "The BRANCH you selected is not available." 25 | rm -f revision.txt 26 | exit 0 27 | fi 28 | 29 | if [[ -f "revision.txt" ]]; then 30 | echo -en "CURRENT: " 31 | tr -d '\n' < revision.txt 32 | rm -f revision.txt 33 | if [[ -f ".cache/git_shallow.${KERNEL}-${BRANCH}" ]]; then 34 | source .cache/git_shallow.${KERNEL}-${BRANCH} 35 | if [[ "$GIT_COMMIT" == "$GIT_HASH" ]]; then echo -e ""; else echo -e " ${ITL}NEW!${FIN}"; fi; else echo -e ""; 36 | fi 37 | else 38 | echo -e "Something went wrong?" 39 | rm -f revision.txt 40 | exit 1 41 | fi 42 | echo -e "COMMIT: ${GIT_HASH}" 43 | 44 | exit 0 45 | -------------------------------------------------------------------------------- /scripts/clean: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cleanup (){ 4 | umount p2/proc p2/sys p2/dev p2/run > /dev/null 2>&1 5 | umount sysroot/proc sysroot/sys sysroot/dev/pts sysroot/dev sysroot/run > /dev/null 2>&1 6 | umount -l p1 p2 sysroot BOOT ROOTFS > /dev/null 2>&1 7 | rm -fdr p1 p2 img sysroot BOOT ROOTFS > /dev/null 2>&1 8 | rm -f {part-uuid.txt,kernel.release,kpart*,gcc.txt,ccache.txt,clang.txt} 9 | losetup -d /dev/loop* > /dev/null 2>&1 10 | sleep 1s 11 | losetup -d /dev/loop* > /dev/null 2>&1 12 | if [[ -f "shrink.img" ]]; then kpartx -d shrink.img; fi 13 | rm -f shrink.img 14 | } 15 | 16 | echo -en "Cleaning" 17 | cleanup > /dev/null 2>&1 18 | echo -e " [done]" 19 | 20 | exit 0 21 | -------------------------------------------------------------------------------- /scripts/rootfs: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source lib/function/echoes 3 | source lib/source 4 | validation 5 | if [[ -f "board.txt" ]]; then . board.txt; else noboard; fi 6 | sleep 1 7 | source userdata.txt 8 | source lib/function/rootfs 9 | source lib/function/release 10 | source custom.txt 11 | # clean 12 | if [[ -d "sysroot" ]] || [[ -d "p1" ]] || [[ -d "BOOT" ]] || [[ -f "shrink.img" ]]; then make clean; clear -x; fi 13 | # verbosity 14 | if [ $VERBOSE -eq 1 ]; then set -eux -o pipefail; else set -eu -o pipefail; fi 15 | mirrors 16 | # restrictions 17 | if [[ "$HOST_ARCH" == "aarch64" ]] && [[ "$DISTRO" == "raspbian" ]]; then 18 | echo -e "Aarch64 is currently not supported." 19 | echo -e "To build an Raspbian IMG you need to use x86_64." 20 | echo -e "" 21 | read -p "Press enter to continue." 22 | exit 0 23 | fi 24 | if [[ "$ROOTFS_ARCH" == "rootfs-armel" ]] && [[ "$DISTRO" == "ubuntu" ]]; then 25 | echo -e "Ubuntu does not support ${ARCH_EXT}." 26 | echo -e "" 27 | read -p "Press enter to continue." 28 | exit 0 29 | fi 30 | if [[ "$ROOTFS_ARCH" == "rootfs-armel" || "$ROOTFS_ARCH" == "rootfs-arm64" ]] && [[ "$DISTRO" == "raspbian" ]]; then 31 | echo -e "Raspbian does not support ${ARCH_EXT}." 32 | echo -e "" 33 | read -p "Press enter to continue." 34 | exit 0 35 | fi 36 | # keyrings and setups 37 | if [[ "$DISTRO" =~ ^(devuan||kali|raspbian)$ ]]; then ${DISTRO}_keyring; fi 38 | if [[ "$HOST_MACHINE" == "Ubuntu" ]]; then :; else if [[ "$DISTRO" == "ubuntu" ]]; then ${DISTRO}_keyring; fi; fi 39 | # check for qemu 40 | if [[ `command -v ${STATIC}` ]]; then 41 | :; 42 | else 43 | echo -e "Missing depends: ${STATIC}" 44 | echo -e "Run ./install.sh" 45 | exit 1 46 | fi 47 | if [[ `command -v mmdebstrap` ]]; then 48 | :; 49 | else 50 | echo -e "Missing depends: mmdebstrap" 51 | apt install -y mmdebstrap 52 | fi 53 | 54 | P_VALUE="sysroot" 55 | ${DISTRO}_sources_list 56 | RELEASE_TARBALL=${DISTRO}-${DISTRO_VERSION}-${ROOTFS_ARCH}.tar.xz 57 | if [[ -f "$RELEASE_TARBALL" ]]; then ls -ls $RELEASE_TARBALL; exit 0; fi 58 | CAP_DISTRO=`echo "${DISTRO}" | sed -e "s/\b\(.\)/\u\1/g"` 59 | CAP_RELEASE=`echo "${DISTRO_VERSION}" | sed -e "s/\b\(.\)/\u\1/g"` 60 | echo -e "" 61 | echo -e "${WHT}Distribution${FIN} ${PNK}[${FIN}${GRN}${CAP_DISTRO} ${CAP_RELEASE}${FIN}${PNK}]${FIN}" 62 | echo -e "" 63 | echo -e "${WHT}Running bootstrap${FIN} ..." 64 | # start bootstrap 65 | if [ $DEVROOTFS -eq 1 ]; then 66 | RAM=0 67 | ROOTFS_FOLDER="img/" 68 | RELEASE_NAME=${DISTRO}-${DISTRO_VERSION}-${ROOTFS_ARCH} 69 | if [ $RAM -ne 0 ]; then IMAGE_FOLDER="ram/"; fi 70 | mkdir -p "$ROOTFS_FOLDER" 71 | if [ $RAM -ne 0 ]; then mount -t tmpfs -o size=4G tmpfs $ROOTFS_FOLDER; fi 72 | if [ $VERBOSE -eq 1 ]; then sysroot_partition; else sysroot_partition > /dev/null 2>&1; fi 73 | fi 74 | mkdir -p ${P_VALUE}/usr/bin 75 | cp $(command -v "${STATIC}") ${P_VALUE}/usr/bin 76 | run_debootstrap 77 | 78 | # creating developer tarball 79 | if [ $DEVROOTFS -eq 1 ]; then 80 | sysroot_setup 81 | mount -o bind /dev ${P_VALUE}/dev 82 | mount -o bind /dev/pts ${P_VALUE}/dev/pts 83 | cp -f lib/source ${P_VALUE}/root/source.txt 84 | cp -f {scripts/rootfs-extra,userdata.txt,board.txt} ${P_VALUE}/root/ 85 | chroot ${P_VALUE} /root/rootfs-extra 86 | umount ${P_VALUE}/dev/pts 87 | umount ${P_VALUE}/dev 88 | rm -fr ${P_VALUE}/root/{rootfs-extra,*.txt} 89 | rm -f ${P_VALUE}/etc/dpkg/dpkg.cfg.d/dpkg-unsafe-io 90 | rm -f ${P_VALUE}/etc/apt/sources.list 91 | rm -f ${SOURCES_LIST} 92 | fi 93 | 94 | # clean up 95 | rm -f ${P_VALUE}/usr/bin/${STATIC} 96 | rm -fdr ${P_VALUE}/lost+found 97 | rm -fdr ${P_VALUE}/var/cache/debconf/* 98 | rm -fdr ${P_VALUE}/*usr-is-merged* 99 | 100 | # finish 101 | echo "" 102 | echo -e "── Archiving ${PNK}[${FIN}${WHT}${RELEASE_TARBALL}${FIN}${PNK}]${FIN}" 103 | cd ${P_VALUE} 104 | XZ_DEFAULTS="--threads=${CORES}"; export XZ_DEFAULTS;tar cfJ - * | (pv -terb > ../$RELEASE_TARBALL) 105 | cd .. 106 | if [ $DEVROOTFS -eq 1 ]; then 107 | losetup -d "${IMAGE_LOOP_DEV}" 108 | rm -f "${ROOTFS_FOLDER}${RELEASE_NAME}" 109 | if [ $RAM -ne 0 ]; then umount "${ROOTFS_FOLDER}"; fi 110 | rmdir "${ROOTFS_FOLDER}" 111 | fi 112 | 113 | if [[ -d "${P_VALUE}" ]]; then umount ${P_VALUE}; sleep .50; rm -fdr ${P_VALUE}; fi 114 | if [[ -v "SPOOF_SCRIPT" ]] && [[ "$SPOOF_SCRIPT" == "true" ]]; then rm -f ${DEBOOTSTRAP_DIR}/${DISTRO_VERSION}; fi 115 | 116 | exit 0 117 | -------------------------------------------------------------------------------- /scripts/rootfs-extra: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | source /root/source.txt 4 | source /root/board.txt 5 | source /root/userdata.txt 6 | export DEBIAN_FRONTEND="noninteractive" 7 | 8 | CAP_DISTRO=`echo "$DISTRO" | sed -e "s/\b\(.\)/\u\1/g"` 9 | CAP_RELEASE=`echo "$DISTRO_VERSION" | sed -e "s/\b\(.\)/\u\1/g"` 10 | 11 | echo "" 12 | echo -e "\e[1;37mAdding additional packages to $CAP_DISTRO $CAP_RELEASE\e[0m ..." 13 | 14 | mount -t proc proc proc/ 15 | mount -t sysfs sys sys/ 16 | 17 | if [[ "$DISTRO" == "ubuntu" ]]; then rm -f /etc/resolv.conf; fi 18 | echo "nameserver ${NAMESERVER1}" > /etc/resolv.conf 19 | echo "nameserver ${NAMESERVER2}" >> /etc/resolv.conf 20 | 21 | if [[ -f "/etc/apt/trusted.gpg" ]] && [[ "$DISTRO" == "raspbian" ]]; then 22 | mkdir -p /etc/apt/trusted.gpg.d 23 | mv -f /etc/apt/trusted.gpg /etc/apt/trusted.gpg.d/raspbian-archive-keyring.gpg 24 | fi 25 | 26 | # dpkg: error: failed to open package info file '/var/lib/dpkg/available' for reading: No such file or directory 27 | if [[ "$DISTRO_VERSION" == "focal" ]]; then dpkg --clear-avail; fi 28 | 29 | apt-get update 30 | apt-get install -y apt-utils 31 | 32 | # locales 33 | apt install -y locales 34 | export LANGUAGE=${LOCALE} 35 | export LANG=${LOCALE} 36 | export LC_ALL=${LOCALE_LC_ALL} 37 | locale-gen ${LOCALE} 38 | 39 | # timezone 40 | ln -snf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime 41 | echo -n "${TIMEZONE}" > /etc/timezone 42 | 43 | apt upgrade -y 44 | apt dist-upgrade -y 45 | if [[ "$DISTRO_VERSION" =~ ^(oracular|plucky)$ ]]; then WIRELESS="iw"; else WIRELESS="iw wireless-tools"; fi 46 | if [[ "$DISTRO" =~ ^(debian|raspbian)$ ]]; then 47 | apt install -y ${PKGS} ${USER_PKGS} ${SYSMODS} ${WIRELESS} resolvconf openssh-client openssh-server 48 | fi 49 | if [[ "$DISTRO" == "devuan" ]]; then 50 | apt install -y openssh-client openssh-server --no-install-recommends 51 | apt install -y ${PKGS} ${USER_PKGS} ${SYSMODS} ${WIRELESS} openresolv 52 | fi 53 | if [[ "$DISTRO" == "kali" ]]; then 54 | apt install -y ${PKGS} ${USER_PKGS} ${WIRELESS} dbus-user-session libical3 resolvconf haveged 55 | fi 56 | if [[ "$DISTRO" == "ubuntu" ]]; then 57 | if [[ "$DISTRO_VERSION" =~ ^(focal|jammy)$ ]]; then RESOLV="resolvconf"; else RESOLV="systemd-resolved"; fi 58 | apt install -y ${PKGS} ${USER_PKGS} ${SYSMODS} ${RESOLV} ${WIRELESS} openssh-client openssh-server 59 | fi 60 | apt -y clean 61 | apt -y autoclean 62 | 63 | if [[ "$DISTRO" == "ubuntu" ]]; then rm -f /etc/resolv.conf; fi 64 | umount /proc 65 | umount /sys 66 | -------------------------------------------------------------------------------- /scripts/rpi-commit: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source lib/function/echoes 3 | source lib/source 4 | validation 5 | if [[ -f "board.txt" ]]; then . board.txt; else noboard; fi 6 | source kernel.txt 7 | source userdata.txt 8 | if [ $VERBOSE -eq 1 ]; then set -x; fi 9 | source packaging/pkgvars 10 | source lib/function/rpi-commit 11 | source lib/function/patching 12 | source lib/function/defconfig 13 | source lib/function/compilers 14 | 15 | # prep 16 | validation 17 | if [[ "$HOST_ARCH" == "aarch64" ]] && [[ "$ARCH" == "arm64" ]]; then CROSSCOMPILE="0"; fi 18 | if [[ "$HOST_ARCH" == "aarch64" ]] && [[ "$ARCH" == "arm" ]]; then CROSSCOMPILE="1"; fi 19 | if [[ "$HOST_ARCH" == "x86_64" ]] && [[ "$ARCH" == "arm" || "$ARCH" == "arm64" ]]; then CROSSCOMPILE="1"; fi 20 | # compiler 21 | linux_compilers 22 | # source directory 23 | source_dir 24 | # commit 25 | if [ $ENABLE_COMMIT -eq 1 ]; then 26 | echo "" 27 | echo -e "${WHT}Using commit: ${FIN}${COMMIT}" 28 | else 29 | echo "" 30 | echo -en "${WHT}Paste commit: ${FIN}" 31 | read COMMIT 32 | fi 33 | 34 | if [[ -e "${CKERNEL}-${COMMIT}" ]]; then 35 | echo "" 36 | echo -en "${WHT}${CKERNEL}-${COMMIT}${FIN}" 37 | echo -en " ${PNK}[${FIN}${YLW}removing${FIN}${PNK}]${FIN}" 38 | rm -fdr ${CKERNEL}-${COMMIT} 39 | echo -en " ${PNK}[${FIN}${GRN}done${FIN}${PNK}]${FIN}" 40 | fi 41 | # download 42 | if [[ `wget -S --spider https://github.com/raspberrypi/linux/archive/${COMMIT}.tar.gz 2>&1 | grep 'HTTP/1.1 200 OK'` ]]; then 43 | download 44 | else 45 | echo "" 46 | echo -e "${WHT}It appears the commit you selected is not available${FIN}?" 47 | exit 0 48 | fi 49 | # extract 50 | extract 51 | # setup and firmware 52 | setup 53 | firmware 54 | # patching and packaging 55 | if [[ -f "Makefile" ]]; then 56 | VER=`cat Makefile | grep -m1 "VERSION" | sed 's/VERSION = //g'` 57 | LVL=`cat Makefile | grep -m1 "PATCHLEVEL" | sed 's/PATCHLEVEL = /./g'` 58 | VERSION="${VER}${LVL}.y" 59 | fi 60 | linux_patching 61 | # defconfig 62 | if [ $CUSTOM_DEFCONFIG -eq 1 ]; then cconfig; else fconfig; fi 63 | # menuconfig 64 | if [ $MENUCONFIG -eq 1 ]; then menuconfig; fi 65 | # builddeb 66 | builddeb 67 | echo "" 68 | # finish 69 | cd .. 70 | rm -f {*linux-image-dbg*.deb,linux-libc-dev*.deb,*.buildinfo,*.changes} 71 | if [[ `ls *linux*.deb` ]] > /dev/null 2>&1; then 72 | if [[ `ls ../${OUTPUT}/*linux*.deb` ]] > /dev/null 2>&1; then 73 | mkdir -p ../${OUTPUT}/tmp 74 | mv -f ../${OUTPUT}/{*linux-image*.deb,*linux-headers*.deb} ../${OUTPUT}/tmp 75 | fi 76 | mkdir -p ../${OUTPUT} 77 | mv -f *.deb ../${OUTPUT}/ 78 | echo_done 79 | exit 0 80 | else 81 | echo "" 82 | echo -e "${CKERNEL}-${COMMIT} [FAILED]" 83 | read -p "Press enter to continue." 84 | exit 1 85 | fi 86 | 87 | exit 0 88 | -------------------------------------------------------------------------------- /scripts/rpi-linux: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source lib/function/echoes 3 | source lib/source 4 | validation 5 | if [[ -f "board.txt" ]]; then . board.txt; else noboard; fi 6 | source kernel.txt 7 | source userdata.txt 8 | if [ $VERBOSE -eq 1 ]; then set -x; fi 9 | source packaging/pkgvars 10 | source lib/function/rpi-linux 11 | source lib/function/patching 12 | source lib/function/defconfig 13 | source lib/function/compilers 14 | source lib/function/wireless 15 | 16 | # prep 17 | validation 18 | if [[ "$HOST_ARCH" == "aarch64" ]] && [[ "$ARCH" == "arm64" ]]; then CROSSCOMPILE="0"; fi 19 | if [[ "$HOST_ARCH" == "aarch64" ]] && [[ "$ARCH" == "arm" ]]; then CROSSCOMPILE="1"; fi 20 | if [[ "$HOST_ARCH" == "x86_64" ]] && [[ "$ARCH" == "arm" || "$ARCH" == "arm64" ]]; then CROSSCOMPILE="1"; fi 21 | # compiler 22 | linux_compilers 23 | # source directory 24 | source_dir 25 | # download 26 | download 27 | extra_wireless 28 | # setup and firmware 29 | setup 30 | firmware 31 | # patching and packaging 32 | linux_patching 33 | # defconfig 34 | if [ $CUSTOM_DEFCONFIG -eq 1 ]; then cconfig; else fconfig; fi 35 | # menuconfig 36 | if [ $MENUCONFIG -eq 1 ]; then menuconfig; fi 37 | # builddeb 38 | builddeb 39 | echo "" 40 | # finish 41 | cd .. 42 | rm -f {*linux-image-dbg*.deb,linux-libc-dev*.deb,*.buildinfo,*.changes} 43 | if [[ `ls *linux*.deb` ]] > /dev/null 2>&1; then 44 | if [[ `ls ../${OUTPUT}/*linux*.deb` ]] > /dev/null 2>&1; then 45 | mkdir -p ../${OUTPUT}/tmp 46 | mv -f ../${OUTPUT}/{*linux-image*.deb,*linux-headers*.deb} ../${OUTPUT}/tmp 47 | fi 48 | mkdir -p ../${OUTPUT} 49 | mv -f *.deb ../${OUTPUT}/ 50 | echo_done 51 | exit 0 52 | else 53 | echo "" 54 | echo -e "${KERNEL} ${VERSION} [FAILED]" 55 | read -p "Press enter to continue." 56 | exit 1 57 | fi 58 | 59 | exit 0 60 | -------------------------------------------------------------------------------- /scripts/stage1: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source lib/function/echoes 3 | source lib/source 4 | validation 5 | source lib/function/release 6 | source custom.txt 7 | source lib/function/staging 8 | source lib/function/shrink 9 | sleep 1 10 | source userdata.txt 11 | if [[ "$USERNAME" == "root" ]]; then 12 | echo -e "The username $USERNAME is not viable, choose another." 13 | echo -e "" 14 | read -p "Press enter to continue." 15 | exit 1 16 | fi 17 | # check user data file 18 | if [ $USERACCT -eq 0 ]; then 19 | # prevent build fail because of white spaces 20 | NAME_FIXUP=`echo ${NAME} | sed "s/ //g"` 21 | if [ -z $NAME_FIXUP ] && [ -z $USERNAME ] && [ -z $PASSWORD ]; then 22 | echo -e "" 23 | echo -e "Name, Username and Password fields are empty?" 24 | echo -e "Enable the user account service or input your" 25 | echo -e "information into the userdata.txt file." 26 | echo -e "" 27 | read -p "Press enter to continue." 28 | exit 1 29 | fi 30 | fi 31 | source lib/function/miscellaneous 32 | source lib/function/rpi-pkgs 33 | # start uscripts 34 | if [ $USCRIPTS -eq 1 ]; then uscripts_pre-stage1; fi 35 | if [[ -f "board.txt" ]]; then . board.txt; else noboard; fi 36 | # clean 37 | if [[ -d "sysroot" ]] || [[ -d "p1" ]] || [[ -d "BOOT" ]] || [[ -f "shrink.img" ]]; then make clean; clear -x; fi 38 | # verbosity 39 | if [ $VERBOSE -eq 1 ]; then set -eux -o pipefail; else set -eu -o pipefail; fi 40 | mirrors 41 | # check output 42 | if [[ -d "output/${BOARD}" ]] && [[ `ls output/${BOARD}/linux-*.deb` ]]; then 43 | :; 44 | else 45 | echo -e "Missing linux deb packages" 46 | exit 1 47 | fi 48 | # check for qemu 49 | if [[ `command -v ${STATIC}` ]]; then 50 | :; 51 | else 52 | echo -e "Missing depends: ${STATIC}" 53 | echo -e "Run ./install.sh" 54 | exit 1 55 | fi 56 | 57 | CAP_DISTRO=`echo "${DISTRO}" | sed -e "s/\b\(.\)/\u\1/g"` 58 | CAP_RELEASE=`echo "${DISTRO_VERSION}" | sed -e "s/\b\(.\)/\u\1/g"` 59 | echo "" 60 | echo -e "${WHT}Board${FIN} ${PNK}[${FIN}${GRN}${BOARD}-${BOARD_EXT}${FIN}${PNK}]${FIN}" 61 | echo -e "${WHT}Distribution${FIN} ${PNK}[${FIN}${GRN}${CAP_DISTRO} ${CAP_RELEASE}${FIN}${PNK}]${FIN}" 62 | RAM=0 63 | PROXY="" 64 | IMAGE_FOLDER="img/" 65 | IMAGE_DATE="$(date +%F)" 66 | IMAGE_FILE_NAME="${BOARD_EXT}-${DISTRO}-${DISTRO_VERSION}-${IMAGE_DATE}.img" 67 | if [ $RAM -ne 0 ]; then IMAGE_FOLDER="ram/"; fi 68 | mkdir -p "$IMAGE_FOLDER" 69 | if [ $RAM -ne 0 ]; then mount -t tmpfs -o size=4G tmpfs $IMAGE_FOLDER; fi 70 | if [ $VERBOSE -eq 1 ]; then partition; uuid; else partition > /dev/null 2>&1; uuid > /dev/null 2>&1; fi 71 | # command line 72 | cmdline > /dev/null 2>&1 73 | if [[ -f "p1/cmdline.txt" ]]; then 74 | :; 75 | else 76 | echo -en "${WHT}cmdline.txt${FIN} " 77 | sleep .50 78 | echo_fail 79 | exit 1 80 | fi 81 | # config dot txt 82 | config_dot_txt > /dev/null 2>&1 83 | if [[ -f "p1/config.txt" ]]; then 84 | :; 85 | else 86 | echo "" 87 | echo -en "${WHT}config.txt${FIN} " 88 | sleep .50 89 | echo_fail 90 | exit 1 91 | fi 92 | if [[ "$ARCH" == "arm" ]]; then sed -i '1d' p1/config.txt; fi 93 | 94 | # extract rootfs 95 | if [[ -f "${DISTRO}-${DISTRO_VERSION}-${ROOTFS_ARCH}.tar.xz" ]]; then 96 | echo -en "${WHT}Extracting rootfs${FIN} " 97 | tar -xf ${DISTRO}-${DISTRO_VERSION}-${ROOTFS_ARCH}.tar.xz -C ${P_VALUE}/ 98 | echo_bdone 99 | else 100 | echo -e "${YLW}Missing rootfs tarball${FIN}!" 101 | make cleanup 102 | exit 1 103 | fi 104 | echo "" 105 | 106 | mkdir -p p2/etc/apt/apt.conf.d p2/etc/dpkg/dpkg.cfg.d 107 | echo "force-unsafe-io" > "p2/etc/dpkg/dpkg.cfg.d/dpkg-unsafe-io" 108 | 109 | # qemu static 110 | mkdir -p p2/usr/bin 111 | cp $(command -v "${STATIC}") p2/usr/bin 112 | 113 | if [[ ! -z $P_VALUE ]]; then ${DISTRO}_sources_list; fi 114 | if [ $VERBOSE -eq 1 ]; then choose_release; fstab; else choose_release > /dev/null 2>&1; fstab > /dev/null 2>&1; fi 115 | 116 | if [ -n "$PROXY" ] ; then 117 | tee "p2/etc/apt/apt.conf.d/30proxy" < /dev/null 2>&1; fi 174 | if [[ "$FSTYPE" == "btrfs" ]]; then btrfs filesystem defragment -f -r ${P_VALUE} > /dev/null 2>&1; fi 175 | if [[ "$FSTYPE" == "xfs" ]]; then xfs_fsr ${P_VALUE} > /dev/null 2>&1; fi 176 | fi 177 | umount p2 178 | umount p1 179 | losetup -d "${IMAGE_LOOP_DEV}" 180 | mv "${IMAGE_FOLDER}${IMAGE_FILE_NAME}" "${IMAGE_FILE_NAME}" 181 | if [ $RAM -ne 0 ]; then umount "${IMAGE_FOLDER}"; fi 182 | rmdir "${IMAGE_FOLDER}" 183 | rmdir p1 p2 184 | 185 | if [[ "$SHRINK" == "true" ]]; then shrink; else echo ""; echo -en "Shrink ${PNK}[${FIN}${WHT}disabled${FIN}${PNK}]${FIN}"; fi 186 | finish_image 187 | rm -f {part-uuid.txt,board.txt,kernel.release} 188 | 189 | exit 0 190 | --------------------------------------------------------------------------------