Merge ab6e11afef into 330ce73491
				
					
				
			This commit is contained in:
		
						commit
						f84e86f983
					
				
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							|  | @ -7,3 +7,4 @@ SKIP_IMAGES | ||||||
| .pc | .pc | ||||||
| *-pc | *-pc | ||||||
| apt-cacher-ng/ | apt-cacher-ng/ | ||||||
|  | stage2/01-sys-tweaks/files/authorized_keys | ||||||
|  |  | ||||||
							
								
								
									
										39
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										39
									
								
								README.md
									
									
									
									
									
								
							|  | @ -61,7 +61,7 @@ The following environment variables are supported: | ||||||
|    be built and cached.  Note, `WORK_DIR` stores a complete copy of the target |    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 |    system for each build stage, amounting to tens of gigabytes in the case of | ||||||
|    Raspbian. |    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. |    **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"`) |  * `DEPLOY_DIR`  (Default: `"$BASE_DIR/deploy"`) | ||||||
|  | @ -73,6 +73,39 @@ The following environment variables are supported: | ||||||
|    Setting to '1' enables the QEMU mode - creating an image that can be mounted via QEMU for an emulated |    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. |    environment. These images include "-qemu" in the image file name. | ||||||
| 
 | 
 | ||||||
|  |  * `LAST_STAGE` (Default: `"5"`) | ||||||
|  | 
 | ||||||
|  |    If you wish to build up to a specified stage (such as building up to stage 2 for a lite system) | ||||||
|  | 
 | ||||||
|  |  * `RPI_LOCALHOST` (Default: `"raspberrypi"`) | ||||||
|  | 
 | ||||||
|  |    Your image hostname. | ||||||
|  | 
 | ||||||
|  |  * `RPI_USERNAME` (Default: `"pi"`) | ||||||
|  | 
 | ||||||
|  |    Default non priviledged user name. | ||||||
|  | 
 | ||||||
|  |  * `RPI_USERPASS` (Default: `"raspberry"`) | ||||||
|  | 
 | ||||||
|  |    Default user password. | ||||||
|  | 
 | ||||||
|  |  * `RPI_ROOTPASS` (Default: `"root"`) | ||||||
|  | 
 | ||||||
|  |    root user default password. | ||||||
|  | 
 | ||||||
|  |  * `KEYBOARD_LANG` (Default: `"gb"`) | ||||||
|  | 
 | ||||||
|  |    Change the keyboard default mapping (gb=qwerty, fr=azerty). | ||||||
|  | 
 | ||||||
|  |  * `FREE_SPACE_MB` (Default: <int> 400) | ||||||
|  | 
 | ||||||
|  |    Add a free space in the partition (value in megabyte). If Qemu image is generated it could be usefull to have a lot of free space. | ||||||
|  | 
 | ||||||
|  |  * `USE_SSH` (Default: `"0"`) | ||||||
|  | 
 | ||||||
|  |    For security SSH server is disabled by default so if you want to activate it set this to `"1"`.   | ||||||
|  |    If `stage2/01-sys-tweaks/files/authorized_keys` is present then it will be copied in `/root/.ssh/` | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| A simple example for building Raspbian: | A simple example for building Raspbian: | ||||||
| 
 | 
 | ||||||
|  | @ -213,6 +246,8 @@ maintenance and allows for more easy customization. | ||||||
| 
 | 
 | ||||||
| ### Stage specification | ### Stage specification | ||||||
| 
 | 
 | ||||||
