initial implementation
This commit is contained in:
parent
08fc0b9a82
commit
c15fc69be3
16
Dockerfile
16
Dockerfile
|
@ -1,15 +1,21 @@
|
||||||
FROM debian:buster
|
FROM i386/debian:buster
|
||||||
|
|
||||||
ENV DEBIAN_FRONTEND noninteractive
|
ENV DEBIAN_FRONTEND noninteractive
|
||||||
|
|
||||||
RUN apt-get -y update && \
|
RUN apt-get -y update && \
|
||||||
apt-get -y install --no-install-recommends \
|
apt-get -y install --no-install-recommends \
|
||||||
git vim parted \
|
git vim parted \
|
||||||
quilt coreutils qemu-user-static debootstrap zerofree zip dosfstools \
|
quilt coreutils debootstrap zerofree zip dosfstools \
|
||||||
bsdtar libcap2-bin rsync grep udev xz-utils curl xxd file kmod bc\
|
bsdtar libcap2-bin rsync grep udev xz-utils curl xxd file kmod bc\
|
||||||
binfmt-support ca-certificates \
|
qemu-user-static binfmt-support ca-certificates gnupg\
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
COPY . /pi-gen/
|
COPY export-image /pi-gen/export-image
|
||||||
|
COPY export-noobs /pi-gen/export-noobs
|
||||||
|
COPY scripts /pi-gen/scripts
|
||||||
|
COPY build.sh /pi-gen/build.sh
|
||||||
|
COPY config /pi-gen/config
|
||||||
|
|
||||||
VOLUME [ "/pi-gen/work", "/pi-gen/deploy"]
|
ENV GIT_HASH=develop
|
||||||
|
|
||||||
|
WORKDIR /pi-gen
|
25
LICENSE
25
LICENSE
|
@ -1,3 +1,28 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2020 adamthesax
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
||||||
|
-----------------------------------------------
|
||||||
|
Original `pi-gen` License
|
||||||
|
|
||||||
Copyright (c) 2015 Raspberry Pi (Trading) Ltd.
|
Copyright (c) 2015 Raspberry Pi (Trading) Ltd.
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
384
README.md
384
README.md
|
@ -1,356 +1,34 @@
|
||||||
# pi-gen
|
# pikube-gen
|
||||||
|
|
||||||
_Tool used to create the raspberrypi.org Raspbian images_
|
_Tool used to create the raspberrypi.org Raspbian images_
|
||||||
|
|
||||||
|
|*If you are looking for a simple way to get started, use the [pikube cli tool](https://github.com/adamthesax/pikube-cli).*|
|
||||||
## Dependencies
|
|-------|
|
||||||
|
|
||||||
pi-gen runs on Debian based operating systems. Currently it is only supported on
|
pikube-gen is a fork of [pi-gen](https://github.com/RPi-Distro/pi-gen) which intends to deliver a
|
||||||
either Debian Buster or Ubuntu Xenial and is known to have issues building on
|
simple way to setup a kubernetes cluster on a number of raspberry pi. To do so pi-kube generates a
|
||||||
earlier releases of these systems. On other Linux distributions it may be possible
|
single Raspbian based disk image with Docker and Kubernetes pre-installed. It also contains a
|
||||||
to use the Docker build described below.
|
bootstraping service which will allow you to customize and secure your cluster by dropping a few
|
||||||
|
additional files onto the boot mount.
|
||||||
To install the required dependencies for pi-gen you should run:
|
|
||||||
|
To customize your image build further see the [customization guide](doc/customization.md)
|
||||||
```bash
|
|
||||||
apt-get install coreutils quilt parted qemu-user-static debootstrap zerofree zip \
|
## Usage
|
||||||
dosfstools bsdtar libcap2-bin grep rsync xz-utils file git curl bc
|
`pikube` ships with a docker/kubernetes pre-installed as well as a bootstrapping service which will
|
||||||
```
|
initialize the cluster (on join an existing one), set up SSH keys and configure your hostname.
|
||||||
|
|
||||||
The file `depends` contains a list of tools needed. The format of this
|
To setup pikube:
|
||||||
package is `<tool>[:<debian-package>]`.
|
1) Grab the image (either from grabbing a prebuilt from the releases or running `./build-docker.sh`)
|
||||||
|
2) Flash the image to your SD card
|
||||||
|
3) Create a `pikube.tar.gz` with the folowing files:
|
||||||
## Config
|
* `hostname`: Text file containing the hostname
|
||||||
|
* `ssh.pub` A public ssh key which will be installed into `~/.ssh/authorized_hosts` for passwordless ssh
|
||||||
Upon execution, `build.sh` will source the file `config` in the current
|
* `kube.yaml` A `kubeadm` config file to be run upon first boot
|
||||||
working directory. This bash shell fragment is intended to set needed
|
* `pki/` directory of certs to be installed at `/etc/kubernetes/pki` for the master you will need the following:
|
||||||
environment variables.
|
* `ca.crt`
|
||||||
|
* `ca.key`
|
||||||
The following environment variables are supported:
|
* `front-proxy-ca.crt`
|
||||||
|
* `front-proxy-ca.key`
|
||||||
* `IMG_NAME` **required** (Default: unset)
|
* `etcd/ca.crt`
|
||||||
|
* `etcd/ca.key`
|
||||||
The name of the image to build with the current stage directories. Setting
|
4) Copy `pikube.tar.gz` to `/boot/pikube.tar.gz` on your SD card.
|
||||||
`IMG_NAME=Raspbian` is logical for an unmodified RPi-Distro/pi-gen build,
|
|
||||||
but you should use something else for a customized version. Export files
|
|
||||||
in stages may add suffixes to `IMG_NAME`.
|
|
||||||
|
|
||||||
* `RELEASE` (Default: buster)
|
|
||||||
|
|
||||||
The release version to build images against. Valid values are jessie, stretch
|
|
||||||
buster, bullseye, and testing.
|
|
||||||
|
|
||||||
* `APT_PROXY` (Default: unset)
|
|
||||||
|
|
||||||
If you require the use of an apt proxy, set it here. This proxy setting
|
|
||||||
will not be included in the image, making it safe to use an `apt-cacher` or
|
|
||||||
similar package for development.
|
|
||||||
|
|
||||||
If you have Docker installed, you can set up a local apt caching proxy to
|
|
||||||
like speed up subsequent builds like this:
|
|
||||||
|
|
||||||
docker-compose up -d
|
|
||||||
echo 'APT_PROXY=http://172.17.0.1:3142' >> config
|
|
||||||
|
|
||||||
* `BASE_DIR` (Default: location of `build.sh`)
|
|
||||||
|
|
||||||
**CAUTION**: Currently, changing this value will probably break build.sh
|
|
||||||
|
|
||||||
Top-level directory for `pi-gen`. Contains stage directories, build
|
|
||||||
scripts, and by default both work and deployment directories.
|
|
||||||
|
|
||||||
* `WORK_DIR` (Default: `"$BASE_DIR/work"`)
|
|
||||||
|
|
||||||
Directory in which `pi-gen` builds the target system. This value can be
|
|
||||||
changed if you have a suitably large, fast storage location for stages to
|
|
||||||
be built and cached. Note, `WORK_DIR` stores a complete copy of the target
|
|
||||||
system for each build stage, amounting to tens of gigabytes in the case of
|
|
||||||
Raspbian.
|
|
||||||
|
|
||||||
**CAUTION**: If your working directory is on an NTFS partition you probably won't be able to build. Make sure this is a proper Linux filesystem.
|
|
||||||
|
|
||||||
* `DEPLOY_DIR` (Default: `"$BASE_DIR/deploy"`)
|
|
||||||
|
|
||||||
Output directory for target system images and NOOBS bundles.
|
|
||||||
|
|
||||||
* `DEPLOY_ZIP` (Default: `1`)
|
|
||||||
|
|
||||||
Setting to `0` will deploy the actual image (`.img`) instead of a zipped image (`.zip`).
|
|
||||||
|
|
||||||
* `USE_QEMU` (Default: `"0"`)
|
|
||||||
|
|
||||||
Setting to '1' enables the QEMU mode - creating an image that can be mounted via QEMU for an emulated
|
|
||||||
environment. These images include "-qemu" in the image file name.
|
|
||||||
|
|
||||||
* `LOCALE_DEFAULT` (Default: "en_GB.UTF-8" )
|
|
||||||
|
|
||||||
Default system locale.
|
|
||||||
|
|
||||||
* `TARGET_HOSTNAME` (Default: "raspberrypi" )
|
|
||||||
|
|
||||||
Setting the hostname to the specified value.
|
|
||||||
|
|
||||||
* `KEYBOARD_KEYMAP` (Default: "gb" )
|
|
||||||
|
|
||||||
Default keyboard keymap.
|
|
||||||
|
|
||||||
To get the current value from a running system, run `debconf-show
|
|
||||||
keyboard-configuration` and look at the
|
|
||||||
`keyboard-configuration/xkb-keymap` value.
|
|
||||||
|
|
||||||
* `KEYBOARD_LAYOUT` (Default: "English (UK)" )
|
|
||||||
|
|
||||||
Default keyboard layout.
|
|
||||||
|
|
||||||
To get the current value from a running system, run `debconf-show
|
|
||||||
keyboard-configuration` and look at the
|
|
||||||
`keyboard-configuration/variant` value.
|
|
||||||
|
|
||||||
* `TIMEZONE_DEFAULT` (Default: "Europe/London" )
|
|
||||||
|
|
||||||
Default keyboard layout.
|
|
||||||
|
|
||||||
To get the current value from a running system, look in
|
|
||||||
`/etc/timezone`.
|
|
||||||
|
|
||||||
* `FIRST_USER_NAME` (Default: "pi" )
|
|
||||||
|
|
||||||
Username for the first user
|
|
||||||
|
|
||||||
* `FIRST_USER_PASS` (Default: "raspberry")
|
|
||||||
|
|
||||||
Password for the first user
|
|
||||||
|
|
||||||
* `WPA_ESSID`, `WPA_PASSWORD` and `WPA_COUNTRY` (Default: unset)
|
|
||||||
|
|
||||||
If these are set, they are use to configure `wpa_supplicant.conf`, so that the Raspberry Pi can automatically connect to a wifi network on first boot. If `WPA_ESSID` is set and `WPA_PASSWORD` is unset an unprotected wifi network will be configured. If set, `WPA_PASSWORD` must be between 8 and 63 characters.
|
|
||||||
|
|
||||||
* `ENABLE_SSH` (Default: `0`)
|
|
||||||
|
|
||||||
Setting to `1` will enable ssh server for remote log in. Note that if you are using a common password such as the defaults there is a high risk of attackers taking over you Raspberry Pi.
|
|
||||||
|
|
||||||
* `STAGE_LIST` (Default: `stage*`)
|
|
||||||
|
|
||||||
If set, then instead of working through the numeric stages in order, this list will be followed. For example setting to `"stage0 stage1 mystage stage2"` will run the contents of `mystage` before stage2. Note that quotes are needed around the list. An absolute or relative path can be given for stages outside the pi-gen directory.
|
|
||||||
|
|
||||||
A simple example for building Raspbian:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
IMG_NAME='Raspbian'
|
|
||||||
```
|
|
||||||
|
|
||||||
The config file can also be specified on the command line as an argument the `build.sh` or `build-docker.sh` scripts.
|
|
||||||
|
|
||||||
```
|
|
||||||
./build.sh -c myconfig
|
|
||||||
```
|
|
||||||
|
|
||||||
This is parsed after `config` so can be used to override values set there.
|
|
||||||
|
|
||||||
## How the build process works
|
|
||||||
|
|
||||||
The following process is followed to build images:
|
|
||||||
|
|
||||||
* Loop through all of the stage directories in alphanumeric order
|
|
||||||
|
|
||||||
* Move on to the next directory if this stage directory contains a file called
|
|
||||||
"SKIP"
|
|
||||||
|
|
||||||
* Run the script ```prerun.sh``` which is generally just used to copy the build
|
|
||||||
directory between stages.
|
|
||||||
|
|
||||||
* In each stage directory loop through each subdirectory and then run each of the
|
|
||||||
install scripts it contains, again in alphanumeric order. These need to be named
|
|
||||||
with a two digit padded number at the beginning.
|
|
||||||
There are a number of different files and directories which can be used to
|
|
||||||
control different parts of the build process:
|
|
||||||
|
|
||||||
- **00-run.sh** - A unix shell script. Needs to be made executable for it to run.
|
|
||||||
|
|
||||||
- **00-run-chroot.sh** - A unix shell script which will be run in the chroot
|
|
||||||
of the image build directory. Needs to be made executable for it to run.
|
|
||||||
|
|
||||||
- **00-debconf** - Contents of this file are passed to debconf-set-selections
|
|
||||||
to configure things like locale, etc.
|
|
||||||
|
|
||||||
- **00-packages** - A list of packages to install. Can have more than one, space
|
|
||||||
separated, per line.
|
|
||||||
|
|
||||||
- **00-packages-nr** - As 00-packages, except these will be installed using
|
|
||||||
the ```--no-install-recommends -y``` parameters to apt-get.
|
|
||||||
|
|
||||||
- **00-patches** - A directory containing patch files to be applied, using quilt.
|
|
||||||
If a file named 'EDIT' is present in the directory, the build process will
|
|
||||||
be interrupted with a bash session, allowing an opportunity to create/revise
|
|
||||||
the patches.
|
|
||||||
|
|
||||||
* If the stage directory contains files called "EXPORT_NOOBS" or "EXPORT_IMAGE" then
|
|
||||||
add this stage to a list of images to generate
|
|
||||||
|
|
||||||
* Generate the images for any stages that have specified them
|
|
||||||
|
|
||||||
It is recommended to examine build.sh for finer details.
|
|
||||||
|
|
||||||
|
|
||||||
## Docker Build
|
|
||||||
|
|
||||||
Docker can be used to perform the build inside a container. This partially isolates
|
|
||||||
the build from the host system, and allows using the script on non-debian based
|
|
||||||
systems (e.g. Fedora Linux). The isolate is not complete due to the need to use
|
|
||||||
some kernel level services for arm emulation (binfmt) and loop devices (losetup).
|
|
||||||
|
|
||||||
To build:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
vi config # Edit your config file. See above.
|
|
||||||
./build-docker.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
If everything goes well, your finished image will be in the `deploy/` folder.
|
|
||||||
You can then remove the build container with `docker rm -v pigen_work`
|
|
||||||
|
|
||||||
If something breaks along the line, you can edit the corresponding scripts, and
|
|
||||||
continue:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
CONTINUE=1 ./build-docker.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
To examine the container after a failure you can enter a shell within it using:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo docker run -it --privileged --volumes-from=pigen_work pi-gen /bin/bash
|
|
||||||
```
|
|
||||||
|
|
||||||
After successful build, the build container is by default removed. This may be undesired when making incremental changes to a customized build. To prevent the build script from remove the container add
|
|
||||||
|
|
||||||
```bash
|
|
||||||
PRESERVE_CONTAINER=1 ./build-docker.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
There is a possibility that even when running from a docker container, the
|
|
||||||
installation of `qemu-user-static` will silently fail when building the image
|
|
||||||
because `binfmt-support` _must be enabled on the underlying kernel_. An easy
|
|
||||||
fix is to ensure `binfmt-support` is installed on the host machine before
|
|
||||||
starting the `./build-docker.sh` script (or using your own docker build
|
|
||||||
solution).
|
|
||||||
|
|
||||||
|
|
||||||
## Stage Anatomy
|
|
||||||
|
|
||||||
### Raspbian Stage Overview
|
|
||||||
|
|
||||||
The build of Raspbian is divided up into several stages for logical clarity
|
|
||||||
and modularity. This causes some initial complexity, but it simplifies
|
|
||||||
maintenance and allows for more easy customization.
|
|
||||||
|
|
||||||
- **Stage 0** - bootstrap. The primary purpose of this stage is to create a
|
|
||||||
usable filesystem. This is accomplished largely through the use of
|
|
||||||
`debootstrap`, which creates a minimal filesystem suitable for use as a
|
|
||||||
base.tgz on Debian systems. This stage also configures apt settings and
|
|
||||||
installs `raspberrypi-bootloader` which is missed by debootstrap. The
|
|
||||||
minimal core is installed but not configured, and the system will not quite
|
|
||||||
boot yet.
|
|
||||||
|
|
||||||
- **Stage 1** - truly minimal system. This stage makes the system bootable by
|
|
||||||
installing system files like `/etc/fstab`, configures the bootloader, makes
|
|
||||||
the network operable, and installs packages like raspi-config. At this
|
|
||||||
stage the system should boot to a local console from which you have the
|
|
||||||
means to perform basic tasks needed to configure and install the system.
|
|
||||||
This is as minimal as a system can possibly get, and its arguably not
|
|
||||||
really usable yet in a traditional sense yet. Still, if you want minimal,
|
|
||||||
this is minimal and the rest you could reasonably do yourself as sysadmin.
|
|
||||||
|
|
||||||
- **Stage 2** - lite system. This stage produces the Raspbian-Lite image. It
|
|
||||||
installs some optimized memory functions, sets timezone and charmap
|
|
||||||
defaults, installs fake-hwclock and ntp, wifi and bluetooth support,
|
|
||||||
dphys-swapfile, and other basics for managing the hardware. It also
|
|
||||||
creates necessary groups and gives the pi user access to sudo and the
|
|
||||||
standard console hardware permission groups.
|
|
||||||
|
|
||||||
There are a few tools that may not make a whole lot of sense here for
|
|
||||||
development purposes on a minimal system such as basic Python and Lua
|
|
||||||
packages as well as the `build-essential` package. They are lumped right
|
|
||||||
in with more essential packages presently, though they need not be with
|
|
||||||
pi-gen. These are understandable for Raspbian's target audience, but if
|
|
||||||
you were looking for something between truly minimal and Raspbian-Lite,
|
|
||||||
here's where you start trimming.
|
|
||||||
|
|
||||||
- **Stage 3** - desktop system. Here's where you get the full desktop system
|
|
||||||
with X11 and LXDE, web browsers, git for development, Raspbian custom UI
|
|
||||||
enhancements, etc. This is a base desktop system, with some development
|
|
||||||
tools installed.
|
|
||||||
|
|
||||||
- **Stage 4** - Normal Raspbian image. System meant to fit on a 4GB card. This is the
|
|
||||||
stage that installs most things that make Raspbian friendly to new
|
|
||||||
users like system documentation.
|
|
||||||
|
|
||||||
- **Stage 5** - The Raspbian Full image. More development
|
|
||||||
tools, an email client, learning tools like Scratch, specialized packages
|
|
||||||
like sonic-pi, office productivity, etc.
|
|
||||||
|
|
||||||
### Stage specification
|
|
||||||
|
|
||||||
If you wish to build up to a specified stage (such as building up to stage 2
|
|
||||||
for a lite system), place an empty file named `SKIP` in each of the `./stage`
|
|
||||||
directories you wish not to include.
|
|
||||||
|
|
||||||
Then add an empty file named `SKIP_IMAGES` to `./stage4` and `./stage5` (if building up to stage 2) or
|
|
||||||
to `./stage2` (if building a minimal system).
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Example for building a lite system
|
|
||||||
echo "IMG_NAME='Raspbian'" > config
|
|
||||||
touch ./stage3/SKIP ./stage4/SKIP ./stage5/SKIP
|
|
||||||
touch ./stage4/SKIP_IMAGES ./stage5/SKIP_IMAGES
|
|
||||||
sudo ./build.sh # or ./build-docker.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
If you wish to build further configurations upon (for example) the lite
|
|
||||||
system, you can also delete the contents of `./stage3` and `./stage4` and
|
|
||||||
replace with your own contents in the same format.
|
|
||||||
|
|
||||||
|
|
||||||
## Skipping stages to speed up development
|
|
||||||
|
|
||||||
If you're working on a specific stage the recommended development process is as
|
|
||||||
follows:
|
|
||||||
|
|
||||||
* Add a file called SKIP_IMAGES into the directories containing EXPORT_* files
|
|
||||||
(currently stage2, stage4 and stage5)
|
|
||||||
* Add SKIP files to the stages you don't want to build. For example, if you're
|
|
||||||
basing your image on the lite image you would add these to stages 3, 4 and 5.
|
|
||||||
* Run build.sh to build all stages
|
|
||||||
* Add SKIP files to the earlier successfully built stages
|
|
||||||
* Modify the last stage
|
|
||||||
* Rebuild just the last stage using ```sudo CLEAN=1 ./build.sh```
|
|
||||||
* Once you're happy with the image you can remove the SKIP_IMAGES files and
|
|
||||||
export your image to test
|
|
||||||
|
|
||||||
# Troubleshooting
|
|
||||||
|
|
||||||
## `64 Bit Systems`
|
|
||||||
Please note there is currently an issue when compiling with a 64 Bit OS. See https://github.com/RPi-Distro/pi-gen/issues/271
|
|
||||||
|
|
||||||
## `binfmt_misc`
|
|
||||||
|
|
||||||
Linux is able execute binaries from other architectures, meaning that it should be
|
|
||||||
possible to make use of `pi-gen` on an x86_64 system, even though it will be running
|
|
||||||
ARM binaries. This requires support from the [`binfmt_misc`](https://en.wikipedia.org/wiki/Binfmt_misc)
|
|
||||||
kernel module.
|
|
||||||
|
|
||||||
You may see the following error:
|
|
||||||
|
|
||||||
```
|
|
||||||
update-binfmts: warning: Couldn't load the binfmt_misc module.
|
|
||||||
```
|
|
||||||
|
|
||||||
To resolve this, ensure that the following files are available (install them if necessary):
|
|
||||||
|
|
||||||
```
|
|
||||||
/lib/modules/$(uname -r)/kernel/fs/binfmt_misc.ko
|
|
||||||
/usr/bin/qemu-arm-static
|
|
||||||
```
|
|
||||||
|
|
||||||
You may also need to load the module by hand - run `modprobe binfmt_misc`.
|
|
129
build-docker.sh
129
build-docker.sh
|
@ -14,95 +14,46 @@ if ! ${DOCKER} ps >/dev/null; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
CONFIG_FILE=""
|
if [ -f config ]; then
|
||||||
if [ -f "${DIR}/config" ]; then
|
# shellcheck disable=SC1091
|
||||||
CONFIG_FILE="${DIR}/config"
|
source config
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while getopts "c:" flag
|
|
||||||
do
|
BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
case "${flag}" in
|
STAGE_LIST=${STAGE_LIST:-${BASE_DIR}/stage*}
|
||||||
c)
|
IMAGE_NAME=${IMAGE_NAME:-pikube_gen}
|
||||||
CONFIG_FILE="${OPTARG}"
|
|
||||||
;;
|
|
||||||
*)
|
echo "Building base image..."
|
||||||
;;
|
${DOCKER} build -t ${IMAGE_NAME}:init "${DIR}"
|
||||||
esac
|
|
||||||
|
|
||||||
|
PREVIOUS_IMAGE=${IMAGE_NAME}:init
|
||||||
|
|
||||||
|
for STAGE_DIR in $STAGE_LIST; do
|
||||||
|
STAGE_NAME=$(basename $STAGE_DIR)
|
||||||
|
CONTAINER_NAME=${IMAGE_NAME}_${STAGE_NAME}
|
||||||
|
|
||||||
|
BASE_IMAGE_NAME="${IMAGE_NAME}:${STAGE_NAME}_base"
|
||||||
|
|
||||||
|
BEFORE_BUILD_ID=$(docker inspect --format {{.Id}} ${BASE_IMAGE_NAME} || echo "noexists")
|
||||||
|
docker build --rm -t ${IMAGE_NAME}:${STAGE_NAME}_base -f- $STAGE_DIR <<EOF
|
||||||
|
FROM ${PREVIOUS_IMAGE}
|
||||||
|
|
||||||
|
COPY . /pi-gen/${STAGE_NAME}/
|
||||||
|
|
||||||
|
CMD dpkg-reconfigure qemu-user-static && ./build.sh && touch ${STAGE_NAME}/SKIP
|
||||||
|
EOF
|
||||||
|
|
||||||
|
AFTER_BUILD_ID=$(docker inspect --format {{.Id}} ${BASE_IMAGE_NAME})
|
||||||
|
|
||||||
|
if [ "$AFTER_BUILD_ID" != "$BEFORE_BUILD_ID" ]; then
|
||||||
|
echo "doing it"
|
||||||
|
docker run -v ${DIR}/deploy:/pi-gen/deploy --name ${CONTAINER_NAME} --privileged ${BASE_IMAGE_NAME} || echo "${STAGE_NAME} Failed!"
|
||||||
|
${DOCKER} commit ${IMAGE_NAME}_${STAGE_NAME} ${IMAGE_NAME}:${STAGE_NAME}
|
||||||
|
docker rm ${CONTAINER_NAME}
|
||||||
|
fi
|
||||||
|
|
||||||
|
PREVIOUS_IMAGE=${IMAGE_NAME}:${STAGE_NAME}
|
||||||
done
|
done
|
||||||
|
|
||||||
# Ensure that the configuration file is an absolute path
|
|
||||||
if test -x /usr/bin/realpath; then
|
|
||||||
CONFIG_FILE=$(realpath -s "$CONFIG_FILE" || realpath "$CONFIG_FILE")
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Ensure that the confguration file is present
|
|
||||||
if test -z "${CONFIG_FILE}"; then
|
|
||||||
echo "Configuration file need to be present in '${DIR}/config' or path passed as parameter"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
# shellcheck disable=SC1090
|
|
||||||
source ${CONFIG_FILE}
|
|
||||||
fi
|
|
||||||
|
|
||||||
CONTAINER_NAME=${CONTAINER_NAME:-pigen_work}
|
|
||||||
CONTINUE=${CONTINUE:-0}
|
|
||||||
PRESERVE_CONTAINER=${PRESERVE_CONTAINER:-0}
|
|
||||||
|
|
||||||
if [ -z "${IMG_NAME}" ]; then
|
|
||||||
echo "IMG_NAME not set in 'config'" 1>&2
|
|
||||||
echo 1>&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Ensure the Git Hash is recorded before entering the docker container
|
|
||||||
GIT_HASH=${GIT_HASH:-"$(git rev-parse HEAD)"}
|
|
||||||
|
|
||||||
CONTAINER_EXISTS=$(${DOCKER} ps -a --filter name="${CONTAINER_NAME}" -q)
|
|
||||||
CONTAINER_RUNNING=$(${DOCKER} ps --filter name="${CONTAINER_NAME}" -q)
|
|
||||||
if [ "${CONTAINER_RUNNING}" != "" ]; then
|
|
||||||
echo "The build is already running in container ${CONTAINER_NAME}. Aborting."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ "${CONTAINER_EXISTS}" != "" ] && [ "${CONTINUE}" != "1" ]; then
|
|
||||||
echo "Container ${CONTAINER_NAME} already exists and you did not specify CONTINUE=1. Aborting."
|
|
||||||
echo "You can delete the existing container like this:"
|
|
||||||
echo " ${DOCKER} rm -v ${CONTAINER_NAME}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Modify original build-options to allow config file to be mounted in the docker container
|
|
||||||
BUILD_OPTS="$(echo "${BUILD_OPTS:-}" | sed -E 's@\-c\s?([^ ]+)@-c /config@')"
|
|
||||||
|
|
||||||
${DOCKER} build -t pi-gen "${DIR}"
|
|
||||||
if [ "${CONTAINER_EXISTS}" != "" ]; then
|
|
||||||
trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${CONTAINER_NAME}_cont' SIGINT SIGTERM
|
|
||||||
time ${DOCKER} run --rm --privileged \
|
|
||||||
--volume "${CONFIG_FILE}":/config:ro \
|
|
||||||
-e "GIT_HASH=${GIT_HASH}" \
|
|
||||||
--volumes-from="${CONTAINER_NAME}" --name "${CONTAINER_NAME}_cont" \
|
|
||||||
pi-gen \
|
|
||||||
bash -e -o pipefail -c "dpkg-reconfigure qemu-user-static &&
|
|
||||||
cd /pi-gen; ./build.sh ${BUILD_OPTS} &&
|
|
||||||
rsync -av work/*/build.log deploy/" &
|
|
||||||
wait "$!"
|
|
||||||
else
|
|
||||||
trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${CONTAINER_NAME}' SIGINT SIGTERM
|
|
||||||
time ${DOCKER} run --name "${CONTAINER_NAME}" --privileged \
|
|
||||||
--volume "${CONFIG_FILE}":/config:ro \
|
|
||||||
-e "GIT_HASH=${GIT_HASH}" \
|
|
||||||
pi-gen \
|
|
||||||
bash -e -o pipefail -c "dpkg-reconfigure qemu-user-static &&
|
|
||||||
cd /pi-gen; ./build.sh ${BUILD_OPTS} &&
|
|
||||||
rsync -av work/*/build.log deploy/" &
|
|
||||||
wait "$!"
|
|
||||||
fi
|
|
||||||
echo "copying results from deploy/"
|
|
||||||
${DOCKER} cp "${CONTAINER_NAME}":/pi-gen/deploy .
|
|
||||||
ls -lah deploy
|
|
||||||
|
|
||||||
# cleanup
|
|
||||||
if [ "${PRESERVE_CONTAINER}" != "1" ]; then
|
|
||||||
${DOCKER} rm -v "${CONTAINER_NAME}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Done! Your image(s) should be in deploy/"
|
|
||||||
|
|
8
build.sh
8
build.sh
|
@ -152,12 +152,12 @@ if [ -z "${IMG_NAME}" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export USE_QEMU="${USE_QEMU:-0}"
|
export USE_QEMU="${USE_QEMU:-0}"
|
||||||
export IMG_DATE="${IMG_DATE:-"$(date +%Y-%m-%d)"}"
|
export IMG_VERSION="${IMG_VERSION:-"dev"}"
|
||||||
export IMG_FILENAME="${IMG_FILENAME:-"${IMG_DATE}-${IMG_NAME}"}"
|
export IMG_FILENAME="${IMG_FILENAME:-"${IMG_VERSION}-${IMG_NAME}"}"
|
||||||
export ZIP_FILENAME="${ZIP_FILENAME:-"image_${IMG_DATE}-${IMG_NAME}"}"
|
export ZIP_FILENAME="${ZIP_FILENAME:-"image_${IMG_VERSION}-${IMG_NAME}"}"
|
||||||
|
|
||||||
export SCRIPT_DIR="${BASE_DIR}/scripts"
|
export SCRIPT_DIR="${BASE_DIR}/scripts"
|
||||||
export WORK_DIR="${WORK_DIR:-"${BASE_DIR}/work/${IMG_DATE}-${IMG_NAME}"}"
|
export WORK_DIR="${WORK_DIR:-"${BASE_DIR}/work/${IMG_VERSION}-${IMG_NAME}"}"
|
||||||
export DEPLOY_DIR=${DEPLOY_DIR:-"${BASE_DIR}/deploy"}
|
export DEPLOY_DIR=${DEPLOY_DIR:-"${BASE_DIR}/deploy"}
|
||||||
export DEPLOY_ZIP="${DEPLOY_ZIP:-1}"
|
export DEPLOY_ZIP="${DEPLOY_ZIP:-1}"
|
||||||
export LOG_FILE="${WORK_DIR}/build.log"
|
export LOG_FILE="${WORK_DIR}/build.log"
|
||||||
|
|
297
docs/customization.md
Normal file
297
docs/customization.md
Normal file
|
@ -0,0 +1,297 @@
|
||||||
|
# Customizations
|
||||||
|
> This guide is largely adapted from [pi-gen]()'s README.md
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
|
||||||
|
pikube-gen runs on Debian based operating systems or can be run within a docker container.
|
||||||
|
It is recommended to run this within a Docker container by using `./build-docker` see below.
|
||||||
|
|
||||||
|
Currently if building natively, it is only supported on either Debian Buster or Ubuntu Xenial
|
||||||
|
and is known to have issues building on earlier releases of these systems.
|
||||||
|
|
||||||
|
To install the required dependencies for pikube-gen you should run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
apt-get install coreutils quilt parted qemu-user-static debootstrap zerofree zip \
|
||||||
|
dosfstools bsdtar libcap2-bin grep rsync xz-utils file git curl bc
|
||||||
|
```
|
||||||
|
|
||||||
|
The file `depends` contains a list of tools needed. The format of this
|
||||||
|
package is `<tool>[:<debian-package>]`.
|
||||||
|
|
||||||
|
|
||||||
|
## Config
|
||||||
|
|
||||||
|
Upon execution, `build.sh` will source the file `config` in the current
|
||||||
|
working directory. This bash shell fragment is intended to set needed
|
||||||
|
environment variables.
|
||||||
|
|
||||||
|
The following environment variables are supported:
|
||||||
|
|
||||||
|
* `IMG_NAME` (Default: pikube)
|
||||||
|
|
||||||
|
The name of the image to build with the current stage directories. Export files
|
||||||
|
in stages may add suffixes to `IMG_NAME`.
|
||||||
|
|
||||||
|
* `RELEASE` (Default: buster)
|
||||||
|
|
||||||
|
The release version to build images against. Valid values are jessie, stretch
|
||||||
|
buster, bullseye, and testing.
|
||||||
|
|
||||||
|
* `APT_PROXY` (Default: unset)
|
||||||
|
|
||||||
|
If you require the use of an apt proxy, set it here. This proxy setting
|
||||||
|
will not be included in the image, making it safe to use an `apt-cacher` or
|
||||||
|
similar package for development.
|
||||||
|
|
||||||
|
If you have Docker installed, you can set up a local apt caching proxy to
|
||||||
|
like speed up subsequent builds like this:
|
||||||
|
|
||||||
|
docker-compose up -d
|
||||||
|
echo 'APT_PROXY=http://172.17.0.1:3142' >> config
|
||||||
|
|
||||||
|
* `BASE_DIR` (Default: location of `build.sh`)
|
||||||
|
|
||||||
|
**CAUTION**: Currently, changing this value will probably break build.sh
|
||||||
|
|
||||||
|
Top-level directory for `pikube-gen`. Contains stage directories, build
|
||||||
|
scripts, and by default both work and deployment directories.
|
||||||
|
|
||||||
|
* `WORK_DIR` (Default: `"$BASE_DIR/work"`)
|
||||||
|
|
||||||
|
Directory in which `pikube-gen` builds the target system. This value can be
|
||||||
|
changed if you have a suitably large, fast storage location for stages to
|
||||||
|
be built and cached. Note, `WORK_DIR` stores a complete copy of the target
|
||||||
|
system for each build stage, amounting to tens of gigabytes in the case of
|
||||||
|
Raspbian.
|
||||||
|
|
||||||
|
**CAUTION**: If your working directory is on an NTFS partition you probably won't be able to build. Make sure this is a proper Linux filesystem.
|
||||||
|
|
||||||
|
* `DEPLOY_DIR` (Default: `"$BASE_DIR/deploy"`)
|
||||||
|
|
||||||
|
Output directory for target system images and NOOBS bundles.
|
||||||
|
|
||||||
|
* `DEPLOY_ZIP` (Default: `1`)
|
||||||
|
|
||||||
|
Setting to `0` will deploy the actual image (`.img`) instead of a zipped image (`.zip`).
|
||||||
|
|
||||||
|
* `USE_QEMU` (Default: `"0"`)
|
||||||
|
|
||||||
|
Setting to '1' enables the QEMU mode - creating an image that can be mounted via QEMU for an emulated
|
||||||
|
environment. These images include "-qemu" in the image file name.
|
||||||
|
|
||||||
|
* `LOCALE_DEFAULT` (Default: "en_US.UTF-8" )
|
||||||
|
|
||||||
|
Default system locale.
|
||||||
|
|
||||||
|
* `TARGET_HOSTNAME` (Default: "pikube" )
|
||||||
|
|
||||||
|
Setting the hostname to the specified value.
|
||||||
|
|
||||||
|
* `KEYBOARD_KEYMAP` (Default: "us" )
|
||||||
|
|
||||||
|
Default keyboard keymap.
|
||||||
|
|
||||||
|
To get the current value from a running system, run `debconf-show
|
||||||
|
keyboard-configuration` and look at the
|
||||||
|
`keyboard-configuration/xkb-keymap` value.
|
||||||
|
|
||||||
|
* `KEYBOARD_LAYOUT` (Default: "English (US)" )
|
||||||
|
|
||||||
|
Default keyboard layout.
|
||||||
|
|
||||||
|
To get the current value from a running system, run `debconf-show
|
||||||
|
keyboard-configuration` and look at the
|
||||||
|
`keyboard-configuration/variant` value.
|
||||||
|
|
||||||
|
* `TIMEZONE_DEFAULT` (Default: "Europe/London" )
|
||||||
|
|
||||||
|
Default keyboard layout.
|
||||||
|
|
||||||
|
To get the current value from a running system, look in
|
||||||
|
`/etc/timezone`.
|
||||||
|
|
||||||
|
* `FIRST_USER_NAME` (Default: "pi" )
|
||||||
|
|
||||||
|
Username for the first user
|
||||||
|
|
||||||
|
* `WPA_ESSID`, `WPA_PASSWORD` and `WPA_COUNTRY` (Default: unset)
|
||||||
|
|
||||||
|
If these are set, they are use to configure `wpa_supplicant.conf`, so that the Raspberry Pi can automatically connect to a wifi network on first boot. If `WPA_ESSID` is set and `WPA_PASSWORD` is unset an unprotected wifi network will be configured. If set, `WPA_PASSWORD` must be between 8 and 63 characters.
|
||||||
|
|
||||||
|
* `ENABLE_SSH` (Default: `1`)
|
||||||
|
Setting to `0` will disable ssh server for remote log in. pikube will setup an SSH keypair so you can login
|
||||||
|
using the generated private key.
|
||||||
|
|
||||||
|
* `STAGE_LIST` (Default: `stage*`)
|
||||||
|
|
||||||
|
If set, then instead of working through the numeric stages in order, this list will be followed. For example setting to `"stage0 stage1 mystage stage2"` will run the contents of `mystage` before stage2. Note that quotes are needed around the list. An absolute or relative path can be given for stages outside the pikube-gen directory.
|
||||||
|
|
||||||
|
## How the build process works
|
||||||
|
|
||||||
|
The following process is followed to build images:
|
||||||
|
|
||||||
|
* Loop through all of the stage directories in alphanumeric order
|
||||||
|
|
||||||
|
* Move on to the next directory if this stage directory contains a file called
|
||||||
|
"SKIP"
|
||||||
|
|
||||||
|
* Run the script ```prerun.sh``` which is generally just used to copy the build
|
||||||
|
directory between stages.
|
||||||
|
|
||||||
|
* In each stage directory loop through each subdirectory and then run each of the
|
||||||
|
install scripts it contains, again in alphanumeric order. These need to be named
|
||||||
|
with a two digit padded number at the beginning.
|
||||||
|
There are a number of different files and directories which can be used to
|
||||||
|
control different parts of the build process:
|
||||||
|
|
||||||
|
- **00-run.sh** - A unix shell script. Needs to be made executable for it to run.
|
||||||
|
|
||||||
|
- **00-run-chroot.sh** - A unix shell script which will be run in the chroot
|
||||||
|
of the image build directory. Needs to be made executable for it to run.
|
||||||
|
|
||||||
|
- **00-debconf** - Contents of this file are passed to debconf-set-selections
|
||||||
|
to configure things like locale, etc.
|
||||||
|
|
||||||
|
- **00-packages** - A list of packages to install. Can have more than one, space
|
||||||
|
separated, per line.
|
||||||
|
|
||||||
|
- **00-packages-nr** - As 00-packages, except these will be installed using
|
||||||
|
the ```--no-install-recommends -y``` parameters to apt-get.
|
||||||
|
|
||||||
|
- **00-patches** - A directory containing patch files to be applied, using quilt.
|
||||||
|
If a file named 'EDIT' is present in the directory, the build process will
|
||||||
|
be interrupted with a bash session, allowing an opportunity to create/revise
|
||||||
|
the patches.
|
||||||
|
|
||||||
|
* If the stage directory contains files called "EXPORT_NOOBS" or "EXPORT_IMAGE" then
|
||||||
|
add this stage to a list of images to generate
|
||||||
|
|
||||||
|
* Generate the images for any stages that have specified them
|
||||||
|
|
||||||
|
It is recommended to examine build.sh for finer details.
|
||||||
|
|
||||||
|
|
||||||
|
## Docker Build
|
||||||
|
|
||||||
|
Docker can be used to perform the build inside a container. This partially isolates
|
||||||
|
the build from the host system, and allows using the script on non-debian based
|
||||||
|
systems (e.g. Fedora Linux). The isolate is not complete due to the need to use
|
||||||
|
some kernel level services for arm emulation (binfmt) and loop devices (losetup).
|
||||||
|
|
||||||
|
To build:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
vi config # Edit your config file. See above.
|
||||||
|
./build-docker.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
If everything goes well, your finished image will be in the `deploy/` folder.
|
||||||
|
You can then remove the build container with `docker rm -v pigen_work`
|
||||||
|
|
||||||
|
If something breaks along the line, you can edit the corresponding scripts, and
|
||||||
|
continue:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
CONTINUE=1 ./build-docker.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
To examine the container after a failure you can enter a shell within it using:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo docker run -it --privileged --volumes-from=pigen_work pikube-gen /bin/bash
|
||||||
|
```
|
||||||
|
|
||||||
|
After successful build, the build container is by default removed. This may be undesired when making incremental changes to a customized build. To prevent the build script from remove the container add
|
||||||
|
|
||||||
|
```bash
|
||||||
|
PRESERVE_CONTAINER=1 ./build-docker.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
There is a possibility that even when running from a docker container, the
|
||||||
|
installation of `qemu-user-static` will silently fail when building the image
|
||||||
|
because `binfmt-support` _must be enabled on the underlying kernel_. An easy
|
||||||
|
fix is to ensure `binfmt-support` is installed on the host machine before
|
||||||
|
starting the `./build-docker.sh` script (or using your own docker build
|
||||||
|
solution).
|
||||||
|
|
||||||
|
|
||||||
|
## Stage Anatomy
|
||||||
|
|
||||||
|
### Raspbian Stage Overview
|
||||||
|
|
||||||
|
The build of Raspbian is divided up into several stages for logical clarity
|
||||||
|
and modularity. This causes some initial complexity, but it simplifies
|
||||||
|
maintenance and allows for more easy customization.
|
||||||
|
|
||||||
|
- **Stage 0** - bootstrap. The primary purpose of this stage is to create a
|
||||||
|
usable filesystem. This is accomplished largely through the use of
|
||||||
|
`debootstrap`, which creates a minimal filesystem suitable for use as a
|
||||||
|
base.tgz on Debian systems. This stage also configures apt settings and
|
||||||
|
installs `raspberrypi-bootloader` which is missed by debootstrap. The
|
||||||
|
minimal core is installed but not configured, and the system will not quite
|
||||||
|
boot yet.
|
||||||
|
|
||||||
|
- **Stage 1** - truly minimal system. This stage makes the system bootable by
|
||||||
|
installing system files like `/etc/fstab`, configures the bootloader, makes
|
||||||
|
the network operable, and installs packages like raspi-config. At this
|
||||||
|
stage the system should boot to a local console from which you have the
|
||||||
|
means to perform basic tasks needed to configure and install the system.
|
||||||
|
This is as minimal as a system can possibly get, and its arguably not
|
||||||
|
really usable yet in a traditional sense yet. Still, if you want minimal,
|
||||||
|
this is minimal and the rest you could reasonably do yourself as sysadmin.
|
||||||
|
|
||||||
|
- **Stage 2** - lite system. This stage produces the Raspbian-Lite image. It
|
||||||
|
installs some optimized memory functions, sets timezone and charmap
|
||||||
|
defaults, installs fake-hwclock and ntp, wifi and bluetooth support,
|
||||||
|
dphys-swapfile, and other basics for managing the hardware. It also
|
||||||
|
creates necessary groups and gives the default user access to sudo and the
|
||||||
|
standard console hardware permission groups.
|
||||||
|
|
||||||
|
- **Stage 3** - docker + kubernetes. This stage installs setups the docker and
|
||||||
|
kubernetes apt repos and installs `docker-ce` and `kubeadm`. It also makes sure
|
||||||
|
that pre-requisites for kubernetes are taken care of
|
||||||
|
(disabling swap, setting up c-group driver for docker, etc)
|
||||||
|
|
||||||
|
- **Stage 4** - pikube bootstrapping. This stage sets up a service that runs on first
|
||||||
|
boot to configure you kubernetes master/worker and configures the ssh keypair
|
||||||
|
|
||||||
|
### Stage specification
|
||||||
|
|
||||||
|
If you wish to build up to a specified stage (such as building up to stage 2
|
||||||
|
for a lite system), place an empty file named `SKIP` in each of the `./stage`
|
||||||
|
directories you wish not to include.
|
||||||
|
|
||||||
|
Then add an empty file named `SKIP_IMAGES` to `./stage4` and `./stage5` (if building up to stage 2) or
|
||||||
|
to `./stage2` (if building a minimal system).
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Example for building a lite system
|
||||||
|
touch ./stage3/SKIP ./stage4/SKIP ./stage5/SKIP
|
||||||
|
touch ./stage4/SKIP_IMAGES ./stage5/SKIP_IMAGES
|
||||||
|
sudo ./build.sh # or ./build-docker.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
If you wish to build further configurations upon (for example) the lite
|
||||||
|
system, you can also delete the contents of `./stage3` and `./stage4` and
|
||||||
|
replace with your own contents in the same format.
|
||||||
|
|
||||||
|
|
||||||
|
## Skipping stages to speed up development
|
||||||
|
The easiest way to speed up development is to use the `./docker-build.sh` workflow
|
||||||
|
which will use docker images to cache each stage.
|
||||||
|
|
||||||
|
|
||||||
|
If you're working on a specific stage the recommended development process is as
|
||||||
|
follows:
|
||||||
|
|
||||||
|
* Add a file called SKIP_IMAGES into the directories containing EXPORT_* files
|
||||||
|
(currently stage2, stage4 and stage5)
|
||||||
|
* Add SKIP files to the stages you don't want to build. For example, if you're
|
||||||
|
basing your image on the lite image you would add these to stages 3, 4 and 5.
|
||||||
|
* Run build.sh to build all stages
|
||||||
|
* Add SKIP files to the earlier successfully built stages
|
||||||
|
* Modify the last stage
|
||||||
|
* Rebuild just the last stage using ```sudo CLEAN=1 ./build.sh```
|
||||||
|
* Once you're happy with the image you can remove the SKIP_IMAGES files and
|
||||||
|
export your image to test
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
|
|
||||||
NOOBS_DIR="${STAGE_WORK_DIR}/${IMG_DATE}-${IMG_NAME}${IMG_SUFFIX}"
|
NOOBS_DIR="${STAGE_WORK_DIR}/${IMG_VERSION}-${IMG_NAME}${IMG_SUFFIX}"
|
||||||
|
|
||||||
install -v -m 744 files/partition_setup.sh "${NOOBS_DIR}/"
|
install -v -m 744 files/partition_setup.sh "${NOOBS_DIR}/"
|
||||||
install -v files/partitions.json "${NOOBS_DIR}/"
|
install -v files/partitions.json "${NOOBS_DIR}/"
|
||||||
|
@ -33,11 +33,11 @@ sed "${NOOBS_DIR}/partitions.json" -i -e "s|ROOT_SIZE|${ROOT_SIZE}|"
|
||||||
sed "${NOOBS_DIR}/partitions.json" -i -e "s|BOOT_NOM|${BOOT_NOM}|"
|
sed "${NOOBS_DIR}/partitions.json" -i -e "s|BOOT_NOM|${BOOT_NOM}|"
|
||||||
sed "${NOOBS_DIR}/partitions.json" -i -e "s|ROOT_NOM|${ROOT_NOM}|"
|
sed "${NOOBS_DIR}/partitions.json" -i -e "s|ROOT_NOM|${ROOT_NOM}|"
|
||||||
|
|
||||||
sed "${NOOBS_DIR}/os.json" -i -e "s|UNRELEASED|${IMG_DATE}|"
|
sed "${NOOBS_DIR}/os.json" -i -e "s|UNRELEASED|${IMG_VERSION}|"
|
||||||
sed "${NOOBS_DIR}/os.json" -i -e "s|NOOBS_NAME|${NOOBS_NAME}|"
|
sed "${NOOBS_DIR}/os.json" -i -e "s|NOOBS_NAME|${NOOBS_NAME}|"
|
||||||
sed "${NOOBS_DIR}/os.json" -i -e "s|NOOBS_DESCRIPTION|${NOOBS_DESCRIPTION}|"
|
sed "${NOOBS_DIR}/os.json" -i -e "s|NOOBS_DESCRIPTION|${NOOBS_DESCRIPTION}|"
|
||||||
sed "${NOOBS_DIR}/os.json" -i -e "s|RELEASE|${RELEASE}|"
|
sed "${NOOBS_DIR}/os.json" -i -e "s|RELEASE|${RELEASE}|"
|
||||||
|
|
||||||
sed "${NOOBS_DIR}/release_notes.txt" -i -e "s|UNRELEASED|${IMG_DATE}|"
|
sed "${NOOBS_DIR}/release_notes.txt" -i -e "s|UNRELEASED|${IMG_VERSION}|"
|
||||||
|
|
||||||
cp -a "${NOOBS_DIR}" "${DEPLOY_DIR}/"
|
cp -a "${NOOBS_DIR}" "${DEPLOY_DIR}/"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
|
|
||||||
IMG_FILE="${STAGE_WORK_DIR}/${IMG_FILENAME}${IMG_SUFFIX}.img"
|
IMG_FILE="${STAGE_WORK_DIR}/${IMG_FILENAME}${IMG_SUFFIX}.img"
|
||||||
NOOBS_DIR="${STAGE_WORK_DIR}/${IMG_DATE}-${IMG_NAME}${IMG_SUFFIX}"
|
NOOBS_DIR="${STAGE_WORK_DIR}/${IMG_VERSION}-${IMG_NAME}${IMG_SUFFIX}"
|
||||||
unmount_image "${IMG_FILE}"
|
unmount_image "${IMG_FILE}"
|
||||||
|
|
||||||
mkdir -p "${STAGE_WORK_DIR}"
|
mkdir -p "${STAGE_WORK_DIR}"
|
||||||
|
|
|
@ -95,6 +95,6 @@ on_chroot() {
|
||||||
export -f on_chroot
|
export -f on_chroot
|
||||||
|
|
||||||
update_issue() {
|
update_issue() {
|
||||||
echo -e "Raspberry Pi reference ${IMG_DATE}\nGenerated using ${PI_GEN}, ${PI_GEN_REPO}, ${GIT_HASH}, ${1}" > "${ROOTFS_DIR}/etc/rpi-issue"
|
echo -e "Raspberry Pi reference ${IMG_VERSION}\nGenerated using ${PI_GEN}, ${PI_GEN_REPO}, ${GIT_HASH}, ${1}" > "${ROOTFS_DIR}/etc/rpi-issue"
|
||||||
}
|
}
|
||||||
export -f update_issue
|
export -f update_issue
|
||||||
|
|
|
@ -54,3 +54,11 @@ usermod --pass='*' root
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
rm -f "${ROOTFS_DIR}/etc/ssh/"ssh_host_*_key*
|
rm -f "${ROOTFS_DIR}/etc/ssh/"ssh_host_*_key*
|
||||||
|
|
||||||
|
install -m 440 files/010_user-nopasswd "${ROOTFS_DIR}/etc/sudoers.d/010_${FIRST_USER_NAME}-nopasswd"
|
||||||
|
sed -i "s/USER_NAME/${FIRST_USER_NAME}/g" "${ROOTFS_DIR}/etc/sudoers.d/010_${FIRST_USER_NAME}-nopasswd"
|
||||||
|
|
||||||
|
if [ -n "${SSH_AUTHORIZED_KEY}" ]; then
|
||||||
|
mkdir -p ${ROOTFS_DIR}/home/${FIRST_USER_NAME}/.ssh
|
||||||
|
echo $SSH_AUTHORIZED_KEY > ${ROOTFS_DIR}/home/${FIRST_USER_NAME}/.ssh/authorized_keys
|
||||||
|
fi
|
||||||
|
|
1
stage2/01-sys-tweaks/files/010_user-nopasswd
Normal file
1
stage2/01-sys-tweaks/files/010_user-nopasswd
Normal file
|
@ -0,0 +1 @@
|
||||||
|
USER_NAME ALL=(ALL) NOPASSWD: ALL
|
|
@ -1,2 +0,0 @@
|
||||||
# Do you accept the Wolfram - Raspberry Pi® Bundle License Agreement?
|
|
||||||
wolfram-engine shared/accepted-wolfram-eula boolean true
|
|
|
@ -1,4 +0,0 @@
|
||||||
IMG_SUFFIX="-lite"
|
|
||||||
if [ "${USE_QEMU}" = "1" ]; then
|
|
||||||
export IMG_SUFFIX="${IMG_SUFFIX}-qemu"
|
|
||||||
fi
|
|
|
@ -1,2 +0,0 @@
|
||||||
NOOBS_NAME="Raspbian Lite"
|
|
||||||
NOOBS_DESCRIPTION="A port of Debian with no desktop environment"
|
|
2
stage3/00-configure-apt/00-packages
Normal file
2
stage3/00-configure-apt/00-packages
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
apt-transport-https
|
||||||
|
ca-certificates
|
11
stage3/00-configure-apt/01-run.sh
Executable file
11
stage3/00-configure-apt/01-run.sh
Executable file
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/bash -e
|
||||||
|
|
||||||
|
install -m 644 files/docker.list "${ROOTFS_DIR}/etc/apt/sources.list.d/docker.list"
|
||||||
|
sed -i "s/RELEASE/${RELEASE}/g" "${ROOTFS_DIR}/etc/apt/sources.list.d/docker.list"
|
||||||
|
install -m 644 files/kubernetes.list "${ROOTFS_DIR}/etc/apt/sources.list.d/kubernetes.list"
|
||||||
|
|
||||||
|
on_chroot apt-key add - < files/docker.gpg.key
|
||||||
|
on_chroot apt-key add - < files/kubernetes.gpg.key
|
||||||
|
on_chroot << EOF
|
||||||
|
apt-get update
|
||||||
|
EOF
|
62
stage3/00-configure-apt/files/docker.gpg.key
Normal file
62
stage3/00-configure-apt/files/docker.gpg.key
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||||
|
|
||||||
|
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
|
||||||
|
YT90qFF93M3v01BbxP+EIY2/9tiIPbrd
|
||||||
|
=0YYh
|
||||||
|
-----END PGP PUBLIC KEY BLOCK-----
|
1
stage3/00-configure-apt/files/docker.list
Normal file
1
stage3/00-configure-apt/files/docker.list
Normal file
|
@ -0,0 +1 @@
|
||||||
|
deb [arch=armhf] https://download.docker.com/linux/raspbian RELEASE stable
|
BIN
stage3/00-configure-apt/files/kubernetes.gpg.key
Normal file
BIN
stage3/00-configure-apt/files/kubernetes.gpg.key
Normal file
Binary file not shown.
1
stage3/00-configure-apt/files/kubernetes.list
Normal file
1
stage3/00-configure-apt/files/kubernetes.list
Normal file
|
@ -0,0 +1 @@
|
||||||
|
deb https://apt.kubernetes.io/ kubernetes-xenial main
|
|
@ -1,2 +0,0 @@
|
||||||
# Adobe Flash Player. Copyright 1996-2015. Adobe Systems Incorporated. All Rights Reserved.
|
|
||||||
rpi-chromium-mods rpi-chromium-mods/adobe note
|
|
|
@ -1,15 +0,0 @@
|
||||||
gstreamer1.0-x gstreamer1.0-omx gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-alsa gstreamer1.0-libav
|
|
||||||
qpdfview gtk2-engines alsa-utils
|
|
||||||
desktop-base
|
|
||||||
git
|
|
||||||
omxplayer
|
|
||||||
raspberrypi-artwork
|
|
||||||
policykit-1
|
|
||||||
gvfs
|
|
||||||
rfkill
|
|
||||||
chromium-browser rpi-chromium-mods
|
|
||||||
gldriver-test
|
|
||||||
fonts-droid-fallback
|
|
||||||
fonts-liberation2
|
|
||||||
obconf
|
|
||||||
arandr
|
|
|
@ -1,6 +0,0 @@
|
||||||
xserver-xorg-video-fbdev xserver-xorg xinit xserver-xorg-video-fbturbo
|
|
||||||
mousepad
|
|
||||||
lxde lxtask menu-xdg
|
|
||||||
zenity xdg-utils
|
|
||||||
gvfs-backends gvfs-fuse
|
|
||||||
lightdm gnome-themes-standard-data gnome-icon-theme
|
|
|
@ -1,8 +0,0 @@
|
||||||
#!/bin/bash -e
|
|
||||||
|
|
||||||
on_chroot << EOF
|
|
||||||
update-alternatives --install /usr/bin/x-www-browser \
|
|
||||||
x-www-browser /usr/bin/chromium-browser 86
|
|
||||||
update-alternatives --install /usr/bin/gnome-www-browser \
|
|
||||||
gnome-www-browser /usr/bin/chromium-browser 86
|
|
||||||
EOF
|
|
2
stage3/01-install-docker/00-packages-nr
Normal file
2
stage3/01-install-docker/00-packages-nr
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
docker-ce
|
||||||
|
kubeadm
|
8
stage3/01-install-docker/01-run.sh
Executable file
8
stage3/01-install-docker/01-run.sh
Executable file
|
@ -0,0 +1,8 @@
|
||||||
|
#!/bin/bash -e
|
||||||
|
|
||||||
|
mkdir "${ROOTFS_DIR}/etc/docker"
|
||||||
|
install -m 644 files/daemon.json "${ROOTFS_DIR}/etc/docker/daemon.json"
|
||||||
|
|
||||||
|
on_chroot << EOF
|
||||||
|
usermod -aG docker $FIRST_USER_NAME
|
||||||
|
EOF
|
6
stage3/01-install-docker/02-patches/00-disable-swap.diff
Normal file
6
stage3/01-install-docker/02-patches/00-disable-swap.diff
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
--- stage2.orig/rootfs/boot/cmdline.txt
|
||||||
|
+++ stage2/rootfs/boot/cmdline.txt
|
||||||
|
@@ -1 +1 @@
|
||||||
|
-console=serial0,115200 console=tty1 root=ROOTDEV rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet init=/usr/lib/raspi-config/init_resize.sh
|
||||||
|
+console=serial0,115200 console=tty1 root=ROOTDEV rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet init=/usr/lib/raspi-config/init_resize.sh cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory
|
||||||
|
|
1
stage3/01-install-docker/02-patches/series
Normal file
1
stage3/01-install-docker/02-patches/series
Normal file
|
@ -0,0 +1 @@
|
||||||
|
00-disable-swap.diff
|
9
stage3/01-install-docker/files/daemon.json
Normal file
9
stage3/01-install-docker/files/daemon.json
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"exec-opts": ["native.cgroupdriver=systemd"],
|
||||||
|
"log-driver": "json-file",
|
||||||
|
"log-opts": {
|
||||||
|
"max-size": "100m"
|
||||||
|
},
|
||||||
|
"storage-driver": "overlay2"
|
||||||
|
}
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
#!/bin/bash -e
|
|
||||||
|
|
||||||
rm -f "${ROOTFS_DIR}/etc/systemd/system/dhcpcd.service.d/wait.conf"
|
|
|
@ -1,2 +0,0 @@
|
||||||
# Enable realtime process priority?
|
|
||||||
jackd2 jackd/tweak_rt_limits boolean true
|
|
|
@ -1,25 +0,0 @@
|
||||||
python python3-pygame python-pygame python-tk
|
|
||||||
python3 python3-tk thonny
|
|
||||||
python3-pgzero
|
|
||||||
python-serial python3-serial
|
|
||||||
python-picamera python3-picamera
|
|
||||||
debian-reference-en dillo
|
|
||||||
raspberrypi-net-mods raspberrypi-ui-mods
|
|
||||||
python-pip python3-pip
|
|
||||||
python3-numpy
|
|
||||||
pypy
|
|
||||||
alacarte rc-gui sense-hat
|
|
||||||
tree
|
|
||||||
libgl1-mesa-dri libgles1 libgles2-mesa xcompmgr
|
|
||||||
geany
|
|
||||||
piclone
|
|
||||||
wiringpi pigpio python-pigpio python3-pigpio raspi-gpio python-gpiozero python3-gpiozero python3-rpi.gpio
|
|
||||||
python-spidev python3-spidev
|
|
||||||
python-twython python3-twython
|
|
||||||
python-smbus python3-smbus
|
|
||||||
python-flask python3-flask
|
|
||||||
pprompt
|
|
||||||
piwiz
|
|
||||||
rp-prefapps
|
|
||||||
ffmpeg
|
|
||||||
vlc
|
|
|
@ -1,2 +0,0 @@
|
||||||
pi-package
|
|
||||||
realvnc-vnc-server
|
|
|
@ -1,22 +0,0 @@
|
||||||
python-automationhat python3-automationhat
|
|
||||||
python-blinkt python3-blinkt
|
|
||||||
python-cap1xxx python3-cap1xxx
|
|
||||||
python-drumhat python3-drumhat
|
|
||||||
python-envirophat python3-envirophat
|
|
||||||
python-explorerhat python3-explorerhat
|
|
||||||
python-fourletterphat python3-fourletterphat
|
|
||||||
python-microdotphat python3-microdotphat
|
|
||||||
python-mote python3-mote
|
|
||||||
python-motephat python3-motephat
|
|
||||||
python-phatbeat python3-phatbeat
|
|
||||||
python-pianohat python3-pianohat
|
|
||||||
python-piglow python3-piglow
|
|
||||||
python-rainbowhat python3-rainbowhat
|
|
||||||
python-scrollphat python3-scrollphat
|
|
||||||
python-scrollphathd python3-scrollphathd
|
|
||||||
python-sn3218 python3-sn3218
|
|
||||||
python-skywriter python3-skywriter
|
|
||||||
python-touchphat python3-touchphat
|
|
||||||
python-buttonshim python3-buttonshim
|
|
||||||
python-unicornhathd python3-unicornhathd
|
|
||||||
python-pantilthat python3-pantilthat
|
|
|
@ -1,4 +0,0 @@
|
||||||
hunspell-en-gb
|
|
||||||
hyphen-en-gb
|
|
||||||
wamerican
|
|
||||||
wbritish
|
|
12
stage4/00-setup-bootstrap/00-run.sh
Executable file
12
stage4/00-setup-bootstrap/00-run.sh
Executable file
|
@ -0,0 +1,12 @@
|
||||||
|
|
||||||
|
|
||||||
|
sudo cp myscript.service /etc/systemd/system/myscript.service
|
||||||
|
install -m 644 files/pikube-bootstrap.service "${ROOTFS_DIR}/etc/systemd/system/pikube-bootstrap.service"
|
||||||
|
|
||||||
|
mkdir -p "${ROOTFS_DIR}/opt/pikube"
|
||||||
|
install -m 744 files/bootstrap.sh "${ROOTFS_DIR}/opt/pikube/bootstrap.sh"
|
||||||
|
sed -i "s/USERNAME/${FIRST_USER_NAME}/g" "${ROOTFS_DIR}/opt/pikube/bootstrap.sh"
|
||||||
|
|
||||||
|
on_chroot << EOF
|
||||||
|
systemctl enable pikube-bootstrap
|
||||||
|
EOF
|
70
stage4/00-setup-bootstrap/files/bootstrap.sh
Normal file
70
stage4/00-setup-bootstrap/files/bootstrap.sh
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
#!/usr/bin/bash -e
|
||||||
|
|
||||||
|
echo "Begining pikube bootstrapping"
|
||||||
|
|
||||||
|
if [ ! -f "/boot/pikube.tar.gz" ];then
|
||||||
|
echo "Error: unable to find /boot/pikube.tar.gz" | tee /var/pikube.status
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
root_dir=/opt/pikube
|
||||||
|
conf_dir=$root_dir/conf
|
||||||
|
|
||||||
|
mkdir -p $conf_dir
|
||||||
|
tar -xzf /boot/pikube.tar.gz -C $conf_dir
|
||||||
|
|
||||||
|
if [ -f "$conf_dir/hostname" ];then
|
||||||
|
echo "Updating hostname" | tee /var/pikube.status
|
||||||
|
old_hostname=$(hostname)
|
||||||
|
new_hostname=$(cat $conf_dir/hostname)
|
||||||
|
hostnamectl set-hostname $new_hostname
|
||||||
|
sed -i "s/${old_hostname}/${new_hostname}/g" /etc/hosts
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Disabling swap" > /var/pikube.status
|
||||||
|
dphys-swapfile swapoff
|
||||||
|
dphys-swapfile uninstall
|
||||||
|
systemctl disable dphys-swapfile
|
||||||
|
|
||||||
|
# TODO: VARIABLE EXAPNSION ON USERNAME
|
||||||
|
user=USER_NAME
|
||||||
|
if [ -f "$conf_dir/ssh.pub" ];then
|
||||||
|
echo "Installing ssh key" | tee /var/pikube.status
|
||||||
|
mkdir -p /home/$user/.ssh
|
||||||
|
cp $conf_dir/ssh.pub /home/$user/.ssh/authorized_keys
|
||||||
|
chown $user:$user /home/$user/.ssh/authorized_keys
|
||||||
|
chmod 644 /home/$user/.ssh/authorized_keys
|
||||||
|
passwd --delete kube
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if [ -f "$conf_dir/ca.crt" ];then
|
||||||
|
echo "Installing CA certificate" | tee /var/pikube.status
|
||||||
|
cp $conf_dir/pki/ca.crt /usr/local/share/ca-certificates/kubernetes.crt
|
||||||
|
update-ca-certificates
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "$conf_dir/kube.yaml" ];then
|
||||||
|
echo "Applying kubernetes config" | tee /var/pikube.status
|
||||||
|
|
||||||
|
if [ -d "$conf_dir/pki" ];then
|
||||||
|
mkdir -p /etc/kubernetes/pki
|
||||||
|
cp $config_dir/pki/* /etc/kubernetes/pki
|
||||||
|
fi
|
||||||
|
|
||||||
|
kubeadm init --config conf/kube.yaml
|
||||||
|
|
||||||
|
# setup the kube config for the kube user
|
||||||
|
mkdir -p /home/kube/.kube
|
||||||
|
sudo cp -i /etc/kubernetes/admin.conf /home/kube/.kube/config
|
||||||
|
sudo chown $user:$user /home/kube/.kube/config
|
||||||
|
|
||||||
|
# install weave network
|
||||||
|
kubectl apply --kubeconfig=/etc/kubernetes/admin.conf -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Initialized" > /var/pikube.status
|
||||||
|
|
||||||
|
systemctl disable pikube-bootstrap
|
||||||
|
sleep 120
|
||||||
|
reboot
|
14
stage4/00-setup-bootstrap/files/pikube-bootstrap.service
Normal file
14
stage4/00-setup-bootstrap/files/pikube-bootstrap.service
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
[Unit]
|
||||||
|
Description=pikube bootstrap
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/usr/bin/bash bootstrap.sh
|
||||||
|
WorkingDirectory=/opt/pikube
|
||||||
|
StandardOutput=file:/var/log/pikube.log
|
||||||
|
StandardError=file:/var/log/pikube.log
|
||||||
|
Restart=no
|
||||||
|
User=root
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
|
@ -1,5 +0,0 @@
|
||||||
#!/bin/bash -e
|
|
||||||
|
|
||||||
on_chroot << EOF
|
|
||||||
SUDO_USER="${FIRST_USER_NAME}" raspi-config nonint do_boot_behaviour B4
|
|
||||||
EOF
|
|
|
@ -1,7 +0,0 @@
|
||||||
#!/bin/bash -e
|
|
||||||
|
|
||||||
#Alacarte fixes
|
|
||||||
install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/${FIRST_USER_NAME}/.local"
|
|
||||||
install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/${FIRST_USER_NAME}/.local/share"
|
|
||||||
install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/${FIRST_USER_NAME}/.local/share/applications"
|
|
||||||
install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/${FIRST_USER_NAME}/.local/share/desktop-directories"
|
|
|
@ -1,15 +0,0 @@
|
||||||
#!/bin/sh -e
|
|
||||||
|
|
||||||
magpi_regex="MagPi[[:digit:]]*.pdf"
|
|
||||||
magpi_loc="$(curl -s https://magpi.raspberrypi.org/latest-pdf)"
|
|
||||||
magpi_latest="$(echo "$magpi_loc" | grep "$magpi_regex" -m 1 -o)"
|
|
||||||
|
|
||||||
if [ ! -f "files/$magpi_latest" ]; then
|
|
||||||
find files/ -regextype grep -regex "files/$magpi_regex" -delete
|
|
||||||
wget "$magpi_loc" -O "files/$magpi_latest"
|
|
||||||
fi
|
|
||||||
|
|
||||||
file "files/$magpi_latest" | grep -q "PDF document"
|
|
||||||
|
|
||||||
install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/${FIRST_USER_NAME}/MagPi"
|
|
||||||
install -v -o 1000 -g 1000 -m 644 "files/$magpi_latest" "${ROOTFS_DIR}/home/${FIRST_USER_NAME}/MagPi/"
|
|
1
stage4/03-magpi/files/.gitignore
vendored
1
stage4/03-magpi/files/.gitignore
vendored
|
@ -1 +0,0 @@
|
||||||
*.pdf
|
|
|
@ -1,5 +0,0 @@
|
||||||
#!/bin/bash -e
|
|
||||||
|
|
||||||
on_chroot << EOF
|
|
||||||
raspi-config nonint do_xcompmgr 0
|
|
||||||
EOF
|
|
|
@ -1,2 +0,0 @@
|
||||||
NOOBS_NAME="Raspbian"
|
|
||||||
NOOBS_DESCRIPTION="A port of Debian with the Raspberry Pi Desktop"
|
|
|
@ -1,16 +0,0 @@
|
||||||
mu-editor
|
|
||||||
sonic-pi
|
|
||||||
scratch nuscratch scratch2 scratch3
|
|
||||||
smartsim
|
|
||||||
|
|
||||||
minecraft-pi python-minecraftpi python-picraft python3-picraft
|
|
||||||
python-sense-emu sense-emu-tools python-sense-emu-doc
|
|
||||||
|
|
||||||
wolfram-engine
|
|
||||||
claws-mail
|
|
||||||
greenfoot-unbundled bluej
|
|
||||||
nodered
|
|
||||||
realvnc-vnc-viewer
|
|
||||||
|
|
||||||
python-games
|
|
||||||
code-the-classics
|
|
|
@ -1,3 +0,0 @@
|
||||||
libreoffice-pi
|
|
||||||
libreoffice-help-en-gb
|
|
||||||
libreoffice-l10n-en-gb
|
|
|
@ -1,4 +0,0 @@
|
||||||
IMG_SUFFIX="-full"
|
|
||||||
if [ "${USE_QEMU}" = "1" ]; then
|
|
||||||
export IMG_SUFFIX="${IMG_SUFFIX}-qemu"
|
|
||||||
fi
|
|
|
@ -1,2 +0,0 @@
|
||||||
NOOBS_NAME="Raspbian Full"
|
|
||||||
NOOBS_DESCRIPTION="A port of Debian with desktop and recommended applications"
|
|
|
@ -1,5 +0,0 @@
|
||||||
#!/bin/bash -e
|
|
||||||
|
|
||||||
if [ ! -d "${ROOTFS_DIR}" ]; then
|
|
||||||
copy_previous
|
|
||||||
fi
|
|
Loading…
Reference in New Issue
Block a user