From: Paul Hänsch Date: Wed, 17 Jul 2019 16:13:15 +0000 (+0200) Subject: makefile indentation for readability, working shutdown in xfce, hostname setting X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=35a1269915906c26c6eb81f77db2ddc7b89f17c0;p=blast makefile indentation for readability, working shutdown in xfce, hostname setting --- diff --git a/Makefile b/Makefile index 03fd52b..41a9993 100644 --- a/Makefile +++ b/Makefile @@ -23,113 +23,112 @@ endef PACKAGES := ${PACKAGES} apt busybox-static debian-archive-keyring init systemd +include config.mk config.mk: cp "config.example" "$@" -include config.mk - ifdef disk -VOLUME := ${disk} -PBOOT := ${disk}1 -PROOT := ${disk}2 -SYSROOT := hdd_mount/ -CFGROOT := hdd_mount/ - -_target: _mbr _umount _config _install _partition - -_partition: -_format: _partition -_mount: _format -_bootstrap: _mount -_install: _bootstrap _mount -_config: _install _mount -_bootloader: _mount -_umount: _mount _config _bootloader -_mbr: _umount _bootloader + VOLUME := ${disk} + PBOOT := ${disk}1 + PROOT := ${disk}2 + SYSROOT := hdd_mount/ + CFGROOT := hdd_mount/ + + _target: _mbr _umount _config _install _partition + + _partition: + _format: _partition + _mount: _format + _bootstrap: _mount + _install: _bootstrap _mount + _config: _install _mount + _bootloader: _mount + _umount: _mount _config _bootloader + _mbr: _umount _bootloader else ifdef image -VOLUME := ${image} -PBOOT := part_boot.img -PROOT := part_root.img -SYSROOT := sys_root/ -CFGROOT := img_mount/ - -_target: _mbr _umount _partcopy _config _install - -_bootstrap: -_install: _bootstrap -_sparse: -_format: _sparse -_mount: _format -_copy: _install _mount -_config: _copy _mount -_bootloader: _mount -_umount: _mount _config _bootloader -_partition: -_partcopy: _partition _umount -_mbr: _partcopy _bootloader + VOLUME := ${image} + PBOOT := part_boot.img + PROOT := part_root.img + SYSROOT := sys_root/ + CFGROOT := img_mount/ + + _target: _mbr _umount _partcopy _config _install + + _bootstrap: + _install: _bootstrap + _sparse: + _format: _sparse + _mount: _format + _copy: _install _mount + _config: _copy _mount + _bootloader: _mount + _umount: _mount _config _bootloader + _partition: + _partcopy: _partition _umount + _mbr: _partcopy _bootloader else ifdef squash -SQUASH := ${squash} -SYSROOT := sys_root/ -CFGROOT := cfg_root/ - -_target: _squash _install _config - -_bootstrap: -_install: _bootstrap -_copy: _install -_config: _copy -_squash: _config + SQUASH := ${squash} + SYSROOT := sys_root/ + CFGROOT := cfg_root/ + + _target: _squash _install _config + + _bootstrap: + _install: _bootstrap + _copy: _install + _config: _copy + _squash: _config else ifdef raspi -VOLUME := ${raspi} -PBOOT := rpi_boot.img -PROOT := rpi_root.img -SYSROOT := rpi_root/ -CFGROOT := img_mount/ - -ARCH := armhf -KEYRING := keys/raspbian-archive-keyring.gpg -BOOTSTRAP := http://raspbian.raspberrypi.org/raspbian - -define SOURCES = -deb http://raspbian.raspberrypi.org/raspbian stretch main non-free firmware rpi -deb http://archive.raspberrypi.org/debian stretch main -endef + VOLUME := ${raspi} + PBOOT := rpi_boot.img + PROOT := rpi_root.img + SYSROOT := rpi_root/ + CFGROOT := img_mount/ + + ARCH := armhf + KEYRING := keys/raspbian-archive-keyring.gpg + BOOTSTRAP := http://raspbian.raspberrypi.org/raspbian + + define SOURCES = + deb http://raspbian.raspberrypi.org/raspbian stretch main non-free firmware rpi + deb http://archive.raspberrypi.org/debian stretch main + endef PACKAGES := ${PACKAGES} firmware-brcm80211 libraspberrypi-bin libraspberrypi0 pi-bluetooth raspberrypi-bootloader raspberrypi-kernel -_target: _umount _partcopy _config _install - -_qemu: -_bootstrap: _qemu -_install: _bootstrap -_sparse: -_format: _sparse -_mount: _format -_copy: _install _mount -_config_raspi: _copy _mount -_config: _copy _mount _config_raspi -_umount: _mount _config -_partition_raspi: -_partcopy: _partition_raspi _umount + _target: _umount _partcopy _config _install + + _qemu: + _bootstrap: _qemu + _install: _bootstrap + _sparse: + _format: _sparse + _mount: _format + _copy: _install _mount + _config_raspi: _copy _mount + _config: _copy _mount _config_raspi + _umount: _mount _config + _partition_raspi: + _partcopy: _partition_raspi _umount else -_target: + _target: false endif include modules/default.mk ifdef modules -include $(addsuffix .mk, $(addprefix modules/, $(subst ${comma_},${space_},${modules}))) + include $(addsuffix .mk, $(addprefix modules/, $(subst ${comma_},${space_},${modules}))) endif ifeq "${ARCH}" "amd64" -PACKAGES := ${PACKAGES} linux-image-amd64 + PACKAGES += linux-image-amd64 else ifeq "${ARCH}" "i386" -PACKAGES := ${PACKAGES} linux-image-686 + PACKAGES += linux-image-686 endif export SOURCES SYSROOT CFGROOT VOLUME PBOOT PROOT SQUASH ARCH KEYRING BOOTSTRAP diff --git a/config.example b/config.example index 33c962e..d7c6688 100644 --- a/config.example +++ b/config.example @@ -12,6 +12,9 @@ ## Comma separated list of config modules from modules/ directory # modules=nodm,xfce +## Hostname for the generated machine +# hostname=blast + ## Root password will be salted and encrypted in image # rootpass=topsecret diff --git a/modules/default.mk b/modules/default.mk index fdeff30..47f958b 100644 --- a/modules/default.mk +++ b/modules/default.mk @@ -1,11 +1,11 @@ ifdef imagesize -ROOT_MB := $(shell printf '%i\n' "$$(( ${imagesize} - ${BOOT_MB} - 3 ))") + ROOT_MB := $(shell printf '%i\n' "$$(( ${imagesize} - ${BOOT_MB} - 3 ))") endif -PACKAGES := ${PACKAGES} btrfs-tools bzip2 ca-certificates cron deborphan firmware-linux-free gzip htop ifupdown iputils-ping irqbalance isc-dhcp-client less make net-tools nmap ntpdate openssh-client psmisc rsync sshfs sudo traceroute unzip vim wget wireless-tools wpasupplicant xz-utils zip +PACKAGES += btrfs-tools bzip2 ca-certificates cron deborphan firmware-linux-free gzip htop ifupdown iputils-ping irqbalance isc-dhcp-client less make net-tools nmap ntpdate openssh-client psmisc rsync sshfs sudo traceroute unzip vim wget wireless-tools wpasupplicant xz-utils zip ifdef packages -PACKAGES := ${PACKAGES} $(subst ${comma_},${space_},${packages}) + PACKAGES += $(subst ${comma_},${space_},${packages}) endif export DEBCONF @@ -23,14 +23,14 @@ _debconf_selections: ${SYSROOT} .PHONY: _timezone _locales ifdef timezone -export timezone -PACKAGES := ${PACKAGES} tzdata -_config: _timezone + export timezone + PACKAGES += tzdata + _config: _timezone endif ifdef locales -PACKAGES := ${PACKAGES} locales -_config: _locales + PACKAGES += locales + _config: _locales endif _timezone: ${CFGROOT} @@ -44,15 +44,20 @@ _locales: ${CFGROOT} printf 'LANG=%s\n' "$(firstword $(subst ${comma_},${space_},${locales}))" >"$${CFGROOT}/etc/default/locale" chroot "$${CFGROOT}" locale-gen -.PHONY: _rootpass _users +.PHONY: _rootpass _users _hostname ifdef rootpass -export rootpass -_config: _rootpass + export rootpass + _config: _rootpass endif ifdef users -_config: _users + _config: _users +endif + +ifdef hostname + export hostname + _config: _hostname endif _rootpass: ${CFGROOT} @@ -63,17 +68,20 @@ _users: ${CFGROOT} chroot "$${CFGROOT}" useradd -m -s /bin/bash -p "$$(openssl passwd "")" "$$u"; \ done +_hostname: ${CFGROOT} + printf '%s\n' "$${hostname}" "$${CFGROOT}/etc/hostname" + ifdef wifi -ifdef wifipass -export wifi wifipass -${CFGROOT}/etc/network/interfaces.d/wifi: ${CFGROOT} + _config: ${CFGROOT}/etc/network/interfaces.d/wifi + ifdef wifipass + export wifi wifipass + ${CFGROOT}/etc/network/interfaces.d/wifi: ${CFGROOT} printf 'auto wlan0\nallow-hotplug wlan0\n\niface wlan0 inet dhcp\n' >$@ printf ' wpa-ssid "%s"\n wpa-psk "%s"\n' "$$wifi" "$$wifipass" >>$@ -else -export wifi -${CFGROOT}/etc/network/interfaces.d/wifi: ${CFGROOT} + else + export wifi + ${CFGROOT}/etc/network/interfaces.d/wifi: ${CFGROOT} printf 'auto wlan0\nallow-hotplug wlan0\n\niface wlan0 inet dhcp\n' >$@ printf ' wireless-ssid "%s"\n' "$$wifi" >>$@ -endif -_config: ${CFGROOT}/etc/network/interfaces.d/wifi + endif endif diff --git a/modules/xfce.mk b/modules/xfce.mk index f16581a..ffa2452 100644 --- a/modules/xfce.mk +++ b/modules/xfce.mk @@ -1,4 +1,4 @@ -PACKAGES := ${PACKAGES} xfce4 xauth x11-xserver-utils x2x xvkbd blueman xfce4-terminal xfce4-clipman-plugin xfce4-whiskermenu-plugin thunar gvfs gvfs-backends gvfs-fuse xscreensaver +PACKAGES := ${PACKAGES} xfce4 xauth x11-xserver-utils x2x xvkbd blueman xfce4-terminal xfce4-clipman-plugin xfce4-whiskermenu-plugin thunar gvfs gvfs-backends gvfs-fuse xscreensaver policykit-1 .PHONY: _xfce _config: _xfce