commit 05d538e677aad995ea659ab41ee92223f7a4574e Author: g-vidal Date: Sun Oct 26 18:06:53 2025 +0100 Initial commit diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d159169 --- /dev/null +++ b/LICENSE @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/README.md b/README.md new file mode 100644 index 0000000..77d4f91 --- /dev/null +++ b/README.md @@ -0,0 +1,404 @@ +# rpi23-gen-image +## Introduction +`rpi23-gen-image.sh` is an advanced Debian Linux bootstrapping shell script for generating Debian OS images for all Raspberry Pi computers. The script at this time supports the bootstrapping of the Debian (armhf/armel) releases `stretch` and `buster`. Raspberry Pi 0/1/2/3/4 images are generated for 32-bit mode only. Raspberry Pi 3 supports 64-bit images that can be generated using custom configuration parameters (```templates/rpi3-stretch-arm64-4.14.y```). + +## Build dependencies +The following list of Debian packages must be installed on the build system because they are essentially required for the bootstrapping process. The script will check if all required packages are installed and missing packages will be installed automatically if confirmed by the user. + + ```debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus sudo``` + +It is recommended to configure the `rpi23-gen-image.sh` script to build and install the latest Raspberry Pi Linux kernel. For the Raspberry 3 this is mandatory. Kernel compilation and linking will be performed on the build system using an ARM (armhf/armel/aarch64) cross-compiler toolchain. + +The script has been tested using the default `crossbuild-essential-armhf` and `crossbuild-essential-armel` toolchain meta packages on Debian Linux `stretch` build systems. Please check the [Debian CrossToolchains Wiki](https://wiki.debian.org/CrossToolchains) for further information. + +## Command-line parameters +The script accepts certain command-line parameters to enable or disable specific OS features, services and configuration settings. These parameters are passed to the `rpi23-gen-image.sh` script via (simple) shell-variables. Unlike environment shell-variables (simple) shell-variables are defined at the beginning of the command-line call of the `rpi23-gen-image.sh` script. + +##### Command-line examples: +```shell +ENABLE_UBOOT=true ./rpi23-gen-image.sh +ENABLE_CONSOLE=false ENABLE_IPV6=false ./rpi23-gen-image.sh +ENABLE_WM=xfce4 ENABLE_FBTURBO=true ENABLE_MINBASE=true ./rpi23-gen-image.sh +ENABLE_HARDNET=true ENABLE_IPTABLES=true /rpi23-gen-image.sh +APT_SERVER=ftp.de.debian.org APT_PROXY="http://127.0.0.1:3142/" ./rpi23-gen-image.sh +ENABLE_MINBASE=true ./rpi23-gen-image.sh +BUILD_KERNEL=true ENABLE_MINBASE=true ENABLE_IPV6=false ./rpi23-gen-image.sh +BUILD_KERNEL=true KERNELSRC_DIR=/tmp/linux ./rpi23-gen-image.sh +ENABLE_MINBASE=true ENABLE_REDUCE=true ENABLE_MINGPU=true BUILD_KERNEL=true ./rpi23-gen-image.sh +ENABLE_CRYPTFS=true CRYPTFS_PASSWORD=changeme EXPANDROOT=false ENABLE_MINBASE=true ENABLE_REDUCE=true ENABLE_MINGPU=true BUILD_KERNEL=true ./rpi23-gen-image.sh +RELEASE=buster BUILD_KERNEL=true ./rpi23-gen-image.sh +RPI_MODEL=3 ENABLE_WIRELESS=true ENABLE_MINBASE=true BUILD_KERNEL=true ./rpi23-gen-image.sh +RELEASE=buster RPI_MODEL=3 ENABLE_WIRELESS=true ENABLE_MINBASE=true BUILD_KERNEL=true ./rpi23-gen-image.sh +``` + +## Configuration template files +To avoid long lists of command-line parameters and to help to store the favourite parameter configurations the `rpi23-gen-image.sh` script supports so called configuration template files (`CONFIG_TEMPLATE`=template). These are simple text files located in the `./templates` directory that contain the list of configuration parameters that will be used. New configuration template files can be added to the `./templates` directory. + +##### Command-line examples: +```shell +CONFIG_TEMPLATE=rpi3stretch ./rpi23-gen-image.sh +CONFIG_TEMPLATE=rpi2stretch ./rpi23-gen-image.sh +``` + +## Working with the your template: + * **A Pipe ("|") represents a logical OR** + * **A valuetype of boolean represents the options true or false** + * **Values without a default are required if you want do use that feature. It is possible that not every feature has a (working) sanity check.** + * **If it's not working as expected, search your option in all the files in this repository (With e.g.grep or notepad++).** + * **Check if your missing a required option while looking at the code** + +## Supported parameters and settings + +#### APT settings: +|Option|Value|default value|value format|desciption| +|---|---|---|---|---| +|APT_SERVER|string|ftp.debian.org|`URL`|Set Debian packages server address. Choose a server from the list of Debian worldwide [mirror sites](https://www.debian.org/mirror/list). Using a nearby server will probably speed-up all required downloads within the bootstrapping process.| +|APT_PROXY|string||`URL`|Set Proxy server address. Using a local Proxy-Cache like `apt-cacher-ng` will speed-up the bootstrapping process because all required Debian packages will only be downloaded from the Debian mirror site once. If `apt-cacher-ng` is running on default `http://127.0.0.1:3142` it is autodetected and you don't need to set this.| +|KEEP_APT_PROXY|boolean|false|`true`\|`false`|true=Keep the APT_PROXY settings used in the bootsrapping process in the generated image| +|APT_INCLUDES|string list||`packageA`,`packageB`,...|A comma-separated list of additional packages to be installed by debootstrap during bootstrapping.| +|APT_INCLUDES_LATE|string list||`packageA`,`packageB`,...|A comma-separated list of additional packages to be installed by apt after bootstrapping and after APT sources are set up. This is useful for packages with pre-depends, which debootstrap do not handle well.| +|APT_EXCLUDES|string list||`packageA`,`packageB`,...|A comma-separated list of packages to exclude. Use carefully| +--- + +#### General system settings: +|Option|Value|default value|value format|desciption| +|---|---|---|---|---| +|SET_ARCH|integer|32|`32`\|`64`|Set Architecture to default 32bit. If you want to compile 64-bit (RPI3/RPI3+/RPI4) set it to `64`. This option will set every needed cross-compiler or board specific option for a successful build.| +|RPI_MODEL|string|3P|`0`\|`1`\|`1P`\|`2`\|`3`\|`3P`\|`4`|Set Architecture. This option will set most build options accordingly. Specify the target Raspberry Pi hardware model.| +|RELEASE|string|buster|`jessie`\|`buster`\|`stretch`
\|`bullseye`\|`testing`\|`stable`
\|`oldstable`|Set the desired Debian release name. The script at this time supports the bootstrapping of the Debian releases `stretch` and `buster`.| +|HOSTNAME|string|RPI_MODEL-RELEASE(e.g. RPI3-buster)|`SomeImageName.img`|Set system hostname. It's recommended that the hostname is unique in the corresponding subnet.| +|DEFLOCAL|string|en_US.UTF-8|`Locale.Charset`|Set default system locale. This setting can also be changed inside the running OS using the `dpkg-reconfigure locales` command. Please note that on using this parameter the script will automatically install the required packages `locales`, `keyboard-configuration` and `console-setup`.| +|TIMEZONE|string|Europe/Berlin|`Timezone`|Set default system timezone. All available timezones can be found in the `/usr/share/zoneinfo/` directory. This setting can also be changed inside the running OS using the `dpkg-reconfigure tzdata` command.| +|EXPANDROOT|boolean|true|`true`\|`false`|true=Expand the root partition and filesystem automatically on first boot| + +--- + +#### User settings: +|Option|Value|default value|desciption| +|---|---|---|---| +|ENABLE_ROOT|boolean|false|true=root login if ROOT_PASSWORD is set| +|ROOT_PASSWORD|string|raspberry|Set password for `root` user. It's **STRONGLY** recommended that you choose a custom password.| +|ENABLE_USER|boolean|true|true=Create non-root user with password `USER_PASSWORD` and username `USER_NAME`| +|USER_NAME|string|pi|Set username for non-root user, if `ENABLE_USER` is true| +|USER_PASSWORD|string|raspberry|Set password for non-root user, if `ENABLE_USER` is true. It's **STRONGLY** recommended that you choose a custom password.| + +--- + +#### Keyboard settings: + +These options are used to configure keyboard layout in `/etc/default/keyboard` for console and Xorg. These settings can also be changed inside the running OS using the `dpkg-reconfigure keyboard-configuration` command. + +|Option|Value|default value|value format|desciption| +|---|---|---|---|---| +|XKB_MODEL|string||`pc104`|Set the name of the model of your keyboard type| +|XKB_LAYOUT|string||`us`|Set the supported keyboard layout(s)| +|XKB_VARIANT|string||`basic`|Set the supported variant(s) of the keyboard layout(s)| +|XKB_OPTIONS|string||`grp:alt_shift_toggle`|Set extra xkb configuration options| + +--- + +#### Networking settings: +ethernet setting go to `/etc/systemd/network/eth0.network`. +wifi settings go to `/etc/systemd/network/wlan0.network`. + +The default location of network configuration files in the Debian `stretch` release was changed to `/lib/systemd/network`.` + +|Option|Value|default value|desciption| +|---|---|---|---| +|ENABLE_IPV6|boolean|true|true=Enable IPv6 support via systemd-networkd| +|ENABLE_WIRELESS|boolean|false|true=Download and install the [closed-source firmware binary blob](https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm) that is required to run the internal wireless interface of the Raspberry Pi model `3`. This parameter is ignored if the specified `RPI_MODEL` is not `0`,`3`,`3P`,`4`| +|ENABLE_IPTABLES|boolean|false|true=Enable iptables IPv4/IPv6 firewall. Simplified ruleset: Allow all outgoing connections. Block all incoming connections except to OpenSSH service.| +|ENABLE_HARDNET|boolean|false|true=Enable IPv4/IPv6 network stack hardening settings| +|ENABLE_IFNAMES|boolean|true|true=creates complex and long interface names like e.g. encx8945924. Enable automatic assignment of predictable, stable network interface names for all NICs| + +--- + +#### Networking settings (DHCP): + + +|Option|Value|default value|desciption| +|---|---|---|---| +|ENABLE_ETH_DHCP|boolean|true|Set the system to use DHCP on wired interface. This requires an DHCP server| +|ENABLE_WIFI_DHCP|boolean|true|Set the system to use DHCP on wifi interface. This requires an DHCP server. Requires ENABLE_WIRELESS| + +--- + +#### Networking settings (ethernet static): +The following static networking parameters are only supported if `ENABLE_ETH_DHCP` was set to `false`. + +|Option|Value|value format|desciption| +|---|---|---|---| +|NET_ETH_ADDRESS|string|`CIDR`|static IPv4 or IPv6 address and its prefix, separated by "/", eg. "192.169.0.3/24"| +|NET_ETH_GATEWAY|string|`IP`|default gateway| +|NET_ETH_DNS_1|string|`IP`|first DNS server| +|NET_ETH_DNS_2|string|`IP`|second DNS server| +|NET_ETH_DNS_DOMAINS|string|`example.local`|default DNS search domains to use for non fully qualified hostnames| +|NET_ETH_NTP_1|string|`IP`|first NTP server| +|NET_ETH_NTP_2|string|`IP`|second NTP server| + +--- + +#### Networking settings (WIFI): + +|Option|Value|value format|desciption| +|---|---|---|---| +|NET_WIFI_SSID|string|`yourwifiname`|WIFI SSID| +|NET_WIFI_PSK|string|`yourwifikeytojoinnetwork`|WPA/WPA2 PSK| + +--- + +#### Networking settings (WIFI static): +The following static networking parameters are only supported if `ENABLE_WIFI_DHCP` was set to `false`. + +|Option|Value|value format|desciption| +|---|---|---|---| +|NET_WIFI_ADDRESS|string|`CIDR`|static IPv4 or IPv6 address and its prefix, separated by "/", eg. "192.169.0.3/24"| +|NET_WIFI_GATEWAY|string|`IP`|default gateway| +|NET_WIFI_DNS_1|string|`IP`|first DNS server| +|NET_WIFI_DNS_2|string|`IP`|second DNS server| +|NET_WIFI_DNS_DOMAINS|string|`example.local`|default DNS search domains to use for non fully qualified hostnames| +|NET_WIFI_NTP_1|string|`IP`|first NTP server| +|NET_WIFI_NTP_2|string|`IP`|second NTP server| + +--- + +#### Basic system features: + +|Option|Value|default value|value format|desciption| +|---|---|---|---|---| +|ENABLE_CONSOLE|boolean|false|`true`\|`false`|true=Enable serial console interface.Recommended if no monitor or keyboard is connected to the RPi2/3. In case of problems fe. if the network (auto) configuration failed - the serial console can be used to access the system. On RPI `0` `3` `3P` the CPU speed is locked at lowest speed.| +|ENABLE_PRINTK|boolean|false|`true`\|`false`|true=Enables printing kernel messages to konsole. printk is `3 4 1 3` as in raspbian| +|ENABLE_BLUETOOTH|boolean|false|`true`\|`false`|true=Enable onboard Bluetooth interface on the RPi0/3/3P. See: [Configuring the GPIO serial port on Raspbian jessie and stretch](https://spellfoundry.com/2016/05/29/configuring-gpio-serial-port-raspbian-jessie-including-pi-3/)| +|ENABLE_MINIUART_OVERLAY|boolean|false|`true`\|`false`|true=Enable Bluetooth to use this. Adds overlay to swap UART0 with UART1. Enabling (slower) Bluetooth and full speed serial console. - RPI `0` `3` `3P` have a fast `hardware UART0` (ttyAMA0) and a `mini UART1` (ttyS0)! RPI `1` `1P` `2` only have a `hardware UART0`. `UART0` is considered better, because is faster and more stable than `mini UART1`. By default the Bluetooth modem is mapped to the `hardware UART0` and `mini UART` is used for console. The `mini UART` is a problem for the serial console, because its baudrate depends on the CPU frequency, which is changing on runtime. Resulting in a volatile baudrate and thus in an unusable serial console.| +|ENABLE_TURBO|boolean|false|`true`\|`false`|true=Enable Turbo mode. This setting locks cpu at the highest frequency. As setting ENABLE_CONSOLE=true locks RPI to lowest CPU speed, this is can be used additionally to lock cpu hat max speed. Need a good power supply and probably cooling for the Raspberry PI| +|ENABLE_I2C|boolean|true|`true`\|`false`|true=Enable I2C interface on the RPi 0/1/2/3. Please check the [RPi 0/1/2/3 pinout diagrams](https://elinux.org/RPi_Low-level_peripherals) to connect the right GPIO pins| +|ENABLE_SPI|boolean|true|`true`\|`false`|true=Enable SPI interface on the RPi 0/1/2/3. Please check the [RPi 0/1/2/3 pinout diagrams](https://elinux.org/RPi_Low-level_peripherals) to connect the right GPIO pins| +|SSH_ENABLE|boolean|true|`true`\|`false`|Install and enable OpenSSH service. The default configuration of the service doesn't allow `root` to login. Please use the user `pi` instead and `su -` or `sudo` to execute commands as root| +|ENABLE_NONFREE|boolean|false|`true`\|`false`|true=enable non-free\|false=disable non free. Edits /etc/apt/sources.list in your resulting image| +|ENABLE_RSYSLOG|boolean|false|`true`\|`false`|true=keep rsyslog\|false=remove rsyslog. If rsyslog is removed (false), logs will be available only in journal files)| +|ENABLE_SOUND|boolean|false|`true`\|`false`|true=Enable sound\|false=Disable sound| +|ENABLE_HWRANDOM|boolean|true|`true`\|`false`|true=Enable Hardware Random Number Generator(RNG)\|false=Disable Hardware RNG\|Strong random numbers are important for most network-based communications that use encryption. It's recommended to be enabled| +|ENABLE_MINGPU|boolean|false|`true`\|`false`|true=GPU 16MB RAM\|false=64MB RAM\|Minimize the amount of shared memory reserved for the GPU. It doesn't seem to be possible to fully disable the GPU. Also removes start.elf,fixup.dat,start_x.elf,fixup_x.dat form /boot| +|ENABLE_XORG|boolean|false|`true`\|`false`|true=Install Xorg X Window System|\false=install no Xorg| +|ENABLE_WM|string||`blackbox`, `openbox`, `fluxbox`,
`jwm`, `dwm`, `xfce4`, `awesome`|Install a user-defined window manager for the X Window System. To make sure all X related package dependencies are getting installed `ENABLE_XORG` will automatically set true if `ENABLE_WM` is used| +|ENABLE_SYSVINIT|boolean|false|`true`\|`false`|true=Support for halt,init,poweroff,reboot,runlevel,shutdown,init commands\|false=use systemd commands| +|ENABLE_SPLASH|boolean|true|`true`\|`false`|true=Enable default Raspberry Pi boot up rainbow splash screen| +|ENABLE_LOGO|boolean|true|`true`\|`false`|true=Enable default Raspberry Pi console logo (image of four raspberries in the top left corner)| +|ENABLE_SILENT_BOOT|boolean|false|`true`\|`false`|true=Set the verbosity of console messages shown during boot up to a strict minimum| +|DISABLE_UNDERVOLT_WARNINGS|integer||`1`\|`2`|Unset to keep default behaviour. Setting the parameter to `1` will disable the warning overlay. Setting it to `2` will additionally allow RPi2/3 turbo mode when low-voltage is present| + +--- + +#### Advanced system features: + +|Option|Value|default value|value format|desciption| +|---|---|---|---|---| +|ENABLE_DPHYSSWAP|boolean|true|`true`\|`false`|Enable swap. The size of the swapfile is chosen relative to the size of the root partition. It'll use the `dphys-swapfile` package for that| +|ENABLE_SYSTEMDSWAP|boolean|false|`true`\|`false`|Enables [Systemd-swap service](https://github.com/Nefelim4ag/systemd-swap). Usefull if `KERNEL_ZSWAP` is enabled| +|ENABLE_QEMU|boolean|false|`true`\|`false`|Generate kernel (`vexpress_defconfig`), file system image (`qcow2`) and DTB files that can be used for QEMU full system emulation (`vexpress-A15`). The output files are stored in the `$(pwd)/images/qemu` directory. You can find more information about running the generated image in the QEMU section of this readme file| +|QEMU_BINARY|string||`FullPathToQemuBinaryFile`|Sets the QEMU enviornment for the Debian archive. **Set by RPI_MODEL**| +|ENABLE_KEYGEN|boolean|false|`true`\|`false`|Recover your lost codec license| +|ENABLE_MINBASE|boolean|false|`true`\|`false`|Use debootstrap script variant `minbase` which only includes essential packages and apt. This will reduce the disk usage by about 65 MB| +|ENABLE_SPLITFS|boolean|false|`true`\|`false`|Enable having root partition on an USB drive by creating two image files: one for the `/boot/firmware` mount point, and another for `/`| +|ENABLE_INITRAMFS|boolean|false|`true`\|`false`|Create an initramfs that that will be loaded during the Linux startup process. `ENABLE_INITRAMFS` will automatically get enabled if `ENABLE_CRYPTFS`=true. This parameter will be ignored if `BUILD_KERNEL`=false| +|ENABLE_DBUS|boolean|true|`true`\|`false`|Install and enable D-Bus message bus. Please note that systemd should work without D-bus but it's recommended to be enabled| +|ENABLE_USBBOOT|boolean|false|`true`\|`false`|true=prepare image for usbboot. use with `ENABLE_SPLTFS`=true| +|CHROOT_SCRIPTS|string||`FullPathToScriptFolder`|Full path to a directory with scripts that should be run in the chroot before the image is finally built. Every executable file in this directory is run in lexicographical order| +|ENABLE_UBOOT|boolean|false|`true`\|`false`|Replace the default RPi 0/1/2/3 second stage bootloader (bootcode.bin) with [U-Boot bootloader](https://git.denx.de/?p=u-boot.git;a=summary). U-Boot can boot images via the network using the BOOTP/TFTP protocol. RPI4 needs tbd| +|UBOOTSRC_DIR|string||`FullPathToUBootFolder`|Full path to a directory named `u-boot` of [U-Boot bootloader sources](https://git.denx.de/?p=u-boot.git;a=summary) that will be copied, configured, build and installed inside the chroot| +|ENABLE_FBTURBO|boolean|false|`true`\|`false`|Install and enable the [hardware accelerated Xorg video driver](https://github.com/ssvb/xf86-video-fbturbo) `fbturbo`. Please note that this driver is currently limited to hardware accelerated window moving and scrolling| +|ENABLE_GR_ACCEL|boolean|false|`true`\|`false`|Install and enable [one of the 3D graphics accelerators for Raspi4](https://www.raspberrypi.org/documentation/configuration/config-txt/video.md) `vc4-fkms-v3d`. Not compatible with `fbturbo` mutually excluded and installed for Raspberry4 only| +|FBTURBOSRC_DIR|string||`FullPathToFbTurboFolder`|Full path to a directory named `xf86-video-fbturbo` of [hardware accelerated Xorg video driver sources](https://github.com/ssvb/xf86-video-fbturbo) that will be copied, configured, build and installed inside the chroot| +|ENABLE_VIDEOCORE|boolean|false|`true`\|`false`|Install and enable the [ARM side libraries for interfacing to Raspberry Pi GPU](https://github.com/raspberrypi/userland) `vcgencmd`. Please note that this driver is currently limited to hardware accelerated window moving and scrolling| +|VIDEOCORESRC_DIR|string||`FullPathToVideoSrcFolder`|Full path to a directory named `userland` of [ARM side libraries for interfacing to Raspberry Pi GPU](https://github.com/raspberrypi/userland) that will be copied, configured, build and installed inside the chroot| +|ENABLE_NEXMON|boolean|false|`true`\|`false`|Install and enable the source code for a C-based firmware patching framework for Broadcom/Cypress WiFi chips that enables you to write your own firmware patches, for example, to enable monitor mode with radiotap headers and frame injection](https://github.com/seemoo-lab/nexmon.git)| +|NEXMONSRC_DIR|string||`FullPathToNexmonFolder`|Full path to a directory named `nexmon` of [Source code for ARM side libraries for interfacing to Raspberry Pi GPU](https://github.com/raspberrypi/userland) that will be copied, configured, build and installed inside the chroot| + +--- + +#### SSH settings: + +|Option|Value|default value|value format|desciption| +|---|---|---|---|---| +|SSH_ENABLE_ROOT|boolean|false|`true`\|`false`|Enable password-based root login via SSH. This may be a security risk with the default password set, use only in trusted environments. `ENABLE_ROOT` must be set to `true`| +|SSH_DISABLE_PASSWORD_AUTH|boolean|false|`true`\|`false`|Disable password-based SSH authentication. Only public key based SSH (v2) authentication will be supported| +|SSH_LIMIT_USERS|boolean|false|`true`\|`false`|Limit the users that are allowed to login via SSH. Only allow user `USER_NAME`=pi and root if `SSH_ENABLE_ROOT`=true to login. This parameter will be ignored if `dropbear` SSH is used (`REDUCE_SSHD`=true)| +|SSH_ROOT_PUB_KEY|string||`PathToYourROOT`
`RSAPublicKeyFile`|Full path to file. Add SSH (v2) public key(s) from specified file to `authorized_keys` file to enable public key based SSH (v2) authentication of user `root`. The specified file can also contain multiple SSH (v2) public keys. SSH protocol version 1 is not supported. `ENABLE_ROOT` **and** `SSH_ENABLE_ROOT` must be set to `true`| +|SSH_USER_PUB_KEY|string||`PathToYourUSER`
`RSAPublicKeyFile`|Full path to file. Add SSH (v2) public key(s) from specified file to `authorized_keys` file to enable public key based SSH (v2) authentication of user `USER_NAME`=pi. The specified file can also contain multiple SSH (v2) public keys. SSH protocol version 1 is not supported| + +--- + +#### Kernel settings: + +|Option|Value|default value|value format|desciption| +|---|---|---|---|---| +|BUILD_KERNEL||true|`true`\|`false`|Build and install the latest RPi 0/1/2/3/4 Linux kernel. The default RPi 0/1/2/3/ kernel configuration is used most of the time. ENABLE_NEXMON - Changes Kernel Source to [https://github.com/Re4son/](Kali Linux Kernel) Precompiled 32bit kernel for RPI0/1/2/3 by [https://github.com/hypriot/](hypriot) Precompiled 64bit kernel for RPI3/4 by [https://github.com/sakaki-/](sakaki)| +|CROSS_COMPILE|string|||This sets the cross-compile environment for the compiler. Set by RPI_MODEL| +|KERNEL_ARCH|string|||This sets the kernel architecture for the compiler. Set by RPI_MODEL| +|KERNEL_IMAGE|string|||Name of the image file in the boot partition. Set by RPI_MODEL| +|KERNEL_BRANCH|string|||Name of the requested branch from the GIT location for the RPi Kernel. Default is using the current default branch from the GIT site| +|KERNEL_DEFCONFIG|string|||Sets the default config for kernel compiling. Set by RPI_MODEL| +|KERNEL_THREADS|integer|1|`1`\|`2`\|`3`\|...|Number of threads to build the kernel. If not set, the script will automatically determine the maximum number of CPU cores to speed up kernel compilation| +|KERNEL_HEADERS|boolean|true|`true`\|`false`|Install kernel headers with the built kernel| +|KERNEL_MENUCONFIG|boolean|false|`true`\|`false`|Start `make menuconfig` interactive menu-driven kernel configuration. The script will continue after `make menuconfig` was terminated| +|KERNEL_OLDDEFCONFIG|boolean|false|`true`\|`false`|Run `make olddefconfig` to automatically set all new kernel configuration options to their recommended default values| +|KERNEL_CCACHE|boolean|false|`true`\|`false`|Compile the kernel using ccache. This speeds up kernel recompilation by caching previous compilations and detecting when the same compilation is being done again| +|KERNEL_REMOVESRC|boolean|true|`true`\|`false`|Remove all kernel sources from the generated OS image after it was built and installed| +|KERNELSRC_DIR|string||`FullPathToKernelSrcDir`|Full path to a directory named `linux` of [RaspberryPi Linux kernel sources](https://github.com/raspberrypi/linux) that will be copied, configured, build and installed inside the chroot| +|KERNELSRC_CLEAN|boolean|false|`true`\|`false`|Clean the existing kernel sources directory `KERNELSRC_DIR` (using `make mrproper`) after it was copied to the chroot and before the compilation of the kernel has started. This parameter will be ignored if no `KERNELSRC_DIR` was specified or if `KERNELSRC_PREBUILT`=true| +|KERNELSRC_CONFIG|boolean|true|`true`\|`false`|true=enable custom kernel options. This parameter is automatically set to `true` if no existing kernel sources directory was specified using `KERNELSRC_DIR`. This parameter is ignored if `KERNELSRC_PREBUILT`=true| +|KERNELSRC_USRCONFIG|string||`FullPathToUserKernel.config`|Copy own config file to kernel `.config`. If `KERNEL_MENUCONFIG`=true then running after copy| +|KERNELSRC_PREBUILT|boolean|false|`true`\|`false`|With this parameter set to true the script expects the existing kernel sources directory to be already successfully cross-compiled. The parameters `KERNELSRC_CLEAN`, `KERNELSRC_CONFIG`, `KERNELSRC_USRCONFIG` and `KERNEL_MENUCONFIG` are ignored and no kernel compilation tasks are performed| +|RPI_FIRMWARE_DIR|string||`FullPathToFolder`|Full path to a directory named `firmware`, containing a local copy of the firmware from the [RaspberryPi firmware project](https://github.com/raspberrypi/firmware). Default is to download the latest firmware directly from the project| +|KERNEL_DEFAULT_GOV|string|ondemand|`performance`\|`powersave`
\|`userspace`\|`ondemand`
\|`conservative`\|`schedutil`|Set the default cpu governor at kernel compilation| +|KERNEL_NF|boolean|false|`true`\|`false`|Enable Netfilter modules as kernel modules. You want that for iptables| +|KERNEL_VIRT|boolean|false|`true`\|`false`|Enable Kernel KVM support (/dev/kvm)| +|KERNEL_ZSWAP|boolean|false|`true`\|`false`|Enable Kernel Zswap support. Best use on high RAM load and mediocre CPU load usecases| +|KERNEL_BPF|boolean|true|`true`\|`false`|Allow attaching eBPF programs to a cgroup using the bpf syscall (CONFIG_BPF_SYSCALL CONFIG_CGROUP_BPF) [systemd wants it - File /lib/systemd/system/systemd-journald.server:36 configures an IP firewall (IPAddressDeny=all), but the local system does not support BPF/cgroup based firewalls]| +|KERNEL_SECURITY|boolean|false|`true`\|`false`|Enables Apparmor, integrity subsystem, auditing| +|KERNEL_BTRFS|boolean|false|`true`\|`false`|enable btrfs kernel support| +|KERNEL_POEHAT|boolean|false|`true`\|`false`|enable Enable RPI POE HAT fan kernel support| +|KERNEL_NSPAWN|boolean|false|`true`\|`false`|Enable per-interface network priority control - for systemd-nspawn| +|KERNEL_DHKEY|boolean|true|`true`\|`false`|Diffie-Hellman operations on retained keys - required for >keyutils-1.6| + +--- + +#### Reduce disk usage: +The following list of parameters is ignored if `ENABLE_REDUCE`=false. + +|Option|Value|default value|value format|desciption| +|---|---|---|---|---| +|ENABLE_REDUCE|boolean|false|`true`\|`false`|Reduce the disk space usage by deleting packages and files. See `REDUCE_*` parameters for detailed information| +|REDUCE_APT|boolean|true|`true`\|`false`|Configure APT to use compressed package repository lists and no package caching files| +|REDUCE_DOC|boolean|false|`true`\|`false`|Remove all doc files (harsh). Configure APT to not include doc files on future `apt-get` package installations| +|REDUCE_MAN|boolean|false|`true`\|`false`|Remove all man pages and info files (harsh). Configure APT to not include man pages on future `apt-get` package installations| +|REDUCE_VIM|boolean|false|`true`\|`false`|Replace `vim-tiny` package by `levee` a tiny vim clone| +|REDUCE_BASH|boolean|false|`true`\|`false`|Remove `bash` package and switch to `dash` shell (experimental)| +|REDUCE_HWDB|boolean|false|`true`\|`false`|Remove PCI related hwdb files (experimental)| +|REDUCE_SSHD|boolean|false|`true`\|`false`|Replace `openssh-server` with `dropbear`| +|REDUCE_LOCALE|boolean|false|`true`\|`false`|Remove all `locale` translation files| +|REDUCE_KERNEL|boolean|false|`true`\|`false`|Reduce the size of the generated kernel by removing unwanted devices, network and filesystem drivers (experimental)| +--- + +#### Encrypted root partition: +#### On first boot, you will be asked to enter you password several time +#### See cryptsetup options for a more information about opttion values(https://wiki.archlinux.org/index.php/Dm-crypt/Device_encryption) + +|Option|Value|default value|value format|desciption| +|---|---|---|---|---| +|ENABLE_CRYPTFS|boolean|false|`true`\|`false`|Enable full system encryption with dm-crypt. Setup a fully LUKS encrypted root partition (aes-xts-plain64:sha512) and generate required initramfs. The /boot directory will not be encrypted. This parameter will be ignored if `BUILD_KERNEL`=false. `ENABLE_CRYPTFS` is experimental| +|CRYPTFS_PASSWORD|string||`YourPasswordToUnlockCrypto`|Set password of the encrypted root partition. This parameter is mandatory if `ENABLE_CRYPTFS`=true| +|CRYPTFS_MAPPING|string|secure|`YourDevMNapperName`|crypsetup device-mapper name| +|CRYPTFS_CIPHER|string|aes-xts-plain64|`aes-cbc-essiv:sha256`|cryptsetup cipher `aes-xts*` ciphers are strongly recommended| +|CRYPTFS_HASH|string|sha256|`sha256`\|`sha512`|cryptsetup hash algorithm| +|CRYPTFS_XTSKEYSIZE|integer|256|`256`\|`512`||Sets key size in bits. The argument has to be a multiple of 8| +|CRYPTFS_DROPBEAR|boolean|false|`true`\|`false`|true=Enable Dropbear Initramfs support\|false=disable dropbear| +|CRYPTFS_DROPBEAR_PUBKEY|string||`PathToYourPublicDropbearKeyFile`|Full path to dropbear Public RSA-OpenSSH Key| + +--- + +#### Build settings: +|Option|Value|default value|value format|desciption| +|---|---|---|---|---| +|BASEDIR|string||`FullPathToScriptRootDir`|If unset start from scriptroot or set to Full path to rpi123-gen-image directory| +|IMAGE_NAME|string||`YourImageName`|if unset creates a name after this template: rpi`RPI_MODEL`-`RELEASE`-`RELEASE_ARCH`| + +--- + +## Understanding the script +The functions of this script that are required for the different stages of the bootstrapping are split up into single files located inside the `bootstrap.d` directory. During the bootstrapping every script in this directory gets executed in lexicographical order: + +| Script | Description | +| --- | --- | +| `10-bootstrap.sh` | Debootstrap basic system | +| `11-apt.sh` | Setup APT repositories | +| `12-locale.sh` | Setup Locales and keyboard settings | +| `13-kernel.sh` | Build and install RPi 0/1/2/3 Kernel | +| `14-fstab.sh` | Setup fstab and initramfs | +| `15-rpi-config.sh` | Setup RPi 0/1/2/3 config and cmdline | +| `20-networking.sh` | Setup Networking | +| `21-firewall.sh` | Setup Firewall | +| `30-security.sh` | Setup Users and Security settings | +| `31-logging.sh` | Setup Logging | +| `32-sshd.sh` | Setup SSH and public keys | +| `41-uboot.sh` | Build and Setup U-Boot | +| `42-fbturbo.sh` | Build and Setup fbturbo Xorg driver | +| `43-videocore.sh` | Build and Setup videocore libraries | +| `50-firstboot.sh` | First boot actions | +| `99-reduce.sh` | Reduce the disk space usage | + +All the required configuration files that will be copied to the generated OS image are located inside the `files` directory. It is not recommended to modify these configuration files manually. + +| Directory | Description | +| --- | --- | +| `apt` | APT management configuration files | +| `boot` | Boot and RPi 0/1/2/3 configuration files | +| `dpkg` | Package Manager configuration | +| `etc` | Configuration files and rc scripts | +| `firstboot` | Scripts that get executed on first boot | +| `initramfs` | Initramfs scripts | +| `iptables` | Firewall configuration files | +| `locales` | Locales configuration | +| `modules` | Kernel Modules configuration | +| `mount` | Fstab configuration | +| `network` | Networking configuration files | +| `sysctl.d` | Swapping and Network Hardening configuration | +| `xorg` | fbturbo Xorg driver configuration | + +## Custom packages and scripts +Debian custom packages, i.e. those not in the debian repositories, can be installed by placing them in the `packages` directory. They are installed immediately after packages from the repositories are installed. Any dependencies listed in the custom packages will be downloaded automatically from the repositories. Do not list these custom packages in `APT_INCLUDES`. + +Scripts in the custom.d directory will be executed after all other installation is complete but before the image is created. + +## Logging of the bootstrapping process +All information related to the bootstrapping process and the commands executed by the `rpi23-gen-image.sh` script can easily be saved into a logfile. The common shell command `script` can be used for this purpose: + +```shell +script -c 'APT_SERVER=ftp.de.debian.org ./rpi23-gen-image.sh' ./build.log +``` + +## Flashing the image file +After the image file was successfully created by the `rpi23-gen-image.sh` script it can be copied to the microSD card that will be used by the RPi 0/1/2/3 computer. This can be performed by using the tools `bmaptool` or `dd`. Using `bmaptool` will probably speed-up the copy process because `bmaptool` copies more wisely than `dd`. + +##### Flashing examples: +```shell +bmaptool copy ./images/buster/2017-01-23-rpi3-buster.img /dev/mmcblk0 +dd bs=4M if=./images/buster/2017-01-23-rpi3-buster.img of=/dev/mmcblk0 +``` +If you have set `ENABLE_SPLITFS`, copy the `-frmw` image on the microSD card, then the `-root` one on the USB drive: +```shell +bmaptool copy ./images/buster/2017-01-23-rpi3-buster-frmw.img /dev/mmcblk0 +bmaptool copy ./images/buster/2017-01-23-rpi3-buster-root.img /dev/sdc +``` + +## QEMU emulation +Start QEMU full system emulation: +```shell +qemu-system-arm -m 2048M -M vexpress-a15 -cpu cortex-a15 -kernel kernel7.img -no-reboot -dtb vexpress-v2p-ca15_a7.dtb -sd ${IMAGE_NAME}.qcow2 -append "root=/dev/mmcblk0p2 rw rootfstype=ext4 console=tty1" +``` + +Start QEMU full system emulation and output to console: +```shell +qemu-system-arm -m 2048M -M vexpress-a15 -cpu cortex-a15 -kernel kernel7.img -no-reboot -dtb vexpress-v2p-ca15_a7.dtb -sd ${IMAGE_NAME}.qcow2 -append "root=/dev/mmcblk0p2 rw rootfstype=ext4 console=ttyAMA0,115200 init=/bin/systemd" -serial stdio +``` + +Start QEMU full system emulation with SMP and output to console: +```shell +qemu-system-arm -m 2048M -M vexpress-a15 -cpu cortex-a15 -smp cpus=2,maxcpus=2 -kernel kernel7.img -no-reboot -dtb vexpress-v2p-ca15_a7.dtb -sd ${IMAGE_NAME}.qcow2 -append "root=/dev/mmcblk0p2 rw rootfstype=ext4 console=ttyAMA0,115200 init=/bin/systemd" -serial stdio +``` + +Start QEMU full system emulation with cryptfs, initramfs and output to console: +```shell +qemu-system-arm -m 2048M -M vexpress-a15 -cpu cortex-a15 -kernel kernel7.img -no-reboot -dtb vexpress-v2p-ca15_a7.dtb -sd ${IMAGE_NAME}.qcow2 -initrd "initramfs-${KERNEL_VERSION}" -append "root=/dev/mapper/secure cryptdevice=/dev/mmcblk0p2:secure rw rootfstype=ext4 console=ttyAMA0,115200 init=/bin/systemd" -serial stdio +``` + +## External links and references +* [Debian worldwide mirror sites](https://www.debian.org/mirror/list) +* [Debian Raspberry Pi 2 Wiki](https://wiki.debian.org/RaspberryPi2) +* [Debian CrossToolchains Wiki](https://wiki.debian.org/CrossToolchains) +* [Official Raspberry Pi Firmware on github](https://github.com/raspberrypi/firmware) +* [Official Raspberry Pi Kernel on github](https://github.com/raspberrypi/linux) +* [U-BOOT git repository](https://git.denx.de/?p=u-boot.git;a=summary) +* [Xorg DDX driver fbturbo](https://github.com/ssvb/xf86-video-fbturbo) +* [RPi3 Wireless interface firmware](https://github.com/RPi-Distro/firmware-nonfree/tree/master/brcm) +* [Collabora RPi2 Kernel precompiled](https://repositories.collabora.co.uk/debian/) diff --git a/bootstrap.d/10-bootstrap.sh b/bootstrap.d/10-bootstrap.sh new file mode 100644 index 0000000..9e39b5d --- /dev/null +++ b/bootstrap.d/10-bootstrap.sh @@ -0,0 +1,49 @@ +# +# Debootstrap basic system +# + +# Load utility functions +. ./functions.sh + +VARIANT="" +COMPONENTS="main" + +# Use non-free Debian packages if needed +# One use variable which is only needed by wifi firmware blob => reworked to use non free in /etc/apt/sources.list - we could just use ENABLE_WIRELESS here +if [ "$ENABLE_WIRELESS" = true ] || [ "$ENABLE_NONFREE" = true ] ; then + COMPONENTS="main,non-free,contrib,non-free-firmware" +fi + +# Use minbase bootstrap variant which only includes essential packages +if [ "$ENABLE_MINBASE" = true ] ; then + VARIANT="--variant=minbase" +fi + + +# Exclude packages if required by Debian release +#if [ "$RELEASE" = "bookworm" ] || [ "$RELEASE" = "bullseye" ] ; then +# APT_EXCLUDES="--exclude=init,systemd-sysv" +#fi + + +# Base debootstrap (unpack only) +http_proxy=${APT_PROXY} debootstrap ${APT_EXCLUDES} --arch="${RELEASE_ARCH}" --foreign ${VARIANT} --components="${COMPONENTS}" --include="${APT_INCLUDES}" "${RELEASE}" "${R}" "http://${APT_SERVER}/debian" + +# Copy qemu emulator binary to chroot +install -m 755 -o root -g root "${QEMU_BINARY}" "${R}${QEMU_BINARY}" + +# Copy debian-archive-keyring.pgp +mkdir -p "${R}/usr/share/keyrings" +install_readonly /usr/share/keyrings/debian-archive-keyring.gpg "${R}/usr/share/keyrings/debian-archive-keyring.gpg" + +# Complete the bootstrapping process +chroot_exec /debootstrap/debootstrap --second-stage + +# Mount required filesystems +mount -t proc none "${R}/proc" +mount -t sysfs none "${R}/sys" + +# Mount pseudo terminal slave if supported by Debian release +if [ -d "${R}/dev/pts" ] ; then + mount --bind /dev/pts "${R}/dev/pts" +fi diff --git a/bootstrap.d/11-apt.sh b/bootstrap.d/11-apt.sh new file mode 100644 index 0000000..b2fe234 --- /dev/null +++ b/bootstrap.d/11-apt.sh @@ -0,0 +1,54 @@ +# +# Setup APT repositories +# + +# Load utility functions +. ./functions.sh + +# Install and setup APT proxy configuration +if [ -z "$APT_PROXY" ] ; then + install_readonly files/apt/10proxy "${ETC_DIR}/apt/apt.conf.d/10proxy" + sed -i "s/\"\"/\"${APT_PROXY}\"/" "${ETC_DIR}/apt/apt.conf.d/10proxy" +fi + +# Install APT sources.list +install_readonly files/apt/sources.list "${ETC_DIR}/apt/sources.list" + +# Use specified APT server and release +sed -i "s/\/ftp.debian.org\//\/${APT_SERVER}\//" "${ETC_DIR}/apt/sources.list" + +#Fix for changing path for security updates in oldstable / bullseye +if [ "$RELEASE" = "oldstable" ] || [ "$RELEASE" = "bullseye " ] ; then +sed -i "s:bookworm-security:${RELEASE}\\/updates:" "${ETC_DIR}/apt/sources.list" +sed -i "s:security.debian.org/debian-security:security.debian.org:" "${ETC_DIR}/apt/sources.list" +fi + +if [ "$ENABLE_NONFREE" = "true" ] ; then +sed -i "s,main contrib,main contrib non-free non-free-firmware," "${ETC_DIR}/apt/sources.list" +fi + +if [ "$RELEASE" != "$RELEASE" ] ; then +# Change release in sources list +sed -i "s/ ${HOSTRELEASE}/ ${RELEASE}/" "${ETC_DIR}/apt/sources.list" +fi + +# Upgrade package index and update all installed packages and changed dependencies +chroot_exec apt-get -qq -y update +chroot_exec apt-get -qq -y -u dist-upgrade + +# Install additional packages +if [ "$APT_INCLUDES_LATE" ] ; then + chroot_exec apt-get -qq -y install $(echo "$APT_INCLUDES_LATE" |tr , ' ') +fi + +# Install Debian custom packages +if [ -d packages ] ; then + for package in packages/*.deb ; do + cp "$package" "${R}"/tmp + chroot_exec dpkg --unpack /tmp/"$(basename "$package")" + done +fi + +chroot_exec apt-get -qq -y -f install + +chroot_exec apt-get -qq -y check diff --git a/bootstrap.d/12-locale.sh b/bootstrap.d/12-locale.sh new file mode 100644 index 0000000..c086ee2 --- /dev/null +++ b/bootstrap.d/12-locale.sh @@ -0,0 +1,66 @@ +# +# Setup Locales and keyboard settings +# + +# Load utility functions +. ./functions.sh + +# Install and setup timezone +echo "${TIMEZONE}" > "${ETC_DIR}/timezone" +if [ -f "${ETC_DIR}/localtime" ]; then + # 1. If 11-apt.sh upgrades the package 'tzdata', '/etc/localtime' was created + # because 'dpkg-reconfigure -f noninteractive tzdata' was executed by apt-get. + # 2. If '/etc/localtime' exists, our execution of 'dpkg-reconfigure -f noninteractive tzdata' + # will ignore the our timezone set in '/etc/timezone'. + # 3. Removing /etc/localtime will solve this. + rm -f "${ETC_DIR}/localtime" +fi +chroot_exec dpkg-reconfigure -f noninteractive tzdata + +# Install and setup default locale and keyboard configuration +if [ "$(echo "$APT_INCLUDES" | grep ",locales")" ] ; then + # Set locale choice in debconf db, even though dpkg-reconfigure ignores and overwrites them due to some bug + # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=684134 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=685957 + # ... so we have to set locales manually + if [ "$DEFLOCAL" = "en_US.UTF-8" ] ; then + chroot_exec echo "locales locales/locales_to_be_generated multiselect ${DEFLOCAL} UTF-8 | debconf-set-selections" + else + # en_US.UTF-8 should be available anyway : https://www.debian.org/doc/manuals/debian-reference/ch08.en.html#_the_reconfiguration_of_the_locale + chroot_exec echo "locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8, ${DEFLOCAL} UTF-8 | debconf-set-selections" + sed -i "/en_US.UTF-8/s/^#//" "${ETC_DIR}/locale.gen" + fi + + sed -i "/${DEFLOCAL}/s/^#//" "${ETC_DIR}/locale.gen" + chroot_exec echo "locales locales/default_environment_locale select ${DEFLOCAL} | debconf-set-selections" + chroot_exec locale-gen + chroot_exec update-locale LANG="${DEFLOCAL}" + + # Install and setup default keyboard configuration + if [ "$XKB_MODEL" != "" ] ; then + sed -i "s/^XKBMODEL.*/XKBMODEL=\"${XKB_MODEL}\"/" "${ETC_DIR}/default/keyboard" + fi + if [ "$XKB_LAYOUT" != "" ] ; then + sed -i "s/^XKBLAYOUT.*/XKBLAYOUT=\"${XKB_LAYOUT}\"/" "${ETC_DIR}/default/keyboard" + fi + if [ "$XKB_VARIANT" != "" ] ; then + sed -i "s/^XKBVARIANT.*/XKBVARIANT=\"${XKB_VARIANT}\"/" "${ETC_DIR}/default/keyboard" + fi + if [ "$XKB_OPTIONS" != "" ] ; then + sed -i "s/^XKBOPTIONS.*/XKBOPTIONS=\"${XKB_OPTIONS}\"/" "${ETC_DIR}/default/keyboard" + fi + chroot_exec dpkg-reconfigure -f noninteractive keyboard-configuration + + # Install and setup font console + case "${DEFLOCAL}" in + *UTF-8) + sed -i 's/^CHARMAP.*/CHARMAP="UTF-8"/' "${ETC_DIR}/default/console-setup" + ;; + *) + sed -i 's/^CHARMAP.*/CHARMAP="guess"/' "${ETC_DIR}/default/console-setup" + ;; + esac + chroot_exec dpkg-reconfigure -f noninteractive console-setup +else # (no locales were installed) + # Install POSIX default locale + install_readonly files/locales/locale "${ETC_DIR}/default/locale" +fi diff --git a/bootstrap.d/13-kernel.sh b/bootstrap.d/13-kernel.sh new file mode 100644 index 0000000..c5fff0a --- /dev/null +++ b/bootstrap.d/13-kernel.sh @@ -0,0 +1,886 @@ +# +# Build and Setup RPi2/3/4 Kernel 4.XX 5.XX +# + +# Load utility functions +. ./functions.sh + +# Need to use kali kernel src if nexmon is enabled +if [ "$ENABLE_NEXMON" = true ] ; then + KERNEL_URL="${KALI_KERNEL_URL}" + # Clear Branch and KernelSRC_DIR if using nexmon. Everyone will forget to clone kali kernel instead of nomrla kernel + KERNEL_BRANCH="" + KERNELSRC_DIR="" +fi + +# Fetch and build latest raspberry kernel +if [ "$BUILD_KERNEL" = true ] ; then + # Setup source directory + mkdir -p "${KERNEL_DIR}" + + # Copy existing kernel sources into chroot directory + if [ -n "$KERNELSRC_DIR" ] && [ -d "$KERNELSRC_DIR" ] ; then + # Copy kernel sources and include hidden files + cp -r "${KERNELSRC_DIR}/". "${KERNEL_DIR}" + + # Clean the kernel sources + if [ "$KERNELSRC_CLEAN" = true ] && [ "$KERNELSRC_PREBUILT" = false ] ; then + make -j "${NB_CORES}" -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" mrproper + fi + else # KERNELSRC_DIR="" + # Create temporary directory for kernel sources + temp_dir=$(as_nobody mktemp -d) + + # Fetch current RPi2/3/4 kernel sources + if [ -z "${KERNEL_BRANCH}" ] ; then + as_nobody -H git -C "${temp_dir}" clone --depth=1 "${KERNEL_URL}" linux + else + as_nobody -H git -C "${temp_dir}" clone --depth=1 --branch "${KERNEL_BRANCH}" "${KERNEL_URL}" linux + fi + + # Copy downloaded kernel sources + cp -r "${temp_dir}/linux/"* "${KERNEL_DIR}" + + # Remove temporary directory for kernel sources + rm -fr "${temp_dir}" + + # Set permissions of the kernel sources + chown -R root:root "${R}/usr/src" + fi + + # Calculate optimal number of kernel building threads + if [ -n "$KERNEL_THREADS" ] && [ -r /proc/cpuinfo ] ; then + KERNEL_THREADS=$(grep -c processor /proc/cpuinfo) + fi + +# TODO: Check if defined Threadcount is higher than actual cores +# if [ "$KERNEL_THREADS" > grep -c processor /proc/cpuinfo] ; then +# echo "Defined more Threads than core assigned to this system" +# exit 1 +# fi + + #Copy 32bit config to 64bit + if [ "$ENABLE_QEMU" = true ] && [ "$KERNEL_ARCH" = arm64 ]; then + cp "${KERNEL_DIR}"/arch/arm/configs/vexpress_defconfig "${KERNEL_DIR}"/arch/arm64/configs/ + fi + + # Configure and build kernel + if [ "$KERNELSRC_PREBUILT" = false ] ; then + # Remove device, network and filesystem drivers from kernel configuration + if [ "$REDUCE_KERNEL" = true ] ; then + make -j "${NB_CORES}" -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}" + sed -i\ + -e "s/\(^CONFIG_SND.*\=\).*/\1n/"\ + -e "s/\(^CONFIG_SOUND.*\=\).*/\1n/"\ + -e "s/\(^CONFIG_AC97.*\=\).*/\1n/"\ + -e "s/\(^CONFIG_VIDEO_.*\=\).*/\1n/"\ + -e "s/\(^CONFIG_MEDIA_TUNER.*\=\).*/\1n/"\ + -e "s/\(^CONFIG_DVB.*\=\)[ym]/\1n/"\ + -e "s/\(^CONFIG_REISERFS.*\=\).*/\1n/"\ + -e "s/\(^CONFIG_JFS.*\=\).*/\1n/"\ + -e "s/\(^CONFIG_XFS.*\=\).*/\1n/"\ + -e "s/\(^CONFIG_GFS2.*\=\).*/\1n/"\ + -e "s/\(^CONFIG_OCFS2.*\=\).*/\1n/"\ + -e "s/\(^CONFIG_BTRFS.*\=\).*/\1n/"\ + -e "s/\(^CONFIG_HFS.*\=\).*/\1n/"\ + -e "s/\(^CONFIG_JFFS2.*\=\)[ym]/\1n/"\ + -e "s/\(^CONFIG_UBIFS.*\=\).*/\1n/"\ + -e "s/\(^CONFIG_SQUASHFS.*\=\)[ym]/\1n/"\ + -e "s/\(^CONFIG_W1.*\=\)[ym]/\1n/"\ + -e "s/\(^CONFIG_HAMRADIO.*\=\).*/\1n/"\ + -e "s/\(^CONFIG_CAN.*\=\).*/\1n/"\ + -e "s/\(^CONFIG_IRDA.*\=\).*/\1n/"\ + -e "s/\(^CONFIG_BT_.*\=\).*/\1n/"\ + -e "s/\(^CONFIG_WIMAX.*\=\)[ym]/\1n/"\ + -e "s/\(^CONFIG_6LOWPAN.*\=\).*/\1n/"\ + -e "s/\(^CONFIG_IEEE802154.*\=\).*/\1n/"\ + -e "s/\(^CONFIG_NFC.*\=\).*/\1n/"\ + -e "s/\(^CONFIG_FB_TFT=.*\=\).*/\1n/"\ + -e "s/\(^CONFIG_TOUCHSCREEN.*\=\).*/\1n/"\ + -e "s/\(^CONFIG_USB_GSPCA_.*\=\).*/\1n/"\ + -e "s/\(^CONFIG_DRM.*\=\).*/\1n/"\ + "${KERNEL_DIR}/.config" + fi + + if [ "$KERNELSRC_CONFIG" = true ] ; then + # Load default raspberry kernel configuration + make -j "${NB_CORES}" -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}" + + #Switch to KERNELSRC_DIR so we can use set_kernel_config + cd "${KERNEL_DIR}" || exit + + # Enable RPI POE HAT fan + if [ "$KERNEL_POEHAT" = true ]; then + set_kernel_config CONFIG_SENSORS_RPI_POE_FAN m + fi + + # Enable per-interface network priority control + # (for systemd-nspawn) + if [ "$KERNEL_NSPAN" = true ]; then + set_kernel_config CONFIG_CGROUP_NET_PRIO y + fi + + # Compile in BTRFS + if [ "$KERNEL_BTRFS" = true ]; then + set_kernel_config CONFIG_BTRFS_FS y + set_kernel_config CONFIG_BTRFS_FS_POSIX_ACL y + set_kernel_config CONFIG_BTRFS_FS_REF_VERIFY y + fi + + # Diffie-Hellman operations on retained keys + # (required for >keyutils-1.6) + if [ "$KERNEL_DHKEY" = true ]; then + set_kernel_config CONFIG_KEY_DH_OPERATIONS y + fi + + if [ "$KERNEL_ARCH" = arm64 ] && [ "$ENABLE_QEMU" = false ]; then + # Mask this temporarily during switch to rpi-4.19.y + #Fix SD_DRIVER upstream and downstream mess in 64bit RPIdeb_config + # use correct driver MMC_BCM2835_MMC instead of MMC_BCM2835_SDHOST - see https://www.raspberrypi.org/forums/viewtopic.php?t=210225 + #set_kernel_config CONFIG_MMC_BCM2835 n + #set_kernel_config CONFIG_MMC_SDHCI_IPROC n + #set_kernel_config CONFIG_USB_DWC2 n + #sed -i "s|depends on MMC_BCM2835_MMC && MMC_BCM2835_DMA|depends on MMC_BCM2835_MMC|" "${KERNEL_DIR}"/drivers/mmc/host/Kconfig + + #VLAN got disabled without reason in arm64bit + set_kernel_config CONFIG_IPVLAN m + fi + + # enable ZSWAP see https://askubuntu.com/a/472227 or https://wiki.archlinux.org/index.php/zswap + if [ "$KERNEL_ZSWAP" = true ] ; then + set_kernel_config CONFIG_ZPOOL y + set_kernel_config CONFIG_ZSWAP y + set_kernel_config CONFIG_ZBUD y + set_kernel_config CONFIG_Z3FOLD y + set_kernel_config CONFIG_ZSMALLOC y + set_kernel_config CONFIG_PGTABLE_MAPPING y + set_kernel_config CONFIG_LZO_COMPRESS y + fi + + if [ "$RPI_MODEL" = 4 ] ; then + # Following are set in current 32-bit LPAE kernel + set_kernel_config CONFIG_CGROUP_PIDS y + set_kernel_config CONFIG_NET_IPVTI m + set_kernel_config CONFIG_NF_TABLES_SET m + set_kernel_config CONFIG_NF_TABLES_INET y + set_kernel_config CONFIG_NF_TABLES_NETDEV y + set_kernel_config CONFIG_NF_FLOW_TABLE m + set_kernel_config CONFIG_NFT_FLOW_OFFLOAD m + set_kernel_config CONFIG_NFT_CONNLIMIT m + set_kernel_config CONFIG_NFT_TUNNEL m + set_kernel_config CONFIG_NFT_OBJREF m + set_kernel_config CONFIG_NFT_FIB_IPV4 m + set_kernel_config CONFIG_NFT_FIB_IPV6 m + set_kernel_config CONFIG_NFT_FIB_INET m + set_kernel_config CONFIG_NFT_SOCKET m + set_kernel_config CONFIG_NFT_OSF m + set_kernel_config CONFIG_NFT_TPROXY m + set_kernel_config CONFIG_NF_DUP_NETDEV m + set_kernel_config CONFIG_NFT_DUP_NETDEV m + set_kernel_config CONFIG_NFT_FWD_NETDEV m + set_kernel_config CONFIG_NFT_FIB_NETDEV m + set_kernel_config CONFIG_NF_FLOW_TABLE_INET m + set_kernel_config CONFIG_NF_FLOW_TABLE m + set_kernel_config CONFIG_NETFILTER_XT_MATCH_SOCKET m + set_kernel_config CONFIG_NFT_CHAIN_ROUTE_IPV6 m + set_kernel_config CONFIG_NFT_CHAIN_NAT_IPV6 m + set_kernel_config CONFIG_NFT_MASQ_IPV6 m + set_kernel_config CONFIG_NFT_REDIR_IPV6 m + set_kernel_config CONFIG_NFT_REJECT_IPV6 m + set_kernel_config CONFIG_NFT_DUP_IPV6 m + set_kernel_config CONFIG_NFT_FIB_IPV6 m + set_kernel_config CONFIG_NF_FLOW_TABLE_IPV6 m + set_kernel_config CONFIG_NF_TABLES_BRIDGE m + set_kernel_config CONFIG_NFT_BRIDGE_REJECT m + set_kernel_config CONFIG_NF_LOG_BRIDGE m + set_kernel_config CONFIG_MT76_CORE m + set_kernel_config CONFIG_MT76_LEDS m + set_kernel_config CONFIG_MT76_USB m + set_kernel_config CONFIG_MT76x2_COMMON m + set_kernel_config CONFIG_MT76x0U m + set_kernel_config CONFIG_MT76x2U m + set_kernel_config CONFIG_TOUCHSCREEN_ILI210X m + set_kernel_config CONFIG_BCM_VC_SM m + set_kernel_config CONFIG_BCM2835_SMI_DEV m + set_kernel_config CONFIG_RPIVID_MEM m + set_kernel_config CONFIG_HW_RANDOM_BCM2835 y + set_kernel_config CONFIG_TCG_TPM m + set_kernel_config CONFIG_HW_RANDOM_TPM y + set_kernel_config CONFIG_TCG_TIS m + set_kernel_config CONFIG_TCG_TIS_SPI m + set_kernel_config CONFIG_I2C_MUX m + set_kernel_config CONFIG_I2C_MUX_GPMUX m + set_kernel_config CONFIG_I2C_MUX_PCA954x m + set_kernel_config CONFIG_SPI_GPIO m + set_kernel_config CONFIG_BATTERY_MAX17040 m + set_kernel_config CONFIG_SENSORS_GPIO_FAN m + set_kernel_config CONFIG_SENSORS_RASPBERRYPI_HWMON m + set_kernel_config CONFIG_BCM2835_THERMAL y + set_kernel_config CONFIG_RC_CORE y + set_kernel_config CONFIG_RC_MAP y + set_kernel_config CONFIG_LIRC y + set_kernel_config CONFIG_RC_DECODERS y + set_kernel_config CONFIG_IR_NEC_DECODER m + set_kernel_config CONFIG_IR_RC5_DECODER m + set_kernel_config CONFIG_IR_RC6_DECODER m + set_kernel_config CONFIG_IR_JVC_DECODER m + set_kernel_config CONFIG_IR_SONY_DECODER m + set_kernel_config CONFIG_IR_SANYO_DECODER m + set_kernel_config CONFIG_IR_SHARP_DECODER m + set_kernel_config CONFIG_IR_MCE_KBD_DECODER m + set_kernel_config CONFIG_IR_XMP_DECODER m + set_kernel_config CONFIG_IR_IMON_DECODER m + set_kernel_config CONFIG_RC_DEVICES y + set_kernel_config CONFIG_RC_ATI_REMOTE m + set_kernel_config CONFIG_IR_IMON m + set_kernel_config CONFIG_IR_MCEUSB m + set_kernel_config CONFIG_IR_REDRAT3 m + set_kernel_config CONFIG_IR_STREAMZAP m + set_kernel_config CONFIG_IR_IGUANA m + set_kernel_config CONFIG_IR_TTUSBIR m + set_kernel_config CONFIG_RC_LOOPBACK m + set_kernel_config CONFIG_IR_GPIO_CIR m + set_kernel_config CONFIG_IR_GPIO_TX m + set_kernel_config CONFIG_IR_PWM_TX m + set_kernel_config CONFIG_VIDEO_V4L2_SUBDEV_API y + set_kernel_config CONFIG_VIDEO_AU0828_RC y + set_kernel_config CONFIG_VIDEO_CX231XX m + set_kernel_config CONFIG_VIDEO_CX231XX_RC y + set_kernel_config CONFIG_VIDEO_CX231XX_ALSA m + set_kernel_config CONFIG_VIDEO_CX231XX_DVB m + set_kernel_config CONFIG_VIDEO_TM6000 m + set_kernel_config CONFIG_VIDEO_TM6000_ALSA m + set_kernel_config CONFIG_VIDEO_TM6000_DVB m + set_kernel_config CONFIG_DVB_USB m + set_kernel_config CONFIG_DVB_USB_DIB3000MC m + set_kernel_config CONFIG_DVB_USB_A800 m + set_kernel_config CONFIG_DVB_USB_DIBUSB_MB m + set_kernel_config CONFIG_DVB_USB_DIBUSB_MB_FAULTY y + set_kernel_config CONFIG_DVB_USB_DIBUSB_MC m + set_kernel_config CONFIG_DVB_USB_DIB0700 m + set_kernel_config CONFIG_DVB_USB_UMT_010 m + set_kernel_config CONFIG_DVB_USB_CXUSB m + set_kernel_config CONFIG_DVB_USB_M920X m + set_kernel_config CONFIG_DVB_USB_DIGITV m + set_kernel_config CONFIG_DVB_USB_VP7045 m + set_kernel_config CONFIG_DVB_USB_VP702X m + set_kernel_config CONFIG_DVB_USB_GP8PSK m + set_kernel_config CONFIG_DVB_USB_NOVA_T_USB2 m + set_kernel_config CONFIG_DVB_USB_TTUSB2 m + set_kernel_config CONFIG_DVB_USB_DTT200U m + set_kernel_config CONFIG_DVB_USB_OPERA1 m + set_kernel_config CONFIG_DVB_USB_AF9005 m + set_kernel_config CONFIG_DVB_USB_AF9005_REMOTE m + set_kernel_config CONFIG_DVB_USB_PCTV452E m + set_kernel_config CONFIG_DVB_USB_DW2102 m + set_kernel_config CONFIG_DVB_USB_CINERGY_T2 m + set_kernel_config CONFIG_DVB_USB_DTV5100 m + set_kernel_config CONFIG_DVB_USB_AZ6027 m + set_kernel_config CONFIG_DVB_USB_TECHNISAT_USB2 m + set_kernel_config CONFIG_DVB_USB_AF9015 m + set_kernel_config CONFIG_DVB_USB_LME2510 m + set_kernel_config CONFIG_DVB_USB_RTL28XXU m + set_kernel_config CONFIG_VIDEO_EM28XX_RC m + set_kernel_config CONFIG_SMS_SIANO_RC m + set_kernel_config CONFIG_VIDEO_IR_I2C m + set_kernel_config CONFIG_VIDEO_ADV7180 m + set_kernel_config CONFIG_VIDEO_TC358743 m + set_kernel_config CONFIG_VIDEO_OV5647 m + set_kernel_config CONFIG_DVB_M88DS3103 m + set_kernel_config CONFIG_DVB_AF9013 m + set_kernel_config CONFIG_DVB_RTL2830 m + set_kernel_config CONFIG_DVB_RTL2832 m + set_kernel_config CONFIG_DVB_SI2168 m + set_kernel_config CONFIG_DVB_GP8PSK_FE m + set_kernel_config CONFIG_DVB_USB m + set_kernel_config CONFIG_DVB_LGDT3306A m + set_kernel_config CONFIG_FB_SIMPLE y + set_kernel_config CONFIG_SND_BCM2708_SOC_IQAUDIO_CODEC m + set_kernel_config CONFIG_SND_BCM2708_SOC_I_SABRE_Q2M m + set_kernel_config CONFIG_SND_AUDIOSENSE_PI m + set_kernel_config CONFIG_SND_SOC_AD193X m + set_kernel_config CONFIG_SND_SOC_AD193X_SPI m + set_kernel_config CONFIG_SND_SOC_AD193X_I2C m + set_kernel_config CONFIG_SND_SOC_CS4265 m + set_kernel_config CONFIG_SND_SOC_DA7213 m + set_kernel_config CONFIG_SND_SOC_ICS43432 m + set_kernel_config CONFIG_SND_SOC_TLV320AIC32X4 m + set_kernel_config CONFIG_SND_SOC_TLV320AIC32X4_I2C m + set_kernel_config CONFIG_SND_SOC_I_SABRE_CODEC m + set_kernel_config CONFIG_HID_BIGBEN_FF m + #set_kernel_config CONFIG_USB_XHCI_PLATFORM y + set_kernel_config CONFIG_USB_TMC m + set_kernel_config CONFIG_USB_UAS y + set_kernel_config CONFIG_USBIP_VUDC m + set_kernel_config CONFIG_USB_CONFIGFS m + set_kernel_config CONFIG_USB_CONFIGFS_SERIAL y + set_kernel_config CONFIG_USB_CONFIGFS_ACM y + set_kernel_config CONFIG_USB_CONFIGFS_OBEX y + set_kernel_config CONFIG_USB_CONFIGFS_NCM y + set_kernel_config CONFIG_USB_CONFIGFS_ECM y + set_kernel_config CONFIG_USB_CONFIGFS_ECM_SUBSET y + set_kernel_config CONFIG_USB_CONFIGFS_RNDIS y + set_kernel_config CONFIG_USB_CONFIGFS_EEM y + set_kernel_config CONFIG_USB_CONFIGFS_MASS_STORAGE y + set_kernel_config CONFIG_USB_CONFIGFS_F_LB_SS y + set_kernel_config CONFIG_USB_CONFIGFS_F_FS y + set_kernel_config CONFIG_USB_CONFIGFS_F_UAC1 y + set_kernel_config CONFIG_USB_CONFIGFS_F_UAC2 y + set_kernel_config CONFIG_USB_CONFIGFS_F_MIDI y + set_kernel_config CONFIG_USB_CONFIGFS_F_HID y + set_kernel_config CONFIG_USB_CONFIGFS_F_UVC y + set_kernel_config CONFIG_USB_CONFIGFS_F_PRINTER y + set_kernel_config CONFIG_LEDS_PCA963X m + set_kernel_config CONFIG_LEDS_IS31FL32XX m + set_kernel_config CONFIG_LEDS_TRIGGER_NETDEV m + set_kernel_config CONFIG_RTC_DRV_RV3028 m + set_kernel_config CONFIG_AUXDISPLAY y + set_kernel_config CONFIG_HD44780 m + set_kernel_config CONFIG_FB_TFT_SH1106 m + set_kernel_config CONFIG_VIDEO_CODEC_BCM2835 m + set_kernel_config CONFIG_BCM2835_POWER y + set_kernel_config CONFIG_INV_MPU6050_IIO m + set_kernel_config CONFIG_INV_MPU6050_I2C m + set_kernel_config CONFIG_SECURITYFS y + + # Safer to build this in + set_kernel_config CONFIG_BINFMT_MISC y + + # pulseaudio wants a buffer of at least this size + set_kernel_config CONFIG_SND_HDA_PREALLOC_SIZE 2048 + + # PR#3063: enable 3D acceleration with 64-bit kernel on RPi4 + # set the appropriate kernel configs unlocked by this PR + set_kernel_config CONFIG_ARCH_BCM y + set_kernel_config CONFIG_ARCH_BCM2835 y + set_kernel_config CONFIG_DRM_V3D m + set_kernel_config CONFIG_DRM_VC4 m + set_kernel_config CONFIG_DRM_VC4_HDMI_CEC y + + # PR#3144: add arm64 pcie bounce buffers; enables 4GiB on RPi4 + # required by PR#3144; should already be applied, but just to be safe + set_kernel_config CONFIG_PCIE_BRCMSTB y + set_kernel_config CONFIG_BCM2835_MMC y + + # Snap needs squashfs. The ubuntu eoan-preinstalled-server image at + # http://cdimage.ubuntu.com/ubuntu-server/daily-preinstalled/current/ uses snap + # during cloud-init setup at first boot. Without this the login accounts are not + # created and the user can not login. + set_kernel_config CONFIG_SQUASHFS y + + # Ceph support for Block Device (RBD) and Filesystem (FS) + # https://docs.ceph.com/docs/master/ + set_kernel_config CONFIG_CEPH_LIB m + set_kernel_config CONFIG_CEPH_LIB_USE_DNS_RESOLVER y + set_kernel_config CONFIG_CEPH_FS m + set_kernel_config CONFIG_CEPH_FSCACHE y + set_kernel_config CONFIG_CEPH_FS_POSIX_ACL y + set_kernel_config CONFIG_BLK_DEV_RBD m + fi + + # enable basic KVM support; see https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=210546&start=25#p1300453 + if [ "$KERNEL_VIRT" = true ] && { [ "$RPI_MODEL" = 2 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ]; } ; then + set_kernel_config CONFIG_HAVE_KVM y + set_kernel_config CONFIG_HIGH_RES_TIMERS y + set_kernel_config CONFIG_HAVE_KVM_IRQCHIP y + set_kernel_config CONFIG_HAVE_KVM_ARCH_TLB_FLUSH_ALL y + set_kernel_config CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT y + set_kernel_config CONFIG_HAVE_KVM_EVENTFD y + set_kernel_config CONFIG_HAVE_KVM_IRQFD y + set_kernel_config CONFIG_HAVE_KVM_IRQ_ROUTING y + set_kernel_config CONFIG_HAVE_KVM_MSI y + set_kernel_config CONFIG_KVM y + set_kernel_config CONFIG_KVM_ARM_HOST y + set_kernel_config CONFIG_KVM_ARM_PMU y + set_kernel_config CONFIG_KVM_COMPAT y + set_kernel_config CONFIG_KVM_GENERIC_DIRTYLOG_READ_PROTECT y + set_kernel_config CONFIG_KVM_MMIO y + set_kernel_config CONFIG_KVM_VFIO y + set_kernel_config CONFIG_KVM_MMU_AUDIT y + set_kernel_config CONFIG_VHOST m + set_kernel_config CONFIG_VHOST_CROSS_ENDIAN_LEGACY y + set_kernel_config CONFIG_VHOST_NET m + set_kernel_config CONFIG_VIRTUALIZATION y + set_kernel_config CONFIG_SLAB_FREELIST_RANDOM=y + set_kernel_config CONFIG_SLAB_FREELIST_HARDENED=y + set_kernel_config CONFIG_MMU_NOTIFIER y + + # erratum + set_kernel_config ARM64_ERRATUM_834220 y + + # https://sourceforge.net/p/kvm/mailman/message/18440797/ + set_kernel_config CONFIG_PREEMPT_NOTIFIERS y + fi + + # enable apparmor,integrity audit, + if [ "$KERNEL_SECURITY" = true ] ; then + + # security filesystem, security models and audit + set_kernel_config CONFIG_SECURITYFS y + set_kernel_config CONFIG_SECURITY y + set_kernel_config CONFIG_AUDIT y + + # harden strcpy and memcpy + set_kernel_config CONFIG_HARDENED_USERCOPY y + set_kernel_config CONFIG_HAVE_HARDENED_USERCOPY_ALLOCATOR y + set_kernel_config CONFIG_FORTIFY_SOURCE y + + # integrity sub-system + set_kernel_config CONFIG_INTEGRITY y + set_kernel_config CONFIG_INTEGRITY_ASYMMETRIC_KEYS y + set_kernel_config CONFIG_INTEGRITY_AUDIT y + set_kernel_config CONFIG_INTEGRITY_SIGNATURE y + set_kernel_config CONFIG_INTEGRITY_TRUSTED_KEYRING y + + # This option provides support for retaining authentication tokens and access keys in the kernel. + set_kernel_config CONFIG_KEYS y + set_kernel_config CONFIG_KEYS_COMPAT y + + # Apparmor + set_kernel_config CONFIG_SECURITY_APPARMOR_BOOTPARAM_VALUE 0 + set_kernel_config CONFIG_SECURITY_APPARMOR_HASH_DEFAULT y + set_kernel_config CONFIG_DEFAULT_SECURITY_APPARMOR y + set_kernel_config CONFIG_SECURITY_APPARMOR y + set_kernel_config CONFIG_SECURITY_APPARMOR_HASH y + set_kernel_config CONFIG_DEFAULT_SECURITY "apparmor" + + # restrictions on unprivileged users reading the kernel + set_kernel_config CONFIG_SECURITY_DMESG_RESTRICT y + + # network security hooks + set_kernel_config CONFIG_SECURITY_NETWORK y + set_kernel_config CONFIG_SECURITY_NETWORK_XFRM y + set_kernel_config CONFIG_SECURITY_PATH y + set_kernel_config CONFIG_SECURITY_YAMA n + + set_kernel_config CONFIG_SECURITY_SELINUX n + set_kernel_config CONFIG_SECURITY_SMACK n + set_kernel_config CONFIG_SECURITY_TOMOYO n + set_kernel_config CONFIG_SECURITY_APPARMOR_DEBUG n + set_kernel_config CONFIG_SECURITY_LOADPIN n + set_kernel_config CONFIG_HARDENED_USERCOPY_PAGESPAN n + set_kernel_config CONFIG_IMA n + set_kernel_config CONFIG_EVM n + set_kernel_config CONFIG_FANOTIFY_ACCESS_PERMISSIONS y + set_kernel_config CONFIG_NFSD_V4_SECURITY_LABEL y + set_kernel_config CONFIG_PKCS7_MESSAGE_PARSER y + set_kernel_config CONFIG_SYSTEM_TRUSTED_KEYRING y + set_kernel_config CONFIG_SYSTEM_EXTRA_CERTIFICATE y + set_kernel_config CONFIG_SECONDARY_TRUSTED_KEYRING y + set_kernel_config CONFIG_IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY n + set_kernel_config CONFIG_SYSTEM_TRUSTED_KEYS m + set_kernel_config CONFIG_SYSTEM_EXTRA_CERTIFICATE_SIZE 4096 + fi + + if [ "$ENABLE_CRYPTFS" = true ] ; then + set_kernel_config CONFIG_EMBEDDED y + set_kernel_config CONFIG_EXPERT y + set_kernel_config CONFIG_DAX y + set_kernel_config CONFIG_MD y + set_kernel_config CONFIG_BLK_DEV_MD y + set_kernel_config CONFIG_MD_AUTODETECT y + set_kernel_config CONFIG_BLK_DEV_DM y + set_kernel_config CONFIG_BLK_DEV_DM_BUILTIN y + set_kernel_config CONFIG_DM_CRYPT y + set_kernel_config CONFIG_CRYPTO_BLKCIPHER y + set_kernel_config CONFIG_CRYPTO_CBC y + set_kernel_config CONFIG_CRYPTO_XTS y + set_kernel_config CONFIG_CRYPTO_SHA512 y + set_kernel_config CONFIG_CRYPTO_MANAGER y + set_kernel_config CONFIG_ARM64_CRYPTO y + set_kernel_config CONFIG_CRYPTO_SHA256_ARM64 m + set_kernel_config CONFIG_CRYPTO_SHA512_ARM64 m + set_kernel_config CONFIG_CRYPTO_SHA1_ARM64_CE m + set_kernel_config CRYPTO_GHASH_ARM64_CE m + set_kernel_config CRYPTO_SHA2_ARM64_CE m + set_kernel_config CONFIG_CRYPTO_CRCT10DIF_ARM64_CE m + set_kernel_config CONFIG_CRYPTO_CRC32_ARM64_CE m + set_kernel_config CONFIG_CRYPTO_AES_ARM64 m + set_kernel_config CONFIG_CRYPTO_AES_ARM64_CE m + set_kernel_config CONFIG_CRYPTO_AES_ARM64_CE_CCM y + set_kernel_config CONFIG_CRYPTO_AES_ARM64_CE_BLK y + set_kernel_config CONFIG_CRYPTO_AES_ARM64_NEON_BLK m + set_kernel_config CONFIG_CRYPTO_CHACHA20_NEON m + set_kernel_config CONFIG_CRYPTO_AES_ARM64_BS m + fi + + # Netfilter kernel support See https://github.com/raspberrypi/linux/issues/2177#issuecomment-354647406 + if [ "$KERNEL_NF" = true ] ; then + set_kernel_config CONFIG_IP_NF_SECURITY m + set_kernel_config CONFIG_NETLABEL y + set_kernel_config CONFIG_IP6_NF_SECURITY m + set_kernel_config CONFIG_IP_NF_TARGET_SYNPROXY m + set_kernel_config CONFIG_NETFILTER_XT_TARGET_AUDIT m + set_kernel_config CONFIG_NETFILTER_XT_MATCH_CGROUP m + set_kernel_config CONFIG_NETFILTER_XT_MATCH_IPCOMP m + set_kernel_config CONFIG_NETFILTER_XT_MATCH_SOCKET m + set_kernel_config CONFIG_NFT_FIB_INET m + set_kernel_config CONFIG_NFT_FIB_IPV4 m + set_kernel_config CONFIG_NFT_FIB_IPV6 m + set_kernel_config CONFIG_NFT_FIB_NETDEV m + set_kernel_config CONFIG_NFT_OBJREF m + set_kernel_config CONFIG_NFT_RT m + set_kernel_config CONFIG_NFT_SET_BITMAP m + set_kernel_config CONFIG_NF_CONNTRACK_TIMEOUT y + set_kernel_config CONFIG_NF_LOG_ARP m + set_kernel_config CONFIG_NF_SOCKET_IPV4 m + set_kernel_config CONFIG_NF_SOCKET_IPV6 m + set_kernel_config CONFIG_BRIDGE_EBT_BROUTE m + set_kernel_config CONFIG_BRIDGE_EBT_T_FILTER m + set_kernel_config CONFIG_BRIDGE_NF_EBTABLES m + set_kernel_config CONFIG_IP6_NF_IPTABLES m + set_kernel_config CONFIG_IP6_NF_MATCH_AH m + set_kernel_config CONFIG_IP6_NF_MATCH_EUI64 m + set_kernel_config CONFIG_IP6_NF_NAT m + set_kernel_config CONFIG_IP6_NF_TARGET_MASQUERADE m + set_kernel_config CONFIG_IP6_NF_TARGET_NPT m + set_kernel_config CONFIG_IP_SET_BITMAP_IPMAC m + set_kernel_config CONFIG_IP_SET_BITMAP_PORT m + set_kernel_config CONFIG_IP_SET_HASH_IP m + set_kernel_config CONFIG_IP_SET_HASH_IPMARK m + set_kernel_config CONFIG_IP_SET_HASH_IPPORT m + set_kernel_config CONFIG_IP_SET_HASH_IPPORTIP m + set_kernel_config CONFIG_IP_SET_HASH_IPPORTNET m + set_kernel_config CONFIG_IP_SET_HASH_MAC m + set_kernel_config CONFIG_IP_SET_HASH_NET m + set_kernel_config CONFIG_IP_SET_HASH_NETIFACE m + set_kernel_config CONFIG_IP_SET_HASH_NETNET m + set_kernel_config CONFIG_IP_SET_HASH_NETPORT m + set_kernel_config CONFIG_IP_SET_HASH_NETPORTNET m + set_kernel_config CONFIG_IP_SET_LIST_SET m + set_kernel_config CONFIG_NETFILTER_XTABLES m + set_kernel_config CONFIG_NETFILTER_XTABLES m + set_kernel_config CONFIG_NFT_BRIDGE_META m + set_kernel_config CONFIG_NFT_BRIDGE_REJECT m + set_kernel_config CONFIG_NFT_CHAIN_NAT_IPV4 m + set_kernel_config CONFIG_NFT_CHAIN_NAT_IPV6 m + set_kernel_config CONFIG_NFT_CHAIN_ROUTE_IPV4 m + set_kernel_config CONFIG_NFT_CHAIN_ROUTE_IPV6 m + set_kernel_config CONFIG_NFT_COMPAT m + set_kernel_config CONFIG_NFT_COUNTER m + set_kernel_config CONFIG_NFT_CT m + set_kernel_config CONFIG_NFT_DUP_IPV4 m + set_kernel_config CONFIG_NFT_DUP_IPV6 m + set_kernel_config CONFIG_NFT_DUP_NETDEV m + set_kernel_config CONFIG_NFT_EXTHDR m + set_kernel_config CONFIG_NFT_FWD_NETDEV m + set_kernel_config CONFIG_NFT_HASH m + set_kernel_config CONFIG_NFT_LIMIT m + set_kernel_config CONFIG_NFT_LOG m + set_kernel_config CONFIG_NFT_MASQ m + set_kernel_config CONFIG_NFT_MASQ_IPV4 m + set_kernel_config CONFIG_NFT_MASQ_IPV6 m + set_kernel_config CONFIG_NFT_META m + set_kernel_config CONFIG_NFT_NAT m + set_kernel_config CONFIG_NFT_NUMGEN m + set_kernel_config CONFIG_NFT_QUEUE m + set_kernel_config CONFIG_NFT_QUOTA m + set_kernel_config CONFIG_NFT_REDIR m + set_kernel_config CONFIG_NFT_REDIR_IPV4 m + set_kernel_config CONFIG_NFT_REDIR_IPV6 m + set_kernel_config CONFIG_NFT_REJECT m + set_kernel_config CONFIG_NFT_REJECT_INET m + set_kernel_config CONFIG_NFT_REJECT_IPV4 m + set_kernel_config CONFIG_NFT_REJECT_IPV6 m + set_kernel_config CONFIG_NFT_SET_HASH m + set_kernel_config CONFIG_NFT_SET_RBTREE m + set_kernel_config CONFIG_NF_CONNTRACK_IPV4 m + set_kernel_config CONFIG_NF_CONNTRACK_IPV6 m + set_kernel_config CONFIG_NF_DEFRAG_IPV4 m + set_kernel_config CONFIG_NF_DEFRAG_IPV6 m + set_kernel_config CONFIG_NF_DUP_IPV4 m + set_kernel_config CONFIG_NF_DUP_IPV6 m + set_kernel_config CONFIG_NF_DUP_NETDEV m + set_kernel_config CONFIG_NF_LOG_BRIDGE m + set_kernel_config CONFIG_NF_LOG_IPV4 m + set_kernel_config CONFIG_NF_LOG_IPV6 m + set_kernel_config CONFIG_NF_NAT_IPV4 m + set_kernel_config CONFIG_NF_NAT_IPV6 m + set_kernel_config CONFIG_NF_NAT_MASQUERADE_IPV4 y + set_kernel_config CONFIG_NF_NAT_MASQUERADE_IPV6 y + set_kernel_config CONFIG_NF_NAT_PPTP m + set_kernel_config CONFIG_NF_NAT_PROTO_GRE m + set_kernel_config CONFIG_NF_NAT_REDIRECT y + set_kernel_config CONFIG_NF_NAT_SIP m + set_kernel_config CONFIG_NF_NAT_SNMP_BASIC m + set_kernel_config CONFIG_NF_NAT_TFTP m + set_kernel_config CONFIG_NF_REJECT_IPV4 m + set_kernel_config CONFIG_NF_REJECT_IPV6 m + set_kernel_config CONFIG_NF_TABLES m + set_kernel_config CONFIG_NF_TABLES_IPV4 y + set_kernel_config CONFIG_NF_TABLES_IPV6 y + set_kernel_config CONFIG_NF_TABLES_SET m + set_kernel_config CONFIG_NF_TABLES_INET y + set_kernel_config CONFIG_NF_TABLES_NETDEV y + set_kernel_config CONFIG_NFT_CONNLIMIT m + set_kernel_config CONFIG_NFT_TUNNEL m + set_kernel_config CONFIG_NFT_SOCKET m + set_kernel_config CONFIG_NFT_TPROXY m + set_kernel_config CONFIG_NF_FLOW_TABLE m + set_kernel_config CONFIG_NFT_FLOW_OFFLOAD m + set_kernel_config CONFIG_NF_FLOW_TABLE_INET m + set_kernel_config CONFIG_NF_TABLES_ARP y + set_kernel_config CONFIG_NF_FLOW_TABLE_IPV4 y + set_kernel_config CONFIG_NF_FLOW_TABLE_IPV6 y + set_kernel_config CONFIG_NF_TABLES_BRIDGE y + set_kernel_config CONFIG_NF_CT_NETLINK_TIMEOUT m + set_kernel_config CONFIG_NFT_OSF m + + fi + + # Enables BPF syscall for systemd-journald see https://github.com/torvalds/linux/blob/master/init/Kconfig#L848 or https://groups.google.com/forum/#!topic/linux.gentoo.user/_2aSc_ztGpA + if [ "$KERNEL_BPF" = true ] ; then + set_kernel_config CONFIG_BPF_SYSCALL y + set_kernel_config CONFIG_BPF_EVENTS y + set_kernel_config CONFIG_BPF_STREAM_PARSER y + set_kernel_config CONFIG_CGROUP_BPF y + set_kernel_config CONFIG_XDP_SOCKETS y + fi + + # KERNEL_DEFAULT_GOV was set by user + if [ "$KERNEL_DEFAULT_GOV" != ondemand ] && [ -n "$KERNEL_DEFAULT_GOV" ] ; then + case "$KERNEL_DEFAULT_GOV" in + performance) + set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE y + ;; + userspace) + set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE y + ;; + ondemand) + set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND y + ;; + conservative) + set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE y + ;; + shedutil) + set_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL y + ;; + *) + echo "error: unsupported default cpu governor" + exit 1 + ;; + esac + # unset previous default governor + unset_kernel_config CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND + fi + + #Revert to previous directory + cd "${WORKDIR}" || exit + + # Set kernel configuration parameters to enable qemu emulation + if [ "$ENABLE_QEMU" = true ] ; then + echo "CONFIG_FHANDLE=y" >> "${KERNEL_DIR}"/.config + echo "CONFIG_LBDAF=y" >> "${KERNEL_DIR}"/.config + fi + + # Copy custom kernel configuration file + if [ -n "$KERNELSRC_USRCONFIG" ] ; then + cp "$KERNELSRC_USRCONFIG" "${KERNEL_DIR}"/.config + fi + + # Set kernel configuration parameters to their default values + if [ "$KERNEL_OLDDEFCONFIG" = true ] ; then + make -j "${NB_CORES}" -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" olddefconfig + fi + + # Start menu-driven kernel configuration (interactive) + if [ "$KERNEL_MENUCONFIG" = true ] ; then + make -j "${NB_CORES}" -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" menuconfig + fi + # end if "$KERNELSRC_CONFIG" = true + fi + + # Use ccache to cross compile the kernel + if [ "$KERNEL_CCACHE" = true ] ; then + cc="ccache ${CROSS_COMPILE}gcc" + else + cc="${CROSS_COMPILE}gcc" + fi + + # Cross compile kernel and dtbs + make -j "${NB_CORES}" -C "${KERNEL_DIR}" -j"${KERNEL_THREADS}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" "${KERNEL_BIN_IMAGE}" dtbs + + # Cross compile kernel modules + if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then + make -j "${NB_CORES}" -C "${KERNEL_DIR}" -j"${KERNEL_THREADS}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" modules + fi + # end if "$KERNELSRC_PREBUILT" = false + fi + + # Check if kernel compilation was successful + if [ ! -r "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" ] ; then + echo "error: kernel compilation failed! (kernel image not found)" + cleanup + exit 1 + fi + + # Install kernel modules + if [ "$ENABLE_REDUCE" = true ] ; then + if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then + make -j "${NB_CORES}" -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=../../.. modules_install + fi + else + if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then + make -j "${NB_CORES}" -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_PATH=../../.. modules_install + fi + + # Install kernel firmware + if grep -q "^firmware_install:" "${KERNEL_DIR}/Makefile" ; then + make -j "${NB_CORES}" -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_FW_PATH=../../../lib firmware_install + fi + fi + + # Install kernel headers + if [ "$KERNEL_HEADERS" = true ] && [ "$REDUCE_KERNEL" = false ] ; then + make -j "${NB_CORES}" -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_HDR_PATH=../.. headers_install + fi + + # Prepare boot (firmware) directory + mkdir "${BOOT_DIR}" + + # Get kernel release version + KERNEL_VERSION=$(cat "${KERNEL_DIR}/include/config/kernel.release") + + # Copy kernel configuration file to the boot directory + install_readonly "${KERNEL_DIR}/.config" "${R}/boot/config-${KERNEL_VERSION}" + + # Prepare device tree directory + mkdir "${BOOT_DIR}/overlays" + + # Ensure the proper .dtb is located + if [ "$KERNEL_ARCH" = "arm" ] ; then + for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/"*.dtb ; do + if [ -f "${dtb}" ] ; then + install_readonly "${dtb}" "${BOOT_DIR}/" + fi + done + else + for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/broadcom/"*.dtb ; do + if [ -f "${dtb}" ] ; then + install_readonly "${dtb}" "${BOOT_DIR}/" + fi + done + fi + + # Copy compiled dtb device tree files + if [ -d "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays" ] ; then + for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/"*.dtbo ; do + if [ -f "${dtb}" ] ; then + install_readonly "${dtb}" "${BOOT_DIR}/overlays/" + fi + done + + if [ -f "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" ] ; then + install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" "${BOOT_DIR}/overlays/README" + fi + fi + + if [ "$ENABLE_UBOOT" = false ] ; then + # Convert and copy kernel image to the boot directory + cp "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" "${BOOT_DIR}/${KERNEL_IMAGE}" + else + # Copy kernel image to the boot directory + install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" "${BOOT_DIR}/${KERNEL_IMAGE}" + fi + + # Remove kernel sources + if [ "$KERNEL_REMOVESRC" = true ] ; then + rm -fr "${KERNEL_DIR}" + else + # Prepare compiled kernel modules + if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then + if grep -q "^modules_prepare:" "${KERNEL_DIR}/Makefile" ; then + make -j "${NB_CORES}" -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" modules_prepare + fi + + # Create symlinks for kernel modules + chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/build" + chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/source" + fi + fi + +else # BUILD_KERNEL=false + if [ "$SET_ARCH" = 64 ] ; then + if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then + # Use Sakakis modified kernel if ZSWAP is active + if [ "$KERNEL_ZSWAP" = true ] || [ "$KERNEL_VIRT" = true ] || [ "$KERNEL_NF" = true ] || [ "$KERNEL_BPF" = true ] ; then + RPI3_64_KERNEL_URL="${RPI3_64_BIS_KERNEL_URL}" + fi + + # Create temporary directory for dl + temp_dir=$(as_nobody mktemp -d) + + # Fetch kernel dl + as_nobody wget -O "${temp_dir}"/kernel.tar.xz -c "$RPI3_64_KERNEL_URL" + fi + if [ "$SET_ARCH" = 64 ] && [ "$RPI_MODEL" = 4 ] ; then + # Create temporary directory for dl + temp_dir=$(as_nobody mktemp -d) + + # Fetch kernel dl + as_nobody wget -O "${temp_dir}"/kernel.tar.xz -c "$RPI4_64_KERNEL_URL" + fi + + #extract download + tar -xJf "${temp_dir}"/kernel.tar.xz -C "${temp_dir}" + + #move extracted kernel to /boot/firmware + mkdir "${R}/boot/firmware" + cp "${temp_dir}"/boot/* "${R}"/boot/firmware/ + cp -r "${temp_dir}"/lib/* "${R}"/lib/ + + # Remove temporary directory for kernel sources + rm -fr "${temp_dir}" + + # Set permissions of the kernel sources + chown -R root:root "${R}/boot/firmware" + chown -R root:root "${R}/lib/modules" + fi + + # Install Kernel from hypriot comptabile with all Raspberry PI (dunno if its compatible with RPI4 - better compile your own kernel) + if [ "$SET_ARCH" = 32 ] && [ "$RPI_MODEL" != 4 ] ; then + # Create temporary directory for dl + temp_dir=$(as_nobody mktemp -d) + + # Fetch kernel + as_nobody wget -O "${temp_dir}"/kernel.deb -c "$RPI_32_KERNEL_URL" + + # Copy downloaded kernel package + mv "${temp_dir}"/kernel.deb "${R}"/tmp/kernel.deb + + # Set permissions + chown -R root:root "${R}"/tmp/kernel.deb + + # Install kernel + chroot_exec dpkg -i /tmp/kernel.deb + + # move /boot to /boot/firmware to fit script env. + #mkdir "${BOOT_DIR}" + mkdir "${temp_dir}"/firmware + mv "${R}"/boot/* "${temp_dir}"/firmware/ + mv "${temp_dir}"/firmware "${R}"/boot/ + + #same for kernel headers + if [ "$KERNEL_HEADERS" = true ] ; then + # Fetch kernel header + as_nobody wget -O "${temp_dir}"/kernel-header.deb -c "$RPI_32_KERNELHEADER_URL" + mv "${temp_dir}"/kernel-header.deb "${R}"/tmp/kernel-header.deb + chown -R root:root "${R}"/tmp/kernel-header.deb + # Install kernel header + chroot_exec dpkg -i /tmp/kernel-header.deb + rm -f "${R}"/tmp/kernel-header.deb + fi + + # Remove temporary directory and files + rm -fr "${temp_dir}" + rm -f "${R}"/tmp/kernel.deb + fi + + # Check if kernel installation was successful + KERNEL="$(ls -1 "${R}"/boot/firmware/kernel* | sort | tail -n 1)" + if [ -z "$KERNEL" ] ; then + echo "error: kernel installation failed! (/boot/kernel* not found)" + cleanup + exit 1 + fi +fi diff --git a/bootstrap.d/14-fstab.sh b/bootstrap.d/14-fstab.sh new file mode 100644 index 0000000..e408758 --- /dev/null +++ b/bootstrap.d/14-fstab.sh @@ -0,0 +1,120 @@ +# +# Setup fstab and initramfs +# + +# Load utility functions +. ./functions.sh + +# Install and setup fstab +install_readonly files/mount/fstab "${ETC_DIR}/fstab" + +# Generate initramfs file +if [ "$ENABLE_INITRAMFS" = true ] ; then + if [ "$ENABLE_CRYPTFS" = true ] ; then + + # Include initramfs scripts to auto expand encrypted root partition + if [ "$EXPANDROOT" = true ] ; then + install_exec files/initramfs/expand_encrypted_rootfs "${ETC_DIR}/initramfs-tools/scripts/init-premount/expand_encrypted_rootfs" + install_exec files/initramfs/expand-premount "${ETC_DIR}/initramfs-tools/scripts/local-premount/expand-premount" + install_exec files/initramfs/expand-tools "${ETC_DIR}/initramfs-tools/hooks/expand-tools" + fi + + # Replace fstab root partition with encrypted partition mapping + sed -i "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING}/" "${ETC_DIR}/fstab" + + # Add encrypted partition to crypttab and fstab + install_readonly files/mount/crypttab "${ETC_DIR}/crypttab" + echo "${CRYPTFS_MAPPING} /dev/mmcblk0p2 none luks,initramfs" >> "${ETC_DIR}/crypttab" + + if [ "$ENABLE_USBBOOT" = true ] && [ "$ENABLE_SPLITFS" = false ]; then + sed -i "s/mmcblk0p1/sda1/" "${ETC_DIR}/fstab" + # Add usb/sda2 disk to crypttab + sed -i "s/mmcblk0p2/sda2/" "${ETC_DIR}/crypttab" + fi + + # Add encrypted root partition to fstab and crypttab + if [ "$ENABLE_SPLITFS" = true ] && [ "$ENABLE_USBBOOT" = false ]; then + # Add usb/sda1 disk to crypttab + sed -i "s/mmcblk0p2/sda1/" "${ETC_DIR}/crypttab" + fi + + if [ "$CRYPTFS_DROPBEAR" = true ] ; then + if [ "$ENABLE_ETH_DHCP" = false ] ; then + # Get cdir from NET_ADDRESS e.g. 24 + cdir=$(printf "%s" "${NET_ETH_ADDRESS}" | cut -d '/' -f2) + + # Convert cdir ro netmask e.g. 24 to 255.255.255.0 + NET_MASK=$(cdr2mask "$cdir") + + # Write static ip settings to "${ETC_DIR}"/initramfs-tools/initramfs.conf + # ip=:::::: + sed -i "\$a\nIP=${NET_ETH_ADDRESS}::${NET_ETH_GATEWAY}:${NET_MASK}:${HOSTNAME}:" "${ETC_DIR}"/initramfs-tools/initramfs.conf + else + sed -i "\$a\nIP=::::${HOSTNAME}::dhcp" "${ETC_DIR}"/initramfs-tools/initramfs.conf + fi + + if [ -n "$CRYPTFS_DROPBEAR_PUBKEY" ] && [ -f "$CRYPTFS_DROPBEAR_PUBKEY" ] ; then + install_readonly "${CRYPTFS_DROPBEAR_PUBKEY}" "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub + cat "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub >> "${ETC_DIR}"/dropbear-initramfs/authorized_keys + else + # Create key + chroot_exec /usr/bin/dropbearkey -t rsa -f /etc/dropbear-initramfs/id_rsa.dropbear + + # Convert dropbear key to openssh key + chroot_exec /usr/lib/dropbear/dropbearconvert dropbear openssh /etc/dropbear-initramfs/id_rsa.dropbear /etc/dropbear-initramfs/id_rsa + + # Get Public Key Part + chroot_exec /usr/bin/dropbearkey -y -f /etc/dropbear-initramfs/id_rsa.dropbear | chroot_exec tee /etc/dropbear-initramfs/id_rsa.pub + + # Delete unwanted lines + sed -i '/Public/d' "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub + sed -i '/Fingerprint/d' "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub + + # Trust the new key + cat "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub > "${ETC_DIR}"/dropbear-initramfs/authorized_keys + + # Save Keys - convert with putty from rsa/openssh to puttkey + cp -f "${ETC_DIR}"/dropbear-initramfs/id_rsa "${BASEDIR}"/dropbear_initramfs_key.rsa + + # Get unlock script + install_exec files/initramfs/crypt_unlock.sh "${ETC_DIR}"/initramfs-tools/hooks/crypt_unlock.sh + + # Enable Dropbear inside initramfs + printf "#\n# DROPBEAR: [ y | n ]\n#\n\nDROPBEAR=y\n" >> "${ETC_DIR}/initramfs-tools/initramfs.conf" + + # Enable Dropbear inside initramfs + sed -i "54 i sleep 5" "${R}"/usr/share/initramfs-tools/scripts/init-premount/dropbear + fi + # CRYPTFSDROPBEAR=false + else + # Disable SSHD inside initramfs + printf "#\n# DROPBEAR: [ y | n ]\n#\n\nDROPBEAR=n\n" >> "${ETC_DIR}/initramfs-tools/initramfs.conf" + fi + + # Add cryptsetup modules to initramfs + #printf "#\n# CRYPTSETUP: [ y | n ]\n#\n\nCRYPTSETUP=y\n" >> "${ETC_DIR}/initramfs-tools/conf-hook" + + # Dummy mapping required by mkinitramfs + echo "0 1 crypt "${CRYPTFS_CIPHER}" ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0 7:0 4096" | chroot_exec dmsetup create "${CRYPTFS_MAPPING}" + + # Generate initramfs with encrypted root partition support + chroot_exec mkinitramfs -o "/boot/firmware/initramfs-${KERNEL_VERSION}" "${KERNEL_VERSION}" + + # Remove dummy mapping + chroot_exec cryptsetup close "${CRYPTFS_MAPPING}" + # CRYPTFS=false + else + #USB BOOT /boot on sda1 / on sda2 + if [ "$ENABLE_USBBOOT" = true ] ; then + sed -i "s/mmcblk0p1/sda1/" "${ETC_DIR}/fstab" + sed -i "s/mmcblk0p2/sda2/" "${ETC_DIR}/fstab" + fi + + # Add usb/sda disk root partition to fstab + if [ "$ENABLE_SPLITFS" = true ] ; then + sed -i "s/mmcblk0p2/sda1/" "${ETC_DIR}/fstab" + fi + # Generate initramfs without encrypted root partition support + chroot_exec mkinitramfs -o "/boot/firmware/initramfs-${KERNEL_VERSION}" "${KERNEL_VERSION}" + fi +fi diff --git a/bootstrap.d/15-rpi-config.sh b/bootstrap.d/15-rpi-config.sh new file mode 100644 index 0000000..df1630b --- /dev/null +++ b/bootstrap.d/15-rpi-config.sh @@ -0,0 +1,366 @@ +# +# Setup RPi2/3/4 config and cmdline +# + +# Load utility functions +. ./functions.sh + +if [ -n "$RPI_FIRMWARE_DIR" ] && [ -d "$RPI_FIRMWARE_DIR" ] ; then + # Install boot binaries from local directory + cp "${RPI_FIRMWARE_DIR}"/boot/bootcode.bin "${BOOT_DIR}"/bootcode.bin + cp "${RPI_FIRMWARE_DIR}"/boot/fixup.dat "${BOOT_DIR}"/fixup.dat + cp "${RPI_FIRMWARE_DIR}"/boot/fixup_cd.dat "${BOOT_DIR}"/fixup_cd.dat + cp "${RPI_FIRMWARE_DIR}"/boot/fixup_x.dat "${BOOT_DIR}"/fixup_x.dat + cp "${RPI_FIRMWARE_DIR}"/boot/start.elf "${BOOT_DIR}"/start.elf + cp "${RPI_FIRMWARE_DIR}"/boot/start_cd.elf "${BOOT_DIR}"/start_cd.elf + cp "${RPI_FIRMWARE_DIR}"/boot/start_x.elf "${BOOT_DIR}"/start_x.elf + cp "${RPI_FIRMWARE_DIR}"/boot/fixup4cd.dat "${BOOT_DIR}"/fixup4cd.dat + cp "${RPI_FIRMWARE_DIR}"/boot/fixup4.dat "${BOOT_DIR}"/fixup4.dat + cp "${RPI_FIRMWARE_DIR}"/boot/fixup4db.dat "${BOOT_DIR}"/fixup4db.dat + cp "${RPI_FIRMWARE_DIR}"/boot/fixup4x.dat "${BOOT_DIR}"/fixup4x.dat + cp "${RPI_FIRMWARE_DIR}"/boot/start4cd.elf "${BOOT_DIR}"/start4cd.elf + cp "${RPI_FIRMWARE_DIR}"/boot/start4db.elf "${BOOT_DIR}"/start4db.elf + cp "${RPI_FIRMWARE_DIR}"/boot/start4.elf "${BOOT_DIR}"/start4.elf + cp "${RPI_FIRMWARE_DIR}"/boot/start4x.elf "${BOOT_DIR}"/start4x.elf +else + # Create temporary directory for boot binaries + temp_dir=$(as_nobody mktemp -d) + + # Install latest boot binaries from raspberry/firmware github + as_nobody wget -q -O "${temp_dir}/bootcode.bin" "${FIRMWARE_URL}/bootcode.bin" + as_nobody wget -q -O "${temp_dir}/fixup.dat" "${FIRMWARE_URL}/fixup.dat" + as_nobody wget -q -O "${temp_dir}/fixup_cd.dat" "${FIRMWARE_URL}/fixup_cd.dat" + as_nobody wget -q -O "${temp_dir}/fixup_x.dat" "${FIRMWARE_URL}/fixup_x.dat" + as_nobody wget -q -O "${temp_dir}/start.elf" "${FIRMWARE_URL}/start.elf" + as_nobody wget -q -O "${temp_dir}/start_cd.elf" "${FIRMWARE_URL}/start_cd.elf" + as_nobody wget -q -O "${temp_dir}/start_x.elf" "${FIRMWARE_URL}/start_x.elf" + as_nobody wget -q -O "${temp_dir}/fixup4cd.dat" "${FIRMWARE_URL}/fixup4cd.dat" + as_nobody wget -q -O "${temp_dir}/fixup4.dat" "${FIRMWARE_URL}/fixup4.dat" + as_nobody wget -q -O "${temp_dir}/fixup4db.dat" "${FIRMWARE_URL}/fixup4db.dat" + as_nobody wget -q -O "${temp_dir}/fixup4x.dat" "${FIRMWARE_URL}/fixup4x.dat" + as_nobody wget -q -O "${temp_dir}/start4cd.elf" "${FIRMWARE_URL}/start4cd.elf" + as_nobody wget -q -O "${temp_dir}/start4db.elf" "${FIRMWARE_URL}/start4db.elf" + as_nobody wget -q -O "${temp_dir}/start4.elf" "${FIRMWARE_URL}/start4.elf" + as_nobody wget -q -O "${temp_dir}/start4x.elf" "${FIRMWARE_URL}/start4x.elf" + + as_nobody wget -q -O "${temp_dir}/bcm2708-rpi-b.dtb" "${FIRMWARE_URL}/bcm2708-rpi-b.dtb" + as_nobody wget -q -O "${temp_dir}/bcm2708-rpi-b-plus.dtb" "${FIRMWARE_URL}/bcm2708-rpi-b-plus.dtb" + as_nobody wget -q -O "${temp_dir}/bcm2708-rpi-b-rev1.dtb" "${FIRMWARE_URL}/bcm2708-rpi-b-rev1.dtb" + as_nobody wget -q -O "${temp_dir}/bcm2708-rpi-cm.dtb" "${FIRMWARE_URL}/bcm2708-rpi-cm.dtb" + as_nobody wget -q -O "${temp_dir}/bcm2708-rpi-zero.dtb" "${FIRMWARE_URL}/bcm2708-rpi-zero.dtb" + as_nobody wget -q -O "${temp_dir}/bcm2708-rpi-zero-w.dtb" "${FIRMWARE_URL}/bcm2708-rpi-zero-w.dtb" + as_nobody wget -q -O "${temp_dir}/bcm2709-rpi-2-b.dtb" "${FIRMWARE_URL}/bcm2709-rpi-2-b.dtb" + as_nobody wget -q -O "${temp_dir}/bcm2709-rpi-cm2.dtb" "${FIRMWARE_URL}/bcm2709-rpi-cm2.dtb" + as_nobody wget -q -O "${temp_dir}/bcm2710-rpi-2-b.dtb" "${FIRMWARE_URL}/bcm2710-rpi-2-b.dtb" + as_nobody wget -q -O "${temp_dir}/bcm2710-rpi-3-b.dtb" "${FIRMWARE_URL}/bcm2710-rpi-3-b.dtb" + as_nobody wget -q -O "${temp_dir}/bcm2710-rpi-3-b-plus.dtb" "${FIRMWARE_URL}/bcm2710-rpi-3-b-plus.dtb" + as_nobody wget -q -O "${temp_dir}/bcm2710-rpi-cm3.dtb" "${FIRMWARE_URL}/bcm2710-rpi-cm3.dtb" + as_nobody wget -q -O "${temp_dir}/bcm2710-rpi-zero-2.dtb" "${FIRMWARE_URL}/bcm2710-rpi-zero-2.dtb" + as_nobody wget -q -O "${temp_dir}/bcm2710-rpi-zero-2-w.dtb" "${FIRMWARE_URL}/bcm2710-rpi-zero-2-w.dtb" + as_nobody wget -q -O "${temp_dir}/bcm2711-rpi-400.dtb" "${FIRMWARE_URL}/bcm2711-rpi-400.dtb" + as_nobody wget -q -O "${temp_dir}/bcm2711-rpi-4-b.dtb" "${FIRMWARE_URL}/bcm2711-rpi-4-b.dtb" + as_nobody wget -q -O "${temp_dir}/bcm2711-rpi-cm4.dtb" "${FIRMWARE_URL}/bcm2711-rpi-cm4.dtb" + as_nobody wget -q -O "${temp_dir}/bcm2711-rpi-cm4-io.dtb" "${FIRMWARE_URL}/bcm2711-rpi-cm4-io.dtb" + as_nobody wget -q -O "${temp_dir}/bcm2711-rpi-cm4s.dtb" "${FIRMWARE_URL}/bcm2711-rpi-cm4s.dtb" + as_nobody wget -q -O "${temp_dir}/bcm2712d0-rpi-5-b.dtb" "${FIRMWARE_URL}/bcm2712d0-rpi-5-b.dtb" + as_nobody wget -q -O "${temp_dir}/bcm2712-rpi-5-b.dtb" "${FIRMWARE_URL}/bcm2712-rpi-5-b.dtb" + as_nobody wget -q -O "${temp_dir}/bcm2712-rpi-cm5-cm4io.dtb" "${FIRMWARE_URL}/bcm2712-rpi-cm5-cm4io.dtb" + as_nobody wget -q -O "${temp_dir}/bcm2712-rpi-cm5-cm5io.dtb" "${FIRMWARE_URL}/bcm2712-rpi-cm5-cm5io.dtb" + + + # Move downloaded boot binaries + mv "${temp_dir}/"* "${BOOT_DIR}/" + + # Remove temporary directory for boot binaries + rm -fr "${temp_dir}" + + # Set permissions of the boot binaries + chown -R root:root "${BOOT_DIR}" + chmod -R 600 "${BOOT_DIR}" +fi + +# Setup firmware boot cmdline +if [ "$ENABLE_USBBOOT" = true ] ; then + CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline console=tty1 rootwait init=/bin/systemd" +else + if [ "$ENABLE_SPLITFS" = true ] ; then + CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline console=tty1 rootwait init=/bin/systemd" + else + CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline console=tty1 rootwait init=/bin/systemd" + fi +fi + +# Add encrypted root partition to cmdline.txt +if [ "$ENABLE_CRYPTFS" = true ] ; then + if [ "$ENABLE_SPLITFS" = true ] ; then + CMDLINE=$(echo "${CMDLINE}" | sed "s/sda1/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda1:${CRYPTFS_MAPPING}/") + else + if [ "$ENABLE_USBBOOT" = true ] ; then + CMDLINE=$(echo "${CMDLINE}" | sed "s/sda2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda2:${CRYPTFS_MAPPING}/") + else + CMDLINE=$(echo "${CMDLINE}" | sed "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/mmcblk0p2:${CRYPTFS_MAPPING}/") + fi + fi +fi + +# Enable Kernel messages on standard output +if [ "$ENABLE_PRINTK" = true ] ; then + install_readonly files/sysctl.d/83-rpi-printk.conf "${ETC_DIR}/sysctl.d/83-rpi-printk.conf" +fi + +# Enable Kernel messages on standard output +if [ "$KERNEL_SECURITY" = true ] ; then + install_readonly files/sysctl.d/84-rpi-ASLR.conf "${ETC_DIR}/sysctl.d/84-rpi-ASLR.conf" +fi + +# Install udev rule for serial alias - serial0 = console serial1=bluetooth +install_readonly files/etc/99-com.rules "${LIB_DIR}/udev/rules.d/99-com.rules" + +# Remove IPv6 networking support +if [ "$ENABLE_IPV6" = false ] ; then + CMDLINE="${CMDLINE} ipv6.disable=1" +fi + +# Automatically assign predictable network interface names +if [ "$ENABLE_IFNAMES" = false ] ; then + CMDLINE="${CMDLINE} net.ifnames=0" +else + CMDLINE="${CMDLINE} net.ifnames=1" +fi + +# Disable Raspberry Pi console logo +if [ "$ENABLE_LOGO" = false ] ; then + CMDLINE="${CMDLINE} logo.nologo" +fi + +# Strictly limit verbosity of boot up console messages +if [ "$ENABLE_SILENT_BOOT" = true ] ; then + CMDLINE="${CMDLINE} quiet loglevel=0 rd.systemd.show_status=auto rd.udev.log_priority=0" +fi + +# Install firmware config +install_readonly files/boot/config.txt "${BOOT_DIR}/config.txt" + +# Disable Raspberry Pi console logo +if [ "$ENABLE_SPLASH" = false ] ; then + echo "disable_splash=1" >> "${BOOT_DIR}/config.txt" +fi + +# Locks CPU frequency at maximum +if [ "$ENABLE_TURBO" = true ] ; then + echo "force_turbo=1" >> "${BOOT_DIR}/config.txt" + # helps to avoid sdcard corruption when force_turbo is enabled. + echo "boot_delay=1" >> "${BOOT_DIR}/config.txt" +fi + +if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ]; then + + # Bluetooth enabled + if [ "$ENABLE_BLUETOOTH" = true ] ; then + # Create temporary directory for Bluetooth sources + temp_dir=$(as_nobody mktemp -d) + + # Fetch Bluetooth sources + as_nobody git -C "${temp_dir}" clone "${BLUETOOTH_URL}" + + # Copy downloaded sources + mv "${temp_dir}/pi-bluetooth" "${R}/tmp/" + + # Set permissions + chown -R root:root "${R}/tmp/pi-bluetooth" + + # Bluetooth firmware from arch aur https://aur.archlinux.org/packages/pi-bluetooth/ + wget -q -O "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" https://aur.archlinux.org/cgit/aur.git/plain/LICENCE.broadcom_bcm43xx?h=pi-bluetooth + wget -q -O "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" https://raw.githubusercontent.com/RPi-Distro/bluez-firmware/master/broadcom/BCM43430A1.hcd + + # Install tools + install_readonly "${R}/tmp/pi-bluetooth/usr/bin/btuart" "${R}/usr/bin/btuart" + install_readonly "${R}/tmp/pi-bluetooth/usr/bin/bthelper" "${R}/usr/bin/bthelper" + + # make scripts executable + chmod +x "${R}/usr/bin/bthelper" + chmod +x "${R}/usr/bin/btuart" + + # Install bluetooth udev rule + install_readonly "${R}/tmp/pi-bluetooth/lib/udev/rules.d/90-pi-bluetooth.rules" "${LIB_DIR}/udev/rules.d/90-pi-bluetooth.rules" + + # Install Firmware Flash file and apropiate licence + mkdir -p "$BLUETOOTH_FIRMWARE_DIR" + install_readonly "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" "${BLUETOOTH_FIRMWARE_DIR}/LICENCE.broadcom_bcm43xx" + install_readonly "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" "${BLUETOOTH_FIRMWARE_DIR}/BCM43430A1.hcd" + install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.bthelper@.service" "${ETC_DIR}/systemd/system/pi-bluetooth.bthelper@.service" + install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.hciuart.service" "${ETC_DIR}/systemd/system/pi-bluetooth.hciuart.service" + + # Remove temporary directories + rm -fr "${temp_dir}" + rm -fr "${R}"/tmp/pi-bluetooth + + # Switch Pi3 Bluetooth function to use the mini-UART (ttyS0) and restore UART0/ttyAMA0 over GPIOs 14 & 15. Slow Bluetooth and slow cpu. Use /dev/ttyS0 instead of /dev/ttyAMA0 + if [ "$ENABLE_MINIUART_OVERLAY" = true ] ; then + # set overlay to swap ttyAMA0 and ttyS0 + echo "dtoverlay=pi3-miniuart-bt" >> "${BOOT_DIR}/config.txt" + + if [ "$ENABLE_TURBO" = false ] ; then + echo "core_freq=250" >> "${BOOT_DIR}/config.txt" + fi + + fi + + # Activate services + chroot_exec systemctl enable pi-bluetooth.hciuart.service + + else # if ENABLE_BLUETOOTH = false + # set overlay to disable bluetooth + echo "dtoverlay=pi3-disable-bt" >> "${BOOT_DIR}/config.txt" + fi # ENABLE_BLUETOOTH end +fi + +# may need sudo systemctl disable hciuart +if [ "$ENABLE_CONSOLE" = true ] ; then + echo "enable_uart=1" >> "${BOOT_DIR}/config.txt" + #More debug output on early but with serial console + echo "uart_2ndstage=1" >> "${BOOT_DIR}/config.txt" + + # add string to cmdline + CMDLINE="${CMDLINE} console=serial0,115200" + + if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]|| [ "$RPI_MODEL" = 0 ]; then + # if force_turbo didn't lock cpu at high speed, lock it at low speed (XOR logic) or miniuart will be broken + if [ "$ENABLE_TURBO" = false ] ; then + echo "core_freq=250" >> "${BOOT_DIR}/config.txt" + fi + fi + + # Enable serial console systemd style + chroot_exec systemctl enable serial-getty@serial0.service +else + echo "enable_uart=0" >> "${BOOT_DIR}/config.txt" +fi + +# Disable dphys-swapfile service. Will get enabled on first boot +if [ "$ENABLE_DPHYSSWAP" = true ] ; then + chroot_exec systemctl disable dphys-swapfile +fi + +if [ "$ENABLE_SYSTEMDSWAP" = true ] ; then + # Create temporary directory for systemd-swap sources + temp_dir=$(as_nobody mktemp -d) + + # Fetch systemd-swap sources + as_nobody git -C "${temp_dir}" clone "${SYSTEMDSWAP_URL}" + + # Copy downloaded systemd-swap sources + mv "${temp_dir}/systemd-swap" "${R}/tmp/" + + # Change into downloaded src dir + cd "${R}/tmp/systemd-swap" || exit + + # Get Verion + VERSION=$(git tag | tail -n 1) + #sed -i "s/DEB_NAME=.*/DEB_NAME=systemd-swap_all/g" "${R}/tmp/systemd-swap/package.sh" + + # Build package + bash ./package.sh debian + + # Change back into script root dir + cd "${WORKDIR}" || exit + + # Set permissions of the systemd-swap sources + chown -R root:root "${R}/tmp/systemd-swap" + + # Install package - IMPROVE AND MAKE IT POSSIBLE WITHOUT VERSION NR. + chroot_exec dpkg -i /tmp/systemd-swap/systemd-swap_"$VERSION"_all.deb + + # Enable service + chroot_exec systemctl enable systemd-swap + + # Remove temporary directory for systemd-swap sources + rm -fr "${temp_dir}" +else + # Enable ZSWAP in cmdline if systemd-swap is not used + if [ "$KERNEL_ZSWAP" = true ] ; then + CMDLINE="${CMDLINE} zswap.enabled=1 zswap.max_pool_percent=25 zswap.compressor=lz4" + fi +fi + if [ "$KERNEL_SECURITY" = true ] ; then + CMDLINE="${CMDLINE} apparmor=1 security=apparmor" + fi + +# Install firmware boot cmdline +echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt" + +# Setup minimal GPU memory allocation size: 16MB (no X) +if [ "$ENABLE_MINGPU" = true ] ; then + if [ "$ENABLE_GR_ACCEL" = false ] ; then + echo "gpu_mem=16" >> "${BOOT_DIR}/config.txt" + else + ### Cannot reduce memory if graphics acceleration is requested + echo "gpu_mem=128" >> "${BOOT_DIR}/config.txt" + fi +fi + +# Setup boot with initramfs +if [ "$ENABLE_INITRAMFS" = true ] ; then + echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOT_DIR}/config.txt" +fi + +# Create firmware configuration and cmdline symlinks +ln -sf firmware/config.txt "${R}/boot/config.txt" +ln -sf firmware/cmdline.txt "${R}/boot/cmdline.txt" + +# Install and setup kernel modules to load at boot +mkdir -p "${LIB_DIR}/modules-load.d/" +install_readonly files/modules/rpi2.conf "${LIB_DIR}/modules-load.d/rpi2.conf" + +# Load hardware random module at boot +if [ "$ENABLE_HWRANDOM" = true ] && [ "$BUILD_KERNEL" = false ] ; then + sed -i "s/^# bcm2708_rng/bcm2708_rng/" "${LIB_DIR}/modules-load.d/rpi2.conf" +fi + +# Load sound module at boot +if [ "$ENABLE_SOUND" = true ] ; then + sed -i "s/^# snd_bcm2835/snd_bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf" +else + echo "dtparam=audio=off" >> "${BOOT_DIR}/config.txt" +fi + +# Enable I2C interface +if [ "$ENABLE_I2C" = true ] ; then + echo "dtparam=i2c_arm=on" >> "${BOOT_DIR}/config.txt" + sed -i "s/^# i2c-bcm2708/i2c-bcm2708/" "${LIB_DIR}/modules-load.d/rpi2.conf" + sed -i "s/^# i2c-dev/i2c-dev/" "${LIB_DIR}/modules-load.d/rpi2.conf" +fi + +# Enable SPI interface +if [ "$ENABLE_SPI" = true ] ; then + echo "dtparam=spi=on" >> "${BOOT_DIR}/config.txt" + echo "spi-bcm2708" >> "${LIB_DIR}/modules-load.d/rpi2.conf" + if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]; then + sed -i "s/spi-bcm2708/spi-bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf" + fi +fi + +# Disable RPi2/3 under-voltage warnings +if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then + echo "avoid_warnings=${DISABLE_UNDERVOLT_WARNINGS}" >> "${BOOT_DIR}/config.txt" +fi + +#Enable graphics acceleration for Model 4 +if [ "$RPI_MODEL" = 4 ] && [ "$ENABLE_GR_ACCEL" = true ] ; then + echo "max_framebuffers=2" >> "${BOOT_DIR}/config.txt" + echo "arm_64bit=1" >> "${BOOT_DIR}/config.txt" + echo "cmdline=cmdline.txt" >> "${BOOT_DIR}/config.txt" + echo "dtparam=audio=on" >> "${BOOT_DIR}/config.txt" + if [ "$ENABLE_MINGPU" = false ] ; then + echo "gpu_mem=128" >> "${BOOT_DIR}/config.txt" + fi + echo "dtoverlay=vc4-fkms-v3d, cma-128" >> "${BOOT_DIR}/config.txt" +fi + + +# Install kernel modules blacklist +mkdir -p "${ETC_DIR}/modprobe.d/" +install_readonly files/modules/raspi-blacklist.conf "${ETC_DIR}/modprobe.d/raspi-blacklist.conf" + +# Install sysctl.d configuration files +install_readonly files/sysctl.d/81-rpi-vm.conf "${ETC_DIR}/sysctl.d/81-rpi-vm.conf" diff --git a/bootstrap.d/20-networking.sh b/bootstrap.d/20-networking.sh new file mode 100644 index 0000000..6a54457 --- /dev/null +++ b/bootstrap.d/20-networking.sh @@ -0,0 +1,189 @@ +# +# Setup Networking +# + +# Load utility functions +. ./functions.sh + +# Install and setup hostname +install_readonly files/network/hostname "${ETC_DIR}/hostname" +sed -i "s/^RaspberryPI/${HOSTNAME}/" "${ETC_DIR}/hostname" + +# Install and setup hosts +install_readonly files/network/hosts "${ETC_DIR}/hosts" +sed -i "s/RaspberryPI/${HOSTNAME}/" "${ETC_DIR}/hosts" + +# Ensure /etc/systemd/network directory is available +mkdir -p "${ETC_DIR}/systemd/network" + +# Setup hostname entry with static IP +if [ "$NET_ETH_ADDRESS" != "" ] ; then + NET_IP=$(echo "${NET_ETH_ADDRESS}" | cut -f 1 -d'/') + sed -i "s/^127.0.1.1/${NET_IP}/" "${ETC_DIR}/hosts" +fi + +# Remove IPv6 hosts +if [ "$ENABLE_IPV6" = false ] ; then + sed -i -e "/::[1-9]/d" -e "/^$/d" "${ETC_DIR}/hosts" +fi + +# Install hint about network configuration +install_readonly files/network/interfaces "${ETC_DIR}/network/interfaces" + +# Install configuration for interface eth0 +install_readonly files/network/eth0.network "${ETC_DIR}/systemd/network/eth0.network" + +if [ "$RPI_MODEL" = 3P ] ; then +printf "\n[Link]\nGenericReceiveOffload=off\nTCPSegmentationOffload=off\nGenericSegmentationOffload=off" >> "${ETC_DIR}/systemd/network/eth0.network" +fi + +# Install configuration for interface wl* +install_readonly files/network/wlan0.network "${ETC_DIR}/systemd/network/wlan0.network" + +#always with dhcp since wpa_supplicant integration is missing +sed -i -e "s/DHCP=.*/DHCP=yes/" -e "/DHCP/q" "${ETC_DIR}/systemd/network/wlan0.network" + +if [ "$ENABLE_ETH_DHCP" = true ] ; then + # Enable DHCP configuration for interface eth0 + sed -i -e "s/DHCP=.*/DHCP=yes/" -e "/DHCP/q" "${ETC_DIR}/systemd/network/eth0.network" + + # Set DHCP configuration to IPv4 only + if [ "$ENABLE_IPV6" = false ] ; then + sed -i "s/DHCP=.*/DHCP=v4/" "${ETC_DIR}/systemd/network/eth0.network" + sed '/IPv6PrivacyExtensions=true/d' "${ETC_DIR}/systemd/network/eth0.network" + fi + +else # ENABLE_ETH_DHCP=false + # Set static network configuration for interface eth0 + if [ -n NET_ETH_ADDRESS ] && [ -n NET_ETH_GATEWAY ] && [ -n NET_ETH_DNS_1 ] ; then + sed -i\ + -e "s|DHCP=.*|DHCP=no|"\ + -e "s|Address=\$|Address=${NET_ETH_ADDRESS}|"\ + -e "s|Gateway=\$|Gateway=${NET_ETH_GATEWAY}|"\ + -e "0,/DNS=\$/ s|DNS=\$|DNS=${NET_ETH_DNS_1}|"\ + -e "0,/DNS=\$/ s|DNS=\$|DNS=${NET_ETH_DNS_2}|"\ + -e "s|Domains=\$|Domains=${NET_ETH_DNS_DOMAINS}|"\ + -e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_ETH_NTP_1}|"\ + -e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_ETH_NTP_2}|"\ + "${ETC_DIR}/systemd/network/eth0.network" + fi +fi + + +if [ "$ENABLE_WIRELESS" = true ] ; then + mkdir -p "${ETC_DIR}/wpa_supplicant" + if [ "$ENABLE_WIFI_DHCP" = true ] ; then + # Enable DHCP configuration for interface eth0 + sed -i -e "s/DHCP=.*/DHCP=yes/" -e "/DHCP/q" "${ETC_DIR}/systemd/network/wlan0.network" + + # Set DHCP configuration to IPv4 only + if [ "$ENABLE_IPV6" = false ] ; then + sed -i "s/DHCP=.*/DHCP=v4/" "${ETC_DIR}/systemd/network/wlan0.network" + sed '/IPv6PrivacyExtensions=true/d' "${ETC_DIR}/systemd/network/wlan0.network" + fi + + else # ENABLE_WIFI_DHCP=false + # Set static network configuration for interface eth0 + if [ -n NET_WIFI_ADDRESS ] && [ -n NET_WIFI_GATEWAY ] && [ -n NET_WIFI_DNS_1 ] ; then + sed -i\ + -e "s|DHCP=.*|DHCP=no|"\ + -e "s|Address=\$|Address=${NET_WIFI_ADDRESS}|"\ + -e "s|Gateway=\$|Gateway=${NET_WIFI_GATEWAY}|"\ + -e "0,/DNS=\$/ s|DNS=\$|DNS=${NET_WIFI_DNS_1}|"\ + -e "0,/DNS=\$/ s|DNS=\$|DNS=${NET_WIFI_DNS_2}|"\ + -e "s|Domains=\$|Domains=${NET_WIFI_DNS_DOMAINS}|"\ + -e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_WIFI_NTP_1}|"\ + -e "0,/NTP=\$/ s|NTP=\$|NTP=${NET_WIFI_NTP_2}|"\ + "${ETC_DIR}/systemd/network/wlan0.network" + fi + fi + + if [ ! -z "$NET_WIFI_SSID" ] && [ ! -z "$NET_WIFI_PSK" ] ; then + chroot_exec printf " + ctrl_interface=/run/wpa_supplicant + update_config=1 + eapol_version=1 + ap_scan=1 + fast_reauth=1 + + " > "${ETC_DIR}/wpa_supplicant/wpa_supplicant-wlan0.conf" + + #Configure WPA_supplicant + chroot_exec wpa_passphrase "$NET_WIFI_SSID" "$NET_WIFI_PSK" >> "${ETC_DIR}/wpa_supplicant/wpa_supplicant-wlan0.conf" + + chroot_exec systemctl enable wpa_supplicant.service + chroot_exec systemctl enable wpa_supplicant@wlan0.service + fi + # Remove empty settings from wlan configuration + sed -i "/.*=\$/d" "${ETC_DIR}/systemd/network/wlan0.network" + # If WLAN is enabled copy wlan configuration too + mv -v "${ETC_DIR}/systemd/network/wlan0.network" "${LIB_DIR}/systemd/network/11-wlan0.network" +fi + +# Remove empty settings from network configuration +sed -i "/.*=\$/d" "${ETC_DIR}/systemd/network/eth0.network" + +# Move systemd network configuration if required by Debian release +mv -v "${ETC_DIR}/systemd/network/eth0.network" "${LIB_DIR}/systemd/network/10-eth0.network" + +#Clean up +rm -fr "${ETC_DIR}/systemd/network" + +# Enable systemd-networkd service +chroot_exec systemctl enable systemd-networkd + +# Install host.conf resolver configuration +install_readonly files/network/host.conf "${ETC_DIR}/host.conf" + +# Enable network stack hardening +if [ "$ENABLE_HARDNET" = true ] ; then + # Install sysctl.d configuration files + install_readonly files/sysctl.d/82-rpi-net-hardening.conf "${ETC_DIR}/sysctl.d/82-rpi-net-hardening.conf" + + # Setup resolver warnings about spoofed addresses + sed -i "s/^# spoof warn/spoof warn/" "${ETC_DIR}/host.conf" +fi + +# Enable time sync +if [ "$NET_NTP_1" != "" ] ; then + chroot_exec systemctl enable systemd-timesyncd.service +fi + +# Download the firmware binary blob required to use the RPi3 wireless interface +if [ "$ENABLE_WIRELESS" = true ] ; then + if [ ! -d "${WLAN_FIRMWARE_DIR}" ] ; then + mkdir -p "${WLAN_FIRMWARE_DIR}" + fi + + # Create temporary directory for firmware binary blob + temp_dir=$(as_nobody mktemp -d) + + # Fetch firmware binary blob for RPI3B+ or Pi4 + if [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then + # Fetch firmware binary blob for RPi3P + as_nobody wget -q -O "${temp_dir}/brcmfmac43455-sdio.bin" "${WLAN_FIRMWARE_URL}/brcmfmac43455-sdio.bin?raw=true" + as_nobody wget -q -O "${temp_dir}/brcmfmac43455-sdio.txt" "${WLAN_FIRMWARE_URL}/brcmfmac43455-sdio.txt?raw=true" + as_nobody wget -q -O "${temp_dir}/brcmfmac43455-sdio.clm_blob" "${WLAN_FIRMWARE_URL}/brcmfmac43455-sdio.clm_blob?raw=true" + + # Move downloaded firmware binary blob + mv "${temp_dir}/brcmfmac43455-sdio."* "${WLAN_FIRMWARE_DIR}/" + + # Set permissions of the firmware binary blob + chown root:root "${WLAN_FIRMWARE_DIR}/brcmfmac43455-sdio."* + chmod 600 "${WLAN_FIRMWARE_DIR}/brcmfmac43455-sdio."* + elif [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 0 ] ; then + # Fetch firmware binary blob for RPi3 + as_nobody wget -q -O "${temp_dir}/brcmfmac43430-sdio.bin" "${WLAN_FIRMWARE_URL}/brcmfmac43430-sdio.bin?raw=true" + as_nobody wget -q -O "${temp_dir}/brcmfmac43430-sdio.txt" "${WLAN_FIRMWARE_URL}/brcmfmac43430-sdio.txt?raw=true" + + # Move downloaded firmware binary blob + mv "${temp_dir}/brcmfmac43430-sdio."* "${WLAN_FIRMWARE_DIR}/" + + # Set permissions of the firmware binary blob + chown root:root "${WLAN_FIRMWARE_DIR}/brcmfmac43430-sdio."* + chmod 600 "${WLAN_FIRMWARE_DIR}/brcmfmac43430-sdio."* + fi + + # Remove temporary directory for firmware binary blob + rm -fr "${temp_dir}" +fi diff --git a/bootstrap.d/21-firewall.sh b/bootstrap.d/21-firewall.sh new file mode 100644 index 0000000..e8e9707 --- /dev/null +++ b/bootstrap.d/21-firewall.sh @@ -0,0 +1,54 @@ +# +# Setup Firewall +# + +# Load utility functions +. ./functions.sh + +if [ "$ENABLE_IPTABLES" = true ] ; then + # Create iptables configuration directory + mkdir -p "${ETC_DIR}/iptables" + + if [ "$KERNEL_NF" = false ] ; then + # iptables-save and -restore are slaves of iptables and thus are set accordingly + chroot_exec update-alternatives --verbose --set iptables /usr/sbin/iptables-legacy + fi + + # Install iptables systemd service + install_readonly files/iptables/iptables.service "${ETC_DIR}/systemd/system/iptables.service" + + # Install flush-table script called by iptables service + install_exec files/iptables/flush-iptables.sh "${ETC_DIR}/iptables/flush-iptables.sh" + + # Install iptables rule file + install_readonly files/iptables/iptables.rules "${ETC_DIR}/iptables/iptables.rules" + + # Reload systemd configuration and enable iptables service + chroot_exec systemctl daemon-reload + chroot_exec systemctl enable iptables.service + + if [ "$ENABLE_IPV6" = true ] ; then + if [ "$KERNEL_NF" = false ] ; then + # iptables-save and -restore are slaves of iptables and thus are set accordingly + chroot_exec update-alternatives --verbose --set ip6tables /usr/sbin/ip6tables-legacy + fi + + # Install ip6tables systemd service + install_readonly files/iptables/ip6tables.service "${ETC_DIR}/systemd/system/ip6tables.service" + + # Install ip6tables file + install_exec files/iptables/flush-ip6tables.sh "${ETC_DIR}/iptables/flush-ip6tables.sh" + + install_readonly files/iptables/ip6tables.rules "${ETC_DIR}/iptables/ip6tables.rules" + + # Reload systemd configuration and enable iptables service + chroot_exec systemctl daemon-reload + chroot_exec systemctl enable ip6tables.service + fi + + if [ "$SSH_ENABLE" = false ] ; then + # Remove SSHD related iptables rules + sed -i "/^#/! {/SSH/ s/^/# /}" "${ETC_DIR}/iptables/iptables.rules" 2> /dev/null + sed -i "/^#/! {/SSH/ s/^/# /}" "${ETC_DIR}/iptables/ip6tables.rules" 2> /dev/null + fi +fi diff --git a/bootstrap.d/30-security.sh b/bootstrap.d/30-security.sh new file mode 100644 index 0000000..16d78c3 --- /dev/null +++ b/bootstrap.d/30-security.sh @@ -0,0 +1,24 @@ +# +# Setup users and security settings +# + +# Load utility functions +. ./functions.sh + +# Generate crypt(3) password string +ENCRYPTED_PASSWORD=$(mkpasswd -m sha-512 "${ROOT_PASSWORD}") +ENCRYPTED_USER_PASSWORD=$(mkpasswd -m sha-512 "${USER_PASSWORD}") + +# Setup default user +if [ "$ENABLE_USER" = true ] ; then + chroot_exec adduser --gecos "$USER_NAME" --add_extra_groups --disabled-password "$USER_NAME" + chroot_exec usermod -a -G sudo -p "${ENCRYPTED_USER_PASSWORD}" "$USER_NAME" +fi + +# Setup root password or not +if [ "$ENABLE_ROOT" = true ] ; then + chroot_exec usermod -p "${ENCRYPTED_PASSWORD}" root +else + # Set no root password to disable root login + chroot_exec usermod -p \'!\' root +fi diff --git a/bootstrap.d/31-logging.sh b/bootstrap.d/31-logging.sh new file mode 100644 index 0000000..0e2415e --- /dev/null +++ b/bootstrap.d/31-logging.sh @@ -0,0 +1,13 @@ +# +# Setup Logging +# + +# Load utility functions +. ./functions.sh + +# Disable rsyslog +if [ "$ENABLE_RSYSLOG" = false ] ; then + sed -i "s|[#]*ForwardToSyslog=yes|ForwardToSyslog=no|g" "${ETC_DIR}/systemd/journald.conf" + chroot_exec systemctl disable rsyslog + chroot_exec apt-get -qq -y purge rsyslog +fi diff --git a/bootstrap.d/32-sshd.sh b/bootstrap.d/32-sshd.sh new file mode 100644 index 0000000..c439a1e --- /dev/null +++ b/bootstrap.d/32-sshd.sh @@ -0,0 +1,116 @@ +# +# Setup SSH settings and public keys +# + +# Load utility functions +. ./functions.sh + +if [ "$SSH_ENABLE" = true ] ; then + DROPBEAR_ARGS="" + + if [ "$SSH_ENABLE_ROOT" = false ] ; then + if [ "$ENABLE_REDUCE" = false ] || [ "$REDUCE_SSHD" = false ] ; then + # User root is not allowed to log in + sed -i "s|[#]*PermitRootLogin.*|PermitRootLogin no|g" "${ETC_DIR}/ssh/sshd_config" + else + # User root is not allowed to log in + DROPBEAR_ARGS="-w" + fi + fi + + if [ "$ENABLE_ROOT" = true ] && [ "$SSH_ENABLE_ROOT" = true ] ; then + if [ "$ENABLE_REDUCE" = false ] || [ "$REDUCE_SSHD" = false ] ; then + # Permit SSH root login + sed -i "s|[#]*PermitRootLogin.*|PermitRootLogin yes|g" "${ETC_DIR}/ssh/sshd_config" + else + # Permit SSH root login + DROPBEAR_ARGS="" + fi + + # Add SSH (v2) public key for user root + if [ -n "$SSH_ROOT_PUB_KEY" ] ; then + # Create root SSH config directory + mkdir -p "${R}/root/.ssh" + + # Set permissions of root SSH config directory + chroot_exec chmod 700 "/root/.ssh" + chroot_exec chown root:root "/root/.ssh" + + # Add SSH (v2) public key(s) to authorized_keys file + cat "$SSH_ROOT_PUB_KEY" >> "${R}/root/.ssh/authorized_keys" + + # Set permissions of root SSH authorized_keys file + chroot_exec chmod 600 "/root/.ssh/authorized_keys" + chroot_exec chown root:root "/root/.ssh/authorized_keys" + + if [ "$ENABLE_REDUCE" = false ] || [ "$REDUCE_SSHD" = false ] ; then + # Allow SSH public key authentication + sed -i "s|[#]*PubkeyAuthentication.*|PubkeyAuthentication yes|g" "${ETC_DIR}/ssh/sshd_config" + fi + fi + fi + + if [ "$ENABLE_USER" = true ] ; then + # Add SSH (v2) public key for user $USER_NAME + if [ -n "$SSH_USER_PUB_KEY" ] ; then + # Create $USER_NAME SSH config directory + mkdir -p "${R}/home/${USER_NAME}/.ssh" + + # Set permissions of $USER_NAME SSH config directory + chroot_exec chmod 700 "/home/${USER_NAME}/.ssh" + chroot_exec chown "${USER_NAME}":"${USER_NAME}" "/home/${USER_NAME}/.ssh" + + # Add SSH (v2) public key(s) to authorized_keys file + cat "$SSH_USER_PUB_KEY" >> "${R}/home/${USER_NAME}/.ssh/authorized_keys" + + # Set permissions of $USER_NAME SSH config directory + chroot_exec chmod 600 "/home/${USER_NAME}/.ssh/authorized_keys" + chroot_exec chown "${USER_NAME}":"${USER_NAME}" "/home/${USER_NAME}/.ssh/authorized_keys" + + if [ "$ENABLE_REDUCE" = false ] || [ "$REDUCE_SSHD" = false ] ; then + # Allow SSH public key authentication + sed -i "s|[#]*PubkeyAuthentication.*|PubkeyAuthentication yes|g" "${ETC_DIR}/ssh/sshd_config" + fi + fi + fi + + # Limit the users that are allowed to login via SSH + if [ "$SSH_LIMIT_USERS" = true ] && [ "$ENABLE_REDUCE" = false ] ; then + allowed_users="" + if [ "$ENABLE_ROOT" = true ] && [ "$SSH_ENABLE_ROOT" = true ] ; then + allowed_users="root" + fi + + if [ "$ENABLE_USER" = true ] ; then + allowed_users="${allowed_users} ${USER_NAME}" + fi + + if [ -n "$allowed_users" ] ; then + echo "AllowUsers ${allowed_users}" >> "${ETC_DIR}/ssh/sshd_config" + fi + fi + + # Disable password-based authentication + if [ "$SSH_DISABLE_PASSWORD_AUTH" = true ] ; then + if [ "$ENABLE_ROOT" = true ] && [ "$SSH_ENABLE_ROOT" = true ] ; then + if [ "$ENABLE_REDUCE" = false ] || [ "$REDUCE_SSHD" = false ] ; then + sed -i "s|[#]*PermitRootLogin.*|PermitRootLogin without-password|g" "${ETC_DIR}/ssh/sshd_config" + else + DROPBEAR_ARGS="-g" + fi + fi + + if [ "$ENABLE_REDUCE" = false ] || [ "$REDUCE_SSHD" = false ] ; then + sed -i "s|[#]*PasswordAuthentication.*|PasswordAuthentication no|g" "${ETC_DIR}/ssh/sshd_config" + sed -i "s|[#]*ChallengeResponseAuthentication no.*|ChallengeResponseAuthentication no|g" "${ETC_DIR}/ssh/sshd_config" + sed -i "s|[#]*UsePAM.*|UsePAM no|g" "${ETC_DIR}/ssh/sshd_config" + else + DROPBEAR_ARGS="${DROPBEAR_ARGS} -s" + fi + fi + + # Update dropbear SSH configuration + if [ "$ENABLE_REDUCE" = true ] && [ "$REDUCE_SSHD" = true ] ; then + sed "s|^DROPBEAR_EXTRA_ARGS=.*|DROPBEAR_EXTRA_ARGS=\"${DROPBEAR_ARGS}\"|g" "${ETC_DIR}/default/dropbear" + fi +fi \ No newline at end of file diff --git a/bootstrap.d/41-uboot.sh b/bootstrap.d/41-uboot.sh new file mode 100644 index 0000000..56fca4e --- /dev/null +++ b/bootstrap.d/41-uboot.sh @@ -0,0 +1,105 @@ +# +# Build and Setup U-Boot +# + +# Load utility functions +. ./functions.sh + +# Fetch and build U-Boot bootloader +if [ "$ENABLE_UBOOT" = true ] ; then + # Install c/c++ build environment inside the chroot + chroot_install_cc + + # Copy existing U-Boot sources into chroot directory + if [ -n "$UBOOTSRC_DIR" ] && [ -d "$UBOOTSRC_DIR" ] ; then + # Copy local U-Boot sources + cp -r "${UBOOTSRC_DIR}" "${R}/tmp" + else + # Create temporary directory for U-Boot sources + temp_dir=$(as_nobody mktemp -d) + + # Fetch U-Boot sources + as_nobody git -C "${temp_dir}" clone "${UBOOT_URL}" + + # Copy downloaded U-Boot sources + mv "${temp_dir}/u-boot" "${R}/tmp/" + + # Set permissions of the U-Boot sources + chown -R root:root "${R}/tmp/u-boot" + + # Remove temporary directory for U-Boot sources + rm -fr "${temp_dir}" + fi + + # Build and install U-Boot inside chroot + chroot_exec make -j"${KERNEL_THREADS}" -C /tmp/u-boot/ "${UBOOT_CONFIG}" all + + # Copy compiled bootloader binary and set config.txt to load it + install_exec "${R}/tmp/u-boot/tools/mkimage" "${R}/usr/sbin/mkimage" + install_readonly "${R}/tmp/u-boot/u-boot.bin" "${BOOT_DIR}/u-boot.bin" + printf "\n# boot u-boot kernel\nkernel=u-boot.bin\n" >> "${BOOT_DIR}/config.txt" + + # Install and setup U-Boot command file + install_readonly files/boot/uboot.mkimage "${BOOT_DIR}/uboot.mkimage" + printf "# Set the kernel boot command line\nsetenv bootargs \"earlyprintk ${CMDLINE}\"\n\n$(cat "${BOOT_DIR}"/uboot.mkimage)" > "${BOOT_DIR}/uboot.mkimage" + + if [ "$ENABLE_INITRAMFS" = true ] ; then + # Convert generated initramfs for U-Boot using mkimage + chroot_exec /usr/sbin/mkimage -A "${KERNEL_ARCH}" -T ramdisk -C none -n "initramfs-${KERNEL_VERSION}" -d "/boot/firmware/initramfs-${KERNEL_VERSION}" "/boot/firmware/initramfs-${KERNEL_VERSION}.uboot" + + # Remove original initramfs file + rm -f "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" + + # Configure U-Boot to load generated initramfs + printf "# Set initramfs file\nsetenv initramfs initramfs-${KERNEL_VERSION}.uboot\n\n$(cat "${BOOT_DIR}"/uboot.mkimage)" > "${BOOT_DIR}/uboot.mkimage" + printf "\nbootz \${kernel_addr_r} \${ramdisk_addr_r} \${fdt_addr_r}" >> "${BOOT_DIR}/uboot.mkimage" + else # ENABLE_INITRAMFS=false + # Remove initramfs from U-Boot mkfile + sed -i '/.*initramfs.*/d' "${BOOT_DIR}/uboot.mkimage" + + if [ "$BUILD_KERNEL" = false ] ; then + # Remove dtbfile from U-Boot mkfile + sed -i '/.*dtbfile.*/d' "${BOOT_DIR}/uboot.mkimage" + printf "\nbootz \${kernel_addr_r}" >> "${BOOT_DIR}/uboot.mkimage" + else + printf "\nbootz \${kernel_addr_r} - \${fdt_addr_r}" >> "${BOOT_DIR}/uboot.mkimage" + fi + fi + + if [ "$SET_ARCH" = 64 ] ; then + echo "Setting up config.txt to boot 64bit uboot" + { + printf "\n# 64bit-mode" + printf "\n# arm_control=0x200 is deprecated https://www.raspberrypi.org/documentation/configuration/config-txt/misc.md" + printf "\narm_64bit=1" + } >> "${BOOT_DIR}/config.txt" + + #in 64bit uboot booti is used instead of bootz [like in KERNEL_BIN_IMAGE=zImage (armv7)|| Image(armv8)] + sed -i "s|bootz|booti|g" "${BOOT_DIR}/uboot.mkimage" + fi + + # instead of sd, boot from usb device + if [ "$ENABLE_USBBOOT" = true ] ; then + sed -i "s|mmc|usb|g" "${BOOT_DIR}/uboot.mkimage" + fi + + # Set mkfile to use the correct dtb file + sed -i "s|bcm2709-rpi-2-b.dtb|${DTB_FILE}|" "${BOOT_DIR}/uboot.mkimage" + + # Set mkfile to use the correct mach id + if [ "$ENABLE_QEMU" = true ] ; then + sed -i "s/^\(setenv machid \).*/\10x000008e0/" "${BOOT_DIR}/uboot.mkimage" + fi + + # Set mkfile to use kernel image + sed -i "s|kernel7.img|${KERNEL_IMAGE}|" "${BOOT_DIR}/uboot.mkimage" + + # Remove all leading blank lines + sed -i "/./,\$!d" "${BOOT_DIR}/uboot.mkimage" + + # Generate U-Boot bootloader image + chroot_exec /usr/sbin/mkimage -A "${KERNEL_ARCH}" -O linux -T script -C none -a 0x00000000 -e 0x00000000 -n "RPi${RPI_MODEL}" -d /boot/firmware/uboot.mkimage /boot/firmware/boot.scr + + # Remove U-Boot sources + rm -fr "${R}/tmp/u-boot" +fi diff --git a/bootstrap.d/42-fbturbo.sh b/bootstrap.d/42-fbturbo.sh new file mode 100644 index 0000000..828dbfc --- /dev/null +++ b/bootstrap.d/42-fbturbo.sh @@ -0,0 +1,47 @@ +# +# Build and Setup fbturbo Xorg driver +# + +# Load utility functions +. ./functions.sh + +if [ "$ENABLE_FBTURBO" = true ] && [ "$ENABLE_GR_ACCEL" = false ] ; then + # Install c/c++ build environment inside the chroot + chroot_install_cc + + # Copy existing fbturbo sources into chroot directory + if [ -n "$FBTURBOSRC_DIR" ] && [ -d "$FBTURBOSRC_DIR" ] ; then + # Copy local fbturbo sources + cp -r "${FBTURBOSRC_DIR}" "${R}/tmp" + else + # Create temporary directory for fbturbo sources + temp_dir=$(as_nobody mktemp -d) + + # Fetch fbturbo sources + as_nobody git -C "${temp_dir}" clone "${FBTURBO_URL}" + + # Move downloaded fbturbo sources + mv "${temp_dir}/xf86-video-fbturbo" "${R}/tmp/" + + # Remove temporary directory for fbturbo sources + rm -fr "${temp_dir}" + fi + + # Install Xorg build dependencies + chroot_exec apt-get -q -y --no-install-recommends --allow-unauthenticated install xorg-dev xutils-dev x11proto-dri2-dev libltdl-dev libtool automake libdrm-dev + + # Build and install fbturbo driver inside chroot + chroot_exec /bin/bash -x <<'EOF' +cd /tmp/xf86-video-fbturbo +autoreconf -vi +./configure --prefix=/usr +make +make install +EOF + + # Install fbturbo driver Xorg configuration + install_readonly files/xorg/99-fbturbo.conf "${R}/usr/share/X11/xorg.conf.d/99-fbturbo.conf" + + # Remove Xorg build dependencies + chroot_exec apt-get -qq -y --auto-remove purge xorg-dev xutils-dev x11proto-dri2-dev libltdl-dev libtool automake libdrm-dev +fi diff --git a/bootstrap.d/43-videocore.sh b/bootstrap.d/43-videocore.sh new file mode 100644 index 0000000..b0d7a58 --- /dev/null +++ b/bootstrap.d/43-videocore.sh @@ -0,0 +1,56 @@ +# +# Setup videocore - Raspberry Userland +# + +# Load utility functions +. ./functions.sh + +if [ "$ENABLE_VIDEOCORE" = true ] ; then + # Copy existing videocore sources into chroot directory + if [ -n "$VIDEOCORESRC_DIR" ] && [ -d "$VIDEOCORESRC_DIR" ] ; then + # Copy local videocore sources + cp -r "${VIDEOCORESRC_DIR}" "${R}/tmp/userland" + else + # Create temporary directory for videocore sources + temp_dir=$(as_nobody mktemp -d) + + # Fetch videocore sources + as_nobody git -C "${temp_dir}" clone "${VIDEOCORE_URL}" + + # Copy downloaded videocore sources + mv "${temp_dir}/userland" "${R}/tmp/" + + # Set permissions of the U-Boot sources + chown -R root:root "${R}/tmp/userland" + + # Remove temporary directory for U-Boot sources + rm -fr "${temp_dir}" + fi + + # Create build dir + mkdir "${R}"/tmp/userland/build + + # push us to build directory + cd "${R}"/tmp/userland/build + + if [ "$RELEASE_ARCH" = "arm64" ] ; then + cmake -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_BUILD_TYPE=release -DCMAKE_TOOLCHAIN_FILE="${R}"/tmp/userland/makefiles/cmake/toolchains/aarch64-linux-gnu.cmake -DARM64=ON -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ -DCMAKE_ASM_COMPILER=aarch64-linux-gnu-gcc -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -U_FORTIFY_SOURCE" -DCMAKE_ASM_FLAGS="${CMAKE_ASM_FLAGS} -c" -DVIDEOCORE_BUILD_DIR="${R}" "${R}/tmp/userland" + fi + + if [ "$RELEASE_ARCH" = "armel" ] ; then + cmake -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_BUILD_TYPE=release -DCMAKE_TOOLCHAIN_FILE="${R}"/tmp/userland/makefiles/cmake/toolchains/arm-linux-gnueabihf.cmake -DCMAKE_C_COMPILER=arm-linux-gnueabi-gcc -DCMAKE_CXX_COMPILER=arm-linux-gnueabi-g++ -DCMAKE_ASM_COMPILER=arm-linux-gnueabi-gcc -DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -U_FORTIFY_SOURCE" -DCMAKE_ASM_FLAGS="${CMAKE_ASM_FLAGS} -c" -DCMAKE_SYSTEM_PROCESSOR="arm" -DVIDEOCORE_BUILD_DIR="${R}" "${R}/tmp/userland" + fi + + if [ "$RELEASE_ARCH" = "armhf" ] ; then + cmake -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_BUILD_TYPE=release -DCMAKE_TOOLCHAIN_FILE="${R}"/tmp/userland/makefiles/cmake/toolchains/arm-linux-gnueabihf.cmake -DVIDEOCORE_BUILD_DIR="${R}" "${R}/tmp/userland" + fi + + #build userland + make -j "$(nproc)" + + #back to root of scriptdir + cd "${WORKDIR}" + + # Remove videocore sources + rm -fr "${R}"/tmp/userland/ +fi diff --git a/bootstrap.d/44-nexmon_monitor_patch.sh b/bootstrap.d/44-nexmon_monitor_patch.sh new file mode 100644 index 0000000..1dc17b1 --- /dev/null +++ b/bootstrap.d/44-nexmon_monitor_patch.sh @@ -0,0 +1,97 @@ +#!/bin/sh +# +# Build and Setup nexmon with monitor mode patch +# + +# Load utility functions +. ./functions.sh + +if [ "$ENABLE_NEXMON" = true ] && [ "$ENABLE_WIRELESS" = true ]; then + # Copy existing nexmon sources into chroot directory + if [ -n "$NEXMONSRC_DIR" ] && [ -d "$NEXMONSRC_DIR" ] ; then + # Copy local U-Boot sources + cp -r "${NEXMONSRC_DIR}" "${R}/tmp" + else + # Create temporary directory for nexmon sources + temp_dir=$(as_nobody mktemp -d) + + # Fetch nexmon sources + as_nobody git -C "${temp_dir}" clone "${NEXMON_URL}" + + # Copy downloaded nexmon sources + mv "${temp_dir}/nexmon" "${R}"/tmp/ + + # Set permissions of the nexmon sources + chown -R root:root "${R}"/tmp/nexmon + + # Remove temporary directory for nexmon sources + rm -fr "${temp_dir}" + fi + + # Set script Root + export NEXMON_ROOT="${R}"/tmp/nexmon + + # Build nexmon firmware outside the build system, if we can. + cd "${NEXMON_ROOT}" || exit + + # Make ancient isl build + cd buildtools/isl-0.10 || exit + ./configure + make + cd ../.. || exit + + # Disable statistics + touch DISABLE_STATISTICS + + # Setup Enviroment: see https://github.com/NoobieDog/nexmon/blob/master/setup_env.sh + export KERNEL="${KERNEL_IMAGE}" + export ARCH=arm + export SUBARCH=arm + export CC="${NEXMON_ROOT}"/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi- + export CC="${CC}"gcc + export CCPLUGIN="${NEXMON_ROOT}"/buildtools/gcc-nexmon-plugin/nexmon.so + export ZLIBFLATE="zlib-flate -compress" + export Q=@ + export NEXMON_SETUP_ENV=1 + export HOSTUNAME=$(uname -s) + export PLATFORMUNAME=$(uname -m) + + # Make nexmon + make + + # build patches + if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] ; then + cd "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon || exit + sed -i -e 's/all:.*/all: $(RAM_FILE)/g' ${NEXMON_ROOT}/patches/bcm43430a1/7_45_41_46/nexmon/Makefile + make clean + + # We do this so we don't have to install the ancient isl version into /usr/local/lib on systems. + LD_LIBRARY_PATH="${NEXMON_ROOT}"/buildtools/isl-0.10/.libs make ARCH="${KERNEL_ARCH}" CC="${NEXMON_ROOT}"/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi- + + # copy RPi0W & RPi3 firmware + mv "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.org.bin + cp "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon/brcmfmac43430-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.nexmon.bin + cp -f "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon/brcmfmac43430-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.bin + fi + + if [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then + cd "${NEXMON_ROOT}"/patches/bcm43455c0/7_45_154/nexmon || exit + sed -i -e 's/all:.*/all: $(RAM_FILE)/g' ${NEXMON_ROOT}/patches/bcm43455c0/7_45_154/nexmon/Makefile + make clean + + # We do this so we don't have to install the ancient isl version into /usr/local/lib on systems. + LD_LIBRARY_PATH=${NEXMON_ROOT}/buildtools/isl-0.10/.libs make ARCH="${KERNEL_ARCH}" CC="${NEXMON_ROOT}"/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi- + + # RPi3B+ firmware + mv "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.org.bin + cp "${NEXMON_ROOT}"/patches/bcm43455c0/7_45_154/nexmon/brcmfmac43455-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.nexmon.bin + cp -f "${NEXMON_ROOT}"/patches/bcm43455c0/7_45_154/nexmon/brcmfmac43455-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.bin + fi + +#Revert to previous directory +cd "${WORKDIR}" || exit + +# Remove nexmon sources +rm -fr "${NEXMON_ROOT}" + +fi diff --git a/bootstrap.d/50-firstboot.sh b/bootstrap.d/50-firstboot.sh new file mode 100644 index 0000000..0239524 --- /dev/null +++ b/bootstrap.d/50-firstboot.sh @@ -0,0 +1,63 @@ +# +# First boot actions +# + +# Load utility functions +. ./functions.sh + +# Prepare rc.firstboot script +cat files/firstboot/10-begin.sh > "${ETC_DIR}/rc.firstboot" + +# Prepare filesystem auto expand +if [ "$EXPANDROOT" = true ] ; then + if [ "$ENABLE_CRYPTFS" = false ] ; then + cat files/firstboot/20-expandroot.sh >> "${ETC_DIR}/rc.firstboot" + else + # Regenerate initramfs to remove encrypted root partition auto expand + cat files/firstboot/21-regenerate-initramfs.sh >> "${ETC_DIR}/rc.firstboot" + fi + + # Restart dphys-swapfile so the size of the swap file is relative to the resized root partition + if [ "$ENABLE_DPHYSSWAP" = true ] ; then + cat files/firstboot/23-restart-dphys-swapfile.sh >> "${ETC_DIR}/rc.firstboot" + fi +fi + +# Ensure openssh server host keys are regenerated on first boot +if [ "$SSH_ENABLE" = true ] ; then + cat files/firstboot/30-generate-ssh-keys.sh >> "${ETC_DIR}/rc.firstboot" +fi + +if [ "$ENABLE_DBUS" = true ] ; then +# Ensure that dbus machine-id exists +cat files/firstboot/40-generate-machineid.sh >> "${ETC_DIR}/rc.firstboot" +fi + +# Create /etc/resolv.conf symlink +cat files/firstboot/41-create-resolv-symlink.sh >> "${ETC_DIR}/rc.firstboot" + +# Configure automatic network interface names +if [ "$ENABLE_IFNAMES" = true ] ; then + cat files/firstboot/42-config-ifnames.sh >> "${ETC_DIR}/rc.firstboot" +fi + +# Execute custom firstboot scripts +if [ -d "custom.d/firstboot" ] ; then + for SCRIPT in custom.d/firstboot/*.sh; do + . "$SCRIPT" + done +fi + +# Finalize rc.firstboot script +cat files/firstboot/99-finish.sh >> "${ETC_DIR}/rc.firstboot" +chmod +x "${ETC_DIR}/rc.firstboot" + +# Install default rc.local if it does not exist +if [ ! -f "${ETC_DIR}/rc.local" ] ; then + install_exec files/etc/rc.local "${ETC_DIR}/rc.local" +fi + +# Add rc.firstboot script to rc.local +sed -i '/exit 0/d' "${ETC_DIR}/rc.local" +echo /etc/rc.firstboot >> "${ETC_DIR}/rc.local" +echo exit 0 >> "${ETC_DIR}/rc.local" diff --git a/bootstrap.d/99-reduce.sh b/bootstrap.d/99-reduce.sh new file mode 100644 index 0000000..6feaf0f --- /dev/null +++ b/bootstrap.d/99-reduce.sh @@ -0,0 +1,105 @@ +# +# Reduce system disk usage +# + +# Load utility functions +. ./functions.sh + +if [ "$ENABLE_IPV6" = false ] ; then +"$LIB_DIR"/xtables/libip6t_ah.so +"$LIB_DIR"/xtables/libip6t_dst.so +"$LIB_DIR"/xtables/libip6t_eui64.so +"$LIB_DIR"/xtables/libip6t_frag.so +"$LIB_DIR"/xtables/libip6t_hbh.so +"$LIB_DIR"/xtables/libip6t_hl.so +"$LIB_DIR"/xtables/libip6t_HL.so +"$LIB_DIR"/xtables/libip6t_icmp6.so +"$LIB_DIR"/xtables/libip6t_ipv6header.so +"$LIB_DIR"/xtables/libip6t_LOG.so +"$LIB_DIR"/xtables/libip6t_mh.so +"$LIB_DIR"/xtables/libip6t_REJECT.so +"$LIB_DIR"/xtables/libip6t_rt.so +"$LIB_DIR"/xtables/libip6t_DNAT.so +"$LIB_DIR"/xtables/libip6t_DNPT.so +"$LIB_DIR"/xtables/libip6t_MASQUERADE.so +"$LIB_DIR"/xtables/libip6t_NETMAP.so +"$LIB_DIR"/xtables/libip6t_REDIRECT.so +"$LIB_DIR"/xtables/libip6t_SNAT.so +"$LIB_DIR"/xtables/libip6t_SNPT.so +fi +# Reduce the image size by various operations +if [ "$ENABLE_REDUCE" = true ] ; then + if [ "$REDUCE_APT" = true ] ; then + # Install dpkg configuration file + if [ "$REDUCE_DOC" = true ] || [ "$REDUCE_MAN" = true ] ; then + install_readonly files/dpkg/01nodoc "${ETC_DIR}/dpkg/dpkg.cfg.d/01nodoc" + fi + + # Install APT configuration files + install_readonly files/apt/02nocache "${ETC_DIR}/apt/apt.conf.d/02nocache" + install_readonly files/apt/03compress "${ETC_DIR}/apt/apt.conf.d/03compress" + install_readonly files/apt/04norecommends "${ETC_DIR}/apt/apt.conf.d/04norecommends" + + # Remove APT cache files + rm -fr "${R}/var/cache/apt/pkgcache.bin" + rm -fr "${R}/var/cache/apt/srcpkgcache.bin" + fi + + # Remove all doc files + if [ "$REDUCE_DOC" = true ] ; then + find "${R}/usr/share/doc" -depth -type f ! -name copyright -print0 | xargs -0 rm || true + find "${R}/usr/share/doc" -empty -print0 | xargs -0 rmdir || true + fi + + # Remove all man pages and info files + if [ "$REDUCE_MAN" = true ] ; then + rm -rf "${R}/usr/share/man" "${R}/usr/share/groff" "${R}/usr/share/info" "${R}/usr/share/lintian" "${R}/usr/share/linda" "${R}/var/cache/man" + fi + + # Remove all locale translation files + if [ "$REDUCE_LOCALE" = true ] ; then + find "${R}/usr/share/locale" -mindepth 1 -maxdepth 1 ! -name 'en' -print0 | xargs -0 rm -r + fi + + # Remove hwdb PCI device classes (experimental) + if [ "$REDUCE_HWDB" = true ] ; then + rm -fr "/lib/udev/hwdb.d/20-pci-*" + fi + + # Replace bash shell by dash shell (experimental) + if [ "$REDUCE_BASH" = true ] ; then + # Purge bash and update alternatives + echo "Yes, do as I say!" | chroot_exec apt-get purge -qq -y --allow-remove-essential bash + chroot_exec update-alternatives --install /bin/bash bash /bin/dash 100 + fi + + # Remove sound utils and libraries + if [ "$ENABLE_SOUND" = false ] ; then + if [ "$ENABLE_BLUETOOTH" = false ] ; then + chroot_exec apt-get -qq -y purge alsa-utils libsamplerate0 libasound2 libasound2-data + else + chroot_exec apt-get -qq -y purge alsa-utils libsamplerate0 + fi + fi + + # Remove GPU kernels + if [ "$ENABLE_MINGPU" = true ] ; then + rm -f "${BOOT_DIR}/start.elf" + rm -f "${BOOT_DIR}/fixup.dat" + rm -f "${BOOT_DIR}/start_x.elf" + rm -f "${BOOT_DIR}/fixup_x.dat" + fi + + # Remove kernel and initrd from /boot (already in /boot/firmware) + if [ "$BUILD_KERNEL" = false ] ; then + rm -f "${R}/boot/vmlinuz-*" + rm -f "${R}/boot/initrd.img-*" + fi + + #Reduce BOOT + #Only necessary files for my gen pi + + # Clean APT list of repositories + rm -fr "${R}/var/lib/apt/lists/*" + chroot_exec apt-get -qq -y update +fi diff --git a/files/apt/02nocache b/files/apt/02nocache new file mode 100644 index 0000000..ed295c1 --- /dev/null +++ b/files/apt/02nocache @@ -0,0 +1,2 @@ +Dir::Cache::pkgcache ""; +Dir::Cache::srcpkgcache ""; diff --git a/files/apt/03compress b/files/apt/03compress new file mode 100644 index 0000000..9dd10cc --- /dev/null +++ b/files/apt/03compress @@ -0,0 +1,2 @@ +Acquire::GzipIndexes "true"; +Acquire::CompressionTypes::Order:: "gz"; diff --git a/files/apt/04norecommends b/files/apt/04norecommends new file mode 100644 index 0000000..b3cfff9 --- /dev/null +++ b/files/apt/04norecommends @@ -0,0 +1,2 @@ +APT::Install-Suggests "0"; +APT::Install-Recommends "0"; diff --git a/files/apt/10proxy b/files/apt/10proxy new file mode 100644 index 0000000..2a02a0c --- /dev/null +++ b/files/apt/10proxy @@ -0,0 +1 @@ +Acquire::http:Proxy ""; diff --git a/files/apt/sources.list b/files/apt/sources.list new file mode 100644 index 0000000..28ae47d --- /dev/null +++ b/files/apt/sources.list @@ -0,0 +1,8 @@ +deb http://debian.proxad.net/debian/ trixie main contrib non-free non-free-firmware +#deb-src http://ftp.debian.org/debian trixie main contrib + +deb http://debian.proxad.net/debian/ trixie-updates main contrib non-free non-free-firmware +#deb-src http://ftp.debian.org/debian/ trixie-updates main contrib + +deb http://security.debian.org/debian-security trixie-security main contrib non-free +#deb-src http://security.debian.org/ trixie/updates main contrib non-free-firmware diff --git a/files/boot/config.txt b/files/boot/config.txt new file mode 100644 index 0000000..7491765 --- /dev/null +++ b/files/boot/config.txt @@ -0,0 +1,43 @@ +# For more options and information see +# http://www.raspberrypi.org/documentation/configuration/config-txt.md +# Some settings may impact device functionality. See link above for details + +# uncomment if you get no picture on HDMI for a default "safe" mode +#hdmi_safe=1 + +# uncomment this if your display has a black border of unused pixels visible +# and your display can output without overscan +#disable_overscan=1 + +# uncomment the following to adjust overscan. Use positive numbers if console +# goes off screen, and negative if there is too much border +#overscan_left=16 +#overscan_right=16 +#overscan_top=16 +#overscan_bottom=16 + +# uncomment to force a console size. By default it will be display's size minus +# overscan. +#framebuffer_width=1280 +#framebuffer_height=720 + +# uncomment if hdmi display is not detected and composite is being output +#hdmi_force_hotplug=1 + +# uncomment to force a specific HDMI mode (this will force VGA) +#hdmi_group=1 +#hdmi_mode=1 + +# uncomment to force a HDMI mode rather than DVI. This can make audio work in +# DMT (computer monitor) modes +#hdmi_drive=2 + +# uncomment to increase signal to HDMI, if you have interference, blanking, or +# no display +#config_hdmi_boost=4 + +# uncomment for composite PAL +#sdtv_mode=2 + +# uncomment to overclock the arm. 700 MHz is the default. +#arm_freq=800 diff --git a/files/boot/uboot.mkimage b/files/boot/uboot.mkimage new file mode 100644 index 0000000..13267f6 --- /dev/null +++ b/files/boot/uboot.mkimage @@ -0,0 +1,16 @@ +# Set device tree fdtfile +setenv dtbfile bcm2709-rpi-2-b.dtb + +# Tell Linux that it is booting on a Raspberry Pi2/3 +setenv machid 0x00000c42 + +# Save these changes to u-boot's environment +saveenv + +# Load the existing Linux kernel into RAM +mmc dev 0 +fatload mmc 0:1 ${kernel_addr_r} kernel7.img +fatload mmc 0:1 ${fdt_addr_r} ${dtbfile} +fatload mmc 0:1 ${ramdisk_addr_r} ${initramfs} + +# Boot the kernel we have just loaded diff --git a/files/dpkg/01nodoc b/files/dpkg/01nodoc new file mode 100644 index 0000000..c17061f --- /dev/null +++ b/files/dpkg/01nodoc @@ -0,0 +1,9 @@ +path-exclude=/usr/share/doc/* +path-include=/usr/share/doc/*/copyright +path-exclude=/usr/share/man/* +path-exclude=/usr/share/groff/* +path-exclude=/usr/share/info/* +path-exclude=/usr/share/lintian/* +path-exclude=/usr/share/linda/* +path-exclude=/usr/share/locale/* +path-include=/usr/share/locale/en* diff --git a/files/etc/99-com.rules b/files/etc/99-com.rules new file mode 100644 index 0000000..fd6621d --- /dev/null +++ b/files/etc/99-com.rules @@ -0,0 +1,33 @@ +SUBSYSTEM=="input", GROUP="input", MODE="0660" +SUBSYSTEM=="i2c-dev", GROUP="i2c", MODE="0660" +SUBSYSTEM=="spidev", GROUP="spi", MODE="0660" +SUBSYSTEM=="bcm2835-gpiomem", GROUP="gpio", MODE="0660" + +SUBSYSTEM=="gpio", GROUP="gpio", MODE="0660" +SUBSYSTEM=="gpio*", PROGRAM="/bin/sh -c '\ + chown -R root:gpio /sys/class/gpio && chmod -R 770 /sys/class/gpio;\ + chown -R root:gpio /sys/devices/virtual/gpio && chmod -R 770 /sys/devices/virtual/gpio;\ + chown -R root:gpio /sys$devpath && chmod -R 770 /sys$devpath\ +'" + +KERNEL=="ttyAMA[01]", PROGRAM="/bin/sh -c '\ + ALIASES=/proc/device-tree/aliases; \ + if cmp -s $ALIASES/uart0 $ALIASES/serial0; then \ + echo 0;\ + elif cmp -s $ALIASES/uart0 $ALIASES/serial1; then \ + echo 1; \ + else \ + exit 1; \ + fi\ +'", SYMLINK+="serial%c" + +KERNEL=="ttyS0", PROGRAM="/bin/sh -c '\ + ALIASES=/proc/device-tree/aliases; \ + if cmp -s $ALIASES/uart1 $ALIASES/serial0; then \ + echo 0; \ + elif cmp -s $ALIASES/uart1 $ALIASES/serial1; then \ + echo 1; \ + else \ + exit 1; \ + fi \ +'", SYMLINK+="serial%c" diff --git a/files/etc/rc.local b/files/etc/rc.local new file mode 100755 index 0000000..65634df --- /dev/null +++ b/files/etc/rc.local @@ -0,0 +1,14 @@ +#!/bin/sh -e +# +# rc.local +# +# This script is executed at the end of each multiuser runlevel. +# Make sure that the script will "exit 0" on success or any other +# value on error. +# +# In order to enable or disable this script just change the execution +# bits. +# +# By default this script does nothing. + +exit 0 diff --git a/files/firstboot/10-begin.sh b/files/firstboot/10-begin.sh new file mode 100644 index 0000000..6258bb7 --- /dev/null +++ b/files/firstboot/10-begin.sh @@ -0,0 +1,2 @@ +#!/bin/sh -e +logger -t "rc.firstboot" "Starting first boot actions" diff --git a/files/firstboot/20-expandroot.sh b/files/firstboot/20-expandroot.sh new file mode 100644 index 0000000..235c411 --- /dev/null +++ b/files/firstboot/20-expandroot.sh @@ -0,0 +1,68 @@ +logger -t "rc.firstboot" "Expanding root partition" + +# Detect root partition device +ROOT_PART=$(mount | sed -n 's|^/dev/\(.*\) on / .*|\1|p') +if [ -z "$ROOT_PART" ] ; then + log_warning_msg "unable to detect root partition device" + return 1 +fi + +# Extract root device name +case "${ROOT_PART}" in + mmcblk0*) ROOT_DEV=mmcblk0 ;; + sda*) ROOT_DEV=sda ;; +esac + +# Check detected root partition name +PART_NUM=$(echo ${ROOT_PART} | grep -o '[1-9][0-9]*$') +if [ "$PART_NUM" = "$ROOT_PART" ] ; then + logger -t "rc.firstboot" "$ROOT_PART is not an SD card. Don't know how to expand" + return 0 +fi + +# NOTE: the NOOBS partition layout confuses parted. For now, let's only +# agree to work with a sufficiently simple partition layout +if [ "$PART_NUM" -gt 2 ] ; then + logger -t "rc.firstboot" "Your partition layout is not currently supported by this tool." + return 0 +fi + +# Check if last partition number +LAST_PART_NUM=$(parted /dev/${ROOT_DEV} -ms unit s p | tail -n 1 | cut -f 1 -d:) +if [ $LAST_PART_NUM -ne $PART_NUM ]; then + logger -t "rc.firstboot" "$ROOT_PART is not the last partition. Don't know how to expand" + return 0 +fi + +# Get the starting offset of the root partition +PART_START=$(parted /dev/${ROOT_DEV} -ms unit s p | grep "^${PART_NUM}" | cut -f 2 -d: | sed 's/[^0-9]//g') +if [ -z "$PART_START" ] ; then + logger -t "rc.firstboot" "${ROOT_DEV} unable to get starting sector of the partition" + return 1 +fi + +# Get the possible last sector for the root partition +PART_LAST=$(fdisk -l /dev/${ROOT_DEV} | grep '^Disk.*sectors' | awk '{ print $7 - 1 }') +if [ -z "$PART_LAST" ] ; then + logger -t "rc.firstboot" "${ROOT_DEV} unable to get last sector of the partition" + return 1 +fi + +### Since rc.local is run with "sh -e", let's add "|| true" to prevent premature exit +fdisk /dev/${ROOT_DEV} < "${DESTDIR}/bin/unlock" << EOF +#!/bin/sh +if PATH=/lib/unlock:/bin:/sbin /scripts/local-top/cryptroot; then +kill \`ps | grep cryptroot | grep -v "grep" | awk '{print \$1}'\` +# following line kill the remote shell right after the passphrase has +# been entered. +kill -9 \`ps | grep "\-sh" | grep -v "grep" | awk '{print \$1}'\` +exit 0 +fi +exit 1 +EOF + +chmod 755 "${DESTDIR}/bin/unlock" + +mkdir -p "${DESTDIR}/lib/unlock" +cat > "${DESTDIR}/lib/unlock/plymouth" << EOF +#!/bin/sh +[ "\$1" == "--ping" ] && exit 1 +/bin/plymouth "\$@" +EOF + +chmod 755 "${DESTDIR}/lib/unlock/plymouth" + +echo To unlock root-partition run "unlock" >> ${DESTDIR}/etc/motd + +fi \ No newline at end of file diff --git a/files/initramfs/expand-premount b/files/initramfs/expand-premount new file mode 100755 index 0000000..c0c5582 --- /dev/null +++ b/files/initramfs/expand-premount @@ -0,0 +1,19 @@ +#!/bin/sh + +set -e + +# Check for cryptdevice variable +if [ -z "$cryptdevice" ] ; then + echo "unable to get cryptdevice variable (local-premount)" + exit 1 +fi + +if [ -n "$ROOT" ] ; then + # Resize encrypted root partition + cryptsetup resize "${ROOT}" + e2fsck -fp "${ROOT}" + resize2fs -f "${ROOT}" + e2fsck -fp "${ROOT}" +fi + +exit 0 diff --git a/files/initramfs/expand-tools b/files/initramfs/expand-tools new file mode 100755 index 0000000..ad5dea3 --- /dev/null +++ b/files/initramfs/expand-tools @@ -0,0 +1,19 @@ +#!/bin/sh + +set -e + +# Use initramfs utility functions +. /usr/share/initramfs-tools/hook-functions + +# Add binaries required for resizing the filesystem +copy_exec /bin/grep /bin +copy_exec /usr/bin/awk /bin +copy_exec /usr/bin/cut /bin +copy_exec /usr/bin/tail /bin +copy_exec /sbin/fdisk /sbin +copy_exec /sbin/parted /sbin +copy_exec /sbin/e2fsck /sbin +copy_exec /sbin/resize2fs /sbin +copy_exec /sbin/partprobe /sbin + +exit 0 diff --git a/files/initramfs/expand_encrypted_rootfs b/files/initramfs/expand_encrypted_rootfs new file mode 100644 index 0000000..c357b1a --- /dev/null +++ b/files/initramfs/expand_encrypted_rootfs @@ -0,0 +1,96 @@ +#!/bin/sh +# expand_encrypted_rootfs initramfs-tools boot script + +# dependencies: grep awk cut tail fdisk parted e2fsck resize2fs + +set -e + +# Wait for USB devices to be ready +sleep 5 + +# Use initramfs utility functions +if [ -r "/scripts/functions" ] ; then + . /scripts/functions +fi + +# Check for cryptdevice variable +if [ -z "$cryptdevice" ] ; then + echo "unable to get cryptdevice variable (init-premount)" + return 1 +fi + +# Detect root partition device +ROOT_PART=$(echo $cryptdevice | awk -F"/|:" '{ print $3 }') +if [ -z "$ROOT_PART" ] ; then + log_warning_msg "unable to detect encrypted root partition device (cryptdevice)" + return 1 +fi + +# Extract root device name +case "${ROOT_PART}" in + mmcblk0*) ROOT_DEV=mmcblk0 ;; + sda*) ROOT_DEV=sda ;; +esac + +# Check detected root partition name +PART_NUM=$(echo ${ROOT_PART} | grep -o '[1-9][0-9]*$') +if [ "$PART_NUM" = "$ROOT_PART" ] ; then + log_warning_msg "$ROOT_PART is not an SD card. Don't know how to expand" + return 1 +fi + +# NOTE: the NOOBS partition layout confuses parted. For now, let's only +# agree to work with a sufficiently simple partition layout +if [ "$PART_NUM" -gt 2 ] ; then + log_warning_msg "Your partition layout is not currently supported by this tool." + return 1 +fi + +# Check if last partition number +LAST_PART_NUM=$(parted /dev/${ROOT_DEV} -ms unit s p | tail -n 1 | cut -f 1 -d:) +if [ $LAST_PART_NUM -ne $PART_NUM ]; then + log_warning_msg "$ROOT_PART is not the last partition. Don't know how to expand" + return 1 +fi + +# Get the starting offset of the root partition +PART_START=$(parted /dev/${ROOT_DEV} -ms unit s p | grep "^${PART_NUM}" | cut -f 2 -d: | sed 's/[^0-9]//g') +if [ -z "$PART_START" ] ; then + log_warning_msg "${ROOT_DEV} unable to get starting sector of the partition" + return 1 +fi + +# Get the current last sector of the root partition +PART_END=$(parted /dev/${ROOT_DEV} -ms unit s p | grep "^${PART_NUM}" | cut -f 3 -d: | sed 's/[^0-9]//g') +if [ -z "$PART_END" ] ; then + log_warning_msg "${ROOT_DEV} unable to get last sector of the partition" + return 1 +fi + +# Get the possible last sector for the root partition +PART_LAST=$(fdisk -l /dev/${ROOT_DEV} | grep '^Disk.*sectors' | awk '{ print $7 - 1 }') +if [ -z "$PART_LAST" ] ; then + log_warning_msg "${ROOT_DEV} unable to get last possible sector of the partition" + return 1 +fi + +### Since rc.local is run with "sh -e", let's add "|| true" to prevent premature exit +if [ $PART_END != $PART_LAST ] ; then + fdisk /dev/${ROOT_DEV} 2> /dev/null < diff --git a/files/mount/fstab b/files/mount/fstab new file mode 100644 index 0000000..4ec06e9 --- /dev/null +++ b/files/mount/fstab @@ -0,0 +1,2 @@ +/dev/mmcblk0p2 / ext4 noatime,nodiratime,errors=remount-ro,discard,data=writeback,commit=100 0 1 +/dev/mmcblk0p1 /boot/firmware vfat defaults,noatime,nodiratime 0 2 diff --git a/files/network/eth.network b/files/network/eth.network new file mode 100644 index 0000000..db519c9 --- /dev/null +++ b/files/network/eth.network @@ -0,0 +1,12 @@ +[Match] +Name=eth0 + +[Network] +DHCP=no +Address= +Gateway= +DNS= +DNS= +Domains= +NTP= +NTP= diff --git a/files/network/eth0.network b/files/network/eth0.network new file mode 100644 index 0000000..143ca4b --- /dev/null +++ b/files/network/eth0.network @@ -0,0 +1,14 @@ +[Match] +Name=eth0 + +[Network] +RouteMetric=10 +IPv6PrivacyExtensions=true +DHCP=no +Address= +Gateway= +DNS= +DNS= +Domains= +NTP= +NTP= diff --git a/files/network/host.conf b/files/network/host.conf new file mode 100644 index 0000000..2a1612f --- /dev/null +++ b/files/network/host.conf @@ -0,0 +1,2 @@ +# spoof warn +multi on diff --git a/files/network/hostname b/files/network/hostname new file mode 100644 index 0000000..b20bbc3 --- /dev/null +++ b/files/network/hostname @@ -0,0 +1 @@ +RaspberryPI diff --git a/files/network/hosts b/files/network/hosts new file mode 100644 index 0000000..3ae0878 --- /dev/null +++ b/files/network/hosts @@ -0,0 +1,6 @@ +127.0.0.1 localhost +127.0.1.1 RaspberryPI + +::1 localhost ip6-localhost ip6-loopback +ff02::1 ip6-allnodes +ff02::2 ip6-allrouters diff --git a/files/network/interfaces b/files/network/interfaces new file mode 100644 index 0000000..241b666 --- /dev/null +++ b/files/network/interfaces @@ -0,0 +1,2 @@ +# Debian switched to systemd-networkd configuration files. +# please configure your networks in '/etc/systemd/network/' diff --git a/files/network/wlan.network b/files/network/wlan.network new file mode 100644 index 0000000..5f252c3 --- /dev/null +++ b/files/network/wlan.network @@ -0,0 +1,12 @@ +[Match] +Name=wlan0 + +[Network] +DHCP=no +Address= +Gateway= +DNS= +DNS= +Domains= +NTP= +NTP= diff --git a/files/network/wlan0.network b/files/network/wlan0.network new file mode 100644 index 0000000..49091fe --- /dev/null +++ b/files/network/wlan0.network @@ -0,0 +1,14 @@ +[Match] +Name=wlan0 + +[Network] +RouteMetric=20 +IPv6PrivacyExtensions=true +DHCP=no +Address= +Gateway= +DNS= +DNS= +Domains= +NTP= +NTP= diff --git a/files/sysctl.d/81-rpi-vm.conf b/files/sysctl.d/81-rpi-vm.conf new file mode 100644 index 0000000..b818fc6 --- /dev/null +++ b/files/sysctl.d/81-rpi-vm.conf @@ -0,0 +1,6 @@ +# Avoid swapping and increase cache sizes +vm.swappiness=1 +vm.dirty_background_ratio=20 +vm.dirty_ratio=40 +vm.dirty_writeback_centisecs=500 +vm.dirty_expire_centisecs=6000 diff --git a/files/sysctl.d/82-rpi-net-hardening.conf b/files/sysctl.d/82-rpi-net-hardening.conf new file mode 100644 index 0000000..8ee6299 --- /dev/null +++ b/files/sysctl.d/82-rpi-net-hardening.conf @@ -0,0 +1,59 @@ +# Enable network stack hardening +net.ipv4.tcp_timestamps=0 +net.ipv4.tcp_syncookies=1 +net.ipv4.conf.all.rp_filter=1 +net.ipv4.conf.all.accept_redirects=0 +net.ipv4.conf.all.send_redirects=0 +net.ipv4.conf.all.accept_source_route=0 +net.ipv4.conf.default.rp_filter=1 +net.ipv4.conf.default.accept_redirects=0 +net.ipv4.conf.default.send_redirects=0 +net.ipv4.conf.default.accept_source_route=0 +net.ipv4.conf.lo.accept_redirects=0 +net.ipv4.conf.lo.send_redirects=0 +net.ipv4.conf.lo.accept_source_route=0 +net.ipv4.conf.eth0.accept_redirects=0 +net.ipv4.conf.eth0.send_redirects=0 +net.ipv4.conf.eth0.accept_source_route=0 +net.ipv4.icmp_echo_ignore_broadcasts=1 +net.ipv4.icmp_ignore_bogus_error_responses=1 + +net.ipv6.conf.all.accept_redirects=0 +net.ipv6.conf.all.accept_source_route=0 +net.ipv6.conf.all.router_solicitations=0 +net.ipv6.conf.all.accept_ra_rtr_pref=0 +net.ipv6.conf.all.accept_ra_pinfo=0 +net.ipv6.conf.all.accept_ra_defrtr=0 +net.ipv6.conf.all.autoconf=0 +net.ipv6.conf.all.dad_transmits=0 +net.ipv6.conf.all.max_addresses=1 + +net.ipv6.conf.default.accept_redirects=0 +net.ipv6.conf.default.accept_source_route=0 +net.ipv6.conf.default.router_solicitations=0 +net.ipv6.conf.default.accept_ra_rtr_pref=0 +net.ipv6.conf.default.accept_ra_pinfo=0 +net.ipv6.conf.default.accept_ra_defrtr=0 +net.ipv6.conf.default.autoconf=0 +net.ipv6.conf.default.dad_transmits=0 +net.ipv6.conf.default.max_addresses=1 + +net.ipv6.conf.lo.accept_redirects=0 +net.ipv6.conf.lo.accept_source_route=0 +net.ipv6.conf.lo.router_solicitations=0 +net.ipv6.conf.lo.accept_ra_rtr_pref=0 +net.ipv6.conf.lo.accept_ra_pinfo=0 +net.ipv6.conf.lo.accept_ra_defrtr=0 +net.ipv6.conf.lo.autoconf=0 +net.ipv6.conf.lo.dad_transmits=0 +net.ipv6.conf.lo.max_addresses=1 + +net.ipv6.conf.eth0.accept_redirects=0 +net.ipv6.conf.eth0.accept_source_route=0 +net.ipv6.conf.eth0.router_solicitations=0 +net.ipv6.conf.eth0.accept_ra_rtr_pref=0 +net.ipv6.conf.eth0.accept_ra_pinfo=0 +net.ipv6.conf.eth0.accept_ra_defrtr=0 +net.ipv6.conf.eth0.autoconf=0 +net.ipv6.conf.eth0.dad_transmits=0 +net.ipv6.conf.eth0.max_addresses=1 diff --git a/files/sysctl.d/83-rpi-printk.conf b/files/sysctl.d/83-rpi-printk.conf new file mode 100644 index 0000000..f8948fb --- /dev/null +++ b/files/sysctl.d/83-rpi-printk.conf @@ -0,0 +1 @@ +kernel.printk = 3 4 1 3 \ No newline at end of file diff --git a/files/sysctl.d/84-rpi-ASLR.conf b/files/sysctl.d/84-rpi-ASLR.conf new file mode 100644 index 0000000..da4ad13 --- /dev/null +++ b/files/sysctl.d/84-rpi-ASLR.conf @@ -0,0 +1,2 @@ +# ASLR +kernel.randomize_va_space = 2 \ No newline at end of file diff --git a/files/xorg/99-fbturbo.conf b/files/xorg/99-fbturbo.conf new file mode 100644 index 0000000..a7124c9 --- /dev/null +++ b/files/xorg/99-fbturbo.conf @@ -0,0 +1,6 @@ +Section "Device" + Identifier "Allwinner A10/A13 FBDEV" + Driver "fbturbo" + Option "fbdev" "/dev/fb0" + Option "SwapbuffersWait" "true" +EndSection diff --git a/functions.sh b/functions.sh new file mode 100644 index 0000000..603d917 --- /dev/null +++ b/functions.sh @@ -0,0 +1,121 @@ +# This file contains utility functions used by rpi23-gen-image.sh + +cleanup (){ + set +x + set +e + + # Remove exports from nexmon + unset KERNEL + unset ARCH + unset SUBARCH + unset CCPLUGIN + unset ZLIBFLATE + unset Q + unset NEXMON_SETUP_ENV + unset HOSTUNAME + unset PLATFORMUNAME + + # Identify and kill all processes still using files + echo "killing processes using mount point ..." + fuser -k "${R}" + sleep 3 + fuser -9 -k -v "${R}" + + # Clean up temporary .password file + if [ -r ".password" ] ; then + shred -zu .password + fi + + # Clean up all temporary mount points + echo "removing temporary mount points ..." + umount -l "${R}/proc" 2> /dev/null + umount -l "${R}/sys" 2> /dev/null + umount -l "${R}/dev/pts" 2> /dev/null + umount "$BUILDDIR/mount/boot/firmware" 2> /dev/null + umount "$BUILDDIR/mount" 2> /dev/null + cryptsetup close "${CRYPTFS_MAPPING}" 2> /dev/null + losetup -d "$ROOT_LOOP" 2> /dev/null + losetup -d "$FRMW_LOOP" 2> /dev/null + trap - 0 1 2 3 6 +} + +chroot_exec() { + # Exec command in chroot + LANG=C LC_ALL=C DEBIAN_FRONTEND=noninteractive chroot "${R}" "$@" +} + +as_nobody() { + # Exec command as user nobody + sudo -E -u nobody LANG=C LC_ALL=C "$@" +} + +install_readonly() { + # Install file with user read-only permissions + install -o root -g root -m 644 "$@" +} + +install_exec() { + # Install file with root exec permissions + install -o root -g root -m 744 "$@" +} + +use_template () { + # Test if configuration template file exists + if [ ! -r "./templates/${CONFIG_TEMPLATE}" ] ; then + echo "error: configuration template ${CONFIG_TEMPLATE} not found" + exit 1 + fi + + # Load template configuration parameters + . "./templates/${CONFIG_TEMPLATE}" +} + +chroot_install_cc() { + # Install c/c++ build environment inside the chroot + if [ -z "${COMPILER_PACKAGES}" ] ; then + COMPILER_PACKAGES=$(chroot_exec apt-get -s install g++ make bc | grep "^Inst " | awk -v ORS=" " '{ print $2 }') + + +# if [ "$RELEASE" = "trixie" ] || [ "$RELEASE" = "bullseye" ] || [ "$RELEASE" = "bookworm" ] ; then +# chroot_exec apt-get -q -y --no-install-recommends install ${COMPILER_PACKAGES} +# elif [ "$RELEASE" = "bullseye" ] || [ "$RELEASE" = "bookworm" ] || [ "$RELEASE" = "bookworm" ]; then + chroot_exec apt-get -q -y --allow-unauthenticated --no-install-recommends install ${COMPILER_PACKAGES} +# fi + fi +} + +chroot_remove_cc() { + # Remove c/c++ build environment from the chroot + if [ -n "${COMPILER_PACKAGES}" ] ; then + chroot_exec apt-get -qq -y --auto-remove purge ${COMPILER_PACKAGES} + COMPILER_PACKAGES="" + fi +} + +# https://serverfault.com/a/682849 - converts e.g. /24 to 255.255.255.0 +cdr2mask () +{ + # Number of args to shift, 255..255, first non-255 byte, zeroes + set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 << (8 - ($1 % 8))) & 255 )) 0 0 0 + [ $1 -gt 1 ] && shift $1 || shift + echo ${1-0}.${2-0}.${3-0}.${4-0} +} + +# GPL v2.0 - #https://github.com/sakaki-/bcmrpi3-kernel-bis/blob/master/conform_config.sh +set_kernel_config() { + # flag as $1, value to set as $2, config must exist at "./.config" + TGT="CONFIG_${1#CONFIG_}" + REP="${2}" + if grep -q "^${TGT}[^_]" .config; then + sed -i "s/^\(${TGT}=.*\|# ${TGT} is not set\)/${TGT}=${REP}/" .config + else + echo "${TGT}"="${2}" >> .config + fi +} + +# unset kernel config parameter +unset_kernel_config() { + # unsets flag with the value of $1, config must exist at "./.config" + TGT="CONFIG_${1#CONFIG_}" + sed -i "s/^${TGT}=.*/# ${TGT} is not set/" .config +} diff --git a/rpiGenImage.sh b/rpiGenImage.sh new file mode 100755 index 0000000..5ae182d --- /dev/null +++ b/rpiGenImage.sh @@ -0,0 +1,929 @@ +#!/bin/bash +######################################################################## +# rpi23-gen-image.sh 2015-2017 +# +# Advanced Debian "forky" and "trixie" bootstrap script for Raspberry Pi +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# Copyright (C) 2015 Jan Wagner +# +# Big thanks for patches and enhancements by 20+ github contributors! +######################################################################## + +# Are we running as root? +if [ "$(id -u)" -ne "0" ] ; then + echo "error: this script must be executed with root privileges!" + exit 1 +fi + +# Check if ./functions.sh script exists +if [ ! -r "./functions.sh" ] ; then + echo "error: './functions.sh' required script not found!" + exit 1 +fi + +# Load utility functions +. ./functions.sh + +# Load parameters from configuration template file +if [ -n "$CONFIG_TEMPLATE" ] ; then + use_template +fi + +# Introduce settings +set -e +echo -n -e "\n#\n# RPi 0/1/2/3/4 Bootstrap Settings\n#\n" +set -x + +# Raspberry Pi model configuration defaults to 3P +RPI_MODEL=${RPI_MODEL:=3P} + +# Debian release defaults to trixie +RELEASE=${RELEASE:=trixie} +if [ "$RELEASE" = "trixie" ] ; then + RELEASE=testing +fi +echo "Debian release value used : " $RELEASE + +# Kernel Branch +KERNEL_BRANCH=${KERNEL_BRANCH:=""} + +# URLs +KERNEL_URL=${KERNEL_URL:=https://github.com/raspberrypi/linux} +FIRMWARE_URL=${FIRMWARE_URL:=https://github.com/raspberrypi/firmware/raw/master/boot} +#WLAN_FIRMWARE_URL=${WLAN_FIRMWARE_URL:=https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm} +WLAN_FIRMWARE_URL=${WLAN_FIRMWARE_URL:=https://github.com/reMarkable/brcmfmac-firmware/blob/master} +FBTURBO_URL=${FBTURBO_URL:=https://github.com/ssvb/xf86-video-fbturbo.git} +UBOOT_URL=${UBOOT_URL:=https://git.denx.de/u-boot.git} +VIDEOCORE_URL=${VIDEOCORE_URL:=https://github.com/raspberrypi/userland} +BLUETOOTH_URL=${BLUETOOTH_URL:=https://github.com/RPi-Distro/pi-bluetooth.git} +NEXMON_URL=${NEXMON_URL:=https://github.com/seemoo-lab/nexmon.git} +SYSTEMDSWAP_URL=${SYSTEMDSWAP_URL:=https://github.com/Nefelim4ag/systemd-swap.git} + +# Kernel deb packages for 32bit kernel +RPI_32_KERNEL_URL=${RPI_32_KERNEL_URL:=https://github.com/hypriot/rpi-kernel/releases/download/v4.14.34/raspberrypi-kernel_20180422-141901_armhf.deb} +RPI_32_KERNELHEADER_URL=${RPI_32_KERNELHEADER_URL:=https://github.com/hypriot/rpi-kernel/releases/download/v4.14.34/raspberrypi-kernel-headers_20180422-141901_armhf.deb} +# Kernel has KVM and zswap enabled - use if KERNEL_* parameters and precompiled kernel are used +RPI3_64_BIS_KERNEL_URL=${RPI3_64_BIS_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel-bis/releases/download/4.19.102.20200211/bcmrpi3-kernel-bis-4.19.102.20200211.tar.xz} +# Default precompiled 64bit kernel +RPI3_64_DEF_KERNEL_URL=${RPI3_64_DEF_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel/releases/download/4.19.102.20200211/bcmrpi3-kernel-4.19.102.20200211.tar.xz} +# Sakaki BIS Kernel RPI4 - https://github.com/sakaki-/bcm2711-kernel-bis +RPI4_64_BIS_KERNEL_URL=${RPI4_64_BIS_KERNEL_URL:=https://github.com/sakaki-/bcm2711-kernel-bis/releases/download/4.19.102.20200211/bcm2711-kernel-bis-4.19.102.20200211.tar.xz} +# Default precompiled 64bit kernel - https://github.com/sakaki-/bcm2711-kernel +RPI4_64_DEF_KERNEL_URL=${RPI4_64_DEF_KERNEL_URL:=https://github.com/sakaki-/bcm2711-kernel-bis/releases/download/4.19.102.20200211/bcm2711-kernel-bis-4.19.102.20200211.tar.xz} +# Generic +RPI3_64_KERNEL_URL=${RPI3_64_KERNEL_URL:=$RPI3_64_DEF_KERNEL_URL} +RPI4_64_KERNEL_URL=${RPI4_64_KERNEL_URL:=$RPI4_64_DEF_KERNEL_URL} +# Kali kernel src - used if ENABLE_NEXMON=true (they patch the wlan kernel modul) +KALI_KERNEL_URL=${KALI_KERNEL_URL:=https://github.com/Re4son/re4son-raspberrypi-linux.git} + +# Build directories +WORKDIR=$(pwd) +BASEDIR=${BASEDIR:=${WORKDIR}/images/${RELEASE}} +BUILDDIR="${BASEDIR}/build" + +# Chroot directories +R="${BUILDDIR}/chroot" +ETC_DIR="${R}/etc" +LIB_DIR="${R}/lib" +BOOT_DIR="${R}/boot/firmware" +KERNEL_DIR="${R}/usr/src/linux" +WLAN_FIRMWARE_DIR="${LIB_DIR}/firmware/brcm" +BLUETOOTH_FIRMWARE_DIR="${ETC_DIR}/firmware/bt" + +# APT settings +APT_SERVER=${APT_SERVER:="ftp.debian.org"} +APT_PROXY=${APT_PROXY:=""} +KEEP_APT_PROXY=${KEEP_APT_PROXY:=false} +# Packages required in the chroot build environment +APT_INCLUDES=${APT_INCLUDES:=""} +APT_INCLUDES="${APT_INCLUDES},apt-transport-https,apt-utils,ca-certificates,\ + debian-archive-keyring,dialog,sudo,systemd,\ + sysvinit-utils,locales,keyboard-configuration,\ + console-setup,libnss-systemd" +# Packages to exclude from chroot build environment +APT_EXCLUDES=${APT_EXCLUDES:=""} + +# General settings +SET_ARCH=${SET_ARCH:=32} +HOSTNAME=${HOSTNAME:=rpi${RPI_MODEL}-${RELEASE}} +DEFLOCAL=${DEFLOCAL:="en_US.UTF-8"} +TIMEZONE=${TIMEZONE:="Europe/Berlin"} +EXPANDROOT=${EXPANDROOT:=true} + +ENABLE_ROOT=${ENABLE_ROOT:=false} +ROOT_PASSWORD=${ROOT_PASSWORD:=raspberry} +ENABLE_USER=${ENABLE_USER:=true} +USER_NAME=${USER_NAME:="pi"} +USER_PASSWORD=${USER_PASSWORD:=raspberry} + +# Keyboard settings +XKB_MODEL=${XKB_MODEL:=""} +XKB_LAYOUT=${XKB_LAYOUT:=""} +XKB_VARIANT=${XKB_VARIANT:=""} +XKB_OPTIONS=${XKB_OPTIONS:=""} + +# Networking settings: +ENABLE_IPV6=${ENABLE_IPV6:=true} +ENABLE_WIRELESS=${ENABLE_WIRELESS:=false} +ENABLE_IPTABLES=${ENABLE_IPTABLES:=false} +ENABLE_HARDNET=${ENABLE_HARDNET:=false} +ENABLE_IFNAMES=${ENABLE_IFNAMES:=true} + +# Network settings (DHCP) +ENABLE_ETH_DHCP=${ENABLE_ETH_DHCP:=true} +ENABLE_WIFI_DHCP=${ENABLE_ETH_DHCP:=true} + +# Network settings (static) +NET_ETH_ADDRESS=${NET_ETH_ADDRESS:=""} +NET_ETH_GATEWAY=${NET_ETH_GATEWAY:=""} +NET_ETH_DNS_1=${NET_ETH_DNS_1:=""} +NET_ETH_DNS_2=${NET_ETH_DNS_2:=""} +NET_ETH_DNS_DOMAINS=${NET_ETH_DNS_DOMAINS:=""} +NET_ETH_NTP_1=${NET_ETH_NTP_1:=""} +NET_ETH_NTP_2=${NET_ETH_NTP_2:=""} + +# Networking settings (WIFI): +NET_WIFI_SSID=${NET_WIFI_SSID:=""} +NET_WIFI_PSK=${NET_WIFI_PSK:=""} + +# Network settings (static) +NET_WIFI_ADDRESS=${NET_WIFI_ADDRESS:=""} +NET_WIFI_GATEWAY=${NET_WIFI_GATEWAY:=""} +NET_WIFI_DNS_1=${NET_WIFI_DNS_1:=""} +NET_WIFI_DNS_2=${NET_WIFI_DNS_2:=""} +NET_WIFI_DNS_DOMAINS=${NET_WIFI_DNS_DOMAINS:=""} +NET_WIFI_NTP_1=${NET_WIFI_NTP_1:=""} +NET_WIFI_NTP_2=${NET_WIFI_NTP_2:=""} + +# Feature settings +ENABLE_CONSOLE=${ENABLE_CONSOLE:=false} +ENABLE_PRINTK=${ENABLE_PRINTK:=false} +ENABLE_BLUETOOTH=${ENABLE_BLUETOOTH:=false} +ENABLE_MINIUART_OVERLAY=${ENABLE_MINIUART_OVERLAY:=false} +ENABLE_TURBO=${ENABLE_TURBO:=false} +ENABLE_I2C=${ENABLE_I2C:=false} +ENABLE_SPI=${ENABLE_SPI:=false} + +ENABLE_NONFREE=${ENABLE_NONFREE:=false} +ENABLE_RSYSLOG=${ENABLE_RSYSLOG:=true} +ENABLE_SOUND=${ENABLE_SOUND:=false} +ENABLE_HWRANDOM=${ENABLE_HWRANDOM:=true} +ENABLE_MINGPU=${ENABLE_MINGPU:=false} +ENABLE_WAYLAND=${ENABLE_WAYLAND:=false} +ENABLE_WM=${ENABLE_WM:=""} +ENABLE_SYSVINIT=${ENABLE_SYSVINIT:=false} +ENABLE_SPLASH=${ENABLE_SPLASH:=true} +ENABLE_LOGO=${ENABLE_LOGO:=true} +ENABLE_SILENT_BOOT=${ENABLE_SILENT_BOOT=false} +DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS:=} + +# Advanced settings +ENABLE_DPHYSSWAP=${ENABLE_DPHYSSWAP:=true} +ENABLE_SYSTEMDSWAP=${ENABLE_SYSTEMDSWAP:=false} +ENABLE_QEMU=${ENABLE_QEMU:=false} +ENABLE_KEYGEN=${ENABLE_KEYGEN:=false} +ENABLE_MINBASE=${ENABLE_MINBASE:=false} +ENABLE_SPLITFS=${ENABLE_SPLITFS:=false} +ENABLE_INITRAMFS=${ENABLE_INITRAMFS:=false} +ENABLE_DBUS=${ENABLE_DBUS:=true} +ENABLE_USBBOOT=${ENABLE_USBBOOT=false} +CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""} +ENABLE_UBOOT=${ENABLE_UBOOT:=false} +UBOOTSRC_DIR=${UBOOTSRC_DIR:=""} +ENABLE_FBTURBO=${ENABLE_FBTURBO:=false} +ENABLE_GR_ACCEL=${ENABLE_GR_ACCEL:=true} +FBTURBOSRC_DIR=${FBTURBOSRC_DIR:=""} +ENABLE_VIDEOCORE=${ENABLE_VIDEOCORE:=false} +VIDEOCORESRC_DIR=${VIDEOCORESRC_DIR:=""} +ENABLE_NEXMON=${ENABLE_NEXMON:=false} +NEXMONSRC_DIR=${NEXMONSRC_DIR:=""} + +# SSH settings +SSH_ENABLE=${SSH_ENABLE:=true} +SSH_ENABLE_ROOT=${SSH_ENABLE_ROOT:=false} +SSH_DISABLE_PASSWORD_AUTH=${SSH_DISABLE_PASSWORD_AUTH:=false} +SSH_LIMIT_USERS=${SSH_LIMIT_USERS:=false} +SSH_ROOT_PUB_KEY=${SSH_ROOT_PUB_KEY:=""} +SSH_USER_PUB_KEY=${SSH_USER_PUB_KEY:=""} + +# Kernel compilation settings +BUILD_KERNEL=${BUILD_KERNEL:=true} +KERNEL_THREADS=${KERNEL_THREADS:=1} +KERNEL_HEADERS=${KERNEL_HEADERS:=true} +KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false} +KERNEL_OLDDEFCONFIG=${KERNEL_OLDDEFCONFIG:=false} +KERNEL_CCACHE=${KERNEL_CCACHE:=false} +KERNEL_REMOVESRC=${KERNEL_REMOVESRC:=true} +KERNELSRC_DIR=${KERNELSRC_DIR:=""} +KERNELSRC_CLEAN=${KERNELSRC_CLEAN:=false} +KERNELSRC_CONFIG=${KERNELSRC_CONFIG:=true} +KERNELSRC_USRCONFIG=${KERNELSRC_USRCONFIG:=""} +KERNELSRC_PREBUILT=${KERNELSRC_PREBUILT:=false} +# Firmware directory: Blank if download from github +RPI_FIRMWARE_DIR=${RPI_FIRMWARE_DIR:=""} +KERNEL_DEFAULT_GOV=${KERNEL_DEFAULT_GOV:=ondemand} +KERNEL_NF=${KERNEL_NF:=false} +KERNEL_VIRT=${KERNEL_VIRT:=false} +KERNEL_ZSWAP=${KERNEL_ZSWAP:=false} +KERNEL_BPF=${KERNEL_BPF:=false} +KERNEL_SECURITY=${KERNEL_SECURITY:=false} +KERNEL_BTRFS=${KERNEL_BTRFS:=false} +KERNEL_POEHAT=${KERNEL_POEHAT:=false} +KERNEL_NSPAN=${KERNEL_NSPAN:=false} +KERNEL_DHKEY=${KERNEL_DHKEY:=true} + +# Reduce disk usage settings +ENABLE_REDUCE=${ENABLE_REDUCE:=false} +REDUCE_APT=${REDUCE_APT:=true} +REDUCE_DOC=${REDUCE_DOC:=false} +REDUCE_MAN=${REDUCE_MAN:=false} +REDUCE_VIM=${REDUCE_VIM:=false} +REDUCE_BASH=${REDUCE_BASH:=false} +REDUCE_HWDB=${REDUCE_HWDB:=false} +REDUCE_SSHD=${REDUCE_SSHD:=false} +REDUCE_LOCALE=${REDUCE_LOCALE:=false} +REDUCE_KERNEL=${REDUCE_KERNEL:=false} + +# Encrypted filesystem settings +ENABLE_CRYPTFS=${ENABLE_CRYPTFS:=false} +CRYPTFS_PASSWORD=${CRYPTFS_PASSWORD:=""} +CRYPTFS_MAPPING=${CRYPTFS_MAPPING:="secure"} +CRYPTFS_CIPHER=${CRYPTFS_CIPHER:="aes-xts-plain64"} +CRYPTFS_HASH=${CRYPTFS_HASH:="sha256"} +CRYPTFS_XTSKEYSIZE=${CRYPTFS_XTSKEYSIZE:=256} +#Dropbear-initramfs supports unlocking encrypted filesystem via SSH on bootup +CRYPTFS_DROPBEAR=${CRYPTFS_DROPBEAR:=false} +#Provide your own Dropbear Public RSA-OpenSSH Key otherwise it will be generated +CRYPTFS_DROPBEAR_PUBKEY=${CRYPTFS_DROPBEAR_PUBKEY:=""} + +# Packages required for bootstrapping +REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus bison flex libssl-dev sudo" +MISSING_PACKAGES="" + +# Packages installed for c/c++ build environment in chroot (keep empty) +COMPILER_PACKAGES="" + +# Check if apt-cacher-ng has port 3142 open and set APT_PROXY +APT_CACHER_RUNNING=$(lsof -i :3142 | cut -d ' ' -f3 | uniq | sed '/^\s*$/d') +if [ "${APT_CACHER_RUNNING}" = "apt-cacher-ng" ] ; then + APT_PROXY=http://127.0.0.1:3142/ +fi + +# Setup architecture specific settings +if [ -n "$SET_ARCH" ] ; then + ## 64-bit configuration + if [ "$SET_ARCH" = 64 ] ; then + ### General 64-bit depended settings + QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-aarch64} + KERNEL_ARCH=${KERNEL_ARCH:=arm64} + KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="Image"} + + ### Raspberry Pi model specific settings + if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then + if [ "$RPI_MODEL" != 4 ] ; then + KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi3_defconfig} + else + KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2711_defconfig} + fi + + REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-arm64" + RELEASE_ARCH=${RELEASE_ARCH:=arm64} + KERNEL_IMAGE=${KERNEL_IMAGE:=kernel8.img} + CROSS_COMPILE=${CROSS_COMPILE:=aarch64-linux-gnu-} + + else + echo "error: Only Raspberry PI 3, 3B+ and 4 support 64-bit" + exit 1 + fi + fi + + ## 32-bit configuration + if [ "$SET_ARCH" = 32 ] ; then + ### General 32-bit dependend settings + QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-armhf} + KERNEL_ARCH=${KERNEL_ARCH:=arm} + KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="zImage"} + + ### Raspberry Pi (0-1P) model specific settings + if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] ; then + REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armel" + KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi_defconfig} + RELEASE_ARCH=${RELEASE_ARCH:=armel} + KERNEL_IMAGE=${KERNEL_IMAGE:=kernel.img} + CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabi-} + + if [ $ENABLE_WAYLAND = true ] ; then + if [$RELEASE = "bullseye" ] || [$RELEASE = "oldstable" ] ; then + printf "\nBest support for armel architecture is provided under Debian bullseye/oldstable. Choose yes to change release to Debian bullseye[y/n] " + read -r confirm + if [ "$confirm" = "y" ] ; then + $RELEASE = "bullseye" + fi + fi + fi + fi + ### Raspberry Pi (2-4) model specific settings + if [ "$RPI_MODEL" = 2 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then + if [ "$RPI_MODEL" == 4 ] ; then + KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2711_defconfig} + KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7l.img} + else + KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2709_defconfig} + KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img} + fi + + REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf" + RELEASE_ARCH=${RELEASE_ARCH:=armhf} + + CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabihf-} + fi + fi +# SET_ARCH not set +else + echo "error: Please set '32' or '64' as value for SET_ARCH" + exit 1 +fi +# Device specific configuration and U-Boot configuration +case "$RPI_MODEL" in + 0) + DTB_FILE=${DTB_FILE:=bcm2708-rpi-0-w.dtb} + UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig} + ;; + 1) + DTB_FILE=${DTB_FILE:=bcm2708-rpi-b.dtb} + UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig} + ;; + 1P) + DTB_FILE=${DTB_FILE:=bcm2708-rpi-b-plus.dtb} + UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig} + ;; + 2) + DTB_FILE=${DTB_FILE:=bcm2709-rpi-2-b.dtb} + UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_2_defconfig} + ;; + 3) + DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb} + UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig} + ;; + 3P) + DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb} + UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig} + ;; + 4) + DTB_FILE=${DTB_FILE:=bcm2711-rpi-4-b.dtb} + UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_4_defconfig} + ;; + *) + echo "error: Raspberry Pi model $RPI_MODEL is not supported!" + exit 1 + ;; +esac + +# Raspberry PI 0,3,3P,4 with Bluetooth and Wifi onboard +if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then + ## Include bluetooth packages on supported boards + if [ "$ENABLE_BLUETOOTH" = true ] ; then + APT_INCLUDES="${APT_INCLUDES},bluetooth,bluez" + fi + if [ "$ENABLE_WIRELESS" = true ] ; then + APT_INCLUDES="${APT_INCLUDES},wireless-tools,crda,wireless-regdb,wpasupplicant" + fi +# Raspberry PI 1,1P,2 without Wifi and bluetooth onboard +else + ## Check if the internal wireless interface is not supported by the RPi model + if [ "$ENABLE_WIRELESS" = true ] || [ "$ENABLE_BLUETOOTH" = true ]; then + echo "error: The selected Raspberry Pi model has no integrated interface for wireless or bluetooth" + exit 1 + fi +fi + +if [ "$BUILD_KERNEL" = false ] && [ "$ENABLE_NEXMON" = true ]; then + echo "error: You have to compile kernel sources, if you want to enable nexmon" + exit 1 +fi + +# Prepare date string for default image file name +DATE="$(date +%Y-%m-%d)" +if [ -z "$KERNEL_BRANCH" ] ; then + IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}} +else + IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}} +fi + +# Check if DISABLE_UNDERVOLT_WARNINGS parameter value is supported +if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then + if [ "$DISABLE_UNDERVOLT_WARNINGS" != 1 ] && [ "$DISABLE_UNDERVOLT_WARNINGS" != 2 ] ; then + echo "error: DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS} is not supported" + exit 1 + fi +fi + +# Add cmake to compile videocore sources +if [ "$ENABLE_VIDEOCORE" = true ] ; then + REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cmake" +fi + +# Add deps for nexmon +if [ "$ENABLE_NEXMON" = true ] ; then + REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libgmp3-dev gawk qpdf make autoconf automake build-essential libtool" +fi + +# Add libncurses5 to enable kernel menuconfig +if [ "$KERNEL_MENUCONFIG" = true ] ; then + REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libncurses-dev" +fi + +# Add ccache compiler cache for (faster) kernel cross (re)compilation +if [ "$KERNEL_CCACHE" = true ] ; then + REQUIRED_PACKAGES="${REQUIRED_PACKAGES} ccache" +fi + +# Add cryptsetup package to enable filesystem encryption +if [ "$ENABLE_CRYPTFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then + REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cryptsetup" + APT_INCLUDES="${APT_INCLUDES},cryptsetup,busybox,console-setup,cryptsetup-initramfs" + + # If cryptfs,dropbear and initramfs are enabled include dropbear-initramfs package + if [ "$CRYPTFS_DROPBEAR" = true ] && [ "$ENABLE_INITRAMFS" = true ]; then + APT_INCLUDES="${APT_INCLUDES},dropbear-initramfs" + fi + + if [ -z "$CRYPTFS_PASSWORD" ] ; then + echo "error: no password defined (CRYPTFS_PASSWORD)!" + exit 1 + fi + ENABLE_INITRAMFS=true +fi + +# Add initramfs generation tools +if [ "$ENABLE_INITRAMFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then + APT_INCLUDES="${APT_INCLUDES},initramfs-tools" +fi + +# Add device-tree-compiler required for building the U-Boot bootloader +if [ "$ENABLE_UBOOT" = true ] ; then + APT_INCLUDES="${APT_INCLUDES},device-tree-compiler,bc" +fi + +if [ "$ENABLE_USBBOOT" = true ] ; then + if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1P ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 2 ]; then + echo "error: Booting from USB alone is only supported by Raspberry Pi 3 and 3P" + exit 1 + fi +fi + +# Check if root SSH (v2) public key file exists +if [ -n "$SSH_ROOT_PUB_KEY" ] ; then + if [ ! -f "$SSH_ROOT_PUB_KEY" ] ; then + echo "error: '$SSH_ROOT_PUB_KEY' specified SSH public key file not found (SSH_ROOT_PUB_KEY)!" + exit 1 + fi +fi + +# Check if $USER_NAME SSH (v2) public key file exists +if [ -n "$SSH_USER_PUB_KEY" ] ; then + if [ ! -f "$SSH_USER_PUB_KEY" ] ; then + echo "error: '$SSH_USER_PUB_KEY' specified SSH public key file not found (SSH_USER_PUB_KEY)!" + exit 1 + fi +fi + +if [ "$ENABLE_NEXMON" = true ] && [ -n "$KERNEL_BRANCH" ] ; then + echo "error: Please unset KERNEL_BRANCH if using ENABLE_NEXMON" + exit 1 +fi + +# Check if all required packages are installed on the build system +for package in $REQUIRED_PACKAGES ; do + if [ "$(dpkg-query -W -f='${Status}' "$package")" != "install ok installed" ] ; then + MISSING_PACKAGES="${MISSING_PACKAGES} $package" + fi +done + +# If there are missing packages ask confirmation for install, or exit +if [ -n "$MISSING_PACKAGES" ] ; then + echo "the following packages needed by this script are not installed:" + echo "$MISSING_PACKAGES" + + printf "\ndo you want to install the missing packages right now? [y/n] " + read -r confirm + [ "$confirm" != "y" ] && exit 1 + + ## Make sure all missing required packages are installed + apt-get update && apt-get -qq -y install `echo "${MISSING_PACKAGES}" | sed "s/ //"` +fi + +# Check if ./bootstrap.d directory exists +if [ ! -d "./bootstrap.d/" ] ; then + echo "error: './bootstrap.d' required directory not found!" + exit 1 +fi + +# Check if ./files directory exists +if [ ! -d "./files/" ] ; then + echo "error: './files' required directory not found!" + exit 1 +fi + +# Check if specified KERNELSRC_DIR directory exists +if [ -n "$KERNELSRC_DIR" ] && [ ! -d "$KERNELSRC_DIR" ] ; then + echo "error: '${KERNELSRC_DIR}' specified directory not found (KERNELSRC_DIR)!" + exit 1 +fi + +# Check if specified UBOOTSRC_DIR directory exists +if [ -n "$UBOOTSRC_DIR" ] && [ ! -d "$UBOOTSRC_DIR" ] ; then + echo "error: '${UBOOTSRC_DIR}' specified directory not found (UBOOTSRC_DIR)!" + exit 1 +fi + +# Check if specified VIDEOCORESRC_DIR directory exists +if [ -n "$VIDEOCORESRC_DIR" ] && [ ! -d "$VIDEOCORESRC_DIR" ] ; then + echo "error: '${VIDEOCORESRC_DIR}' specified directory not found (VIDEOCORESRC_DIR)!" + exit 1 +fi + +# Check if specified FBTURBOSRC_DIR directory exists +if [ -n "$FBTURBOSRC_DIR" ] && [ ! -d "$FBTURBOSRC_DIR" ] ; then + echo "error: '${FBTURBOSRC_DIR}' specified directory not found (FBTURBOSRC_DIR)!" + exit 1 +fi + +# Check if specified NEXMONSRC_DIR directory exists +if [ -n "$NEXMONSRC_DIR" ] && [ ! -d "$NEXMONSRC_DIR" ] ; then + echo "error: '${NEXMONSRC_DIR}' specified directory not found (NEXMONSRC_DIR)!" + exit 1 +fi + +# Check if specified CHROOT_SCRIPTS directory exists +if [ -n "$CHROOT_SCRIPTS" ] && [ ! -d "$CHROOT_SCRIPTS" ] ; then + echo "error: ${CHROOT_SCRIPTS} specified directory not found (CHROOT_SCRIPTS)!" + exit 1 +fi + +# Check if specified device mapping already exists (will be used by cryptsetup) +if [ -r "/dev/mapping/${CRYPTFS_MAPPING}" ] ; then + echo "error: mapping /dev/mapping/${CRYPTFS_MAPPING} already exists, not proceeding" + exit 1 +fi + +# Don't clobber an old build +if [ -e "$BUILDDIR" ] ; then + echo "error: directory ${BUILDDIR} already exists, not proceeding" + exit 1 +fi + +# Setup chroot directory +mkdir -p "${R}" + +# Check if build directory has enough of free disk space >512MB +if [ "$(df --output=avail "${BUILDDIR}" | sed "1d")" -le "524288" ] ; then + echo "error: ${BUILDDIR} not enough space left to generate the output image!" + exit 1 +fi + +set -x + +# Call "cleanup" function on various signals and errors +trap cleanup 0 1 2 3 6 + +# Add required packages for the minbase installation +if [ "$ENABLE_MINBASE" = true ] ; then + APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools,ifupdown" +fi + +# Add parted package, required to get partprobe utility +if [ "$EXPANDROOT" = true ] ; then + APT_INCLUDES="${APT_INCLUDES},parted" +fi + +# Add dphys-swapfile package, required to enable swap +if [ "$ENABLE_DPHYSSWAP" = true ] ; then + APT_INCLUDES="${APT_INCLUDES},dphys-swapfile" +fi + +# Add dbus package, recommended if using systemd +if [ "$ENABLE_DBUS" = true ] ; then + APT_INCLUDES="${APT_INCLUDES},dbus" +fi + +# Add iptables IPv4/IPv6 package +if [ "$ENABLE_IPTABLES" = true ] ; then + APT_INCLUDES="${APT_INCLUDES},iptables,iptables-persistent" +fi +# Add apparmor for KERNEL_SECURITY +if [ "$KERNEL_SECURITY" = true ] ; then + APT_INCLUDES="${APT_INCLUDES},apparmor,apparmor-utils,apparmor-profiles,apparmor-profiles-extra,libapparmor-perl" +fi + +# Add openssh server package +if [ "$SSH_ENABLE" = true ] ; then + APT_INCLUDES="${APT_INCLUDES},openssh-server" +fi + +# Add alsa-utils package +if [ "$ENABLE_SOUND" = true ] ; then + APT_INCLUDES="${APT_INCLUDES},alsa-utils" +fi + +# Add rng-tools-debian package +if [ "$ENABLE_HWRANDOM" = true ] ; then + APT_INCLUDES="${APT_INCLUDES},rng-tools-debian" +fi + +# Add fbturbo video driver +if [ "$ENABLE_FBTURBO" = true ] ; then + # Enable WAYLAND package dependencies + ENABLE_WAYLAND=true +fi + +# Add user defined window manager package +if [ -n "$ENABLE_WM" ] ; then + APT_INCLUDES="${APT_INCLUDES},${ENABLE_WM}" + + # Enable WAYLAND package dependencies + ENABLE_WAYLAND=true +fi + +# Add WAYLAND package +if [ "$ENABLE_WAYLAND" = true ] ; then + APT_INCLUDES="${APT_INCLUDES},xwayland" +fi + +# Replace selected packages with smaller clones +if [ "$ENABLE_REDUCE" = true ] ; then + ## Add levee package instead of vim-tiny + if [ "$REDUCE_VIM" = true ] ; then + APT_INCLUDES="$(echo ${APT_INCLUDES} | sed "s/vim-tiny/levee/")" + fi + + ## Add dropbear package instead of openssh-server + if [ "$REDUCE_SSHD" = true ] ; then + APT_INCLUDES="$(echo "${APT_INCLUDES}" | sed "s/openssh-server/dropbear/")" + fi +fi + +# Configure systemd-sysv exclude to make halt/reboot/shutdown scripts available +if [ "$ENABLE_SYSVINIT" = false ] ; then + APT_EXCLUDES="--exclude=${APT_EXCLUDES},init,systemd-sysv" +fi + +# Configure kernel sources if no KERNELSRC_DIR +if [ "$BUILD_KERNEL" = true ] && [ -z "$KERNELSRC_DIR" ] ; then + KERNELSRC_CONFIG=true +fi + +# Configure reduced kernel +if [ "$KERNEL_REDUCE" = true ] ; then + KERNELSRC_CONFIG=false +fi + +# Configure qemu compatible kernel +if [ "$ENABLE_QEMU" = true ] ; then + DTB_FILE=vexpress-v2p-ca15_a7.dtb + UBOOT_CONFIG=vexpress_ca15_tc2_defconfig + KERNEL_DEFCONFIG="vexpress_defconfig" + if [ "$KERNEL_MENUCONFIG" = false ] ; then + KERNEL_OLDDEFCONFIG=true + fi +fi + +# Execute bootstrap scripts +for SCRIPT in bootstrap.d/*.sh; do + head -n 3 "$SCRIPT" + . "$SCRIPT" +done + +## Execute custom bootstrap scripts +if [ -d "custom.d" ] ; then + for SCRIPT in custom.d/*.sh; do + . "$SCRIPT" + done +fi + +# Execute custom scripts inside the chroot +if [ -n "$CHROOT_SCRIPTS" ] && [ -d "$CHROOT_SCRIPTS" ] ; then + cp -r "${CHROOT_SCRIPTS}" "${R}/chroot_scripts" + chroot_exec /bin/bash -x <<'EOF' +for SCRIPT in /chroot_scripts/* ; do + if [ -f $SCRIPT -a -x $SCRIPT ] ; then + $SCRIPT + fi +done +EOF + rm -rf "${R}/chroot_scripts" +fi + +# Remove c/c++ build environment from the chroot +chroot_remove_cc + +# Generate required machine-id +MACHINE_ID=$(dbus-uuidgen) +echo -n "${MACHINE_ID}" > "${R}/var/lib/dbus/machine-id" +echo -n "${MACHINE_ID}" > "${ETC_DIR}/machine-id" + +# APT Cleanup +chroot_exec apt-get -y clean +chroot_exec apt-get -y autoclean +chroot_exec apt-get -y autoremove + +# Unmount mounted filesystems +umount -l "${R}/proc" +umount -l "${R}/sys" + +# Clean up directories +rm -rf "${R}/run/*" +rm -rf "${R}/tmp/*" + +# Clean up APT proxy settings +if [ "$KEEP_APT_PROXY" = false ] ; then + rm -f "${ETC_DIR}/apt/apt.conf.d/10proxy" +fi + +# Clean up files +rm -f "${ETC_DIR}/ssh/ssh_host_*" +rm -f "${ETC_DIR}/dropbear/dropbear_*" +rm -f "${ETC_DIR}/apt/sources.list.save" +rm -f "${ETC_DIR}/resolvconf/resolv.conf.d/original" +rm -f "${ETC_DIR}/*-" +rm -f "${ETC_DIR}/resolv.conf" +rm -f "${R}/root/.bash_history" +rm -f "${R}/var/lib/urandom/random-seed" +rm -f "${R}/initrd.img" +rm -f "${R}/vmlinuz" +rm -f "${R}${QEMU_BINARY}" + +if [ "$ENABLE_QEMU" = true ] ; then + # Setup QEMU directory + mkdir "${BASEDIR}/qemu" + + # Copy kernel image to QEMU directory + install_readonly "${BOOT_DIR}/${KERNEL_IMAGE}" "${BASEDIR}/qemu/${KERNEL_IMAGE}" + + # Copy kernel config to QEMU directory + install_readonly "${R}/boot/config-${KERNEL_VERSION}" "${BASEDIR}/qemu/config-${KERNEL_VERSION}" + + # Copy kernel dtbs to QEMU directory + for dtb in "${BOOT_DIR}/"*.dtb ; do + if [ -f "${dtb}" ] ; then + install_readonly "${dtb}" "${BASEDIR}/qemu/" + fi + done + + # Copy kernel overlays to QEMU directory + if [ -d "${BOOT_DIR}/overlays" ] ; then + # Setup overlays dtbs directory + mkdir "${BASEDIR}/qemu/overlays" + + for dtb in "${BOOT_DIR}/overlays/"*.dtbo ; do + if [ -f "${dtb}" ] ; then + install_readonly "${dtb}" "${BASEDIR}/qemu/overlays/" + fi + done + fi + + # Copy u-boot files to QEMU directory + if [ "$ENABLE_UBOOT" = true ] ; then + if [ -f "${BOOT_DIR}/u-boot.bin" ] ; then + install_readonly "${BOOT_DIR}/u-boot.bin" "${BASEDIR}/qemu/u-boot.bin" + fi + if [ -f "${BOOT_DIR}/uboot.mkimage" ] ; then + install_readonly "${BOOT_DIR}/uboot.mkimage" "${BASEDIR}/qemu/uboot.mkimage" + fi + if [ -f "${BOOT_DIR}/boot.scr" ] ; then + install_readonly "${BOOT_DIR}/boot.scr" "${BASEDIR}/qemu/boot.scr" + fi + fi + + # Copy initramfs to QEMU directory + if [ -f "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" ] ; then + install_readonly "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" "${BASEDIR}/qemu/initramfs-${KERNEL_VERSION}" + fi +fi + +# Calculate size of the chroot directory in KB +CHROOT_SIZE=$(expr "$(du -s "${R}" | awk '{ print $1 }')") + +# Calculate the amount of needed 512 Byte sectors +TABLE_SECTORS=$(expr 1 \* 1024 \* 1024 \/ 512) +FRMW_SECTORS=$(expr 128 \* 1024 \* 1024 \/ 512) +ROOT_OFFSET=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}") + +# The root partition is EXT4 +# This means more space than the actual used space of the chroot is used. +# As overhead for journaling and reserved blocks 35% are added. +ROOT_SECTORS=$(expr "$(expr "${CHROOT_SIZE}" + "${CHROOT_SIZE}" \/ 100 \* 35)" \* 1024 \/ 512) + +# Calculate required image size in 512 Byte sectors +IMAGE_SECTORS=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}") + +# Prepare image file +if [ "$ENABLE_SPLITFS" = true ] ; then + dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count="${TABLE_SECTORS}" + dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count=0 seek="${FRMW_SECTORS}" + dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count="${TABLE_SECTORS}" + dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count=0 seek="${ROOT_SECTORS}" + + ## Write firmware/boot partition tables + sfdisk -q -L -uS -f "$IMAGE_NAME-frmw.img" 2> /dev/null < /dev/null < /dev/null < .password + + # Initialize encrypted partition + cryptsetup --verbose --debug -q luksFormat "${ROOT_LOOP}" -c "${CRYPTFS_CIPHER}" -h "${CRYPTFS_HASH}" -s "${CRYPTFS_XTSKEYSIZE}" .password + + # Open encrypted partition and setup mapping + cryptsetup luksOpen "${ROOT_LOOP}" -d .password "${CRYPTFS_MAPPING}" + + # Secure delete password keyfile + shred -zu .password + + # Update temporary loop device + ROOT_LOOP="/dev/mapper/${CRYPTFS_MAPPING}" + + # Wipe encrypted partition (encryption cipher is used for randomness) + dd if=/dev/zero of="${ROOT_LOOP}" bs=512 count="$(blockdev --getsz "${ROOT_LOOP}")" +fi + +# Build filesystems +mkfs.vfat "$FRMW_LOOP" +mkfs.ext4 "$ROOT_LOOP" + +# Mount the temporary loop devices +mkdir -p "$BUILDDIR/mount" +mount "$ROOT_LOOP" "$BUILDDIR/mount" + +mkdir -p "$BUILDDIR/mount/boot/firmware" +mount "$FRMW_LOOP" "$BUILDDIR/mount/boot/firmware" + +# Copy all files from the chroot to the loop device mount point directory +rsync -a "${R}/" "$BUILDDIR/mount/" + +# Unmount all temporary loop devices and mount points +cleanup + +# Create block map file(s) of image(s) +if [ "$ENABLE_SPLITFS" = true ] ; then + # Create block map files for "bmaptool" + bmaptool create -o "$IMAGE_NAME-frmw.bmap" "$IMAGE_NAME-frmw.img" + bmaptool create -o "$IMAGE_NAME-root.bmap" "$IMAGE_NAME-root.img" + + # Image was successfully created + echo "$IMAGE_NAME-frmw.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created" + echo "$IMAGE_NAME-root.img ($(expr \( "${TABLE_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created" +else + # Create block map file for "bmaptool" + bmaptool create -o "$IMAGE_NAME.bmap" "$IMAGE_NAME.img" + + # Image was successfully created + echo "$IMAGE_NAME.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created" + + # Create qemu qcow2 image + if [ "$ENABLE_QEMU" = true ] ; then + QEMU_IMAGE=${QEMU_IMAGE:=${BASEDIR}/qemu/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}} + QEMU_SIZE=16G + + qemu-img convert -f raw -O qcow2 "$IMAGE_NAME".img "$QEMU_IMAGE".qcow2 + qemu-img resize "$QEMU_IMAGE".qcow2 $QEMU_SIZE + + echo "$QEMU_IMAGE.qcow2 ($QEMU_SIZE)" ": successfully created" + fi +fi diff --git a/templates/raspife0W-bullseye_22-01-10.conf b/templates/raspife0W-bullseye_22-01-10.conf new file mode 100644 index 0000000..eaa1d84 --- /dev/null +++ b/templates/raspife0W-bullseye_22-01-10.conf @@ -0,0 +1,161 @@ +# +# Configuration file raspi3 Bullseye IFÉ 2021/12/29 +# +#--------------------- +#--- APT settings ---- +#--------------------- +APT_SERVER=ftp.fr.debian.org +APT_INCLUDES="jed nginx curl wget htop \ +firmware-linux firmware-linux-nonfree \ +rfkill usbutils net-tools rsync make \ +binutils h5utils pcre2-utils util-linux bison byacc \ +openjdk-11-jdk openjdk-11-jre openjdk-11-jdk-headless openjdk-11-jre-headless \ +openjdk-17-jdk openjdk-17-jre openjdk-17-jdk-headless openjdk-17-jre-headless \ +libfontbox-java gcc g++ pipenv pcmanfm-qt autogen automake libtool \ +libpcre3-dev libpython3-all-dev libxslt1-dev sqlite3 \ +libjavascriptcoregtk-4.0-dev libsqlite3-dev liblua5.3-dev libjson-c-dev \ +autotools-dev autogen automake autoconf libpcre++-dev \ +python3 python3-geopy python3-dev python3-cheetah \ +python3-libxml2 libboost1.74-dev libfcgi-dev \ +libxfont-dev libfontenc-dev libboost-system-dev libboost-thread-dev \ +python3-nbconvert libxml2 doxygen \ +libgles2-mesa-dev xorg-dev \ +python3-pip python3-pkgconfig python3-netcdf4 python3-libxml2 \ +libconfuse-dev libcereal-dev libnetcdf-dev libhdf5-dev" +APT_INCLUDES_LATE="lxdm lxqt qterminal \ +git libssl-dev libcrypto++-dev fcgiwrap \ +mate-backgrounds gnome-backgrounds \ +php-fpm php-mysql icedtea-netx python3-openssl \ +wireshark imagemagick tk tcllib tigervnc-standalone-server tigervnc-common \ +pandoc python3-pypandoc python3-pandocfilters texlive-xetex \ +libffi-dev screen ffmpeg \ +texlive-latex-recommended texlive-lang-other cmst \ +xfonts-base fonts-liberation gsfonts \ +ttf-mscorefonts-installer xfonts-100dpi xfonts-75dpi xfonts-utils \ +systemd-sysv" +#------------------------------- +#--- General System Settings --- +#------------------------------- +SET_ARCH=32 +RPI_MODEL=0 +RELEASE="bullseye" +HOSTNAME="raspife0w" +DEFLOCAL="fr_FR.UTF-8" +TIMEZONE="Europe/Paris" +EXPANDROOT=false +#--------------------- +#--- User Settings --- +#--------------------- +ENABLE_ROOT=false +ROOT_PASSWORD="Achanger1$" +ENABLE_USER=true +USER_NAME=ens-ife +USER_PASSWORD="AChanger1$" +#------------------------- +#--- Keyboard Settings --- +#------------------------- +XKB_MODEL="pc105" +XKB_LAYOUT="fr" +XKB_VARIANT="latin9" +XKB_OPTIONS="" +#------------------------ +#--- Network Settings --- +#------------------------ +ENABLE_IPV6=true +ENABLE_WIRELESS=true +ENABLE_IPTABLES=false +ENABLE_IFNAMES=true +ENABLE_HARDNET=true +ENABLE_ETH_DHCP=false +ENABLE_WIFI_DHCP=true +NET_WIFI_SSID=MobileClimatEtMeteo +NET_WIFI_PSK=ClimatEtMeteo +#--------------------- +#--- Basic features--- +#--------------------- +ENABLE_CONSOLE=false +ENABLE_BLUETOOTH=false +ENABLE_MINIUART_OVERLAY=false +ENABLE_TURBO=true +ENABLE_I2C=true +ENABLE_SPI=true +SSH_ENABLE=true +ENABLE_NONFREE=true +ENABLE_RSYSLOG=true +ENABLE_SOUND=true +ENABLE_HWRANDOM=false +ENABLE_MINGPU=true +ENABLE_XORG=true +ENABLE_WM="openbox" +ENABLE_SYSVINIT=false +ENABLE_SPLASH=true +ENABLE_LOGO=true +ENABLE_SILENT_BOOT=false +#-------------------------------- +#--- Advanced System features --- +#-------------------------------- +ENABLE_DPHYSSWAP=false +ENABLE_QEMU=false +ENABLE_MINBASE=false +ENABLE_SPLITFS=false +ENABLE_INITRAMFS=true +ENABLE_DBUS=true +ENABLE_USBBOOT=false +ENABLE_UBOOT=false +# The 2 following are mutually excluded +ENABLE_FBTURBO=true +ENABLE_GR_ACCEL=false +ENABLE_VIDEOCORE=true +ENABLE_NEXMON=false +#-------------------- +#--- ssh settings --- +#-------------------- +SSH_ENABLE_ROOT=false +SSH_DISABLE_PASSWORD_AUTH=false +SSH_LIMIT_USERS=false +SSH_ROOT_PUB_KEY="/home/vidal/.ssh/authorized_keys" +SSH_USER_PUB_KEY="/home/vidal/.ssh/authorized_keys" +#----------------------- +#--- Kernel settings --- +#----------------------- +BUILD_KERNEL=true +KERNEL_BRANCH=rpi-5.15.y # brcmfmac fails with 5.15 on 2021/12/27 +KERNEL_REDUCE=false +KERNEL_HEADERS=true +KERNEL_MENUCONFIG=false +KERNEL_OLDDEFCONFIG=false +KERNEL_CCACHE=true +KERNEL_REMOVESRC=true +KERNELSRC_CLEAN=true +KERNELSRC_CONFIG=true +KERNEL_DEFAULT_GOV=ondemand +KERNEL_VIRT=false +KERNEL_SECURITY=false +KERNEL_DHKEY=true +#------------------------ +#--- Reduce disk usage -- +#------------------------ +ENABLE_REDUCE=false +REDUCE_APT=false +REDUCE_DOC=true +REDUCE_MAN=true +REDUCE_VIM=false +REDUCE_BASH=false +REDUCE_HWDB=false +REDUCE_BASH=false +REDUCE_SSHD=false +REDUCE_LOCALE=false +REDUCE_KERNEL=false +#-------------------------------- +#--- Encrypted root partition --- +#-------------------------------- +ENABLE_CRYPTFS=false +#---------------------- +#--- Build settings --- +#---------------------- +BASEDIR=../Images/${RELEASE} +#BASEDIR=/media/*******/*********/Nano-Ordinateurs/RaspberryPi/RpiGenImage/Images/${RELEASE} +DATE=`date +%Y-%m-%d` +IMAGE_NAME=${BASEDIR}/${DATE}-rpi${RPI_MODEL}-${RELEASE} + + diff --git a/templates/raspife3-bookworm_24-06-05.conf b/templates/raspife3-bookworm_24-06-05.conf new file mode 100644 index 0000000..098b621 --- /dev/null +++ b/templates/raspife3-bookworm_24-06-05.conf @@ -0,0 +1,164 @@ +# +# Configuration file raspi3 bookworm/trixie ENS de Lyon 2024/06/05 +# +#--------------------- +#--- APT settings ---- +#--------------------- +#APT_SERVER=debian.mirrors.ovh.net +APT_SERVER=debian.proxad.net +APT_INCLUDES="gawk,gnupg,dh-autoreconf,\ +gettext,build-essential,git,systemd-sysv,bc,\ +cmake,libjson-c-dev,unzip,usbutils,bison,\ +zstd,libc6,automake,autoconf,autogen,autotools-dev, \ +libtool,libtool-bin,libltdl-dev,pkg-config,\ +menulibre,libnotify-bin,pandoc,pm-utils,\ +acpi-support,python3,python3-dev,python3-pypandoc,\ +python3-scipy,python3-tk,python3-pandocfilters,\ +python3-geopy,python3-pip,python3,python3-dev,\ +python3-tk,python3-pip,python3-userpath, \ +pandoc,python3-configobj,python3-cheetah,\ +python3-pil,python3-serial,python3-usb,pcre2-utils,\ +libpcre2-dev,libjpeg-dev,i2c-tools,rsync, \ +python3-smbus,policykit-1,pmount,ntpdate,ntp,\ +nginx-extras,ffmpeg,network-manager,\ +console-data,keyboard-configuration,\ +libqt5webkit5-dev,libudev-dev, \ +gfortran-12,libgfortran-12-dev,\ +libzzip-dev,zlib1g-dev,libcanberra-gtk-module,\ +libnss-myhostname,libfreetype6-dev,libpng16-16,\ +libffi-dev,libltdl-dev,dbus-user-session,\ +debian-archive-keyring,curl,wget,mousepad,\ +htop,jed,nmap,libboost-all-dev, \ +libbrotli-dev,libhwy-dev,libjxl0.7,liblcms2-dev, \ +libjxl-dev,icedtea-netx,openjdk-17-jdk, \ +openjdk-17-jre,openjdk-17-jre-headless, \ +ca-certificates-java, \ +firmware-linux,firmware-linux-nonfree, \ +firmware-misc-nonfree,firmware-realtek, \ +firmware-brcm80211" +#------------------------------------- +# packages removed for various reasons +#------------------------------------- +#gnome-backgrounds,mate-backgrounds, \ +#geany,openbox-dev,openbox-lxde-session, +#xutils-dev,lxrandr, tightvncserver,\ +#,x11proto-randr-dev,terminator,texlive,texlive-xetex +#APT_INCLUDES_LATE="" + +#------------------------------- +#--- General System Settings --- +#------------------------------- +SET_ARCH=32 +RPI_MODEL=3 +RELEASE="bookworm" +RELEASE_ARCH="armhf" +HOSTNAME="raspife3" +DEFLOCAL="fr_FR.UTF-8" +TIMEZONE="Europe/Paris" +EXPANDROOT=false +ENABLE_QEMU=false +#--------------------- +#--- User Settings --- +#--------------------- +ENABLE_ROOT=false +ROOT_PASSWORD="Achanger1$" +ENABLE_USER=true +USER_NAME=ens-ife +USER_PASSWORD="AChanger1$" +#------------------------- +#--- Keyboard Settings --- +#------------------------- +XKB_MODEL="pc105" +XKB_LAYOUT="fr" +XKB_VARIANT="latin9" +XKB_OPTIONS="" +#------------------------ +#--- Network Settings --- +#------------------------ +ENABLE_IPV6=true +ENABLE_WIRELESS=false +ENABLE_IPTABLES=false +ENABLE_IFNAMES=true +ENABLE_HARDNET=true +ENABLE_ETH_DHCP=true +ENABLE_WIFI_DHCP=true +#NET_WIFI_SSID=MobileClimatEtMeteo +#NET_WIFI_PSK=ClimatEtMeteo +#--------------------- +#--- Basic features--- +#--------------------- +ENABLE_CONSOLE=false +ENABLE_BLUETOOTH=false +ENABLE_I2C=false +ENABLE_SPI=false +ENABLE_SSHD=true +SSH_ENABLE=true +ENABLE_NONFREE=true +ENABLE_RSYSLOG=true +ENABLE_SOUND=true +ENABLE_HWRANDOM=true +ENABLE_MINGPU=true +ENABLE_DBUS=true +ENABLE_XORG=false +ENABLE_WM="" +ENABLE_SYSVINIT=true +ENABLE_SPLASH=true +ENABLE_LOGO=true +#-------------------------------- +#--- Advanced System features --- +#-------------------------------- +ENABLE_DPHYSSWAP=false +ENABLE_QEMU=false +ENABLE_MINBASE=false +ENABLE_REDUCE=false +ENABLE_SPLITFS=false +ENABLE_INITRAMFS=true +ENABLE_DBUS=true +ENABLE_USBBOOT=false +ENABLE_UBOOT=false +ENABLE_FBTURBO=false +ENABLE_VIDEOCORE=false +ENABLE_HARDNET=true +ENABLE_IFNAMES=true +ENABLE_NEXMON=false +#DISABLE_UNDERVOLT_WARNINGS= +#-------------------- +#--- ssh settings --- +#-------------------- +SSH_ENABLE_ROOT=false +SSH_LIMIT_USERS=false +SSH_ROOT_PUB_KEY="/home/vidal/.ssh/authorized_keys" +SSH_USER_PUB_KEY="/home/vidal/.ssh/authorized_keys" +#----------------------- +#--- Kernel settings --- +#----------------------- +BUILD_KERNEL=true +KERNEL_BRANCH=rpi-6.6.y +KERNEL_REDUCE=false +KERNEL_HEADERS=true +KERNEL_REMOVESRC=true +KERNELSRC_CLEAN=true +KERNELSRC_CONFIG=true +KERNEL_DEFCONFIG=bcm2709_defconfig +KERNEL_BIN_IMAGE=zImage +KERNEL_IMAGE=kernel7.img +KERNEL_CCACHE=true +#------------------------ +#--- Reduce disk usage -- +#------------------------ +REDUCE_APT=false +REDUCE_DOC=true +REDUCE_MAN=true +REDUCE_HWDB=false +REDUCE_BASH=false +REDUCE_SSHD=false +REDUCE_LOCALE=false +#------------------------- +ENABLE_CRYPTFS=false +#------------------------- +BASEDIR=/home/vidal/Nano-Ordinateurs/RaspberryPi/RpiGenImage/Images/${RELEASE} +#BASEDIR=/media/*******/*********/Nano-Ordinateurs/RaspberryPi/RpiGenImage/Images/${RELEASE} +DATE=`date +%Y-%m-%d` +IMAGE_NAME=${BASEDIR}/${DATE}-rpi${RPI_MODEL}-${RELEASE} + + diff --git a/templates/raspife3Meteo-bookworm_25-02-02.conf b/templates/raspife3Meteo-bookworm_25-02-02.conf new file mode 100644 index 0000000..48009ae --- /dev/null +++ b/templates/raspife3Meteo-bookworm_25-02-02.conf @@ -0,0 +1,173 @@ +# +# Configuration file raspi3 bookworm/trixie ENS de Lyon 2024/06/05 +# +#--------------------- +#--- APT settings ---- +#--------------------- +#APT_SERVER=debian.mirrors.ovh.net +APT_SERVER=debian.proxad.net +APT_INCLUDES="gawk,gnupg,dh-autoreconf,\ +gettext,build-essential,git,systemd-sysv,bc,\ +cmake,libjson-c-dev,unzip,usbutils,bison,\ +zstd,libc6,automake,autoconf,autogen,autotools-dev, \ +libtool,libtool-bin,libltdl-dev,pkg-config,\ +menulibre,libnotify-bin,pandoc,pm-utils,\ +acpi-support,python3,python3-dev,python3-pypandoc,\ +python3-scipy,python3-tk,python3-pandocfilters,\ +python3-geopy,python3-pip,python3,python3-dev,\ +python3-tk,python3-pip,python3-userpath, \ +pandoc,python3-configobj,python3-cheetah,\ +python3-pil,python3-serial,python3-usb,pcre2-utils,\ +libpcre2-dev,libjpeg-dev,i2c-tools,rsync, \ +python3-smbus,policykit-1,pmount,ntpdate,ntp,\ +nginx-extras,ffmpeg,network-manager,\ +console-data,keyboard-configuration,\ +libqt5webkit5-dev,libudev-dev, \ +gfortran-12,libgfortran-12-dev,\ +libzzip-dev,zlib1g-dev,libcanberra-gtk-module,\ +libnss-myhostname,libfreetype6-dev,libpng16-16,\ +libffi-dev,libltdl-dev,dbus-user-session,\ +debian-archive-keyring,curl,wget,mousepad,\ +htop,jed,nmap,libboost-all-dev, \ +libbrotli-dev,libhwy-dev,libjxl0.7,liblcms2-dev, \ +libjxl-dev,icedtea-netx,openjdk-17-jdk, \ +openjdk-17-jre,openjdk-17-jre-headless, \ +ca-certificates-java, \ +firmware-linux,firmware-linux-nonfree, \ +firmware-misc-nonfree,firmware-realtek, \ +firmware-brcm80211" +#------------------------------------- +# packages removed for various reasons +#------------------------------------- +#gnome-backgrounds,mate-backgrounds, \ +#geany,openbox-dev,openbox-lxde-session, +#xutils-dev,lxrandr, tightvncserver,\ +#,x11proto-randr-dev,terminator,texlive,texlive-xetex +#APT_INCLUDES_LATE="" + +#------------------------------- +#--- General System Settings --- +#------------------------------- +SET_ARCH=32 +RPI_MODEL=3 +RELEASE="bookworm" +RELEASE_ARCH="armhf" +HOSTNAME="raspife3" +DEFLOCAL="fr_FR.UTF-8" +TIMEZONE="Europe/Paris" +EXPANDROOT=false +ENABLE_QEMU=false +#--------------------- +#--- User Settings --- +#--------------------- +ENABLE_ROOT=false +ROOT_PASSWORD="Achanger1$" +ENABLE_USER=true +USER_NAME=ens-ife +USER_PASSWORD="AChanger1$" +#------------------------- +#--- Keyboard Settings --- +#------------------------- +XKB_MODEL="pc105" +XKB_LAYOUT="fr" +XKB_VARIANT="latin9" +XKB_OPTIONS="" +#------------------------ +#--- Network Settings --- +#------------------------ +ENABLE_IPV6=true +ENABLE_WIRELESS=false +ENABLE_IPTABLES=false +ENABLE_IFNAMES=true +ENABLE_HARDNET=true +ENABLE_ETH_DHCP=true +ENABLE_WIFI_DHCP=true +#NET_WIFI_SSID=MobileClimatEtMeteo +#NET_WIFI_PSK=ClimatEtMeteo +#--------------------- +#--- Basic features--- +#--------------------- +ENABLE_CONSOLE=false +ENABLE_BLUETOOTH=false +ENABLE_I2C=false +ENABLE_SPI=false +ENABLE_SSHD=true +SSH_ENABLE=true +ENABLE_NONFREE=true +ENABLE_RSYSLOG=true +ENABLE_SOUND=true +ENABLE_HWRANDOM=true +ENABLE_MINGPU=true +ENABLE_DBUS=true +ENABLE_XORG=false +# ENABLE_WM="" +ENABLE_SYSVINIT=true +ENABLE_SPLASH=true +ENABLE_LOGO=true +#-------------------------------- +#--- Advanced System features --- +#-------------------------------- +ENABLE_DPHYSSWAP=false +ENABLE_QEMU=false +ENABLE_MINBASE=false +ENABLE_REDUCE=false +ENABLE_SPLITFS=false +ENABLE_INITRAMFS=true +ENABLE_DBUS=true +ENABLE_USBBOOT=false +ENABLE_UBOOT=false +ENABLE_FBTURBO=false +ENABLE_VIDEOCORE=false +ENABLE_HARDNET=true +ENABLE_IFNAMES=true +ENABLE_NEXMON=false +#DISABLE_UNDERVOLT_WARNINGS= +#-------------------- +#--- ssh settings --- +#-------------------- +SSH_ENABLE_ROOT=false +SSH_LIMIT_USERS=false +SSH_ROOT_PUB_KEY="/home/vidal/.ssh/authorized_keys" +SSH_USER_PUB_KEY="/home/vidal/.ssh/authorized_keys" +#----------------------- +#--- Kernel settings --- +#----------------------- +BUILD_KERNEL=true +KERNEL_BRANCH=rpi-6.6.y +KERNEL_REDUCE=false +KERNEL_HEADERS=true +KERNEL_REMOVESRC=true +KERNELSRC_CLEAN=true +KERNELSRC_CONFIG=true +KERNEL_DEFCONFIG=bcm2709_defconfig +KERNEL_BIN_IMAGE=zImage +KERNEL_IMAGE=kernel7.img +KERNEL_CCACHE=true +#------------------------ +#--- Reduce disk usage -- +#------------------------ +ENABLE_REDUCE=false +REDUCE_APT=false +REDUCE_DOC=true +REDUCE_MAN=false +REDUCE_VIM=false +REDUCE_BASH=false +REDUCE_HWDB=false +REDUCE_BASH=false +REDUCE_SSHD=false +REDUCE_LOCALE=false +REDUCE_KERNEL=false +#-------------------------------- +#--- Encrypted root partition --- +#-------------------------------- +ENABLE_CRYPTFS=false +#---------------------- +#--- Build settings --- +#---------------------- +#BASEDIR=/data/RpiGenImage/Images/${RELEASE} +BASEDIR=/home/vidal/Nano-Ordinateurs/RaspberryPi/RpiGenImage/Images/${RELEASE} +#BASEDIR=/media/*******/*********/Nano-Ordinateurs/RaspberryPi/RpiGenImage/Images/${RELEASE} +DATE=`date +%Y-%m-%d` +IMAGE_NAME=${BASEDIR}/${DATE}-rpi${RPI_MODEL}-${RELEASE} + + diff --git a/templates/raspife3P-buster_20-11-01.conf b/templates/raspife3P-buster_20-11-01.conf new file mode 100644 index 0000000..35e45ed --- /dev/null +++ b/templates/raspife3P-buster_20-11-01.conf @@ -0,0 +1,149 @@ +# +# Configuration file raspi3 Buster IFÉ 2020/11/01 +# +#--------------------- +#--- APT settings ---- +#--------------------- +APT_SERVER=ftp.fr.debian.org +APT_INCLUDES="jed terminator nginx curl wget htop" +APT_INCLUDES_LATE="pcre2-utils libpcre3-dev \ +openjdk-11-jdk openjdk-11-jre openjdk-11-jdk-headless openjdk-11-jre-headless \ +libpython3-all-dev bison byacc python-pip python3-pip python-pkgconfig python3-pkgconfig \ +python3-netcdf4 python-netcdf4 python-libxml2 libxslt1-dev python-libxslt1 \ +libxml2 libjavascriptcoregtk-4.0-dev \ +libffi-dev screen sqlite3 libsqlite3-dev liblua5.3-dev doxygen libftdi-dev \ +libconfuse-dev libcereal-dev libopenblas-dev libnetcdf-dev libhdf5-dev \ +git lxdm pcmanfm-qt libffi-dev ffmpeg \ +libssl-dev python-openssl python3-openssl libcrypto++-dev \ +mate-backgrounds gnome-backgrounds libjson-c-dev \ +fcgiwrap automake libtool libboost1.67-dev \ +php-fpm libfcgi-dev php7.3-mysql icedtea-netx \ +tigervnc-standalone-server tigervnc-common \ +docker.io openvswitch-switch wireshark imagemagick tk tcllib util-linux \ +xfonts-base fonts-liberation gsfonts libxfont-dev libfontenc-dev \ +ttf-mscorefonts-installer xfonts-100dpi xfonts-75dpi xfonts-base \ +autogen automake libtool libboost-system-dev libboost-thread-dev \ +xfonts-utils" +#------------------------------- +#--- General System Settings --- +#------------------------------- +SET_ARCH=32 +RPI_MODEL=3P +RELEASE="buster" +HOSTNAME="raspife3P" +DEFLOCAL="fr_FR.UTF-8" +TIMEZONE="Europe/Paris" +EXPANDROOT=false +#--------------------- +#--- User Settings --- +#--------------------- +ENABLE_ROOT=false +ROOT_PASSWORD="Achanger1$" +ENABLE_USER=true +USER_NAME=ens-ife +USER_PASSWORD="AChanger1$" +#------------------------- +#--- Keyboard Settings --- +#------------------------- +XKB_MODEL="pc105" +XKB_LAYOUT="fr" +XKB_VARIANT="latin9" +XKB_OPTIONS="" +#------------------------ +#--- Network Settings --- +#------------------------ +ENABLE_IPV6=true +ENABLE_WIRELESS=true +ENABLE_IPTABLES=false +ENABLE_IFNAMES=true +ENABLE_HARDNET=true +ENABLE_ETH_DHCP=true +ENABLE_WIFI_DHCP=true +NET_WIFI_SSID=MobileClimatEtMeteo +NET_WIFI_PSK=ClimatEtMeteo +#--------------------- +#--- Basic features--- +#--------------------- +ENABLE_CONSOLE=false +ENABLE_BLUETOOTH=false +ENABLE_MINIUART_OVERLAY=false +ENABLE_TURBO=false +ENABLE_I2C=true +ENABLE_SPI=true +SSH_ENABLE=true +ENABLE_NONFREE=true +ENABLE_RSYSLOG=true +ENABLE_SOUND=true +ENABLE_HWRANDOM=true +ENABLE_MINGPU=true +ENABLE_XORG=true +ENABLE_WM="lxqt" +ENABLE_SYSVINIT=true +ENABLE_SPLASH=true +ENABLE_LOGO=true +ENABLE_SILENT_BOOT=false +#-------------------------------- +#--- Advanced System features --- +#-------------------------------- +ENABLE_DPHYSSWAP=false +ENABLE_QEMU=false +ENABLE_MINBASE=false +ENABLE_SPLITFS=false +ENABLE_INITRAMFS=true +ENABLE_DBUS=true +ENABLE_USBBOOT=false +ENABLE_UBOOT=false +ENABLE_FBTURBO=true +ENABLE_VIDEOCORE=true +ENABLE_NEXMON=false +#-------------------- +#--- ssh settings --- +#-------------------- +SSH_ENABLE_ROOT=false +SSH_DISABLE_PASSWORD_AUTH=false +SSH_LIMIT_USERS=false +SSH_ROOT_PUB_KEY="/home/vidal/.ssh/authorized_keys" +SSH_USER_PUB_KEY="/home/vidal/.ssh/authorized_keys" +#----------------------- +#--- Kernel settings --- +#----------------------- +BUILD_KERNEL=true +KERNEL_BRANCH=rpi-4.19.y +KERNEL_REDUCE=false +KERNEL_HEADERS=true +KERNEL_MENUCONFIG=false +KERNEL_CCACHE=true +KERNEL_REMOVESRC=true +KERNELSRC_CLEAN=true +KERNELSRC_CONFIG=true +KERNEL_DEFAULT_GOV=ondemand +KERNEL_VIRT=false +KERNEL_SECURITY=false +KERNEL_DHKEY=true +#------------------------ +#--- Reduce disk usage -- +#------------------------ +ENABLE_REDUCE=false +REDUCE_APT=false +REDUCE_DOC=true +REDUCE_MAN=false +REDUCE_VIM=false +REDUCE_BASH=false +REDUCE_HWDB=false +REDUCE_BASH=false +REDUCE_SSHD=false +REDUCE_LOCALE=false +REDUCE_KERNEL=false +#-------------------------------- +#--- Encrypted root partition --- +#-------------------------------- +ENABLE_CRYPTFS=false +#---------------------- +#--- Build settings --- +#---------------------- +BASEDIR=/data/RpiGenImage/Images/${RELEASE} +#BASEDIR=/media/*******/*********/Nano-Ordinateurs/RaspberryPi/RpiGenImage/Images/${RELEASE} +DATE=`date +%Y-%m-%d` +IMAGE_NAME=${BASEDIR}/${DATE}-rpi${RPI_MODEL}-${RELEASE} + + diff --git a/templates/raspife4-32-buster_20-02-04.conf b/templates/raspife4-32-buster_20-02-04.conf new file mode 100644 index 0000000..0657984 --- /dev/null +++ b/templates/raspife4-32-buster_20-02-04.conf @@ -0,0 +1,122 @@ +# Configuration file raspi3 buster IFÉ 2020/02/04 +# +APT_SERVER=debian.mirrors.ovh.net +#APT_SERVER=debian.proxad.net +APT_INCLUDES="gawk,gnupg,firmware-linux,\ +firmware-linux-nonfree,firmware-misc-nonfree,\ +firmware-realtek,firmware-brcm80211,dh-autoreconf,\ +gettext,build-essential,git,systemd-sysv,bc,\ +cmake,libjson-c-dev,unzip,usbutils,bison,\ +automake,autoconf,autogen,\ +libtool,libtool-bin,libltdl-dev,pkg-config,\ +menulibre,libnotify-bin,pandoc,pm-utils,\ +acpi-support,python3,python3-dev,python3-pypandoc,\ +python3-scipy,python3-tk,python3-pandocfilters,\ +python3-geopy,python3-pip,python,python-dev,\ +python-tk,python-pip,\ +python-tk,pandoc,python-configobj,python-cheetah,\ +python-pil,python-serial,python-usb,pcre2-utils,\ +libpcre++-dev,libpcre2-dev,libjpeg-dev,i2c-tools,\ +python3-smbus,policykit-1,pmount,ntpdate,ntp,\ +rsync,gnome-backgrounds,mate-backgrounds,texlive,\ +texlive-xetex,nginx-extras,ffmpeg,network-manager,\ +console-data,keyboard-configuration,\ +libqt5webkit5-dev,libudev-dev,gfortran-8,\ +libgfortran-8-dev,\ +libzzip-dev,zlib1g-dev,libcanberra-gtk-module,\ +libnss-myhostname,libfreetype6-dev,libpng16-16,\ +libffi-dev,libltdl-dev,dbus-user-session,\ +debian-archive-keyring,curl,wget,mousepad,\ +xutils-dev,\ +tightvncserver,geany,openbox-menu,\ +autotools-dev,htop,ca-certificates-java,\ +icedtea-netx,openjdk-11-jdk,\ +openjdk-11-jre,openjdk-11-jre-headless,\ +jed,nmap,terminator,libboost-all-dev" +#x11proto-randr-dev,lxrandr,\ +#APT_INCLUDES_LATE="jed,\ +#" +#---------------------- +RPI_MODEL=4 +RELEASE="buster" +RELEASE_ARCH="arm64" +SET_ARCH=32 +HOSTNAME="raspife4" +PASSWORD="AChanger1$" +USER_PASSWORD="AChanger1$" +DEFLOCAL="fr_FR.UTF-8" +TIMEZONE="Europe/Paris" +EXPANDROOT=false +ENABLE_QEMU=false +#----------------------- +XKB_MODEL="pc105" +XKB_LAYOUT="fr" +XKB_VARIANT="latin9" +XKB_OPTIONS="" +#------------------------ +ENABLE_DHCP=true +#------------------------ +ENABLE_CONSOLE=false +ENABLE_BLUETOOTH=false +ENABLE_I2C=true +ENABLE_SPI=true +ENABLE_IPV6=true +ENABLE_SSHD=true +ENABLE_NONFREE=true +ENABLE_WIRELESS=true +ENABLE_RSYSLOG=true +ENABLE_SOUND=true +ENABLE_HWRANDOM=true +ENABLE_MINGPU=true +ENABLE_DBUS=true +ENABLE_XORG=true +ENABLE_WM="openbox" +ENABLE_SYSVINIT=true +#------------------------ +ENABLE_MINBASE=false +ENABLE_REDUCE=false +ENABLE_UBOOT=false +ENABLE_FBTURBO=false +ENABLE_VIDEOCORE=true +ENABLE_IPTABLES=false +ENABLE_USER=true +USER_NAME=ens-ife +ENABLE_ROOT=false +ENABLE_HARDNET=true +ENABLE_INITRAMFS=true +ENABLE_IFNAMES=true +#DISABLE_UNDERVOLT_WARNINGS= +#------------------------ +SSH_ENABLE_ROOT=false +SSH_LIMIT_USERS=false +SSH_ROOT_PUB_KEY="/home/vidal/.ssh/authorized_keys" +SSH_USER_PUB_KEY="/home/vidal/.ssh/authorized_keys" +#------------------------ +BUILD_KERNEL=true +KERNEL_BRANCH=rpi-4.19.y +KERNEL_REDUCE=false +KERNEL_HEADERS=true +KERNEL_REMOVESRC=true +KERNELSRC_CLEAN=true +KERNELSRC_CONFIG=true +#KERNEL_DEFCONFIG=bcm2835_defconfig +#KERNEL_BIN_IMAGE=Image +#KERNEL_IMAGE=kernel7.img +KERNEL_CCACHE=true +#------------------------ +REDUCE_APT=false +REDUCE_DOC=true +REDUCE_MAN=true +REDUCE_HWDB=false +REDUCE_BASH=false +REDUCE_SSHD=false +REDUCE_LOCALE=false +#------------------------- +ENABLE_CRYPTFS=false +#------------------------- +BASEDIR=/storage/RpiGenImage/Images/${RELEASE} +#BASEDIR=/media/*******/*********/Nano-Ordinateurs/RaspberryPi/RpiGenImage/Images/${RELEASE} +DATE=`date +%Y-%m-%d` +IMAGE_NAME=${BASEDIR}/${DATE}-rpi${RPI_MODEL}-${RELEASE}-${SET_ARCH} + + diff --git a/templates/raspife4-buster_20-11-01.conf b/templates/raspife4-buster_20-11-01.conf new file mode 100644 index 0000000..fcca57a --- /dev/null +++ b/templates/raspife4-buster_20-11-01.conf @@ -0,0 +1,149 @@ +# +# Configuration file raspi3 Buster IFÉ 2020/11/01 +# +#--------------------- +#--- APT settings ---- +#--------------------- +APT_SERVER=ftp.fr.debian.org +APT_INCLUDES="jed terminator nginx curl wget htop" +APT_INCLUDES_LATE="pcre2-utils libpcre3-dev \ +openjdk-11-jdk openjdk-11-jre openjdk-11-jdk-headless openjdk-11-jre-headless \ +libpython3-all-dev bison byacc python-pip python3-pip python-pkgconfig python3-pkgconfig \ +python3-netcdf4 python-netcdf4 python-libxml2 libxslt1-dev python-libxslt1 \ +libxml2 libjavascriptcoregtk-4.0-dev \ +libffi-dev screen sqlite3 libsqlite3-dev liblua5.3-dev doxygen libftdi-dev \ +libconfuse-dev libcereal-dev libopenblas-dev libnetcdf-dev libhdf5-dev \ +git lxdm pcmanfm-qt libffi-dev ffmpeg \ +libssl-dev python-openssl python3-openssl libcrypto++-dev \ +mate-backgrounds gnome-backgrounds \ +fcgiwrap automake libtool libboost1.67-dev \ +php-fpm libfcgi-dev php7.3-mysql icedtea-netx \ +tigervnc-standalone-server tigervnc-common \ +docker.io openvswitch-switch wireshark imagemagick tk tcllib util-linux \ +xfonts-base fonts-liberation gsfonts libxfont-dev libfontenc-dev \ +ttf-mscorefonts-installer xfonts-100dpi xfonts-75dpi xfonts-base \ +autogen automake libtool libboost-system-dev libboost-thread-dev \ +xfonts-utils" +#------------------------------- +#--- General System Settings --- +#------------------------------- +RPI_MODEL=4 +SET_ARCH=32 +RELEASE="buster" +HOSTNAME="raspife4" +DEFLOCAL="fr_FR.UTF-8" +TIMEZONE="Europe/Paris" +EXPANDROOT=false +#--------------------- +#--- User Settings --- +#--------------------- +ENABLE_ROOT=false +ROOT_PASSWORD="Achanger1$" +ENABLE_USER=true +USER_NAME=ens-ife +USER_PASSWORD="AChanger1$" +#------------------------- +#--- Keyboard Settings --- +#------------------------- +XKB_MODEL="pc105" +XKB_LAYOUT="fr" +XKB_VARIANT="latin9" +XKB_OPTIONS="" +#------------------------ +#--- Network Settings --- +#------------------------ +ENABLE_IPV6=true +ENABLE_WIRELESS=true +ENABLE_IPTABLES=false +ENABLE_IFNAMES=true +ENABLE_HARDNET=true +ENABLE_ETH_DHCP=true +ENABLE_WIFI_DHCP=true +NET_WIFI_SSID=MobileClimatEtMeteo +NET_WIFI_PSK=ClimatEtMeteo +#--------------------- +#--- Basic features--- +#--------------------- +ENABLE_CONSOLE=false +ENABLE_BLUETOOTH=false +ENABLE_MINIUART_OVERLAY=false +ENABLE_TURBO=false +ENABLE_I2C=true +ENABLE_SPI=true +SSH_ENABLE=true +ENABLE_NONFREE=true +ENABLE_RSYSLOG=true +ENABLE_SOUND=true +ENABLE_HWRANDOM=true +ENABLE_MINGPU=true +ENABLE_XORG=true +ENABLE_WM="lxqt" +ENABLE_SYSVINIT=true +ENABLE_SPLASH=true +ENABLE_LOGO=true +ENABLE_SILENT_BOOT=false +#-------------------------------- +#--- Advanced System features --- +#-------------------------------- +ENABLE_DPHYSSWAP=false +ENABLE_QEMU=false +ENABLE_MINBASE=false +ENABLE_SPLITFS=false +ENABLE_INITRAMFS=true +ENABLE_DBUS=true +ENABLE_USBBOOT=false +ENABLE_UBOOT=false +ENABLE_FBTURBO=true +ENABLE_VIDEOCORE=true +ENABLE_NEXMON=false +#-------------------- +#--- ssh settings --- +#-------------------- +SSH_ENABLE_ROOT=false +SSH_DISABLE_PASSWORD_AUTH=false +SSH_LIMIT_USERS=false +SSH_ROOT_PUB_KEY="/home/vidal/.ssh/authorized_keys" +SSH_USER_PUB_KEY="/home/vidal/.ssh/authorized_keys" +#----------------------- +#--- Kernel settings --- +#----------------------- +BUILD_KERNEL=true +KERNEL_BRANCH=rpi-5.4.y +KERNEL_REDUCE=false +KERNEL_HEADERS=true +KERNEL_MENUCONFIG=false +KERNEL_CCACHE=true +KERNEL_REMOVESRC=true +KERNELSRC_CLEAN=true +KERNELSRC_CONFIG=true +KERNEL_DEFAULT_GOV=ondemand +KERNEL_VIRT=false +KERNEL_SECURITY=false +KERNEL_DHKEY=true +#------------------------ +#--- Reduce disk usage -- +#------------------------ +ENABLE_REDUCE=false +REDUCE_APT=false +REDUCE_DOC=true +REDUCE_MAN=false +REDUCE_VIM=false +REDUCE_BASH=false +REDUCE_HWDB=false +REDUCE_BASH=false +REDUCE_SSHD=false +REDUCE_LOCALE=false +REDUCE_KERNEL=false +#-------------------------------- +#--- Encrypted root partition --- +#-------------------------------- +ENABLE_CRYPTFS=false +#---------------------- +#--- Build settings --- +#---------------------- +BASEDIR=/data/RpiGenImage/Images/${RELEASE} +#BASEDIR=/media/*******/*********/Nano-Ordinateurs/RaspberryPi/RpiGenImage/Images/${RELEASE} +DATE=`date +%Y-%m-%d` +IMAGE_NAME=${BASEDIR}/${DATE}-rpi${RPI_MODEL}-${RELEASE} + + diff --git a/templates/rpi0buster.conf b/templates/rpi0buster.conf new file mode 100644 index 0000000..3300983 --- /dev/null +++ b/templates/rpi0buster.conf @@ -0,0 +1,5 @@ +# Configuration template file used by rpi23-gen-image.sh +RPI_MODEL=0 +RELEASE=buster +BUILD_KERNEL=true +# ENABLE_BLUETOOTH=false diff --git a/templates/rpi1Pbuster.conf b/templates/rpi1Pbuster.conf new file mode 100644 index 0000000..c1e846f --- /dev/null +++ b/templates/rpi1Pbuster.conf @@ -0,0 +1,4 @@ +# Configuration template file used by rpi23-gen-image.sh +RPI_MODEL=1P +RELEASE=buster +BUILD_KERNEL=true diff --git a/templates/rpi1stretch.conf b/templates/rpi1stretch.conf new file mode 100644 index 0000000..735dea2 --- /dev/null +++ b/templates/rpi1stretch.conf @@ -0,0 +1,4 @@ +# Configuration template file used by rpi23-gen-image.sh +RPI_MODEL=2 +RELEASE=stretch +BUILD_KERNEL=true diff --git a/templates/rpi2stretch.conf b/templates/rpi2stretch.conf new file mode 100644 index 0000000..735dea2 --- /dev/null +++ b/templates/rpi2stretch.conf @@ -0,0 +1,4 @@ +# Configuration template file used by rpi23-gen-image.sh +RPI_MODEL=2 +RELEASE=stretch +BUILD_KERNEL=true diff --git a/templates/rpi3-Full-bookworm_24-06-06.conf b/templates/rpi3-Full-bookworm_24-06-06.conf new file mode 100644 index 0000000..9c55790 --- /dev/null +++ b/templates/rpi3-Full-bookworm_24-06-06.conf @@ -0,0 +1,164 @@ +# +# Configuration file raspi3 bookworm/trixie ENS de Lyon 2024/06/07 +# +#--------------------- +#--- APT settings ---- +#--------------------- +#APT_SERVER=debian.mirrors.ovh.net +APT_SERVER=debian.proxad.net +APT_INCLUDES="gawk,gnupg,dh-autoreconf,\ +gettext,build-essential,git,systemd-sysv,bc,\ +cmake,libjson-c-dev,unzip,usbutils,bison,\ +zstd,libc6,automake,autoconf,autogen,autotools-dev, \ +libtool,libtool-bin,libltdl-dev,pkg-config,\ +menulibre,libnotify-bin,pandoc,pm-utils,\ +acpi-support,python3,python3-dev,python3-pypandoc,\ +python3-scipy,python3-tk,python3-pandocfilters,\ +python3-geopy,python3-pip,python3,python3-dev,\ +python3-tk,python3-pip,python3-userpath, \ +pandoc,python3-configobj,python3-cheetah,\ +python3-pil,python3-serial,python3-usb,pcre2-utils,\ +libpcre2-dev,libjpeg-dev,i2c-tools,rsync, \ +python3-smbus,policykit-1,pmount,ntpdate,ntp,\ +nginx-extras,ffmpeg,network-manager,\ +console-data,keyboard-configuration,\ +libqt5webkit5-dev,libudev-dev, \ +gfortran-12,libgfortran-12-dev,\ +libzzip-dev,zlib1g-dev,libcanberra-gtk-module,\ +libnss-myhostname,libfreetype6-dev,libpng16-16,\ +libffi-dev,libltdl-dev,dbus-user-session,\ +debian-archive-keyring,curl,wget,mousepad,\ +htop,jed,nmap,libboost-all-dev, \ +libbrotli-dev,libhwy-dev,libjxl0.7,liblcms2-dev, \ +libjxl-dev,icedtea-netx,openjdk-17-jdk, \ +openjdk-17-jre,openjdk-17-jre-headless, \ +ca-certificates-java,net-tools \ +firmware-linux,firmware-linux-nonfree, \ +firmware-misc-nonfree,firmware-realtek, \ +firmware-brcm80211,gnome-backgrounds, \ +lightdm,mate-backgrounds, \ +geany,xrdp, \ +xutils-dev,lxrandr, tightvncserver,\ +terminator,texlive,texlive-xetex" +#------------------------------------- +# packages removed for various reasons +#------------------------------------- +#APT_INCLUDES_LATE="" + +#------------------------------- +#--- General System Settings --- +#------------------------------- +SET_ARCH=32 +RPI_MODEL=3 +RELEASE="bookworm" +RELEASE_ARCH="armhf" +HOSTNAME="raspife3" +DEFLOCAL="fr_FR.UTF-8" +TIMEZONE="Europe/Paris" +EXPANDROOT=false +ENABLE_QEMU=false +#--------------------- +#--- User Settings --- +#--------------------- +ENABLE_ROOT=false +ROOT_PASSWORD="Achanger1$" +ENABLE_USER=true +USER_NAME=ens-ife +USER_PASSWORD="AChanger1$" +#------------------------- +#--- Keyboard Settings --- +#------------------------- +XKB_MODEL="pc105" +XKB_LAYOUT="fr" +XKB_VARIANT="latin9" +XKB_OPTIONS="" +#------------------------ +#--- Network Settings --- +#------------------------ +ENABLE_IPV6=true +ENABLE_WIRELESS=false +ENABLE_IPTABLES=false +ENABLE_IFNAMES=true +ENABLE_HARDNET=true +ENABLE_ETH_DHCP=true +ENABLE_WIFI_DHCP=true +NET_WIFI_SSID=MobileClimatEtMeteo +NET_WIFI_PSK=ClimatEtMeteo +#--------------------- +#--- Basic features--- +#--------------------- +ENABLE_CONSOLE=false +ENABLE_BLUETOOTH=false +ENABLE_I2C=false +ENABLE_SPI=false +ENABLE_SSHD=true +SSH_ENABLE=true +ENABLE_NONFREE=true +ENABLE_RSYSLOG=true +ENABLE_SOUND=true +ENABLE_HWRANDOM=true +ENABLE_MINGPU=true +ENABLE_DBUS=true +ENABLE_WAYLAND=true +ENABLE_WM="task-lxqt-desktop" +ENABLE_SYSVINIT=true +ENABLE_SPLASH=true +ENABLE_LOGO=true +#-------------------------------- +#--- Advanced System features --- +#-------------------------------- +ENABLE_DPHYSSWAP=false +ENABLE_QEMU=false +ENABLE_MINBASE=false +ENABLE_REDUCE=false +ENABLE_SPLITFS=false +ENABLE_INITRAMFS=true +ENABLE_DBUS=true +ENABLE_USBBOOT=false +ENABLE_UBOOT=false +ENABLE_FBTURBO=true +ENABLE_VIDEOCORE=false +ENABLE_HARDNET=true +ENABLE_IFNAMES=true +ENABLE_NEXMON=false +#DISABLE_UNDERVOLT_WARNINGS= +#-------------------- +#--- ssh settings --- +#-------------------- +SSH_ENABLE_ROOT=false +SSH_LIMIT_USERS=false +SSH_ROOT_PUB_KEY="/home/vidal/.ssh/authorized_keys" +SSH_USER_PUB_KEY="/home/vidal/.ssh/authorized_keys" +#----------------------- +#--- Kernel settings --- +#----------------------- +BUILD_KERNEL=true +KERNEL_BRANCH=rpi-6.6.y +KERNEL_REDUCE=false +KERNEL_HEADERS=true +KERNEL_REMOVESRC=true +KERNELSRC_CLEAN=true +KERNELSRC_CONFIG=true +KERNEL_DEFCONFIG=bcm2709_defconfig +KERNEL_BIN_IMAGE=zImage +KERNEL_IMAGE=kernel7.img +KERNEL_CCACHE=true +#------------------------ +#--- Reduce disk usage -- +#------------------------ +REDUCE_APT=false +REDUCE_DOC=true +REDUCE_MAN=true +REDUCE_HWDB=false +REDUCE_BASH=false +REDUCE_SSHD=false +REDUCE_LOCALE=false +#------------------------- +ENABLE_CRYPTFS=false +#------------------------- +BASEDIR=/home/vidal/Nano-Ordinateurs/RaspberryPi/RpiGenImage/Images/${RELEASE} +#BASEDIR=/media/*******/*********/Nano-Ordinateurs/RaspberryPi/RpiGenImage/Images/${RELEASE} +DATE=`date +%Y-%m-%d` +IMAGE_NAME=${BASEDIR}/${DATE}-rpi${RPI_MODEL}-${RELEASE} + + diff --git a/templates/rpi3-Full-trixie_24-06-16.conf b/templates/rpi3-Full-trixie_24-06-16.conf new file mode 100644 index 0000000..36e7573 --- /dev/null +++ b/templates/rpi3-Full-trixie_24-06-16.conf @@ -0,0 +1,170 @@ +# +# Configuration file raspi3 bookworm/trixie ENS de Lyon 2024/06/07 +# +#--------------------- +#--- APT settings ---- +#--------------------- +#APT_SERVER=debian.mirrors.ovh.net +APT_SERVER=debian.proxad.net +APT_INCLUDES="gawk,gnupg,dh-autoreconf,\ +gettext,build-essential,git,systemd-sysv,bc,\ +cmake,libjson-c-dev,unzip,usbutils,bison,\ +zstd,libc6,automake,autoconf,autogen,autotools-dev, \ +libtool,libtool-bin,libltdl-dev,pkg-config,\ +libnotify-bin,pandoc,pm-utils,\ +acpi-support,python3,python3-dev,python3-pypandoc,\ +python3-scipy,python3-tk,python3-pandocfilters,\ +python3-geopy,python3-pip,python3,python3-dev,\ +python3-tk,python3-pip,python3-userpath, \ +pandoc,python3-configobj,python3-cheetah,\ +python3-pil,python3-serial,python3-usb,pcre2-utils,\ +libpcre2-dev,libjpeg-dev,i2c-tools,rsync, \ +python3-smbus,policykit-1,pmount,ntpdate,ntp,\ +nginx-extras,ffmpeg,network-manager,\ +console-data,keyboard-configuration,\ +libqt5webkit5-dev,libudev-dev, \ +gfortran-12,libgfortran-12-dev,\ +libzzip-dev,zlib1g-dev,libcanberra-gtk3-module,\ +libnss-myhostname,libfreetype-dev,libpng16-16t64,\ +libffi-dev,libltdl-dev,dbus-user-session,\ +debian-archive-keyring,curl,wget,mousepad,\ +htop,jed,nmap,libboost-all-dev, \ +libbrotli-dev,libhwy-dev,libjxl0.8,liblcms2-dev, \ +libjxl-dev,icedtea-netx,openjdk-17-jdk, \ +openjdk-17-jre,openjdk-17-jre-headless, \ +net-tools \ +firmware-linux,firmware-linux-nonfree, \ +firmware-misc-nonfree,firmware-realtek, \ +firmware-brcm80211,gnome-backgrounds, \ +lightdm,mate-backgrounds, \ +xrdp, \ +xutils-dev,lxrandr" +#------------------------------------- +# packages removed for various reasons +#------------------------------------- +# , tightvncserver +# ca-certificates-java,menulibre, \ +# gir1.2-cairo-1.0,gir1.2-xlib-2.0, \ +# gir1.2-freetype2-2.0,gir1.2-fontconfig-2.0, \ +# gir1.2-xft-2.0, \ +# terminator,texlive,texlive-xetex +#APT_INCLUDES_LATE="" + +#------------------------------- +#--- General System Settings --- +#------------------------------- +SET_ARCH=32 +RPI_MODEL=3 +HOSTRELEASE="trixie" +RELEASE="trixie" +RELEASE_ARCH="armhf" +HOSTNAME="raspife3" +DEFLOCAL="fr_FR.UTF-8" +TIMEZONE="Europe/Paris" +EXPANDROOT=false +ENABLE_QEMU=false +#--------------------- +#--- User Settings --- +#--------------------- +ENABLE_ROOT=false +ROOT_PASSWORD="Achanger1$" +ENABLE_USER=true +USER_NAME=ens-ife +USER_PASSWORD="AChanger1$" +#------------------------- +#--- Keyboard Settings --- +#------------------------- +XKB_MODEL="pc105" +XKB_LAYOUT="fr" +XKB_VARIANT="latin9" +XKB_OPTIONS="" +#------------------------ +#--- Network Settings --- +#------------------------ +ENABLE_IPV6=true +ENABLE_WIRELESS=false +ENABLE_IPTABLES=false +ENABLE_IFNAMES=true +ENABLE_HARDNET=true +ENABLE_ETH_DHCP=true +ENABLE_WIFI_DHCP=true +NET_WIFI_SSID=MobileClimatEtMeteo +NET_WIFI_PSK=ClimatEtMeteo +#--------------------- +#--- Basic features--- +#--------------------- +ENABLE_CONSOLE=false +ENABLE_BLUETOOTH=false +ENABLE_I2C=false +ENABLE_SPI=false +ENABLE_SSHD=true +SSH_ENABLE=true +ENABLE_NONFREE=true +ENABLE_RSYSLOG=true +ENABLE_SOUND=true +ENABLE_HWRANDOM=true +ENABLE_MINGPU=true +ENABLE_DBUS=true +ENABLE_WAYLAND=true +ENABLE_WM="lxqt" +ENABLE_SYSVINIT=true +ENABLE_SPLASH=true +ENABLE_LOGO=true +#-------------------------------- +#--- Advanced System features --- +#-------------------------------- +ENABLE_DPHYSSWAP=false +ENABLE_QEMU=false +ENABLE_MINBASE=false +ENABLE_REDUCE=false +ENABLE_SPLITFS=false +ENABLE_INITRAMFS=true +ENABLE_DBUS=true +ENABLE_USBBOOT=false +ENABLE_UBOOT=false +ENABLE_FBTURBO=true +ENABLE_VIDEOCORE=false +ENABLE_HARDNET=true +ENABLE_IFNAMES=true +ENABLE_NEXMON=false +#DISABLE_UNDERVOLT_WARNINGS= +#-------------------- +#--- ssh settings --- +#-------------------- +SSH_ENABLE_ROOT=false +SSH_LIMIT_USERS=false +SSH_ROOT_PUB_KEY="/home/vidal/.ssh/authorized_keys" +SSH_USER_PUB_KEY="/home/vidal/.ssh/authorized_keys" +#----------------------- +#--- Kernel settings --- +#----------------------- +BUILD_KERNEL=true +KERNEL_BRANCH=rpi-6.6.y +KERNEL_REDUCE=false +KERNEL_HEADERS=true +KERNEL_REMOVESRC=true +KERNELSRC_CLEAN=true +KERNELSRC_CONFIG=true +KERNEL_DEFCONFIG=bcm2709_defconfig +KERNEL_BIN_IMAGE=zImage +KERNEL_IMAGE=kernel7.img +KERNEL_CCACHE=true +#------------------------ +#--- Reduce disk usage -- +#------------------------ +REDUCE_APT=false +REDUCE_DOC=true +REDUCE_MAN=true +REDUCE_HWDB=false +REDUCE_BASH=false +REDUCE_SSHD=false +REDUCE_LOCALE=false +#------------------------- +ENABLE_CRYPTFS=false +#------------------------- +BASEDIR=/home/vidal/Nano-Ordinateurs/RaspberryPi/RpiGenImage/Images/${RELEASE} +#BASEDIR=/media/*******/*********/Nano-Ordinateurs/RaspberryPi/RpiGenImage/Images/${RELEASE} +DATE=`date +%Y-%m-%d` +IMAGE_NAME=${BASEDIR}/${DATE}-rpi${RPI_MODEL}-${RELEASE} + + diff --git a/templates/rpi3-Met-bookworm_24-06-06.conf b/templates/rpi3-Met-bookworm_24-06-06.conf new file mode 100644 index 0000000..31b9a1a --- /dev/null +++ b/templates/rpi3-Met-bookworm_24-06-06.conf @@ -0,0 +1,164 @@ +# +# Configuration file raspi3 bookworm/trixie ENS de Lyon 2024/06/05 +# +#--------------------- +#--- APT settings ---- +#--------------------- +#APT_SERVER=debian.mirrors.ovh.net +APT_SERVER=debian.proxad.net +APT_INCLUDES="gawk,gnupg,dh-autoreconf,\ +gettext,build-essential,git,systemd-sysv,bc,\ +cmake,libjson-c-dev,unzip,usbutils,bison,\ +zstd,libc6,automake,autoconf,autogen,autotools-dev, \ +libtool,libtool-bin,libltdl-dev,pkg-config,\ +menulibre,libnotify-bin,pandoc,pm-utils,\ +acpi-support,python3,python3-dev,python3-pypandoc,\ +python3-scipy,python3-tk,python3-pandocfilters,\ +python3-geopy,python3-pip,python3,python3-dev,\ +python3-tk,python3-pip,python3-userpath, \ +pandoc,python3-configobj,python3-cheetah,\ +python3-pil,python3-serial,python3-usb,pcre2-utils,\ +libpcre2-dev,libjpeg-dev,i2c-tools,rsync, \ +python3-smbus,policykit-1,pmount,ntpdate,ntp,\ +nginx-extras,ffmpeg,network-manager,\ +console-data,keyboard-configuration,\ +libqt5webkit5-dev,libudev-dev, \ +gfortran-12,libgfortran-12-dev,\ +libzzip-dev,zlib1g-dev,libcanberra-gtk-module,\ +libnss-myhostname,libfreetype6-dev,libpng16-16,\ +libffi-dev,libltdl-dev,dbus-user-session,\ +debian-archive-keyring,curl,wget,mousepad,\ +htop,jed,nmap,libboost-all-dev, \ +libbrotli-dev,libhwy-dev,libjxl0.7,liblcms2-dev, \ +libjxl-dev,icedtea-netx,openjdk-17-jdk, \ +openjdk-17-jre,openjdk-17-jre-headless, \ +ca-certificates-java,net-tools \ +firmware-linux,firmware-linux-nonfree, \ +firmware-misc-nonfree,firmware-realtek, \ +firmware-brcm80211" +#------------------------------------- +# packages removed for various reasons +#------------------------------------- +#gnome-backgrounds,mate-backgrounds, \ +#geany,openbox-dev,openbox-lxde-session, +#xutils-dev,lxrandr, tightvncserver,\ +#,x11proto-randr-dev,terminator,texlive,texlive-xetex +#APT_INCLUDES_LATE="" + +#------------------------------- +#--- General System Settings --- +#------------------------------- +SET_ARCH=32 +RPI_MODEL=3 +RELEASE="bookworm" +RELEASE_ARCH="armhf" +HOSTNAME="raspife3" +DEFLOCAL="fr_FR.UTF-8" +TIMEZONE="Europe/Paris" +EXPANDROOT=false +ENABLE_QEMU=false +#--------------------- +#--- User Settings --- +#--------------------- +ENABLE_ROOT=false +ROOT_PASSWORD="Achanger1$" +ENABLE_USER=true +USER_NAME=ens-ife +USER_PASSWORD="AChanger1$" +#------------------------- +#--- Keyboard Settings --- +#------------------------- +XKB_MODEL="pc105" +XKB_LAYOUT="fr" +XKB_VARIANT="latin9" +XKB_OPTIONS="" +#------------------------ +#--- Network Settings --- +#------------------------ +ENABLE_IPV6=true +ENABLE_WIRELESS=false +ENABLE_IPTABLES=false +ENABLE_IFNAMES=true +ENABLE_HARDNET=true +ENABLE_ETH_DHCP=true +ENABLE_WIFI_DHCP=true +#NET_WIFI_SSID=MobileClimatEtMeteo +#NET_WIFI_PSK=ClimatEtMeteo +#--------------------- +#--- Basic features--- +#--------------------- +ENABLE_CONSOLE=false +ENABLE_BLUETOOTH=false +ENABLE_I2C=false +ENABLE_SPI=false +ENABLE_SSHD=true +SSH_ENABLE=true +ENABLE_NONFREE=true +ENABLE_RSYSLOG=true +ENABLE_SOUND=true +ENABLE_HWRANDOM=true +ENABLE_MINGPU=true +ENABLE_DBUS=true +ENABLE_XORG=false +ENABLE_WM="" +ENABLE_SYSVINIT=true +ENABLE_SPLASH=true +ENABLE_LOGO=true +#-------------------------------- +#--- Advanced System features --- +#-------------------------------- +ENABLE_DPHYSSWAP=false +ENABLE_QEMU=false +ENABLE_MINBASE=false +ENABLE_REDUCE=false +ENABLE_SPLITFS=false +ENABLE_INITRAMFS=true +ENABLE_DBUS=true +ENABLE_USBBOOT=false +ENABLE_UBOOT=false +ENABLE_FBTURBO=false +ENABLE_VIDEOCORE=false +ENABLE_HARDNET=true +ENABLE_IFNAMES=true +ENABLE_NEXMON=false +#DISABLE_UNDERVOLT_WARNINGS= +#-------------------- +#--- ssh settings --- +#-------------------- +SSH_ENABLE_ROOT=false +SSH_LIMIT_USERS=false +SSH_ROOT_PUB_KEY="/home/vidal/.ssh/authorized_keys" +SSH_USER_PUB_KEY="/home/vidal/.ssh/authorized_keys" +#----------------------- +#--- Kernel settings --- +#----------------------- +BUILD_KERNEL=true +KERNEL_BRANCH=rpi-6.6.y +KERNEL_REDUCE=false +KERNEL_HEADERS=true +KERNEL_REMOVESRC=true +KERNELSRC_CLEAN=true +KERNELSRC_CONFIG=true +KERNEL_DEFCONFIG=bcm2709_defconfig +KERNEL_BIN_IMAGE=zImage +KERNEL_IMAGE=kernel7.img +KERNEL_CCACHE=true +#------------------------ +#--- Reduce disk usage -- +#------------------------ +REDUCE_APT=false +REDUCE_DOC=true +REDUCE_MAN=true +REDUCE_HWDB=false +REDUCE_BASH=false +REDUCE_SSHD=false +REDUCE_LOCALE=false +#------------------------- +ENABLE_CRYPTFS=false +#------------------------- +BASEDIR=/home/vidal/Nano-Ordinateurs/RaspberryPi/RpiGenImage/Images/${RELEASE} +#BASEDIR=/media/*******/*********/Nano-Ordinateurs/RaspberryPi/RpiGenImage/Images/${RELEASE} +DATE=`date +%Y-%m-%d` +IMAGE_NAME=${BASEDIR}/${DATE}-rpi${RPI_MODEL}-${RELEASE} + + diff --git a/templates/rpi3-Met-trixie_25-10-21.conf b/templates/rpi3-Met-trixie_25-10-21.conf new file mode 100644 index 0000000..d9e1611 --- /dev/null +++ b/templates/rpi3-Met-trixie_25-10-21.conf @@ -0,0 +1,138 @@ +# +# Configuration file raspi3 /trixie ENS de Lyon 2025/10/21 +# +#--------------------- +#--- APT settings ---- +#--------------------- +#APT_SERVER=debian.mirrors.ovh.net +#APT_SERVER=debian.proxad.net +APT_SERVER=deb.debian.org +APT_INCLUDES="zstd,zst,liblzma-dev,libzstd-dev, \ +zarchive-tools" +#------------------------------------- +# packages removed for various reasons +#------------------------------------- +#gnome-backgrounds,mate-backgrounds, \ +#geany,openbox-dev,openbox-lxde-session, +#xutils-dev,lxrandr, tightvncserver,\ +#,x11proto-randr-dev,terminator,texlive,texlive-xetex +APT_INCLUDES_LATE="" + +#------------------------------- +#--- General System Settings --- +#------------------------------- +SET_ARCH=32 +RPI_MODEL=3 +RELEASE="trixie" +RELEASE_ARCH="armhf" +HOSTNAME="raspife3" +DEFLOCAL="fr_FR.UTF-8" +TIMEZONE="Europe/Paris" +EXPANDROOT=false +ENABLE_QEMU=false +#--------------------- +#--- User Settings --- +#--------------------- +ENABLE_ROOT=false +ROOT_PASSWORD="Achanger1$" +ENABLE_USER=true +USER_NAME=ens-ife +USER_PASSWORD="AChanger1$" +#------------------------- +#--- Keyboard Settings --- +#------------------------- +XKB_MODEL="pc105" +XKB_LAYOUT="fr" +XKB_VARIANT="latin9" +XKB_OPTIONS="" +#------------------------ +#--- Network Settings --- +#------------------------ +ENABLE_IPV6=true +ENABLE_WIRELESS=false +ENABLE_IPTABLES=false +ENABLE_IFNAMES=true +ENABLE_HARDNET=true +ENABLE_ETH_DHCP=true +ENABLE_WIFI_DHCP=true +#NET_WIFI_SSID=MobileClimatEtMeteo +#NET_WIFI_PSK=ClimatEtMeteo +#--------------------- +#--- Basic features--- +#--------------------- +ENABLE_CONSOLE=false +ENABLE_BLUETOOTH=false +ENABLE_I2C=false +ENABLE_SPI=false +ENABLE_SSHD=true +SSH_ENABLE=true +ENABLE_NONFREE=true +ENABLE_RSYSLOG=true +ENABLE_SOUND=true +ENABLE_HWRANDOM=true +ENABLE_MINGPU=true +ENABLE_DBUS=true +ENABLE_XORG=false +ENABLE_WM="" +ENABLE_SYSVINIT=true +ENABLE_SPLASH=true +ENABLE_LOGO=true +#-------------------------------- +#--- Advanced System features --- +#-------------------------------- +ENABLE_DPHYSSWAP=false +ENABLE_QEMU=false +ENABLE_MINBASE=false +ENABLE_REDUCE=false +ENABLE_SPLITFS=true +ENABLE_INITRAMFS=true +ENABLE_DBUS=true +ENABLE_USBBOOT=false +ENABLE_UBOOT=false +ENABLE_FBTURBO=false +ENABLE_VIDEOCORE=false +ENABLE_HARDNET=true +ENABLE_IFNAMES=true +ENABLE_NEXMON=false +#DISABLE_UNDERVOLT_WARNINGS= +#-------------------- +#--- ssh settings --- +#-------------------- +SSH_ENABLE_ROOT=false +SSH_LIMIT_USERS=false +SSH_ROOT_PUB_KEY="/home/vidal/.ssh/authorized_keys" +SSH_USER_PUB_KEY="/home/vidal/.ssh/authorized_keys" +#----------------------- +#--- Kernel settings --- +#----------------------- +BUILD_KERNEL=true +KERNEL_BRANCH=rpi-6.12.y +KERNEL_REDUCE=false +KERNEL_HEADERS=true +KERNEL_REMOVESRC=true +KERNELSRC_CLEAN=true +KERNELSRC_CONFIG=true +KERNEL_DEFCONFIG=bcm2709_defconfig +KERNEL_BIN_IMAGE=zImage +KERNEL_IMAGE=kernel7.img +KERNEL_CCACHE=true +NB_CORES=15 +#------------------------ +#--- Reduce disk usage -- +#------------------------ +REDUCE_APT=false +REDUCE_DOC=true +REDUCE_MAN=true +REDUCE_HWDB=false +REDUCE_BASH=false +REDUCE_SSHD=false +REDUCE_LOCALE=false +#------------------------- +ENABLE_CRYPTFS=false +#------------------------- +BASEDIR=/home/vidal/Nano-Ordinateurs/RaspberryPi/RpiGenImage/Images/${RELEASE} +#BASEDIR=/media/*******/*********/Nano-Ordinateurs/RaspberryPi/RpiGenImage/Images/${RELEASE} +DATE=`date +%Y-%m-%d` +IMAGE_NAME=${BASEDIR}/${DATE}-rpi${RPI_MODEL}-${RELEASE} + + diff --git a/templates/rpi3-stretch-arm64-4.14.y.conf b/templates/rpi3-stretch-arm64-4.14.y.conf new file mode 100644 index 0000000..0c5cfaf --- /dev/null +++ b/templates/rpi3-stretch-arm64-4.14.y.conf @@ -0,0 +1,15 @@ +# Configuration template file used by rpi23-gen-image.sh +# Debian Stretch using the Arm64 for kernel compilation and Debian distribution. + +RPI_MODEL=3 +RELEASE=stretch +BUILD_KERNEL=true +KERNEL_ARCH=arm64 +RELEASE_ARCH=arm64 +CROSS_COMPILE=aarch64-linux-gnu- +QEMU_BINARY=/usr/bin/qemu-aarch64-static +KERNEL_DEFCONFIG=bcmrpi3_defconfig +KERNEL_BIN_IMAGE=Image +KERNEL_IMAGE=kernel8.img +KERNEL_BRANCH=rpi-4.14.y +ENABLE_WIRELESS=true