|  | If you wish to skip some steps you can add an empty file `SKIP` in the directory.   | ||||||
|  | It works in `./stage*` or in `./stage*/**-whatever`. | ||||||
| If you wish to build up to a specified stage (such as building up to stage 2 | 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` | for a lite system), place an empty file named `SKIP` in each of the `./stage` | ||||||
| directories you wish not to include. | directories you wish not to include. | ||||||
|  | @ -271,4 +306,4 @@ To resolve this, ensure that the following files are available (install them if | ||||||
| /usr/bin/qemu-arm-static | /usr/bin/qemu-arm-static | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| You may also need to load the module by hand - run `modprobe binfmt_misc`. | You may also need to load the module by hand - run `modprobe binfmt_misc`. | ||||||
							
								
								
									
										24
									
								
								build.sh
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								build.sh
									
									
									
									
									
								
							|  | @ -133,9 +133,17 @@ 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 LAST_STAGE=${LAST_STAGE:-5} | ||||||
|  | export FREE_SPACE_MB=${FREE_SPACE_MB:-400} | ||||||
|  | export RPI_LOCALHOST=${RPI_LOCALHOST:-"raspberrypi"} | ||||||
|  | export RPI_USERNAME=${RPI_USERNAME:-"pi"} | ||||||
|  | export RPI_USERPASS=${RPI_USERPASS:-"raspberry"} | ||||||
|  | export RPI_ROOTPASS=${RPI_ROOTPASS:-"root"} | ||||||
|  | export KEYBOARD_LANG=${KEYBOARD_LANG:-"gb"} | ||||||
|  | export USE_SSH=${USE_SSH:-0} | ||||||
| 
 | 
 | ||||||
| BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | export IMG_DATE=${IMG_DATE:-"$(date +%Y-%m-%d)"} | ||||||
|  | export BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||||||
| 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_DATE}-${IMG_NAME}"}" | ||||||
| export DEPLOY_DIR=${DEPLOY_DIR:-"${BASE_DIR}/deploy"} | export DEPLOY_DIR=${DEPLOY_DIR:-"${BASE_DIR}/deploy"} | ||||||
|  | @ -169,14 +177,22 @@ export QUILT_REFRESH_ARGS="-p ab" | ||||||
| source "${SCRIPT_DIR}/common" | source "${SCRIPT_DIR}/common" | ||||||
| # shellcheck source=scripts/dependencies_check | # shellcheck source=scripts/dependencies_check | ||||||
| source "${SCRIPT_DIR}/dependencies_check" | source "${SCRIPT_DIR}/dependencies_check" | ||||||
|  | mkdir -p "${WORK_DIR}" | ||||||
| 
 | 
 | ||||||
|  | # LAST_STAGE validation | ||||||
|  | if [[ "${LAST_STAGE,,}" =~ ^(2|4|5)$ ]]; then | ||||||
|  | 	log "Valid LAST_STAGE: $LAST_STAGE" | ||||||
|  | else | ||||||
|  | 	log "ERROR INVALID LAST_STAGE: $LAST_STAGE, try 2, 4 or 5" | ||||||
|  | 	exit 2 | ||||||
|  | fi | ||||||
| 
 | 
 | ||||||
| dependencies_check "${BASE_DIR}/depends" | dependencies_check "${BASE_DIR}/depends" | ||||||
| 
 | 
 | ||||||
| mkdir -p "${WORK_DIR}" |  | ||||||
| log "Begin ${BASE_DIR}" | log "Begin ${BASE_DIR}" | ||||||
| 
 | 
 | ||||||
| for STAGE_DIR in "${BASE_DIR}/stage"*; do | for i in $( seq 0 $LAST_STAGE); do | ||||||
|  | 	STAGE_DIR=${BASE_DIR}/stage$i | ||||||
| 	run_stage | 	run_stage | ||||||
| done | done | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										10
									
								
								config.exemple
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								config.exemple
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,10 @@ | ||||||
|  | IMG_NAME="Raspbian" | ||||||
|  | USE_QEMU=1 | ||||||
|  | USE_SSH=1 | ||||||
|  | LAST_STAGE=5 | ||||||
|  | FREE_SPACE_MB=500 | ||||||
|  | KEYBOARD_LANG="gb" | ||||||
|  | RPI_LOCALHOST="raspberrypi" | ||||||
|  | RPI_USERNAME="pi" | ||||||
|  | RPI_USERPASS="raspberry" | ||||||
|  | RPI_ROOTPASS="root" | ||||||
|  | @ -8,8 +8,8 @@ on_chroot << EOF | ||||||
| hardlink -t /usr/share/doc | hardlink -t /usr/share/doc | ||||||
| EOF | EOF | ||||||
| 
 | 
 | ||||||
| if [ -d "${ROOTFS_DIR}/home/pi/.config" ]; then | if [ -d "${ROOTFS_DIR}/home/${RPI_USERNAME}/.config" ]; then | ||||||
| 	chmod 700 "${ROOTFS_DIR}/home/pi/.config" | 	chmod 700 "${ROOTFS_DIR}/home/${RPI_USERNAME}/.config" | ||||||
| fi | fi | ||||||
| 
 | 
 | ||||||
| rm -f "${ROOTFS_DIR}/etc/apt/apt.conf.d/51cache" | rm -f "${ROOTFS_DIR}/etc/apt/apt.conf.d/51cache" | ||||||
|  |  | ||||||
|  | @ -16,6 +16,11 @@ ROUND_SIZE="$((4 * 1024 * 1024))" | ||||||
| ROUNDED_ROOT_SECTOR=$(((2 * BOOT_SIZE + ROUND_SIZE) / ROUND_SIZE * ROUND_SIZE / 512 + 8192)) | ROUNDED_ROOT_SECTOR=$(((2 * BOOT_SIZE + ROUND_SIZE) / ROUND_SIZE * ROUND_SIZE / 512 + 8192)) | ||||||
| IMG_SIZE=$(((BOOT_SIZE + TOTAL_SIZE + (800 * 1024 * 1024) + ROUND_SIZE - 1) / ROUND_SIZE * ROUND_SIZE)) | IMG_SIZE=$(((BOOT_SIZE + TOTAL_SIZE + (800 * 1024 * 1024) + ROUND_SIZE - 1) / ROUND_SIZE * ROUND_SIZE)) | ||||||
| 
 | 
 | ||||||
|  | if [ "${USE_QEMU}" = "1" ]; then | ||||||
|  | 	log "Added ${FREE_SPACE_MB} to qemu image (${IMG_SIZE})" | ||||||
|  | 	IMG_SIZE=$(((BOOT_SIZE + TOTAL_SIZE + (FREE_SPACE_MB * 1024 * 1024) + ROUND_SIZE - 1) / ROUND_SIZE * ROUND_SIZE)) | ||||||
|  | fi | ||||||
|  | 
 | ||||||
| truncate -s "${IMG_SIZE}" "${IMG_FILE}" | truncate -s "${IMG_SIZE}" "${IMG_FILE}" | ||||||
| fdisk -H 255 -S 63 "${IMG_FILE}" <<EOF | fdisk -H 255 -S 63 "${IMG_FILE}" <<EOF | ||||||
| o | o | ||||||
|  |  | ||||||
|  | @ -17,7 +17,7 @@ BOOT_SIZE="$(( BOOT_SIZE / 1000000 + 1))" | ||||||
| ROOT_SIZE="$(( ROOT_SIZE / 1000000 + 1))" | ROOT_SIZE="$(( ROOT_SIZE / 1000000 + 1))" | ||||||
| 
 | 
 | ||||||
| BOOT_NOM="$(( BOOT_SIZE * 3 ))" | BOOT_NOM="$(( BOOT_SIZE * 3 ))" | ||||||
| ROOT_NOM="$(( ROOT_SIZE + 400 ))" | ROOT_NOM="$(( ROOT_SIZE + 400))" | ||||||
| 
 | 
 | ||||||
| mv "${NOOBS_DIR}/OS.png" "${NOOBS_DIR}/${NOOBS_NAME// /_}.png" | mv "${NOOBS_DIR}/OS.png" "${NOOBS_DIR}/${NOOBS_NAME// /_}.png" | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -5,11 +5,9 @@ install -m 644 files/noclear.conf "${ROOTFS_DIR}/etc/systemd/system/getty@tty1.s | ||||||
| install -v -m 644 files/fstab "${ROOTFS_DIR}/etc/fstab" | install -v -m 644 files/fstab "${ROOTFS_DIR}/etc/fstab" | ||||||
| 
 | 
 | ||||||
| on_chroot << EOF | on_chroot << EOF | ||||||
| if ! id -u pi >/dev/null 2>&1; then | if ! id -u ${RPI_USERNAME} >/dev/null 2>&1; then | ||||||
| 	adduser --disabled-password --gecos "" pi | 	adduser --disabled-password --gecos "" ${RPI_USERNAME} | ||||||
| fi | fi | ||||||
| echo "pi:raspberry" | chpasswd | echo "${RPI_USERNAME}:${RPI_USERPASS}" | chpasswd | ||||||
| echo "root:root" | chpasswd | echo "root:${RPI_ROOTPASS}" | chpasswd | ||||||
| EOF | EOF | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -1,9 +0,0 @@ | ||||||
| Index: jessie-stage1/rootfs/etc/hosts
 |  | ||||||
| ===================================================================
 |  | ||||||
| --- jessie-stage1.orig/rootfs/etc/hosts
 |  | ||||||
| +++ jessie-stage1/rootfs/etc/hosts
 |  | ||||||
| @@ -3,3 +3,4 @@
 |  | ||||||
|  ff02::1		ip6-allnodes |  | ||||||
|  ff02::2		ip6-allrouters |  | ||||||
|   |  | ||||||
| +127.0.1.1	raspberrypi
 |  | ||||||
|  | @ -1 +0,0 @@ | ||||||
| 01-hosts.diff |  | ||||||
|  | @ -4,3 +4,6 @@ install -m 644 files/ipv6.conf "${ROOTFS_DIR}/etc/modprobe.d/ipv6.conf" | ||||||
| install -m 644 files/hostname "${ROOTFS_DIR}/etc/hostname" | install -m 644 files/hostname "${ROOTFS_DIR}/etc/hostname" | ||||||
| 
 | 
 | ||||||
| ln -sf /dev/null "${ROOTFS_DIR}/etc/systemd/network/99-default.link" | ln -sf /dev/null "${ROOTFS_DIR}/etc/systemd/network/99-default.link" | ||||||
|  | 
 | ||||||
|  | echo "${RPI_LOCALHOST}" > "${ROOTFS_DIR}/etc/hostname" | ||||||
|  | echo "127.0.1.1 ${RPI_LOCALHOST}" >> "${ROOTFS_DIR}/etc/hosts" | ||||||
|  |  | ||||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							|  | @ -15,29 +15,44 @@ on_chroot << EOF | ||||||
| systemctl disable hwclock.sh | systemctl disable hwclock.sh | ||||||
| systemctl disable nfs-common | systemctl disable nfs-common | ||||||
| systemctl disable rpcbind | systemctl disable rpcbind | ||||||
| systemctl disable ssh |  | ||||||
| systemctl enable regenerate_ssh_host_keys | systemctl enable regenerate_ssh_host_keys | ||||||
| EOF | EOF | ||||||
| 
 | 
 | ||||||
| if [ "${USE_QEMU}" = "1" ]; then | if [ "${USE_QEMU}" = "1" ]; then | ||||||
| 	echo "enter QEMU mode" | 	log "enter QEMU mode" | ||||||
| 	install -m 644 files/90-qemu.rules "${ROOTFS_DIR}/etc/udev/rules.d/" | 	install -m 644 files/90-qemu.rules "${ROOTFS_DIR}/etc/udev/rules.d/" | ||||||
| 	on_chroot << EOF | 	on_chroot << EOF | ||||||
| systemctl disable resize2fs_once | systemctl disable resize2fs_once | ||||||
| EOF | EOF | ||||||
| 	echo "leaving QEMU mode" | 	log "leaving QEMU mode" | ||||||
| else | else | ||||||
| 	on_chroot << EOF | 	on_chroot << EOF | ||||||
| systemctl enable resize2fs_once | systemctl enable resize2fs_once | ||||||
| EOF | EOF | ||||||
| fi | fi | ||||||
| 
 | 
 | ||||||
|  | if [ "${USE_SSH}" = "1" ]; then | ||||||
|  | 	on_chroot << EOF | ||||||
|  | systemctl enable ssh | ||||||
|  | EOF | ||||||
|  | 
 | ||||||
|  | 	if [[ -e files/authorized_keys ]]; then | ||||||
|  | 		log "Copy authorized_keys in root ssh directory" | ||||||
|  | 		install -d                            "${ROOTFS_DIR}/root/.ssh" | ||||||
|  | 		install -m 644 files/authorized_keys 	"${ROOTFS_DIR}/root/.ssh/" | ||||||
|  | 	fi | ||||||
|  | else | ||||||
|  | 	on_chroot << EOF | ||||||
|  | systemctl disable ssh | ||||||
|  | EOF | ||||||
|  | fi | ||||||
|  | 
 | ||||||
| on_chroot << \EOF | on_chroot << \EOF | ||||||
| for GRP in input spi i2c gpio; do | for GRP in input spi i2c gpio; do | ||||||
| 	groupadd -f -r "$GRP" | 	groupadd -f -r "$GRP" | ||||||
| done | done | ||||||
| for GRP in adm dialout cdrom audio users sudo video games plugdev input gpio spi i2c netdev; do | for GRP in adm dialout cdrom audio users sudo video games plugdev input gpio spi i2c netdev; do | ||||||
|   adduser pi $GRP |   adduser ${RPI_USERNAME} $GRP | ||||||
| done | done | ||||||
| EOF | EOF | ||||||
| 
 | 
 | ||||||
|  | @ -45,8 +60,4 @@ on_chroot << EOF | ||||||
| setupcon --force --save-only -v | setupcon --force --save-only -v | ||||||
| EOF | EOF | ||||||
| 
 | 
 | ||||||
| on_chroot << EOF |  | ||||||
| usermod --pass='*' root |  | ||||||
| EOF |  | ||||||
| 
 |  | ||||||
| rm -f "${ROOTFS_DIR}/etc/ssh/"ssh_host_*_key* | rm -f "${ROOTFS_DIR}/etc/ssh/"ssh_host_*_key* | ||||||
|  |  | ||||||
|  | @ -13,13 +13,14 @@ fi | ||||||
| 
 | 
 | ||||||
| ln -sf pip3 "${ROOTFS_DIR}/usr/bin/pip-3.2" | ln -sf pip3 "${ROOTFS_DIR}/usr/bin/pip-3.2" | ||||||
| 
 | 
 | ||||||
| install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/pi/python_games" | install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/${RPI_USERNAME}/python_games" | ||||||
| tar xvf files/python_games.tar.gz -C "${ROOTFS_DIR}/home/pi/python_games" --strip-components=1 | tar xvf files/python_games.tar.gz -C "${ROOTFS_DIR}/home/${RPI_USERNAME}/python_games" --strip-components=1 | ||||||
| chown 1000:1000 "${ROOTFS_DIR}/home/pi/python_games" -Rv | chown 1000:1000 "${ROOTFS_DIR}/home/${RPI_USERNAME}/python_games" -Rv | ||||||
| chmod +x "${ROOTFS_DIR}/home/pi/python_games/launcher.sh" | chmod +x "${ROOTFS_DIR}/home/${RPI_USERNAME}/python_games/launcher.sh" | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| #Alacarte fixes | #Alacarte fixes | ||||||
| install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/pi/.local" | install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/${RPI_USERNAME}/.local" | ||||||
| install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/pi/.local/share" | install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/${RPI_USERNAME}/.local/share" | ||||||
| install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/pi/.local/share/applications" | install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/${RPI_USERNAME}/.local/share/applications" | ||||||
| install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/pi/.local/share/desktop-directories" | install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/${RPI_USERNAME}/.local/share/desktop-directories" | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user