Compare commits

..

1 Commits

Author SHA1 Message Date
Michael Aldridge
c97a67c04f packer: Add AWS AMI
This commit adds a packer configuration to build an AWS AMI.  The AMI
works in that it is a bootable void image that if it could be imported
to AWS it would be bootable and would work.  Unfortunately, AWS is
doing really naive string parsing on files in /boot rather than
checking that the contents are actually what they claim to be so the
import task fails.

NOTICE: AWS is the only cloud that this has been observed happening
on.  We can run as a vendor supported distro in GCP and in Azure
clouds, and so if you need Void on an enterprise cloud those are the
providers to look at.  If you're interested in a hobbyist cloud, Void
runs critical infrastructure in DigitalOcean and it is a fully
supported environment.

We could probably masquerade the kernel as something that would pass
the string parsing, because it appears that this parsing layer exists
only in the vm import service and not actually in any of the
functional parts of EC2, but that would require using a different
mechanism to install Void, and the ROI on supporting a single cloud in
this way just isn't there.  This import mechanism also appears to only
work on amd64 architectures, so it can't even support the newer
graviton instance types.
2020-08-30 15:48:44 -07:00
64 changed files with 1401 additions and 2751 deletions

4
.dockerignore Normal file
View File

@ -0,0 +1,4 @@
xbps-cachedir-*/
*.iso
*.img*
*.tar*

1
.gitattributes vendored
View File

@ -1 +0,0 @@
/README.md linguist-generated=true

View File

@ -1,368 +0,0 @@
name: Build void images
on:
workflow_dispatch:
inputs:
datecode:
description: "Override datecode for images"
required: false
type: string
live_iso_flag:
description: "Build live ISOs"
default: true
required: true
type: boolean
live_archs:
description: "Archs to build live ISOs for"
default: "x86_64 x86_64-musl i686 aarch64 aarch64-musl"
required: false
type: string
live_flavors:
description: "Flavors to build live ISOs for"
default: "base xfce"
required: false
type: string
rootfs_flag:
description: "Build ROOTFSes"
default: true
required: true
type: boolean
rootfs:
description: "Archs to build ROOTFSes for"
default: "x86_64 x86_64-musl i686 armv6l armv6l-musl armv7l armv7l-musl aarch64 aarch64-musl"
required: false
type: string
platformfs_flag:
description: "Build PLATFORMFSes"
default: true
required: true
type: boolean
platformfs:
description: "Platforms to build PLATFORMFSes for"
default: "rpi-armv6l rpi-armv6l-musl rpi-armv7l rpi-armv7l-musl rpi-aarch64 rpi-aarch64-musl"
required: false
type: string
sbc_img_flag:
description: "Build SBC Images"
default: true
required: true
type: boolean
sbc_imgs:
description: "Platforms to build SBC images for"
default: "rpi-armv6l rpi-armv6l-musl rpi-armv7l rpi-armv7l-musl rpi-aarch64 rpi-aarch64-musl"
required: false
type: string
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
prepare:
name: Prepare Environment
runs-on: ubuntu-latest
outputs:
datecode: ${{ steps.prep.outputs.datecode }}
revision: ${{ steps.prep.outputs.revision }}
mirror: ${{ steps.prep.outputs.mirror }}
live_archs: ${{ steps.prep.outputs.live_archs }}
live_flavors: ${{ steps.prep.outputs.live_flavors }}
rootfs: ${{ steps.prep.outputs.rootfs }}
platformfs: ${{ steps.prep.outputs.platformfs }}
sbc_imgs: ${{ steps.prep.outputs.sbc_imgs }}
steps:
- name: Prepare Environment
id: prep
run: |
if [ -z "${{ inputs.datecode }}" ]; then
echo "datecode=$(date -u "+%Y%m%d")" >> $GITHUB_OUTPUT
else
echo "datecode=${{ inputs.datecode }}" >> $GITHUB_OUTPUT
fi
echo "revision=${GITHUB_SHA:0:8}" >> $GITHUB_OUTPUT
echo "mirror=https://repo-ci.voidlinux.org/current" >> $GITHUB_OUTPUT
jsonify() {
sed 's/\s\+/ /g' | jq -Rrc 'split(" ")'
}
echo "live_archs=$(echo "${{ inputs.live_archs }}" | jsonify)" >> $GITHUB_OUTPUT
echo "live_flavors=$(echo "${{ inputs.live_flavors }}" | jsonify)" >> $GITHUB_OUTPUT
echo "rootfs=$(echo "${{ inputs.rootfs }}" | jsonify)" >> $GITHUB_OUTPUT
echo "platformfs=$(echo "${{ inputs.platformfs }}" | jsonify)" >> $GITHUB_OUTPUT
echo "sbc_imgs=$(echo "${{ inputs.sbc_imgs }}" | jsonify)" >> $GITHUB_OUTPUT
build-live-isos:
name: Build Live ISOs
runs-on: ubuntu-latest
needs: prepare
if: ${{ inputs.live_iso_flag }}
strategy:
matrix:
arch: ${{ fromJson(needs.prepare.outputs.live_archs) }}
flavor: ${{ fromJson(needs.prepare.outputs.live_flavors) }}
container:
image: 'ghcr.io/void-linux/void-glibc-full:20231230R1'
options: --privileged
volumes:
- /dev:/dev
env:
PATH: '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/usr/local/bin:/tmp/bin'
MKLIVE_REV: "${{ needs.prepare.outputs.revision }}"
steps:
- name: Prepare container
shell: sh
run: |
# Switch to mirror
mkdir -p /etc/xbps.d && cp /usr/share/xbps.d/*-repository-*.conf /etc/xbps.d/
sed -i 's|https://repo-default.voidlinux.org/current|'"${{ needs.prepare.outputs.mirror }}"'|g' \
/etc/xbps.d/*-repository-*.conf
xbps-install -Syu xbps && xbps-install -yu
xbps-install -yu bash make git kmod xz lzo qemu-user-aarch64 binfmt-support outils dosfstools e2fsprogs
- name: Clone and checkout
uses: classabbyamp/treeless-checkout-action@v1
- name: Build live ISOs
run: |
make live-iso-all-print live-iso-all \
SUDO= REPOSITORY="${{ needs.prepare.outputs.mirror }}" \
DATECODE="${{ needs.prepare.outputs.datecode }}" \
LIVE_ARCHS="${{ matrix.arch }}" LIVE_FLAVORS="${{ matrix.flavor }}"
- name: Prepare artifacts for upload
run: |
make dist DATECODE="${{ needs.prepare.outputs.datecode }}"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: void-iso-${{ matrix.arch }}-${{ matrix.flavor }}-${{ needs.prepare.outputs.datecode }}
path: |
distdir-${{ needs.prepare.outputs.datecode }}/*
if-no-files-found: error
build-rootfs:
name: Build ROOTFSes
runs-on: ubuntu-latest
needs: prepare
if: ${{ inputs.rootfs_flag }}
strategy:
matrix:
arch: ${{ fromJson(needs.prepare.outputs.rootfs) }}
container:
image: 'ghcr.io/void-linux/void-glibc-full:20231230R1'
options: --privileged
volumes:
- /dev:/dev
env:
PATH: '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/usr/local/bin:/tmp/bin'
MKLIVE_REV: "${{ needs.prepare.outputs.revision }}"
steps:
- name: Prepare container
shell: sh
run: |
# Switch to mirror
mkdir -p /etc/xbps.d && cp /usr/share/xbps.d/*-repository-*.conf /etc/xbps.d/
sed -i 's|https://repo-default.voidlinux.org/current|'"${{ needs.prepare.outputs.mirror }}"'|g' \
/etc/xbps.d/*-repository-*.conf
xbps-install -Syu xbps && xbps-install -yu
xbps-install -yu bash make git kmod xz lzo qemu-user-arm qemu-user-aarch64 binfmt-support outils dosfstools e2fsprogs
- name: Clone and checkout
uses: classabbyamp/treeless-checkout-action@v1
- name: Build ROOTFSes
run: |
make rootfs-all-print rootfs-all \
SUDO= REPOSITORY="${{ needs.prepare.outputs.mirror }}" \
DATECODE="${{ needs.prepare.outputs.datecode }}" \
ARCHS="${{ matrix.arch }}"
- name: Prepare artifacts for upload
run: |
make dist DATECODE="${{ needs.prepare.outputs.datecode }}"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: void-rootfs-${{ matrix.arch }}-${{ needs.prepare.outputs.datecode }}
path: |
distdir-${{ needs.prepare.outputs.datecode }}/*
if-no-files-found: error
build-platformfs:
name: Build PLATFORMFSes
runs-on: ubuntu-latest
needs: prepare
if: ${{ inputs.platformfs_flag }}
strategy:
matrix:
platform: ${{ fromJson(needs.prepare.outputs.platformfs) }}
container:
image: 'ghcr.io/void-linux/void-glibc-full:20231230R1'
options: --privileged
volumes:
- /dev:/dev
env:
PATH: '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/usr/local/bin:/tmp/bin'
MKLIVE_REV: "${{ needs.prepare.outputs.revision }}"
steps:
- name: Prepare container
shell: sh
run: |
# Switch to mirror
mkdir -p /etc/xbps.d && cp /usr/share/xbps.d/*-repository-*.conf /etc/xbps.d/
sed -i 's|https://repo-default.voidlinux.org/current|'"${{ needs.prepare.outputs.mirror }}"'|g' \
/etc/xbps.d/*-repository-*.conf
xbps-install -Syu xbps && xbps-install -yu
xbps-install -yu bash make git kmod xz lzo qemu-user-arm qemu-user-aarch64 binfmt-support outils dosfstools e2fsprogs
- name: Clone and checkout
uses: classabbyamp/treeless-checkout-action@v1
- name: Build PLATFORMFSes
run: |
make platformfs-all-print platformfs-all \
SUDO= REPOSITORY="${{ needs.prepare.outputs.mirror }}" \
DATECODE="${{ needs.prepare.outputs.datecode }}" \
PLATFORMS="${{ matrix.platform }}"
- name: Prepare artifacts for upload
run: |
make dist DATECODE="${{ needs.prepare.outputs.datecode }}"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: void-platformfs-${{ matrix.platform }}-${{ needs.prepare.outputs.datecode }}
path: |
distdir-${{ needs.prepare.outputs.datecode }}/*
!distdir-${{ needs.prepare.outputs.datecode }}/*ROOTFS*
if-no-files-found: error
build-sbc-img:
name: Build SBC Images
runs-on: ubuntu-latest
needs: prepare
if: ${{ inputs.sbc_img_flag }}
strategy:
matrix:
platform: ${{ fromJson(needs.prepare.outputs.sbc_imgs) }}
container:
image: 'ghcr.io/void-linux/void-glibc-full:20231230R1'
options: --privileged
volumes:
- /dev:/dev
env:
PATH: '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/usr/local/bin:/tmp/bin'
MKLIVE_REV: "${{ needs.prepare.outputs.revision }}"
steps:
- name: Prepare container
shell: sh
run: |
# Switch to mirror
mkdir -p /etc/xbps.d && cp /usr/share/xbps.d/*-repository-*.conf /etc/xbps.d/
sed -i 's|https://repo-default.voidlinux.org/current|'"${{ needs.prepare.outputs.mirror }}"'|g' \
/etc/xbps.d/*-repository-*.conf
xbps-install -Syu xbps && xbps-install -yu
xbps-install -yu bash make git kmod xz lzo qemu-user-arm qemu-user-aarch64 binfmt-support outils dosfstools e2fsprogs
- name: Clone and checkout
uses: classabbyamp/treeless-checkout-action@v1
- name: Build SBC Images
run: |
make images-all-sbc-print images-all-sbc \
SUDO= REPOSITORY="${{ needs.prepare.outputs.mirror }}" \
DATECODE="${{ needs.prepare.outputs.datecode }}" \
SBC_IMGS="${{ matrix.platform }}"
- name: Prepare artifacts for upload
run: |
make dist DATECODE="${{ needs.prepare.outputs.datecode }}"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: void-sbc-img-${{ matrix.platform }}-${{ needs.prepare.outputs.datecode }}
path: |
distdir-${{ needs.prepare.outputs.datecode }}/*
!distdir-${{ needs.prepare.outputs.datecode }}/*ROOTFS*
!distdir-${{ needs.prepare.outputs.datecode }}/*PLATFORMFS*
if-no-files-found: error
merge-artifacts:
name: Combine artifacts
runs-on: ubuntu-latest
if: ${{ always() }}
needs:
- prepare
- build-live-isos
- build-rootfs
- build-platformfs
- build-sbc-img
container:
image: 'ghcr.io/void-linux/void-glibc-full:20231230R1'
env:
PATH: '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/usr/local/bin:/tmp/bin'
MKLIVE_REV: "${{ needs.prepare.outputs.revision }}"
steps:
- name: Prepare container
shell: sh
run: |
# Switch to mirror
mkdir -p /etc/xbps.d && cp /usr/share/xbps.d/*-repository-*.conf /etc/xbps.d/
sed -i 's|https://repo-default.voidlinux.org/current|'"${{ needs.prepare.outputs.mirror }}"'|g' \
/etc/xbps.d/*-repository-*.conf
# Sync and upgrade once, assume error comes from xbps update
xbps-install -Syu || xbps-install -yu xbps
# Upgrade again (in case there was a xbps update)
xbps-install -yu
# Install depedencies
xbps-install -yu bash make git outils
- name: Clone and checkout
uses: classabbyamp/treeless-checkout-action@v1
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: distdir-${{ needs.prepare.outputs.datecode }}
merge-multiple: true
- name: Prepare artifacts for upload
run: |
make checksum DATECODE="${{ needs.prepare.outputs.datecode }}"
- name: Upload artifacts
id: upload
uses: actions/upload-artifact@v4
with:
name: void-live-${{ needs.prepare.outputs.datecode }}
path: |
distdir-${{ needs.prepare.outputs.datecode }}/*
if-no-files-found: error
- name: Generate summary
run: |
cat << EOF >> "$GITHUB_STEP_SUMMARY"
## Images generated successfully!
### Download
Download the result of this run with \`./release.sh dl ${{ github.run_id }} -- -R ${{ github.repository }}\` or use [this url](${{ steps.upload.outputs.artifact-url }}).
### Checksums
\`\`\`
$(cat distdir-${{ needs.prepare.outputs.datecode }}/sha256sum.txt)
\`\`\`
EOF

7
.gitignore vendored
View File

@ -1,3 +1,4 @@
*.sh
*.img *.img
*.xz *.xz
*.iso *.iso
@ -9,9 +10,3 @@ xbps-cachedir*
stamps* stamps*
!dracut/*/*.sh !dracut/*/*.sh
!packer/scripts/*.sh !packer/scripts/*.sh
void-live-*/
distdir-*/
release/
packer/cloud-*/
packer/vagrant-*/
mklive-build*/

36
Dockerfile Normal file
View File

@ -0,0 +1,36 @@
# 1) use alpine to generate a void environment
FROM alpine:3.12 as stage0
ARG REPOSITORY=https://alpha.de.repo.voidlinux.org
ARG ARCH=x86_64
COPY keys/* /target/var/db/xbps/keys/
RUN apk add ca-certificates curl && \
curl ${REPOSITORY}/static/xbps-static-latest.$(uname -m)-musl.tar.xz | \
tar Jx && \
XBPS_ARCH=${ARCH} xbps-install.static -yMU \
--repository=${REPOSITORY}/current \
--repository=${REPOSITORY}/current/musl \
-r /target \
base-minimal
# 2) using void to generate the final build
FROM scratch as stage1
ARG REPOSITORY=https://alpha.de.repo.voidlinux.org
ARG ARCH=x86_64
ARG BASEPKG=base-minimal
COPY --from=stage0 /target /
COPY keys/* /target/var/db/xbps/keys/
RUN xbps-reconfigure -a && \
mkdir -p /target/var/cache && ln -s /var/cache/xbps /target/var/cache/xbps && \
XBPS_ARCH=${ARCH} xbps-install -yMU \
--repository=${REPOSITORY}/current \
--repository=${REPOSITORY}/current/musl \
-r /target \
${BASEPKG}
# 3) configure and clean up the final image
FROM scratch
COPY --from=stage1 /target /
RUN xbps-reconfigure -a && \
rm -r /var/cache/xbps
CMD ["/bin/sh"]

101
Makefile
View File

@ -1,53 +1,47 @@
DATECODE:=$(shell date -u "+%Y%m%d") GITVER := $(shell git rev-parse --short HEAD)
VERSION = 0.22
SHIN += $(shell find -type f -name '*.sh.in')
SCRIPTS += $(SHIN:.sh.in=.sh)
DATECODE=$(shell date "+%Y%m%d")
SHELL=/bin/bash SHELL=/bin/bash
T_LIVE_ARCHS=i686 x86_64{,-musl} aarch64{,-musl} T_PLATFORMS=rpi{,2,3}{,-musl} beaglebone{,-musl} cubieboard2{,-musl} odroid-c2{,-musl} usbarmory{,-musl} GCP{,-musl}
T_PLATFORMS=rpi-{armv{6,7}l,aarch64}{,-musl} GCP{,-musl} pinebookpro{,-musl}
T_ARCHS=i686 x86_64{,-musl} armv{6,7}l{,-musl} aarch64{,-musl} T_ARCHS=i686 x86_64{,-musl} armv{6,7}l{,-musl} aarch64{,-musl}
T_SBC_IMGS=rpi-{armv{6,7}l,aarch64}{,-musl} pinebookpro{,-musl} T_SBC_IMGS=rpi{,2,3}{,-musl} beaglebone{,-musl} cubieboard2{,-musl} odroid-c2{,-musl} usbarmory{,-musl}
T_CLOUD_IMGS=GCP{,-musl} T_CLOUD_IMGS=GCP{,-musl}
T_PXE_ARCHS=x86_64{,-musl} T_PXE_ARCHS=x86_64{,-musl}
LIVE_ARCHS:=$(shell echo $(T_LIVE_ARCHS)) T_MASTERDIRS=x86_64{,-musl} i686
LIVE_FLAVORS:=base enlightenment xfce mate cinnamon gnome kde lxde lxqt
LIVE_PLATFORMS:=pinebookpro x13s ARCHS=$(shell echo $(T_ARCHS))
ARCHS:=$(shell echo $(T_ARCHS)) PLATFORMS=$(shell echo $(T_PLATFORMS))
PLATFORMS:=$(shell echo $(T_PLATFORMS)) SBC_IMGS=$(shell echo $(T_SBC_IMGS))
SBC_IMGS:=$(shell echo $(T_SBC_IMGS)) CLOUD_IMGS=$(shell echo $(T_CLOUD_IMGS))
CLOUD_IMGS:=$(shell echo $(T_CLOUD_IMGS)) PXE_ARCHS=$(shell echo $(T_PXE_ARCHS))
PXE_ARCHS:=$(shell echo $(T_PXE_ARCHS)) MASTERDIRS=$(shell echo $(T_MASTERDIRS))
ALL_LIVE_ISO=$(foreach arch,$(LIVE_ARCHS), $(foreach flavor,$(LIVE_FLAVORS),void-live-$(arch)-$(DATECODE)-$(flavor).iso))
ALL_ROOTFS=$(foreach arch,$(ARCHS),void-$(arch)-ROOTFS-$(DATECODE).tar.xz) ALL_ROOTFS=$(foreach arch,$(ARCHS),void-$(arch)-ROOTFS-$(DATECODE).tar.xz)
ALL_PLATFORMFS=$(foreach platform,$(PLATFORMS),void-$(platform)-PLATFORMFS-$(DATECODE).tar.xz) ALL_PLATFORMFS=$(foreach platform,$(PLATFORMS),void-$(platform)-PLATFORMFS-$(DATECODE).tar.xz)
ALL_SBC_IMAGES=$(foreach platform,$(SBC_IMGS),void-$(platform)-$(DATECODE).img.xz) ALL_SBC_IMAGES=$(foreach platform,$(SBC_IMGS),void-$(platform)-$(DATECODE).img.xz)
ALL_CLOUD_IMAGES=$(foreach cloud,$(CLOUD_IMGS),void-$(cloud)-$(DATECODE).tar.gz) ALL_CLOUD_IMAGES=$(foreach cloud,$(CLOUD_IMGS),void-$(cloud)-$(DATECODE).tar.gz)
ALL_PXE_ARCHS=$(foreach arch,$(PXE_ARCHS),void-$(arch)-NETBOOT-$(DATECODE).tar.gz) ALL_PXE_ARCHS=$(foreach arch,$(PXE_ARCHS),void-$(arch)-NETBOOT-$(DATECODE).tar.gz)
ALL_MASTERDIRS=$(foreach arch,$(MASTERDIRS), masterdir-$(arch))
SUDO := sudo SUDO := sudo
REPOSITORY := https://repo-default.voidlinux.org/current XBPS_REPOSITORY := -r https://alpha.de.repo.voidlinux.org/current -r https://alpha.de.repo.voidlinux.org/current/musl -r https://alpha.de.repo.voidlinux.org/current/aarch64
XBPS_REPOSITORY := -r $(REPOSITORY) -r $(REPOSITORY)/musl -r $(REPOSITORY)/aarch64 COMPRESSOR_THREADS=2
COMPRESSOR_THREADS:=$(shell nproc)
all: %.sh: %.sh.in
sed -e "s|@@MKLIVE_VERSION@@|$(VERSION) $(GITVER)|g" $^ > $@
chmod +x $@
README.md: README.md.in mkiso.sh mklive.sh mkrootfs.sh mkplatformfs.sh mkimage.sh mknet.sh all: $(SCRIPTS)
printf '<!-- DO NOT EDIT, generated by make README.md -->\n\n' > README.md
cat README.md.in >> README.md
for script in mkiso mklive mkrootfs mkplatformfs mkimage mknet; do \
printf '### %s.sh\n\n```\n' "$${script}" >> README.md ; \
"./$${script}.sh" -h 2>/dev/null >> README.md ; \
printf '```\n\n' >> README.md ; \
done
mkiso.sh: mklive.sh clean:
-rm -f *.sh
checksum: distdir-$(DATECODE)
cd distdir-$(DATECODE)/ && sha256 * > sha256sum.txt
distdir-$(DATECODE): distdir-$(DATECODE):
mkdir -p distdir-$(DATECODE) mkdir -p distdir-$(DATECODE)
@ -55,36 +49,21 @@ distdir-$(DATECODE):
dist: distdir-$(DATECODE) dist: distdir-$(DATECODE)
mv void*$(DATECODE)* distdir-$(DATECODE)/ mv void*$(DATECODE)* distdir-$(DATECODE)/
live-iso-all: $(ALL_LIVE_ISO)
live-iso-all-print:
@echo $(ALL_LIVE_ISO) | sed "s: :\n:g"
void-live-%.iso: mkiso.sh
@[ -n "${CI}" ] && printf "::group::\x1b[32mBuilding $@...\x1b[0m\n" || true
$(SUDO) ./mkiso.sh -r $(REPOSITORY) -t $* -- -P "$(LIVE_PLATFORMS)"
@[ -n "${CI}" ] && printf '::endgroup::\n' || true
rootfs-all: $(ALL_ROOTFS) rootfs-all: $(ALL_ROOTFS)
rootfs-all-print: rootfs-all-print:
@echo $(ALL_ROOTFS) | sed "s: :\n:g" @echo $(ALL_ROOTFS) | sed "s: :\n:g"
void-%-ROOTFS-$(DATECODE).tar.xz: mkrootfs.sh void-%-ROOTFS-$(DATECODE).tar.xz: $(SCRIPTS)
@[ -n "${CI}" ] && printf "::group::\x1b[32mBuilding $@...\x1b[0m\n" || true $(SUDO) ./mkrootfs.sh $(XBPS_REPOSITORY) -x $(COMPRESSOR_THREADS) $*
$(SUDO) ./mkrootfs.sh $(XBPS_REPOSITORY) -x $(COMPRESSOR_THREADS) -o $@ $*
@[ -n "${CI}" ] && printf '::endgroup::\n' || true
platformfs-all: $(ALL_PLATFORMFS) platformfs-all: $(ALL_PLATFORMFS)
platformfs-all-print: platformfs-all-print:
@echo $(ALL_PLATFORMFS) | sed "s: :\n:g" @echo $(ALL_PLATFORMFS) | sed "s: :\n:g"
.SECONDEXPANSION: void-%-PLATFORMFS-$(DATECODE).tar.xz: $(SCRIPTS)
void-%-PLATFORMFS-$(DATECODE).tar.xz: void-$$(shell ./lib.sh platform2arch %)-ROOTFS-$(DATECODE).tar.xz mkplatformfs.sh $(SUDO) ./mkplatformfs.sh $(XBPS_REPOSITORY) -x $(COMPRESSOR_THREADS) $* void-$(shell ./lib.sh platform2arch $*)-ROOTFS-$(DATECODE).tar.xz
@[ -n "${CI}" ] && printf "::group::\x1b[32mBuilding $@...\x1b[0m\n" || true
$(SUDO) ./mkplatformfs.sh $(XBPS_REPOSITORY) -x $(COMPRESSOR_THREADS) -o $@ $* void-$(shell ./lib.sh platform2arch $*)-ROOTFS-$(DATECODE).tar.xz
@[ -n "${CI}" ] && printf '::endgroup::\n' || true
images-all: platformfs-all images-all-sbc images-all-cloud images-all: platformfs-all images-all-sbc images-all-cloud
@ -98,26 +77,28 @@ images-all-cloud: $(ALL_CLOUD_IMAGES)
images-all-print: images-all-print:
@echo $(ALL_SBC_IMAGES) $(ALL_CLOUD_IMAGES) | sed "s: :\n:g" @echo $(ALL_SBC_IMAGES) $(ALL_CLOUD_IMAGES) | sed "s: :\n:g"
void-%-$(DATECODE).img.xz: void-%-PLATFORMFS-$(DATECODE).tar.xz mkimage.sh void-%-$(DATECODE).img.xz: void-%-PLATFORMFS-$(DATECODE).tar.xz
@[ -n "${CI}" ] && printf "::group::\x1b[32mBuilding $@...\x1b[0m\n" || true $(SUDO) ./mkimage.sh -x $(COMPRESSOR_THREADS) void-$*-PLATFORMFS-$(DATECODE).tar.xz
$(SUDO) ./mkimage.sh -x $(COMPRESSOR_THREADS) -o $(basename $@) void-$*-PLATFORMFS-$(DATECODE).tar.xz
@[ -n "${CI}" ] && printf '::endgroup::\n' || true
# Some of the images MUST be compressed with gzip rather than xz, this # Some of the images MUST be compressed with gzip rather than xz, this
# rule services those images. # rule services those images.
void-%-$(DATECODE).tar.gz: void-%-PLATFORMFS-$(DATECODE).tar.xz mkimage.sh void-%-$(DATECODE).tar.gz: void-%-PLATFORMFS-$(DATECODE).tar.xz
@[ -n "${CI}" ] && printf "::group::\x1b[32mBuilding $@...\x1b[0m\n" || true
$(SUDO) ./mkimage.sh -x $(COMPRESSOR_THREADS) void-$*-PLATFORMFS-$(DATECODE).tar.xz $(SUDO) ./mkimage.sh -x $(COMPRESSOR_THREADS) void-$*-PLATFORMFS-$(DATECODE).tar.xz
@[ -n "${CI}" ] && printf '::endgroup::\n' || true
pxe-all: $(ALL_PXE_ARCHS) pxe-all: $(ALL_PXE_ARCHS)
pxe-all-print: pxe-all-print:
@echo $(ALL_PXE_ARCHS) | sed "s: :\n:g" @echo $(ALL_PXE_ARCHS) | sed "s: :\n:g"
void-%-NETBOOT-$(DATECODE).tar.gz: void-%-ROOTFS-$(DATECODE).tar.xz mknet.sh void-%-NETBOOT-$(DATECODE).tar.gz: $(SCRIPTS) void-%-ROOTFS-$(DATECODE).tar.xz
@[ -n "${CI}" ] && printf "::group::\x1b[32mBuilding $@...\x1b[0m\n" || true
$(SUDO) ./mknet.sh void-$*-ROOTFS-$(DATECODE).tar.xz $(SUDO) ./mknet.sh void-$*-ROOTFS-$(DATECODE).tar.xz
@[ -n "${CI}" ] && printf '::endgroup::\n' || true
.PHONY: all checksum dist live-iso-all live-iso-all-print rootfs-all-print rootfs-all platformfs-all-print platformfs-all pxe-all-print pxe-all masterdir-all-print:
@echo $(ALL_MASTERDIRS) | sed "s: :\n:g"
masterdir-all: $(ALL_MASTERDIRS)
masterdir-%:
$(SUDO) docker build --build-arg REPOSITORY=$(XBPS_REPOSITORY) --build-arg ARCH=$* -t voidlinux/masterdir-$*:$(DATECODE) .
.PHONY: clean dist rootfs-all-print rootfs-all platformfs-all-print platformfs-all pxe-all-print pxe-all masterdir-all-print masterdir-all masterdir-push-all

267
README.md
View File

@ -1,255 +1,48 @@
<!-- DO NOT EDIT, generated by make README.md --> ## The Void Linux image/live/rootfs maker and installer
# The Void Linux live image/rootfs generator and installer This repository contains utilities for Void Linux:
## Overview * installer (The Void Linux el-cheapo installer for x86)
* mklive (The Void Linux live image maker for x86)
This repository contains several utilities: * mkimage (The Void Linux image maker for ARM platforms)
* mkplatformfs (The Void Linux filesystem tool to produce a rootfs for a particular platform)
* mkrootfs (The Void Linux rootfs maker for ARM platforms)
* mknet (Script to generate netboot tarballs for Void)
* [*mklive.sh*](#mklivesh) - The Void Linux live image generator for x86 #### Build Dependencies
* [*mkiso.sh*](#mkisosh) - Wrapper script to generate bootable and installable live * make
images for i686, x86_64, and aarch64.
* [*mkrootfs.sh*](#mkrootfssh) - The Void Linux rootfs generator for all platforms
* [*mkplatformfs.sh*](#mkplatformfssh) - The Void Linux filesystem tool to produce
a rootfs for a particular platform
* [*mkimage.sh*](#mkimagesh) - The Void Linux image generator for ARM platforms
* [*mknet.sh*](#mknetsh) - Script to generate netboot tarballs for Void
* *installer.sh* - The Void Linux el-cheapo installer for x86
* *release.sh* - interacts with GitHub CI to generate and sign images for releases
### Workflow #### Dependencies
* Compression type for the initramfs image
* liblz4 (for lz4, xz) (default)
* xbps>=0.45
* qemu-user-static binaries (for mkrootfs)
#### Generating x86 live ISOs #### Usage
To generate a live ISO like the officially-published ones, use Type
[*mkiso.sh*](#mkisosh). To generate a more basic live ISO
(which does not include things like `void-installer`), use [*mklive.sh*](#mklivesh).
#### Generating ROOTFS tarballs $ make
ROOTFS tarballs contain a basic Void Linux root filesystem without a kernel. and then see the usage output:
These can be useful for doing a [chroot install](https://docs.voidlinux.org/installation/guides/chroot.html)
or for [chroots and containers](https://docs.voidlinux.org/config/containers-and-vms/chroot.html).
Use [*mkrootfs.sh*](#mkrootfssh) to generate a Void Linux ROOTFS. $ ./mklive.sh -h
$ ./mkrootfs.sh -h
$ ./mkimage.sh -h
#### Generating platform-specific tarballs #### Examples
Platform-specific ROOTFS tarballs, or PLATFORMFS tarballs, contain a basic Void Build a native live image keyboard set to 'fr':
Linux root filesystem including a kernel. These are commonly used for bootstrapping
ARM systems or other environments that require platform-specific kernels, like
Raspberry Pis.
First create a ROOTFS for the desired architecture, then use # ./mklive.sh -k fr
[*mkplatformfs.sh*](#mkplatformfssh) to generate a Void Linux PLATFORMFS.
#### Generating ARM images Build an i686 (on x86\_64) live image with some additional packages:
Platform-specific filesystem images contain a basic filesystem layout (`/` and # ./mklive.sh -a i686 -p 'vim rtorrent'
`/boot` partitions), ready to be copied to the target drive with `dd`. These are
not "live" images like those available on x86 platforms, and do not need
installation like live ISOs.
To generate these images, first create a PLATFORMFS for the desired platform, Build an x86\_64 musl live image with packages stored in a local repository:
then use [*mkimage.sh*](#mkimagesh) to generate the image.
## Dependencies # ./mklive.sh -a x86_64-musl -r /path/to/host/binpkgs
Note that void-mklive is not guaranteed to work on distributions other than Void
Linux, or in containers.
* Compression type for the initramfs image (by default: liblz4 for lz4, xz)
* xbps>=0.45
* qemu-user-static binaries (for mkrootfs)
* bash
## Kernel Command-line Parameters
`void-mklive`-based live images support several kernel command-line arguments
that can change the behavior of the live system:
- `live.autologin` will skip the initial login screen on `tty1`.
- `live.user` will change the username of the non-root user from the default
`anon`. The password remains `voidlinux`.
- `live.shell` sets the default shell for the non-root user in the live environment.
- `live.accessibility` enables accessibility features like the console screenreader
`espeakup` in the live environment.
- `console` can be set to `ttyS0`, `hvc0`, or `hvsi0` to enable `agetty` on that
serial console.
- `locale.LANG` will set the `LANG` environment variable. Defaults to `en_US.UTF-8`.
- `vconsole.keymap` will set the console keymap. Defaults to `us`.
### Examples:
- `live.autologin live.user=foo live.shell=/bin/bash` would create the user `foo`
with the default shell `/bin/bash` on boot, and log them in automatically on `tty1`
- `live.shell=/bin/bash` would set the default shell for the `anon` user to `/bin/bash`
- `console=ttyS0 vconsole.keymap=cf` would enable `ttyS0` and set the keymap in
the console to `cf`
- `locale.LANG=fr_CA.UTF-8` would set the live system's language to `fr_CA.UTF-8`
## Usage
### mkiso.sh
```
Usage: mkiso.sh [options ...] [-- mklive options ...]
Wrapper script around mklive.sh for several standard flavors of live images.
Adds void-installer and other helpful utilities to the generated images.
OPTIONS
-a <arch> Set XBPS_ARCH in the image
-b <variant> One of base, enlightenment, xfce, mate, cinnamon, gnome, kde,
lxde, or lxqt (default: base). May be specified multiple times
to build multiple variants
-d <date> Override the datestamp on the generated image (YYYYMMDD format)
-t <arch-date-variant>
Equivalent to setting -a, -b, and -d
-r <repo> Use this XBPS repository. May be specified multiple times
-h Show this help and exit
-V Show version and exit
Other options can be passed directly to mklive.sh by specifying them after the --.
See mklive.sh -h for more details.
```
### mklive.sh
```
Usage: mklive.sh [options]
Generates a basic live ISO image of Void Linux. This ISO image can be written
to a CD/DVD-ROM or any USB stick.
To generate a more complete live ISO image, use mkiso.sh.
OPTIONS
-a <arch> Set XBPS_ARCH in the ISO image
-b <system-pkg> Set an alternative base package (default: base-system)
-r <repo> Use this XBPS repository. May be specified multiple times
-c <cachedir> Use this XBPS cache directory (default: ./xbps-cachedir-<arch>)
-k <keymap> Default keymap to use (default: us)
-l <locale> Default locale to use (default: en_US.UTF-8)
-i <lz4|gzip|bzip2|xz>
Compression type for the initramfs image (default: xz)
-s <gzip|lzo|xz> Compression type for the squashfs image (default: xz)
-o <file> Output file name for the ISO image (default: automatic)
-p "<pkg> ..." Install additional packages in the ISO image
-g "<pkg> ..." Ignore packages when building the ISO image
-I <includedir> Include directory structure under given path in the ROOTFS
-S "<service> ..." Enable services in the ISO image
-e <shell> Default shell of the root user (must be absolute path).
Set the live.shell kernel argument to change the default shell of anon.
-C "<arg> ..." Add additional kernel command line arguments
-P "<platform> ..."
Platforms to enable for aarch64 EFI ISO images (available: pinebookpro, x13s)
-T <title> Modify the bootloader title (default: Void Linux)
-v linux<version> Install a custom Linux version on ISO image (default: linux metapackage).
Also accepts linux metapackages (linux-mainline, linux-lts).
-K Do not remove builddir
-h Show this help and exit
-V Show version and exit
```
### mkrootfs.sh
```
Usage: mkrootfs.sh [options] <arch>
Generate a Void Linux ROOTFS tarball for the specified architecture.
Supported architectures:
i686, i686-musl, x86_64, x86_64-musl,
armv5tel, armv5tel-musl, armv6l, armv6l-musl, armv7l, armv7l-musl
aarch64, aarch64-musl,
mipsel, mipsel-musl,
ppc, ppc-musl, ppc64le, ppc64le-musl, ppc64, ppc64-musl
riscv64, riscv64-musl
OPTIONS
-b <system-pkg> Set an alternative base-system package (default: base-container-full)
-c <cachedir> Set XBPS cache directory (default: ./xbps-cachedir-<arch>)
-C <file> Full path to the XBPS configuration file
-r <repo> Use this XBPS repository. May be specified multiple times
-o <file> Filename to write the ROOTFS to (default: automatic)
-x <num> Number of threads to use for image compression (default: dynamic)
-h Show this help and exit
-V Show version and exit
```
### mkplatformfs.sh
```
Usage: mkplatformfs.sh [options] <platform> <rootfs-tarball>
Generates a platform-specific ROOTFS tarball from a generic Void Linux ROOTFS
generated by mkrootfs.sh.
Supported platforms: i686, x86_64, GCP,
rpi-armv6l, rpi-armv7l, rpi-aarch64,
pinebookpro, pinephone, rock64, rockpro64
OPTIONS
-b <system-pkg> Set an alternative base-system package (default: base-system)
-c <cachedir> Set the XBPS cache directory (default: ./xbps-cachedir-<arch>)
-C <file> Full path to the XBPS configuration file
-k <cmd> Call '<cmd> <ROOTFSPATH>' after building the ROOTFS
-n Do not compress the image, instead print out the ROOTFS directory
-o <file> Filename to write the PLATFORMFS archive to (default: automatic)
-p "<pkg> ..." Additional packages to install into the ROOTFS
-r <repo> Use this XBPS repository. May be specified multiple times
-x <num> Number of threads to use for image compression (default: dynamic)
-h Show this help and exit
-V Show version and exit
```
### mkimage.sh
```
Usage: mkimage.sh [options] <platformfs-tarball>
Generates a filesystem image suitable for writing with dd from a PLATFORMFS
tarball generated by mkplatformfs.sh. The filesystem layout is configurable,
but customization of the installed system should be done when generating the
PLATFORMFS. The resulting image will have 2 partitions, /boot and /.
OPTIONS
-b <fstype> /boot filesystem type (default: vfat)
-B <bsize> /boot filesystem size (default: 256MiB)
-r <fstype> / filesystem type (default: ext4)
-s <totalsize> Total image size (default: 768MiB)
-o <output> Image filename (default: guessed automatically)
-x <num> Number of threads to use for image compression (default: dynamic)
-h Show this help and exit
-V Show version and exit
Accepted size suffixes: KiB, MiB, GiB, TiB, EiB.
The <platformfs-tarball> argument expects a tarball generated by mkplatformfs.sh.
The platform is guessed automatically by its name.
```
### mknet.sh
```
Usage: mknet.sh [options] <rootfs-tarball>
Generates a network-bootable tarball from a Void Linux ROOTFS generated by mkrootfs.
OPTIONS
-r <repo> Use this XBPS repository. May be specified multiple times
-c <cachedir> Use this XBPS cache directory (default: )
-i <lz4|gzip|bzip2|xz>
Compression type for the initramfs image (default: xz)
-o <file> Output file name for the netboot tarball (default: automatic)
-K linux<version> Install a custom Linux version on ISO image (default: linux metapackage)
-k <keymap> Default keymap to use (default: us)
-l <locale> Default locale to use (default: en_US.UTF-8)
-C "<arg> ..." Add additional kernel command line arguments
-T <title> Modify the bootloader title (default: Void Linux)
-S <image> Set a custom splash image for the bootloader (default: data/splash.png)
-h Show this help and exit
-V Show version and exit
```
See the usage output for more information :-)

View File

@ -1,90 +0,0 @@
# The Void Linux live image/rootfs generator and installer
## Overview
This repository contains several utilities:
* [*mklive.sh*](#mklivesh) - The Void Linux live image generator for x86
* [*mkiso.sh*](#mkisosh) - Wrapper script to generate bootable and installable live
images for i686, x86_64, and aarch64.
* [*mkrootfs.sh*](#mkrootfssh) - The Void Linux rootfs generator for all platforms
* [*mkplatformfs.sh*](#mkplatformfssh) - The Void Linux filesystem tool to produce
a rootfs for a particular platform
* [*mkimage.sh*](#mkimagesh) - The Void Linux image generator for ARM platforms
* [*mknet.sh*](#mknetsh) - Script to generate netboot tarballs for Void
* *installer.sh* - The Void Linux el-cheapo installer for x86
* *release.sh* - interacts with GitHub CI to generate and sign images for releases
### Workflow
#### Generating x86 live ISOs
To generate a live ISO like the officially-published ones, use
[*mkiso.sh*](#mkisosh). To generate a more basic live ISO
(which does not include things like `void-installer`), use [*mklive.sh*](#mklivesh).
#### Generating ROOTFS tarballs
ROOTFS tarballs contain a basic Void Linux root filesystem without a kernel.
These can be useful for doing a [chroot install](https://docs.voidlinux.org/installation/guides/chroot.html)
or for [chroots and containers](https://docs.voidlinux.org/config/containers-and-vms/chroot.html).
Use [*mkrootfs.sh*](#mkrootfssh) to generate a Void Linux ROOTFS.
#### Generating platform-specific tarballs
Platform-specific ROOTFS tarballs, or PLATFORMFS tarballs, contain a basic Void
Linux root filesystem including a kernel. These are commonly used for bootstrapping
ARM systems or other environments that require platform-specific kernels, like
Raspberry Pis.
First create a ROOTFS for the desired architecture, then use
[*mkplatformfs.sh*](#mkplatformfssh) to generate a Void Linux PLATFORMFS.
#### Generating ARM images
Platform-specific filesystem images contain a basic filesystem layout (`/` and
`/boot` partitions), ready to be copied to the target drive with `dd`. These are
not "live" images like those available on x86 platforms, and do not need
installation like live ISOs.
To generate these images, first create a PLATFORMFS for the desired platform,
then use [*mkimage.sh*](#mkimagesh) to generate the image.
## Dependencies
Note that void-mklive is not guaranteed to work on distributions other than Void
Linux, or in containers.
* Compression type for the initramfs image (by default: liblz4 for lz4, xz)
* xbps>=0.45
* qemu-user-static binaries (for mkrootfs)
* bash
## Kernel Command-line Parameters
`void-mklive`-based live images support several kernel command-line arguments
that can change the behavior of the live system:
- `live.autologin` will skip the initial login screen on `tty1`.
- `live.user` will change the username of the non-root user from the default
`anon`. The password remains `voidlinux`.
- `live.shell` sets the default shell for the non-root user in the live environment.
- `live.accessibility` enables accessibility features like the console screenreader
`espeakup` in the live environment.
- `console` can be set to `ttyS0`, `hvc0`, or `hvsi0` to enable `agetty` on that
serial console.
- `locale.LANG` will set the `LANG` environment variable. Defaults to `en_US.UTF-8`.
- `vconsole.keymap` will set the console keymap. Defaults to `us`.
### Examples:
- `live.autologin live.user=foo live.shell=/bin/bash` would create the user `foo`
with the default shell `/bin/bash` on boot, and log them in automatically on `tty1`
- `live.shell=/bin/bash` would set the default shell for the `anon` user to `/bin/bash`
- `console=ttyS0 vconsole.keymap=cf` would enable `ttyS0` and set the keymap in
the console to `cf`
- `locale.LANG=fr_CA.UTF-8` would set the live system's language to `fr_CA.UTF-8`
## Usage

90
build-x86-images.sh.in Normal file
View File

@ -0,0 +1,90 @@
#!/bin/sh
ARCH=
IMAGE=
while getopts "a:b:hr:" opt; do
case $opt in
a) ARCH="$OPTARG";;
b) IMAGE="$OPTARG";;
h) echo "${0#/*}: [-a arch] [-b base|e|xfce|mate|cinnamon|gnome|kde|lxde|lxqt] [-r repo]" >&2; exit 1;;
r) REPO="-r $OPTARG $REPO";;
esac
done
shift $((OPTIND - 1))
: ${ARCH:=$(uname -m)}
readonly DATE=$(date +%Y%m%d)
readonly BASE_IMG=void-live-${ARCH}-${DATE}.iso
readonly E_IMG=void-live-${ARCH}-${DATE}-enlightenment.iso
readonly XFCE_IMG=void-live-${ARCH}-${DATE}-xfce.iso
readonly MATE_IMG=void-live-${ARCH}-${DATE}-mate.iso
readonly CINNAMON_IMG=void-live-${ARCH}-${DATE}-cinnamon.iso
readonly GNOME_IMG=void-live-${ARCH}-${DATE}-gnome.iso
readonly KDE_IMG=void-live-${ARCH}-${DATE}-kde.iso
readonly LXDE_IMG=void-live-${ARCH}-${DATE}-lxde.iso
readonly LXQT_IMG=void-live-${ARCH}-${DATE}-lxqt.iso
readonly GRUB="grub-i386-efi grub-x86_64-efi"
readonly BASE_PKGS="dialog cryptsetup lvm2 mdadm $GRUB"
readonly X_PKGS="$BASE_PKGS xorg-minimal xorg-input-drivers xorg-video-drivers setxkbmap xauth font-misc-misc terminus-font dejavu-fonts-ttf alsa-plugins-pulseaudio"
readonly E_PKGS="$X_PKGS lxdm enlightenment terminology econnman udisks2 firefox-esr"
readonly XFCE_PKGS="$X_PKGS lxdm xfce4 gnome-themes-standard gnome-keyring network-manager-applet gvfs-afc gvfs-mtp gvfs-smb udisks2 firefox-esr"
readonly MATE_PKGS="$X_PKGS lxdm mate mate-extra gnome-keyring network-manager-applet gvfs-afc gvfs-mtp gvfs-smb udisks2 firefox-esr"
readonly CINNAMON_PKGS="$X_PKGS lxdm cinnamon gnome-keyring colord gnome-terminal gvfs-afc gvfs-mtp gvfs-smb udisks2 firefox-esr"
readonly GNOME_PKGS="$X_PKGS gnome gnome-terminal firefox-esr"
readonly KDE_PKGS="$X_PKGS kde5 konsole firefox dolphin"
readonly LXDE_PKGS="$X_PKGS lxdm lxde gvfs-afc gvfs-mtp gvfs-smb udisks2 firefox-esr"
readonly LXQT_PKGS="$X_PKGS lxdm lxqt gvfs-afc gvfs-mtp gvfs-smb udisks2 qupzilla"
[ ! -x mklive.sh ] && exit 0
if [ -z "$IMAGE" -o "$IMAGE" = base ]; then
if [ ! -e $BASE_IMG ]; then
./mklive.sh -a $ARCH -o $BASE_IMG -p "$BASE_PKGS" ${REPO} $@
fi
fi
if [ -z "$IMAGE" -o "$IMAGE" = e ]; then
if [ ! -e $E_IMG ]; then
./mklive.sh -a $ARCH -o $E_IMG -p "$E_PKGS" ${REPO} $@
fi
fi
if [ -z "$IMAGE" -o "$IMAGE" = xfce ]; then
if [ ! -e $XFCE_IMG ]; then
./mklive.sh -a $ARCH -o $XFCE_IMG -p "$XFCE_PKGS" ${REPO} $@
fi
fi
if [ -z "$IMAGE" -o "$IMAGE" = mate ]; then
if [ ! -e $MATE_IMG ]; then
./mklive.sh -a $ARCH -o $MATE_IMG -p "$MATE_PKGS" ${REPO} $@
fi
fi
if [ -z "$IMAGE" -o "$IMAGE" = cinnamon ]; then
if [ ! -e $CINNAMON_IMG ]; then
./mklive.sh -a $ARCH -o $CINNAMON_IMG -p "$CINNAMON_PKGS" ${REPO} $@
fi
fi
if [ -z "$IMAGE" -o "$IMAGE" = gnome ]; then
if [ ! -e $GNOME_IMG ]; then
./mklive.sh -a $ARCH -o $GNOME_IMG -p "$GNOME_PKGS" ${REPO} $@
fi
fi
if [ -z "$IMAGE" -o "$IMAGE" = lxde ]; then
if [ ! -e $LXDE_IMG ]; then
./mklive.sh -a $ARCH -o $LXDE_IMG -p "$LXDE_PKGS" ${REPO} $@
fi
fi
if [ -z "$IMAGE" -o "$IMAGE" = lxqt ]; then
if [ ! -e $LXQT_IMG ]; then
./mklive.sh -a $ARCH -o $LXQT_IMG -p "$LXQT_PKGS" ${REPO} $@
fi
fi
if [ "$IMAGE" = kde ]; then
if [ ! -e $KDE_IMG ]; then
./mklive.sh -a $ARCH -o $KDE_IMG -p "$KDE_PKGS" ${REPO} $@
fi
fi

View File

@ -18,9 +18,6 @@ sure to configure your network interface and then use:
- xbps-install(1) to install/update packages - xbps-install(1) to install/update packages
- xbps-query(1) to query for package info - xbps-query(1) to query for package info
The Void Linux Handbook is also available for offline access in multiple
formats, and can be accessed with the `void-docs(1)` utility.
Thanks for using Void Linux. Thanks for using Void Linux.
https://www.voidlinux.org https://www.voidlinux.org

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 98 KiB

10
data/void-vpkgs.conf Normal file
View File

@ -0,0 +1,10 @@
# Default void configuration
#
virtualpkg=awk:gawk
virtualpkg=cron-daemon:dcron
virtualpkg=editor:nvi
virtualpkg=man:openbsd-man
virtualpkg=ntp-daemon:openntpd
virtualpkg=openssl:libressl-openssl
virtualpkg=shell:dash
virtualpkg=smtp-server:opensmtpd

View File

@ -20,8 +20,8 @@
# XBPS Configuration # XBPS Configuration
# === # ===
# xbpsrepository: which repo should the install pull from # xbpsrepository: which repo should the install pull from
# default: https://repo-default.voidlinux.org/current # default: http://alpha.de.repo.voidlinux.org/current
#xbpsrepository="https://repo-default.voidlinux.org/current" #xbpsrepository="http://alpha.de.repo.voidlinux.org/current"
# pkgs: additional packages to install into the target # pkgs: additional packages to install into the target
# default: none # default: none

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
type getargbool >/dev/null 2>&1 || . /lib/dracut-lib.sh set -e
# These functions pulled from void's excellent mklive.sh # These functions pulled from void's excellent mklive.sh
VAI_info_msg() { VAI_info_msg() {
@ -67,22 +67,20 @@ VAI_install_base_system() {
# Install additional packages # Install additional packages
if [ -n "${pkgs}" ] ; then if [ -n "${pkgs}" ] ; then
# shellcheck disable=SC2086 XBPS_ARCH="${XBPS_ARCH}" xbps-install -Sy -R "${xbpsrepository}" -r /mnt "${pkgs}"
XBPS_ARCH="${XBPS_ARCH}" xbps-install -Sy -R "${xbpsrepository}" -r /mnt ${pkgs}
fi fi
} }
VAI_prepare_chroot() { VAI_prepare_chroot() {
# Mount dev, bind, proc, etc into chroot # Mount dev, bind, proc, etc into chroot
mount -t proc proc "${target}/proc" mount -t proc proc "${target}/proc"
mount --rbind /sys "${target}/sys" mount -t sysfs sys "${target}/sys"
mount --rbind /dev "${target}/dev" mount -o rbind /dev "${target}/dev"
} }
VAI_configure_sudo() { VAI_configure_sudo() {
# Give wheel sudo # Give wheel sudo
echo "%wheel ALL=(ALL:ALL) ALL" > "${target}/etc/sudoers.d/00-wheel" echo "%wheel ALL=(ALL) ALL" > "${target}/etc/sudoers.d/wheel"
chmod 0440 "${target}/etc/sudoers.d/00-wheel"
} }
VAI_correct_root_permissions() { VAI_correct_root_permissions() {
@ -191,7 +189,6 @@ VAI_configure_autoinstall() {
bootpartitionsize="500M" bootpartitionsize="500M"
disk="$(lsblk -ipo NAME,TYPE,MOUNTPOINT | awk '{if ($2=="disk") {disks[$1]=0; last=$1} if ($3=="/") {disks[last]++}} END {for (a in disks) {if(disks[a] == 0){print a; break}}}')" disk="$(lsblk -ipo NAME,TYPE,MOUNTPOINT | awk '{if ($2=="disk") {disks[$1]=0; last=$1} if ($3=="/") {disks[last]++}} END {for (a in disks) {if(disks[a] == 0){print a; break}}}')"
hostname="$(ip -4 -o -r a | awk -F'[ ./]' '{x=$7} END {print x}')" hostname="$(ip -4 -o -r a | awk -F'[ ./]' '{x=$7} END {print x}')"
# XXX: Set a manual swapsize here if the default doesn't fit your use case
swapsize="$(awk -F"\n" '/MemTotal/ {split($0, b, " "); print b[2] }' /proc/meminfo)"; swapsize="$(awk -F"\n" '/MemTotal/ {split($0, b, " "); print b[2] }' /proc/meminfo)";
target="/mnt" target="/mnt"
timezone="America/Chicago" timezone="America/Chicago"
@ -204,21 +201,18 @@ VAI_configure_autoinstall() {
XBPS_ARCH="$(xbps-uhelper arch)" XBPS_ARCH="$(xbps-uhelper arch)"
case $XBPS_ARCH in case $XBPS_ARCH in
*-musl) *-musl)
xbpsrepository="https://repo-default.voidlinux.org/current/musl" xbpsrepository="https://alpha.de.repo.voidlinux.org/current/musl"
;; ;;
*) *)
xbpsrepository="https://repo-default.voidlinux.org/current" xbpsrepository="https://alpha.de.repo.voidlinux.org/current"
;; ;;
esac esac
# --------------- Pull config URL out of kernel cmdline ------------------------- # --------------- Pull config URL out of kernel cmdline -------------------------
set +e
if getargbool 0 autourl ; then if getargbool 0 autourl ; then
set -e
xbps-uhelper fetch "$(getarg autourl)>/etc/autoinstall.cfg" xbps-uhelper fetch "$(getarg autourl)>/etc/autoinstall.cfg"
else else
set -e
mv /etc/autoinstall.default /etc/autoinstall.cfg mv /etc/autoinstall.default /etc/autoinstall.cfg
fi fi
@ -292,9 +286,8 @@ VAI_main() {
# If we are using the autoinstaller, launch it # If we are using the autoinstaller, launch it
if getargbool 0 auto ; then if getargbool 0 auto ; then
set -e
VAI_main VAI_main
# Very important to release this before returning to dracut code
set +e
fi fi
# Very important to release this before returning to dracut code
set +e

View File

@ -1,10 +0,0 @@
#!/bin/sh -x
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
type getargbool >/dev/null 2>&1 || . /lib/dracut-lib.sh
if getargbool 0 live.accessibility; then
[ -d "${NEWROOT}/etc/sv/espeakup" ] && ln -s "/etc/sv/espeakup" "${NEWROOT}/etc/runit/runsvdir/current/"
[ -d "${NEWROOT}/etc/sv/brltty" ] && ln -s "/etc/sv/brltty" "${NEWROOT}/etc/runit/runsvdir/current/"
fi

View File

@ -2,12 +2,11 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh # ex: ts=8 sw=4 sts=4 et filetype=sh
if ! type getarg >/dev/null 2>&1 && ! type getargbool >/dev/null 2>&1; then type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
. /lib/dracut-lib.sh
fi
echo void-live > ${NEWROOT}/etc/hostname echo void-live > ${NEWROOT}/etc/hostname
AUTOLOGIN=$(getarg live.autologin)
USERNAME=$(getarg live.user) USERNAME=$(getarg live.user)
USERSHELL=$(getarg live.shell) USERSHELL=$(getarg live.shell)
@ -33,7 +32,7 @@ chroot ${NEWROOT} sh -c "echo "$USERNAME:voidlinux" | chpasswd -c SHA512"
# Enable sudo permission by default. # Enable sudo permission by default.
if [ -f ${NEWROOT}/etc/sudoers ]; then if [ -f ${NEWROOT}/etc/sudoers ]; then
echo "${USERNAME} ALL=(ALL:ALL) NOPASSWD: ALL" > "${NEWROOT}/etc/sudoers.d/99-void-live" echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> ${NEWROOT}/etc/sudoers
fi fi
if [ -d ${NEWROOT}/etc/polkit-1 ]; then if [ -d ${NEWROOT}/etc/polkit-1 ]; then
@ -52,6 +51,6 @@ _EOF
chroot ${NEWROOT} chown polkitd:polkitd /etc/polkit-1/rules.d/void-live.rules chroot ${NEWROOT} chown polkitd:polkitd /etc/polkit-1/rules.d/void-live.rules
fi fi
if getargbool 0 live.autologin; then if [ -n "$AUTOLOGIN" ]; then
sed -i "s,GETTY_ARGS=\"--noclear\",GETTY_ARGS=\"--noclear -a $USERNAME\",g" ${NEWROOT}/etc/sv/agetty-tty1/conf sed -i "s,GETTY_ARGS=\"--noclear\",GETTY_ARGS=\"--noclear -a $USERNAME\",g" ${NEWROOT}/etc/sv/agetty-tty1/run
fi fi

View File

@ -25,19 +25,17 @@ fi
if [ -x ${NEWROOT}/usr/bin/sddm ]; then if [ -x ${NEWROOT}/usr/bin/sddm ]; then
cat > ${NEWROOT}/etc/sddm.conf <<_EOF cat > ${NEWROOT}/etc/sddm.conf <<_EOF
[Autologin] [Autologin]
User=${USERNAME} User=anon
Session=plasma.desktop Session=plasma.desktop
_EOF _EOF
fi fi
# Configure lightdm autologin. # Configure lightdm autologin.
if [ -r "${NEWROOT}/etc/lightdm/lightdm.conf" ]; then if [ -r ${NEWROOT}/etc/lightdm.conf ]; then
sed -i -e "s|^\#\(autologin-user=\).*|\1$USERNAME|" \ sed -i -e "s|^\#\(default-user=\).*|\1$USERNAME|" \
"${NEWROOT}/etc/lightdm/lightdm.conf" ${NEWROOT}/etc/lightdm.conf
sed -i -e "s|^\#\(autologin-user-timeout=\).*|\10|" \ sed -i -e "s|^\#\(default-user-timeout=\).*|\10|" \
"${NEWROOT}/etc/lightdm/lightdm.conf" ${NEWROOT}/etc/lightdm.conf
sed -i -e "s|^\#\(autologin-session=\).*|\1$(cat "${NEWROOT}/etc/lightdm/.session")|" \
"${NEWROOT}/etc/lightdm/lightdm.conf"
fi fi
# Configure lxdm autologin. # Configure lxdm autologin.

View File

@ -1,18 +0,0 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
CONSOLE=$(getarg console)
case "$CONSOLE" in
*ttyS0*)
ln -s /etc/sv/agetty-ttyS0 ${NEWROOT}/etc/runit/runsvdir/default/
;;
*hvc0*)
ln -s /etc/sv/agetty-hvc0 ${NEWROOT}/etc/runit/runsvdir/default/
;;
*hvsi0*)
ln -s /etc/sv/agetty-hvsi0 ${NEWROOT}/etc/runit/runsvdir/default/
;;
esac

View File

@ -25,8 +25,6 @@ install() {
inst_hook pre-pivot 01 "$moddir/adduser.sh" inst_hook pre-pivot 01 "$moddir/adduser.sh"
inst_hook pre-pivot 02 "$moddir/display-manager-autologin.sh" inst_hook pre-pivot 02 "$moddir/display-manager-autologin.sh"
inst_hook pre-pivot 02 "$moddir/getty-serial.sh"
inst_hook pre-pivot 03 "$moddir/locale.sh" inst_hook pre-pivot 03 "$moddir/locale.sh"
inst_hook pre-pivot 04 "$moddir/accessibility.sh" inst_hook pre-pivot 04 "$moddir/services.sh"
inst_hook pre-pivot 05 "$moddir/nomodeset.sh"
} }

View File

@ -1,13 +0,0 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
type getargbool >/dev/null 2>&1 || . /lib/dracut-lib.sh
if getargbool 0 nomodeset; then
for dm in lightdm sddm gdm; do
if [ -e "${NEWROOT}/etc/runit/runsvdir/default/${dm}" ]; then
touch "${NEWROOT}/etc/runit/runsvdir/default/${dm}/down"
fi
done
fi

View File

@ -0,0 +1,29 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
SERVICEDIR=$NEWROOT/etc/sv
SERVICES="$(getarg live.services)"
for f in ${SERVICES}; do
ln -sf /etc/sv/$f $NEWROOT/etc/runit/runsvdir/default/
done
dhcpcd=1
for f in connmand NetworkManager wicd; do
if [ -e $SERVICEDIR/$f ]; then
unset dhcpcd
fi
done
# Enable all services by default... with some exceptions.
for f in $SERVICEDIR/*; do
_service=${f##*/}
case "${_service}" in
agetty-console|agetty-generic|agetty-serial|agetty-tty[SAU]*|sulogin|dhcpcd-*|iptables|ip6tables|wpa_supplicant|pulseaudio|lvmetad|dmeventd|mdadm) ;; # ignored
dhcpcd) [ -n "$dhcpcd" ] && ln -sf ${f##$NEWROOT} $NEWROOT/etc/runit/runsvdir/default/;;
*) ln -sf ${f##$NEWROOT} $NEWROOT/etc/runit/runsvdir/default/;;
esac
done

46
grub/grub_void.cfg.in Normal file
View File

@ -0,0 +1,46 @@
set pager="1"
set locale_dir="(${voidlive})/boot/grub/locale"
if [ -e "${prefix}/${grub_cpu}-${grub_platform}/all_video.mod" ]; then
insmod all_video
else
insmod efi_gop
insmod efi_uga
insmod video_bochs
insmod video_cirrus
fi
insmod font
if loadfont "(${voidlive})/boot/grub/fonts/unicode.pf2" ; then
insmod gfxterm
set gfxmode="auto"
terminal_input console
terminal_output gfxterm
insmod png
background_image "(${voidlive})/boot/isolinux/@@SPLASHIMAGE@@"
fi
if [ cpuid -l ]; then
menuentry "@@BOOT_TITLE@@ @@KERNVER@@ (@@ARCH@@)" {
set gfxpayload="keep"
linux (${voidlive})/boot/vmlinuz \
root=live:CDLABEL=VOID_LIVE ro init=/sbin/init \
rd.luks=0 rd.md=0 rd.dm=0 loglevel=4 gpt add_efi_memmap \
vconsole.unicode=1 vconsole.keymap=@@KEYMAP@@ \
locale.LANG=@@LOCALE@@ @@BOOT_CMDLINE@@
initrd (${voidlive})/boot/initrd
}
menuentry "@@BOOT_TITLE@@ @@KERNVER@@ (@@ARCH@@) (RAM)" {
set gfxpayload="keep"
linux (${voidlive})/boot/vmlinuz \
root=live:CDLABEL=VOID_LIVE ro init=/sbin/init \
rd.luks=0 rd.md=0 rd.dm=0 loglevel=4 gpt add_efi_memmap \
vconsole.unicode=1 vconsole.keymap=@@KEYMAP@@ \
locale.LANG=@@LOCALE@@ @@BOOT_CMDLINE@@ rd.live.ram
initrd (${voidlive})/boot/initrd
}
fi

View File

@ -1 +0,0 @@
fi # for if [ cpuid -l ] in grub_void.cfg.pre

View File

@ -1,36 +0,0 @@
export voidlive
set pager="1"
set locale_dir="(${voidlive})/boot/grub/locale"
if [ -e "${prefix}/${grub_cpu}-${grub_platform}/all_video.mod" ]; then
insmod all_video
else
insmod efi_gop
insmod efi_uga
insmod video_bochs
insmod video_cirrus
fi
insmod font
if loadfont "(${voidlive})/boot/grub/fonts/unicode.pf2" ; then
insmod gfxterm
set gfxmode="auto"
terminal_input console
terminal_output gfxterm
insmod png
background_image "(${voidlive})/boot/isolinux/@@SPLASHIMAGE@@"
fi
# Set default menu entry
default=linux
timeout=15
timeout_style=menu
# GRUB init tune for accessibility
play 600 988 1 1319 4
if [ cpuid -l ]; then

1
hooks/README.md Normal file
View File

@ -0,0 +1 @@
hooks for Docker

2
hooks/build Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
docker build --build-arg ARCH=$ARCH -t $IMAGE_NAME .

369
installer.sh → installer.sh.in Executable file → Normal file
View File

@ -36,12 +36,10 @@ USERLOGIN_DONE=
USERPASSWORD_DONE= USERPASSWORD_DONE=
USERNAME_DONE= USERNAME_DONE=
USERGROUPS_DONE= USERGROUPS_DONE=
USERACCOUNT_DONE=
BOOTLOADER_DONE= BOOTLOADER_DONE=
PARTITIONS_DONE= PARTITIONS_DONE=
NETWORK_DONE= NETWORK_DONE=
FILESYSTEMS_DONE= FILESYSTEMS_DONE=
MIRROR_DONE=
TARGETDIR=/mnt/target TARGETDIR=/mnt/target
LOG=/dev/tty8 LOG=/dev/tty8
@ -50,7 +48,6 @@ if [ ! -f $CONF_FILE ]; then
touch -f $CONF_FILE touch -f $CONF_FILE
fi fi
ANSWER=$(mktemp -t vinstall-XXXXXXXX || exit 1) ANSWER=$(mktemp -t vinstall-XXXXXXXX || exit 1)
TARGET_SERVICES=$(mktemp -t vinstall-sv-XXXXXXXX || exit 1)
TARGET_FSTAB=$(mktemp -t vinstall-fstab-XXXXXXXX || exit 1) TARGET_FSTAB=$(mktemp -t vinstall-fstab-XXXXXXXX || exit 1)
trap "DIE" INT TERM QUIT trap "DIE" INT TERM QUIT
@ -113,7 +110,7 @@ DIE() {
rval=$1 rval=$1
[ -z "$rval" ] && rval=0 [ -z "$rval" ] && rval=0
clear clear
rm -f $ANSWER $TARGET_FSTAB $TARGET_SERVICES rm -f $ANSWER $TARGET_FSTAB
# reenable printk # reenable printk
if [ -w /proc/sys/kernel/printk ]; then if [ -w /proc/sys/kernel/printk ]; then
echo 4 >/proc/sys/kernel/printk echo 4 >/proc/sys/kernel/printk
@ -361,15 +358,6 @@ show_disks() {
done done
} }
get_partfs() {
# Get fs type from configuration if available. This ensures
# that the user is shown the proper fs type if they install the system.
local part="$1"
local default="${2:-none}"
local fstype=$(grep "MOUNTPOINT ${part}" "$CONF_FILE"|awk '{print $3}')
echo "${fstype:-$default}"
}
show_partitions() { show_partitions() {
local dev fstype fssize p part local dev fstype fssize p part
@ -387,7 +375,7 @@ show_partitions() {
[ "$fstype" = "LVM2_member" ] && continue [ "$fstype" = "LVM2_member" ] && continue
fssize=$(lsblk -nr /dev/$part|awk '{print $4}'|head -1) fssize=$(lsblk -nr /dev/$part|awk '{print $4}'|head -1)
echo "/dev/$part" echo "/dev/$part"
echo "size:${fssize:-unknown};fstype:$(get_partfs "/dev/$part")" echo "size:${fssize:-unknown};fstype:${fstype:-none}"
fi fi
done done
done done
@ -401,7 +389,7 @@ show_partitions() {
fstype=$(lsblk -nfr $p|awk '{print $2}'|head -1) fstype=$(lsblk -nfr $p|awk '{print $2}'|head -1)
fssize=$(lsblk -nr $p|awk '{print $4}'|head -1) fssize=$(lsblk -nr $p|awk '{print $4}'|head -1)
echo "${p}" echo "${p}"
echo "size:${fssize:-unknown};fstype:$(get_partfs "$p")" echo "size:${fssize:-unknown};fstype:${fstype:-none}"
done done
# Software raid (md) # Software raid (md)
for p in $(ls -d /dev/md* 2>/dev/null|grep '[0-9]'); do for p in $(ls -d /dev/md* 2>/dev/null|grep '[0-9]'); do
@ -412,7 +400,7 @@ show_partitions() {
[ "$fstype" = "LVM2_member" ] && continue [ "$fstype" = "LVM2_member" ] && continue
fssize=$(lsblk -nr /dev/$part|awk '{print $4}') fssize=$(lsblk -nr /dev/$part|awk '{print $4}')
echo "$p" echo "$p"
echo "size:${fssize:-unknown};fstype:$(get_partfs "$p")" echo "size:${fssize:-unknown};fstype:${fstype:-none}"
fi fi
done done
# cciss(4) devices # cciss(4) devices
@ -422,13 +410,13 @@ show_partitions() {
[ "$fstype" = "LVM2_member" ] && continue [ "$fstype" = "LVM2_member" ] && continue
fssize=$(lsblk -nr /dev/cciss/$part|awk '{print $4}') fssize=$(lsblk -nr /dev/cciss/$part|awk '{print $4}')
echo "/dev/cciss/$part" echo "/dev/cciss/$part"
echo "size:${fssize:-unknown};fstype:$(get_partfs "/dev/cciss/$part")" echo "size:${fssize:-unknown};fstype:${fstype:-none}"
done done
if [ -e /sbin/lvs ]; then if [ -e /sbin/lvs ]; then
# LVM # LVM
lvs --noheadings|while read lvname vgname perms size; do lvs --noheadings|while read lvname vgname perms size; do
echo "/dev/mapper/${vgname}-${lvname}" echo "/dev/mapper/${vgname}-${lvname}"
echo "size:${size};fstype:$(get_partfs "/dev/mapper/${vgname}-${lvname}" lvm)" echo "size:${size};fstype:lvm"
done done
fi fi
} }
@ -489,7 +477,6 @@ menu_filesystems() {
echo "MOUNTPOINT $dev $1 $2 $3 $4" >>$CONF_FILE echo "MOUNTPOINT $dev $1 $2 $3 $4" >>$CONF_FILE
fi fi
done done
FILESYSTEMS_DONE=1
} }
menu_partitions() { menu_partitions() {
@ -507,19 +494,17 @@ menu_partitions() {
DIALOG --title "Modify Partition Table on $device" --msgbox "\n DIALOG --title "Modify Partition Table on $device" --msgbox "\n
${BOLD}${software} will be executed in disk $device.${RESET}\n\n ${BOLD}${software} will be executed in disk $device.${RESET}\n\n
For BIOS systems, MBR or GPT partition tables are supported. To use GPT\n For BIOS systems, MBR or GPT partition tables are supported.\n
on PC BIOS systems, an empty partition of 1MB must be added at the first\n To use GPT on PC BIOS systems an empty partition of 1MB must be added\n
2GB of the disk with the partition type \`BIOS Boot'.\n at the first 2GB of the disk with the TOGGLE \`bios_grub' enabled.\n
${BOLD}NOTE: you don't need this on EFI systems.${RESET}\n\n ${BOLD}NOTE: you don't need this on EFI systems.${RESET}\n\n
For EFI systems, GPT is mandatory and a FAT32 partition with at least 100MB\n For EFI systems GPT is mandatory and a FAT32 partition with at least\n
must be created with the partition type \`EFI System'. This will be used as\n 100MB must be created with the TOGGLE \`boot', this will be used as\n
the EFI System Partition. This partition must have the mountpoint \`/boot/efi'.\n\n EFI System Partition. This partition must have mountpoint as \`/boot/efi'.\n\n
At least 1 partition is required for the rootfs (/). For this partition,\n At least 1 partition is required for the rootfs (/).\n
at least 2GB is required, but more is recommended. The rootfs partition\n For swap, RAM*2 must be really enough. For / 600MB are required.\n\n
should have the partition type \`Linux Filesystem'. For swap, RAM*2\n
should be enough and the partition type \`Linux swap' should be used.\n\n
${BOLD}WARNING: /usr is not supported as a separate partition.${RESET}\n ${BOLD}WARNING: /usr is not supported as a separate partition.${RESET}\n
${RESET}\n" 23 80 ${RESET}\n" 18 80
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
while true; do while true; do
clear; $software $device; PARTITIONS_DONE=1 clear; $software $device; PARTITIONS_DONE=1
@ -590,8 +575,7 @@ menu_locale() {
set_locale() { set_locale() {
if [ -f $TARGETDIR/etc/default/libc-locales ]; then if [ -f $TARGETDIR/etc/default/libc-locales ]; then
local LOCALE="$(get_option LOCALE)" local LOCALE=$(get_option LOCALE)
: "${LOCALE:=C.UTF-8}"
sed -i -e "s|LANG=.*|LANG=$LOCALE|g" $TARGETDIR/etc/locale.conf sed -i -e "s|LANG=.*|LANG=$LOCALE|g" $TARGETDIR/etc/locale.conf
# Uncomment locale from /etc/default/libc-locales and regenerate it. # Uncomment locale from /etc/default/libc-locales and regenerate it.
sed -e "/${LOCALE}/s/^\#//" -i $TARGETDIR/etc/default/libc-locales sed -e "/${LOCALE}/s/^\#//" -i $TARGETDIR/etc/default/libc-locales
@ -622,7 +606,7 @@ menu_timezone() {
set_timezone() { set_timezone() {
local TIMEZONE="$(get_option TIMEZONE)" local TIMEZONE="$(get_option TIMEZONE)"
ln -sf "/usr/share/zoneinfo/${TIMEZONE}" "${TARGETDIR}/etc/localtime" sed -i -e "s|#TIMEZONE=.*|TIMEZONE=$TIMEZONE|g" $TARGETDIR/etc/rc.conf
} }
menu_hostname() { menu_hostname() {
@ -639,20 +623,19 @@ menu_hostname() {
} }
set_hostname() { set_hostname() {
local hostname="$(get_option HOSTNAME)" echo $(get_option HOSTNAME) > $TARGETDIR/etc/hostname
echo "${hostname:-void}" > $TARGETDIR/etc/hostname
} }
menu_rootpassword() { menu_rootpassword() {
local _firstpass _secondpass _again _desc local _firstpass _secondpass _desc
while true; do while true; do
if [ -z "${_firstpass}" ]; then if [ -z "${_firstpass}" ]; then
_desc="Enter the root password" _desc="Enter the root password"
else else
_again=" again" _desc="$_desc again"
fi fi
DIALOG --insecure --passwordbox "${_desc}${_again}" ${INPUTSIZE} DIALOG --insecure --passwordbox "${_desc}" ${INPUTSIZE}
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
if [ -z "${_firstpass}" ]; then if [ -z "${_firstpass}" ]; then
_firstpass="$(cat $ANSWER)" _firstpass="$(cat $ANSWER)"
@ -662,7 +645,7 @@ menu_rootpassword() {
if [ -n "${_firstpass}" -a -n "${_secondpass}" ]; then if [ -n "${_firstpass}" -a -n "${_secondpass}" ]; then
if [ "${_firstpass}" != "${_secondpass}" ]; then if [ "${_firstpass}" != "${_secondpass}" ]; then
INFOBOX "Passwords do not match! Please enter again." 6 60 INFOBOX "Passwords do not match! Please enter again." 6 60
unset _firstpass _secondpass _again unset _firstpass _secondpass
sleep 2 && clear && continue sleep 2 && clear && continue
fi fi
set_option ROOTPASSWORD "${_firstpass}" set_option ROOTPASSWORD "${_firstpass}"
@ -676,30 +659,22 @@ menu_rootpassword() {
} }
set_rootpassword() { set_rootpassword() {
echo "root:$(get_option ROOTPASSWORD)" | chroot $TARGETDIR chpasswd -c SHA512 echo "root:$(get_option ROOTPASSWORD)" | chpasswd -R $TARGETDIR -c SHA512
} }
menu_useraccount() { menu_useraccount() {
local _firstpass _secondpass _desc _again local _firstpass _secondpass _desc
local _groups _status _group _checklist local _groups _status _group _checklist
local _preset _userlogin local _preset
while true; do while true; do
_preset=$(get_option USERLOGIN) _preset=$(get_option USERLOGIN)
[ -z "$_preset" ] && _preset="void" [ -z "$_preset" ] && _preset="void"
DIALOG --inputbox "Enter a primary login name:" ${INPUTSIZE} "$_preset" DIALOG --inputbox "Enter a primary login name:" ${INPUTSIZE} "$_preset"
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
_userlogin="$(cat $ANSWER)" set_option USERLOGIN "$(cat $ANSWER)"
# based on useradd(8) § Caveats USERLOGIN_DONE=1
if [ "${#_userlogin}" -le 32 ] && [[ "${_userlogin}" =~ ^[a-z_][a-z0-9_-]*[$]?$ ]]; then break
set_option USERLOGIN "${_userlogin}"
USERLOGIN_DONE=1
break
else
INFOBOX "Invalid login name! Please try again." 6 60
unset _userlogin
sleep 2 && clear && continue
fi
else else
return return
fi fi
@ -708,7 +683,7 @@ menu_useraccount() {
while true; do while true; do
_preset=$(get_option USERNAME) _preset=$(get_option USERNAME)
[ -z "$_preset" ] && _preset="Void User" [ -z "$_preset" ] && _preset="Void User"
DIALOG --inputbox "Enter a display name for login '$(get_option USERLOGIN)' :" \ DIALOG --inputbox "Enter a user name for login '$(get_option USERLOGIN)' :" \
${INPUTSIZE} "$_preset" ${INPUTSIZE} "$_preset"
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
set_option USERNAME "$(cat $ANSWER)" set_option USERNAME "$(cat $ANSWER)"
@ -723,9 +698,9 @@ menu_useraccount() {
if [ -z "${_firstpass}" ]; then if [ -z "${_firstpass}" ]; then
_desc="Enter the password for login '$(get_option USERLOGIN)'" _desc="Enter the password for login '$(get_option USERLOGIN)'"
else else
_again=" again" _desc="$_desc again"
fi fi
DIALOG --insecure --passwordbox "${_desc}${_again}" ${INPUTSIZE} DIALOG --insecure --passwordbox "${_desc}" ${INPUTSIZE}
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
if [ -z "${_firstpass}" ]; then if [ -z "${_firstpass}" ]; then
_firstpass="$(cat $ANSWER)" _firstpass="$(cat $ANSWER)"
@ -735,7 +710,7 @@ menu_useraccount() {
if [ -n "${_firstpass}" -a -n "${_secondpass}" ]; then if [ -n "${_firstpass}" -a -n "${_secondpass}" ]; then
if [ "${_firstpass}" != "${_secondpass}" ]; then if [ "${_firstpass}" != "${_secondpass}" ]; then
INFOBOX "Passwords do not match! Please enter again." 6 60 INFOBOX "Passwords do not match! Please enter again." 6 60
unset _firstpass _secondpass _again unset _firstpass _secondpass
sleep 2 && clear && continue sleep 2 && clear && continue
fi fi
set_option USERPASSWORD "${_firstpass}" set_option USERPASSWORD "${_firstpass}"
@ -747,7 +722,7 @@ menu_useraccount() {
fi fi
done done
_groups="wheel,audio,video,floppy,cdrom,optical,kvm,users,xbuilder" _groups="wheel,audio,video,floppy,cdrom,optical,kvm,xbuilder"
while true; do while true; do
_desc="Select group membership for login '$(get_option USERLOGIN)':" _desc="Select group membership for login '$(get_option USERLOGIN)':"
for _group in $(cat /etc/group); do for _group in $(cat /etc/group); do
@ -759,10 +734,6 @@ menu_useraccount() {
else else
_status=on _status=on
fi fi
# ignore the groups of root, existing users, and package groups
if [[ "${_gid}" -ge 1000 || "${_group}" = "_"* || "${_group}" =~ ^(root|nogroup|chrony|dbus|lightdm|polkitd)$ ]]; then
continue
fi
if [ -z "${_checklist}" ]; then if [ -z "${_checklist}" ]; then
_checklist="${_group} ${_group}:${_gid} ${_status}" _checklist="${_group} ${_group}:${_gid} ${_status}"
else else
@ -781,11 +752,14 @@ menu_useraccount() {
} }
set_useraccount() { set_useraccount() {
[ -z "$USERACCOUNT_DONE" ] && return [ -z "$USERLOGIN_DONE" ] && return
chroot $TARGETDIR useradd -m -G "$(get_option USERGROUPS)" \ [ -z "$USERPASSWORD_DONE" ] && return
-c "$(get_option USERNAME)" "$(get_option USERLOGIN)" [ -z "$USERNAME_DONE" ] && return
[ -z "$USERGROUPS_DONE" ] && return
useradd -R $TARGETDIR -m -G $(get_option USERGROUPS) \
-c "$(get_option USERNAME)" $(get_option USERLOGIN)
echo "$(get_option USERLOGIN):$(get_option USERPASSWORD)" | \ echo "$(get_option USERLOGIN):$(get_option USERPASSWORD)" | \
chroot $TARGETDIR chpasswd -c SHA512 chpasswd -R $TARGETDIR -c SHA512
} }
menu_bootloader() { menu_bootloader() {
@ -827,37 +801,27 @@ set_bootloader() {
chroot $TARGETDIR grub-install $grub_args $dev >$LOG 2>&1 chroot $TARGETDIR grub-install $grub_args $dev >$LOG 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \ DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \
failed to install GRUB to $dev!\nCheck $LOG for errors." ${MSGBOXSIZE} failed to install GRUB to $dev!\nCheck $LOG for errors." ${MSGBOXSIZE}
DIE 1 DIE 1
fi fi
echo "Running grub-mkconfig on $TARGETDIR..." >$LOG echo "Running grub-mkconfig on $TARGETDIR..." >$LOG
chroot $TARGETDIR grub-mkconfig -o /boot/grub/grub.cfg >$LOG 2>&1 chroot $TARGETDIR grub-mkconfig -o /boot/grub/grub.cfg >$LOG 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
DIALOG --msgbox "${BOLD}${RED}ERROR${RESET}: \ DIALOG --msgbox "${BOLD}${RED}ERROR${RESET}: \
failed to run grub-mkconfig!\nCheck $LOG for errors." ${MSGBOXSIZE} failed to run grub-mkconfig!\nCheck $LOG for errors." ${MSGBOXSIZE}
DIE 1 DIE 1
fi fi
} }
test_network() { test_network() {
# Reset the global variable to ensure that network is accessible for this test. rm -f xtraeme.asc && \
NETWORK_DONE= xbps-uhelper fetch http://alpha.de.repo.voidlinux.org/live/xtraeme.asc >$LOG 2>&1
if [ $? -eq 0 ]; then
rm -f otime && \
xbps-uhelper fetch https://repo-default.voidlinux.org/current/otime >$LOG 2>&1
local status=$?
rm -f otime
if [ "$status" -eq 0 ]; then
DIALOG --msgbox "Network is working properly!" ${MSGBOXSIZE} DIALOG --msgbox "Network is working properly!" ${MSGBOXSIZE}
NETWORK_DONE=1 NETWORK_DONE=1
return 1 return 1
fi fi
if [ "$1" = "nm" ]; then DIALOG --msgbox "Network is inaccessible, please set it up properly." ${MSGBOXSIZE}
DIALOG --msgbox "Network Manager is enabled but network is inaccessible, please set it up externally with nmcli, nmtui, or the Network Manager tray applet." ${MSGBOXSIZE}
else
DIALOG --msgbox "Network is inaccessible, please set it up properly." ${MSGBOXSIZE}
fi
} }
configure_wifi() { configure_wifi() {
@ -867,40 +831,32 @@ configure_wifi() {
"SSID:" 1 1 "" 1 16 30 0 \ "SSID:" 1 1 "" 1 16 30 0 \
"Encryption:" 2 1 "" 2 16 4 3 \ "Encryption:" 2 1 "" 2 16 4 3 \
"Password:" 3 1 "" 3 16 63 0 || return 1 "Password:" 3 1 "" 3 16 63 0 || return 1
readarray -t values <<<$(cat $ANSWER) set -- $(cat $ANSWER)
ssid="${values[0]}"; enc="${values[1]}"; pass="${values[2]}" ssid="$1"; enc="$2"; pass="$3";
if [ -z "$ssid" ]; then if [ -z "$ssid" ]; then
DIALOG --msgbox "Invalid SSID." ${MSGBOXSIZE} DIALOG --msgbox "Invalid SSID." ${MSGBOXSIZE}
return 1 return 1
elif [ -z "$enc" -o "$enc" != "wep" -a "$enc" != "wpa" ]; then elif [ -z "$enc" -o "$enc" != "wep" -a "$enc" != "wpa" ]; then
DIALOG --msgbox "Invalid encryption type (possible values: wep or wpa)." ${MSGBOXSIZE} DIALOG --msgbox "Invalid encryption type (possible values: wep or wpa)." ${MSXBOXSIZE}
return 1 return 1
elif [ -z "$pass" ]; then elif [ -z "$pass" ]; then
DIALOG --msgbox "Invalid AP password." ${MSGBOXSIZE} DIALOG --msgbox "Invalid AP password." ${MSGBOXSIZE}
fi fi
# reset the configuration to the default, if necessary rm -f ${_wpasupconf%.conf}-${dev}.conf
# otherwise backup the configuration cp -f ${_wpasupconf} ${_wpasupconf%.conf}-${dev}.conf
if [ -f ${_wpasupconf}.orig ]; then
cp -f ${_wpasupconf}.orig ${_wpasupconf}
else
cp -f ${_wpasupconf} ${_wpasupconf}.orig
fi
if [ "$enc" = "wep" ]; then if [ "$enc" = "wep" ]; then
cat << EOF >> ${_wpasupconf} echo "network={" >> ${_wpasupconf%.conf}-${dev}.conf
network={ echo " ssid=\"$ssid\"" >> ${_wpasupconf%.conf}-${dev}.conf
ssid="$ssid" echo " wep_key0=\"$pass\"" >> ${_wpasupconf%.conf}-${dev}.conf
wep_key0="$pass" echo " wep_tx_keyidx=0" >> ${_wpasupconf%.conf}-${dev}.conf
wep_tx_keyidx=0 echo " auth_alg=SHARED" >> ${_wpasupconf%.conf}-${dev}.conf
auth_alg=SHARED echo "}" >> ${_wpasupconf%.conf}-${dev}.conf
}
EOF
else else
wpa_passphrase "$ssid" "$pass" >> ${_wpasupconf} wpa_passphrase "$ssid" "$pass" >> ${_wpasupconf%.conf}-${dev}.conf
fi fi
sv restart wpa_supplicant
configure_net_dhcp $dev configure_net_dhcp $dev
return $? return $?
} }
@ -918,7 +874,7 @@ configure_net() {
} }
iface_setup() { iface_setup() {
ip addr show dev $1 | grep -q -e 'inet ' -e 'inet6 ' ip addr show dev $1|grep -q 'inet '
return $? return $?
} }
@ -927,14 +883,13 @@ configure_net_dhcp() {
iface_setup $dev iface_setup $dev
if [ $? -eq 1 ]; then if [ $? -eq 1 ]; then
sv restart dhcpcd 2>&1 | tee $LOG | \ dhcpcd -t 10 -w -4 -L $dev -e "wpa_supplicant_conf=/etc/wpa_supplicant/wpa_supplicant-${dev}.conf" 2>&1 | tee $LOG | \
DIALOG --progressbox "Initializing $dev via DHCP..." ${WIDGET_SIZE} DIALOG --progressbox "Initializing $dev via DHCP..." ${WIDGET_SIZE}
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} failed to run dhcpcd. See $LOG for details." ${MSGBOXSIZE} DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} failed to run dhcpcd. See $LOG for details." ${MSGBOXSIZE}
return 1 return 1
fi fi
export -f iface_setup iface_setup $dev
timeout 10s bash -c "while true; do iface_setup $dev; sleep 0.25; done"
if [ $? -eq 1 ]; then if [ $? -eq 1 ]; then
DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} DHCP request failed for $dev. Check $LOG for errors." ${MSGBOXSIZE} DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} DHCP request failed for $dev. Check $LOG for errors." ${MSGBOXSIZE}
return 1 return 1
@ -963,13 +918,13 @@ configure_net_static() {
DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} Failed to bring $dev interface." ${MSGBOXSIZE} DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} Failed to bring $dev interface." ${MSGBOXSIZE}
return 1 return 1
fi fi
echo "running: ip addr add $ip dev $dev" >$LOG echo "running: ip addr add $ip dev $dev"
ip addr add $ip dev $dev >$LOG 2>&1 ip addr add $ip dev $dev >$LOG 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} Failed to set ip to the $dev interface." ${MSGBOXSIZE} DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} Failed to set ip to the $dev interface." ${MSGBOXSIZE}
return 1 return 1
fi fi
ip route add default via $gw >$LOG 2>&1 ip route add $gw dev $dev >$LOG 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} failed to setup your gateway." ${MSGBOXSIZE} DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} failed to setup your gateway." ${MSGBOXSIZE}
return 1 return 1
@ -985,11 +940,6 @@ configure_net_static() {
menu_network() { menu_network() {
local dev addr f DEVICES local dev addr f DEVICES
if [ -e /var/service/NetworkManager ]; then
test_network nm
return
fi
for f in $(ls /sys/class/net); do for f in $(ls /sys/class/net); do
[ "$f" = "lo" ] && continue [ "$f" = "lo" ] && continue
addr=$(cat /sys/class/net/$f/address) addr=$(cat /sys/class/net/$f/address)
@ -1007,17 +957,6 @@ menu_network() {
fi fi
} }
validate_useraccount() {
# don't check that USERNAME has been set because it can be empty
local USERLOGIN=$(get_option USERLOGIN)
local USERPASSWORD=$(get_option USERPASSWORD)
local USERGROUPS=$(get_option USERGROUPS)
if [ -n "$USERLOGIN" ] && [ -n "$USERPASSWORD" ] && [ -n "$USERGROUPS" ]; then
USERACCOUNT_DONE=1
fi
}
validate_filesystems() { validate_filesystems() {
local mnts dev size fstype mntpt mkfs rootfound fmt local mnts dev size fstype mntpt mkfs rootfound fmt
local usrfound efi_system_partition local usrfound efi_system_partition
@ -1067,7 +1006,7 @@ as FAT32, mountpoint /boot/efi and at least with 100MB of size." ${MSGBOXSIZE}
create_filesystems() { create_filesystems() {
local mnts dev mntpt fstype fspassno mkfs size rv uuid local mnts dev mntpt fstype fspassno mkfs size rv uuid
mnts=$(grep -E '^MOUNTPOINT.*' $CONF_FILE | sort -k 5) mnts=$(grep -E '^MOUNTPOINT.*' $CONF_FILE)
set -- ${mnts} set -- ${mnts}
while [ $# -ne 0 ]; do while [ $# -ne 0 ]; do
dev=$2; fstype=$3; mntpt="$5"; mkfs=$6 dev=$2; fstype=$3; mntpt="$5"; mkfs=$6
@ -1092,7 +1031,7 @@ failed to activate swap on $dev!\ncheck $LOG for errors." ${MSGBOXSIZE}
fi fi
# Add entry for target fstab # Add entry for target fstab
uuid=$(blkid -o value -s UUID "$dev") uuid=$(blkid -o value -s UUID "$dev")
echo "UUID=$uuid none swap defaults 0 0" >>$TARGET_FSTAB echo "UUID=$uuid none swap sw 0 0" >>$TARGET_FSTAB
continue continue
fi fi
@ -1128,7 +1067,7 @@ failed to mount $dev on ${mntpt}! check $LOG for errors." ${MSGBOXSIZE}
fi fi
# Add entry to target fstab # Add entry to target fstab
uuid=$(blkid -o value -s UUID "$dev") uuid=$(blkid -o value -s UUID "$dev")
if [ "$fstype" = "f2fs" -o "$fstype" = "btrfs" -o "$fstype" = "xfs" ]; then if [ "$fstype" = "f2fs" ]; then
fspassno=0 fspassno=0
else else
fspassno=1 fspassno=1
@ -1137,7 +1076,7 @@ failed to mount $dev on ${mntpt}! check $LOG for errors." ${MSGBOXSIZE}
done done
# mount all filesystems in target rootfs # mount all filesystems in target rootfs
mnts=$(grep -E '^MOUNTPOINT.*' $CONF_FILE | sort -k 5) mnts=$(grep -E '^MOUNTPOINT.*' $CONF_FILE)
set -- ${mnts} set -- ${mnts}
while [ $# -ne 0 ]; do while [ $# -ne 0 ]; do
dev=$2; fstype=$3; mntpt="$5" dev=$2; fstype=$3; mntpt="$5"
@ -1153,12 +1092,7 @@ failed to mount $dev on $mntpt! check $LOG for errors." ${MSGBOXSIZE}
fi fi
# Add entry to target fstab # Add entry to target fstab
uuid=$(blkid -o value -s UUID "$dev") uuid=$(blkid -o value -s UUID "$dev")
if [ "$fstype" = "f2fs" -o "$fstype" = "btrfs" -o "$fstype" = "xfs" ]; then echo "UUID=$uuid $mntpt $fstype defaults 0 2" >>$TARGET_FSTAB
fspassno=0
else
fspassno=2
fi
echo "UUID=$uuid $mntpt $fstype defaults 0 $fspassno" >>$TARGET_FSTAB
done done
} }
@ -1166,24 +1100,34 @@ mount_filesystems() {
for f in sys proc dev; do for f in sys proc dev; do
[ ! -d $TARGETDIR/$f ] && mkdir $TARGETDIR/$f [ ! -d $TARGETDIR/$f ] && mkdir $TARGETDIR/$f
echo "Mounting $TARGETDIR/$f..." >$LOG echo "Mounting $TARGETDIR/$f..." >$LOG
mount --rbind /$f $TARGETDIR/$f >$LOG 2>&1 mount --bind /$f $TARGETDIR/$f >$LOG 2>&1
done done
} }
umount_filesystems() { umount_filesystems() {
local mnts="$(grep -E '^MOUNTPOINT.*swap.*$' $CONF_FILE | sort -r -k 5)" local f
for f in sys/fs/fuse/connections sys proc dev; do
echo "Unmounting $TARGETDIR/$f..." >$LOG
umount $TARGETDIR/$f >$LOG 2>&1
done
local mnts="$(grep -E '^MOUNTPOINT.*$' $CONF_FILE)"
set -- ${mnts} set -- ${mnts}
while [ $# -ne 0 ]; do while [ $# -ne 0 ]; do
local dev=$2; local fstype=$3 local dev=$2; local fstype=$3; local mntpt=$5
shift 6 shift 6
if [ "$fstype" = "swap" ]; then if [ "$fstype" = "swap" ]; then
echo "Disabling swap space on $dev..." >$LOG echo "Disabling swap space on $dev..." >$LOG
swapoff $dev >$LOG 2>&1 swapoff $dev >$LOG 2>&1
continue continue
fi fi
if [ "$mntpt" != "/" ]; then
echo "Unmounting $TARGETDIR/$mntpt..." >$LOG
umount $TARGETDIR/$mntpt >$LOG 2>&1
fi
done done
echo "Unmounting $TARGETDIR..." >$LOG echo "Unmounting $TARGETDIR..." >$LOG
umount -R $TARGETDIR >$LOG 2>&1 umount $TARGETDIR >$LOG 2>&1
} }
log_and_count() { log_and_count() {
@ -1222,16 +1166,14 @@ copy_rootfs() {
install_packages() { install_packages() {
local _grub= _syspkg= local _grub= _syspkg=
if [ "$(get_option BOOTLOADER)" != none ]; then if [ -n "$EFI_SYSTEM" ]; then
if [ -n "$EFI_SYSTEM" ]; then if [ $EFI_FW_BITS -eq 32 ]; then
if [ $EFI_FW_BITS -eq 32 ]; then _grub="grub-i386-efi"
_grub="grub-i386-efi"
else
_grub="grub-x86_64-efi"
fi
else else
_grub="grub" _grub="grub-x86_64-efi"
fi fi
else
_grub="grub"
fi fi
_syspkg="base-system" _syspkg="base-system"
@ -1239,10 +1181,6 @@ install_packages() {
mkdir -p $TARGETDIR/var/db/xbps/keys $TARGETDIR/usr/share mkdir -p $TARGETDIR/var/db/xbps/keys $TARGETDIR/usr/share
cp -a /usr/share/xbps.d $TARGETDIR/usr/share/ cp -a /usr/share/xbps.d $TARGETDIR/usr/share/
cp /var/db/xbps/keys/*.plist $TARGETDIR/var/db/xbps/keys cp /var/db/xbps/keys/*.plist $TARGETDIR/var/db/xbps/keys
if [ -n "$MIRROR_DONE" ]; then
mkdir -p $TARGETDIR/etc
cp -a /etc/xbps.d $TARGETDIR/etc
fi
mkdir -p $TARGETDIR/boot/grub mkdir -p $TARGETDIR/boot/grub
_arch=$(xbps-uhelper arch) _arch=$(xbps-uhelper arch)
@ -1255,51 +1193,11 @@ install_packages() {
DIE 1 DIE 1
fi fi
xbps-reconfigure -r $TARGETDIR -f base-files >/dev/null 2>&1 xbps-reconfigure -r $TARGETDIR -f base-files >/dev/null 2>&1
stdbuf -oL chroot $TARGETDIR xbps-reconfigure -a 2>&1 | \ chroot $TARGETDIR xbps-reconfigure -a
DIALOG --title "Configuring base system packages..." --programbox 24 80
if [ $? -ne 0 ]; then
DIE 1
fi
} }
menu_services() { enable_dhcpd() {
local sv _status _checklist="" ln -sf /etc/sv/dhcpcd $TARGETDIR/etc/runit/runsvdir/default/dhcpcd
find $TARGETDIR/etc/runit/runsvdir/default -mindepth 1 -maxdepth 1 -xtype d -printf '%f\n' | sort -u > "$TARGET_SERVICES"
while true; do
while read -r sv; do
if [ -n "$sv" ]; then
if grep -qx "$sv" "$TARGET_SERVICES" 2>/dev/null; then
_status=on
else
_status=off
fi
_checklist+=" ${sv} ${sv} ${_status}"
fi
done < <(find $TARGETDIR/etc/sv -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | \
# filter out services that probably shouldn't be messed with
grep -Ev '^(agetty-(tty[1-9]|generic|serial)|udevd|sulogin)$' | sort -u)
echo "$_checklist" 1>&2
DIALOG --no-tags --checklist "Select services to enable:" 20 60 18 ${_checklist}
if [ $? -eq 0 ]; then
comm -13 "$TARGET_SERVICES" <(tr ' ' '\n' "$ANSWER") | while read -r sv; do
enable_service "$sv"
done
comm -23 "$TARGET_SERVICES" <(tr ' ' '\n' "$ANSWER") | while read -r sv; do
disable_service "$sv"
done
break
else
return
fi
done
}
enable_service() {
ln -sf "/etc/sv/$1" "$TARGETDIR/etc/runit/runsvdir/default/$1"
}
disable_service() {
rm -f "$TARGETDIR/etc/runit/runsvdir/default/$1"
} }
menu_install() { menu_install() {
@ -1326,16 +1224,6 @@ please do so before starting the installation.${RESET}" ${MSGBOXSIZE}
return 1 return 1
fi fi
# Validate useraccount. All parameters must be set (name, password, login name, groups).
validate_useraccount
if [ -z "$USERACCOUNT_DONE" ]; then
DIALOG --yesno "${BOLD}The user account is not set up properly.${RESET}\n\n
${BOLD}${RED}WARNING: no user will be created. You will only be able to login \
with the root user in your new system.${RESET}\n\n
${BOLD}Do you want to continue?${RESET}" 10 60 || return
fi
DIALOG --yesno "${BOLD}The following operations will be executed:${RESET}\n\n DIALOG --yesno "${BOLD}The following operations will be executed:${RESET}\n\n
${BOLD}${TARGETFS}${RESET}\n ${BOLD}${TARGETFS}${RESET}\n
${BOLD}${RED}WARNING: data on partitions will be COMPLETELY DESTROYED for new \ ${BOLD}${RED}WARNING: data on partitions will be COMPLETELY DESTROYED for new \
@ -1346,7 +1234,6 @@ ${BOLD}Do you want to continue?${RESET}" 20 80 || return
# Create and mount filesystems # Create and mount filesystems
create_filesystems create_filesystems
SOURCE_DONE="$(get_option SOURCE)"
# If source not set use defaults. # If source not set use defaults.
if [ "$(get_option SOURCE)" = "local" -o -z "$SOURCE_DONE" ]; then if [ "$(get_option SOURCE)" = "local" -o -z "$SOURCE_DONE" ]; then
copy_rootfs copy_rootfs
@ -1359,8 +1246,7 @@ ${BOLD}Do you want to continue?${RESET}" 20 80 || return
# Remove live user. # Remove live user.
echo "Removing $USERNAME live user from targetdir ..." >$LOG echo "Removing $USERNAME live user from targetdir ..." >$LOG
chroot $TARGETDIR userdel -r $USERNAME >$LOG 2>&1 chroot $TARGETDIR userdel -r $USERNAME >$LOG 2>&1
rm -f $TARGETDIR/etc/sudoers.d/99-void-live sed -i -e "/$USERNAME ALL=.*/d" $TARGETDIR/etc/sudoers
sed -i "s,GETTY_ARGS=\"--noclear -a $USERNAME\",GETTY_ARGS=\"--noclear\",g" $TARGETDIR/etc/sv/agetty-tty1/conf
TITLE="Check $LOG for details ..." TITLE="Check $LOG for details ..."
INFOBOX "Rebuilding initramfs for target ..." 4 60 INFOBOX "Rebuilding initramfs for target ..." 4 60
echo "Rebuilding initramfs for target ..." >$LOG echo "Rebuilding initramfs for target ..." >$LOG
@ -1369,21 +1255,7 @@ ${BOLD}Do you want to continue?${RESET}" 20 80 || return
chroot $TARGETDIR dracut --no-hostonly --add-drivers "ahci" --force >>$LOG 2>&1 chroot $TARGETDIR dracut --no-hostonly --add-drivers "ahci" --force >>$LOG 2>&1
INFOBOX "Removing temporary packages from target ..." 4 60 INFOBOX "Removing temporary packages from target ..." 4 60
echo "Removing temporary packages from target ..." >$LOG echo "Removing temporary packages from target ..." >$LOG
TO_REMOVE="dialog xtools-minimal xmirror" xbps-remove -r $TARGETDIR -Ry dialog >>$LOG 2>&1
# only remove espeakup and brltty if it wasn't enabled in the live environment
if ! [ -e "/var/service/espeakup" ]; then
TO_REMOVE+=" espeakup"
fi
if ! [ -e "/var/service/brltty" ]; then
TO_REMOVE+=" brltty"
fi
if [ "$(get_option BOOTLOADER)" = none ]; then
TO_REMOVE+=" grub-x86_64-efi grub-i386-efi grub"
fi
# uninstall separately to minimise errors
for pkg in $TO_REMOVE; do
xbps-remove -r $TARGETDIR -Ry "$pkg" >>$LOG 2>&1
done
rmdir $TARGETDIR/mnt/target rmdir $TARGETDIR/mnt/target
else else
# mount required fs # mount required fs
@ -1411,7 +1283,6 @@ ${BOLD}Do you want to continue?${RESET}" 20 80 || return
# Copy /etc/skel files for root. # Copy /etc/skel files for root.
cp $TARGETDIR/etc/skel/.[bix]* $TARGETDIR/root cp $TARGETDIR/etc/skel/.[bix]* $TARGETDIR/root
NETWORK_DONE="$(get_option NETWORK)"
# network settings for target # network settings for target
if [ -n "$NETWORK_DONE" ]; then if [ -n "$NETWORK_DONE" ]; then
local net="$(get_option NETWORK)" local net="$(get_option NETWORK)"
@ -1421,40 +1292,39 @@ ${BOLD}Do you want to continue?${RESET}" 20 80 || return
# network type empty??!!! # network type empty??!!!
: :
elif [ "$_type" = "dhcp" ]; then elif [ "$_type" = "dhcp" ]; then
if $(echo $_dev|egrep -q "^wl.*" 2>/dev/null); then if [ -f /etc/wpa_supplicant/wpa_supplicant-${_dev}.conf ]; then
cp /etc/wpa_supplicant/wpa_supplicant.conf $TARGETDIR/etc/wpa_supplicant cp /etc/wpa_supplicant/wpa_supplicant-${_dev}.conf $TARGETDIR/etc/wpa_supplicant
enable_service wpa_supplicant ln -sf /etc/sv/dhcpcd-${_dev} $TARGETDIR/etc/runit/runsvdir/default/dhcpcd-${_dev}
else
enable_dhcpd
fi fi
enable_service dhcpcd
elif [ -n "$_dev" -a "$_type" = "static" ]; then elif [ -n "$_dev" -a "$_type" = "static" ]; then
# static IP through dhcpcd. # static IP through dhcpcd.
mv $TARGETDIR/etc/dhcpcd.conf $TARGETDIR/etc/dhcpcd.conf.orig mv $TARGETDIR/etc/dhcpcd.conf $TARGETDIR/etc/dhdpcd.conf.orig
echo "# Static IP configuration set by the void-installer for $_dev." \ echo "# Static IP configuration set by the void-installer for $_dev." \
>$TARGETDIR/etc/dhcpcd.conf >$TARGETDIR/etc/dhcpcd.conf
echo "interface $_dev" >>$TARGETDIR/etc/dhcpcd.conf echo "interface $_dev" >>$TARGETDIR/etc/dhcpcd.conf
echo "static ip_address=$_ip" >>$TARGETDIR/etc/dhcpcd.conf echo "static ip_address=$_ip" >>$TARGETDIR/etc/dhcpcd.conf
echo "static routers=$_gw" >>$TARGETDIR/etc/dhcpcd.conf echo "static routers=$_gw" >>$TARGETDIR/etc/dhcpcd.conf
echo "static domain_name_servers=$_dns1 $_dns2" >>$TARGETDIR/etc/dhcpcd.conf echo "static domain_name_servers=$_dns1 $_dns2" >>$TARGETDIR/etc/dhcpcd.conf
enable_service dhcpcd enable_dhcpd
fi fi
fi fi
if [ -d $TARGETDIR/etc/sudoers.d ]; then if [ -f $TARGETDIR/etc/sudoers ]; then
USERLOGIN="$(get_option USERLOGIN)" USERLOGIN="$(get_option USERLOGIN)"
if [ -z "$(echo $(get_option USERGROUPS) | grep -w wheel)" -a -n "$USERLOGIN" ]; then if [ -z "$(echo $(get_option USERGROUPS) | grep -w wheel)" -a -n "$USERLOGIN" ]; then
# enable sudo for primary user USERLOGIN who is not member of wheel # enable sudo for primary user USERLOGIN who is not member of wheel
echo "# Enable sudo for login '$USERLOGIN'" > "$TARGETDIR/etc/sudoers.d/$USERLOGIN" echo "# Enable sudo for login '$USERLOGIN'" >> $TARGETDIR/etc/sudoers
echo "$USERLOGIN ALL=(ALL:ALL) ALL" >> "$TARGETDIR/etc/sudoers.d/$USERLOGIN" echo "$USERLOGIN ALL=(ALL) ALL" >> $TARGETDIR/etc/sudoers
else else
# enable the sudoers entry for members of group wheel # enable the sudoers entry for members of group wheel
echo "%wheel ALL=(ALL:ALL) ALL" > "$TARGETDIR/etc/sudoers.d/wheel" sed -i $TARGETDIR/etc/sudoers \
-e "s;#.*%wheel ALL=(ALL) ALL;%wheel ALL=(ALL) ALL;"
fi fi
unset USERLOGIN unset USERLOGIN
fi fi
# clean up polkit rule - it's only useful in live systems
rm -f $TARGETDIR/etc/polkit-1/rules.d/void-live.rules
# enable text console for grub if chosen # enable text console for grub if chosen
if [ "$(get_option TEXTCONSOLE)" = "1" ]; then if [ "$(get_option TEXTCONSOLE)" = "1" ]; then
sed -i $TARGETDIR/etc/default/grub \ sed -i $TARGETDIR/etc/default/grub \
@ -1464,10 +1334,6 @@ ${BOLD}Do you want to continue?${RESET}" 20 80 || return
# install bootloader. # install bootloader.
set_bootloader set_bootloader
# menu for enabling services
menu_services
sync && sync && sync sync && sync && sync
# unmount all filesystems. # unmount all filesystems.
@ -1489,14 +1355,12 @@ menu_source() {
DIALOG --title " Select installation source " \ DIALOG --title " Select installation source " \
--menu "$MENULABEL" 8 70 0 \ --menu "$MENULABEL" 8 70 0 \
"Local" "Packages from ISO image" \ "Local" "Packages from ISO image" \
"Network" "Base system only, downloaded from official repository" "Network" "Base system only, downloaded from official reposity"
case "$(cat $ANSWER)" in case "$(cat $ANSWER)" in
"Local") src="local";; "Local") src="local";;
"Network") src="net"; "Network") src="net";
if [ -z "$NETWORK_DONE" ]; then if [ -z "$NETWORK_DONE" ]; then
if test_network; then menu_network;
menu_network
fi
fi;; fi;;
*) return 1;; *) return 1;;
esac esac
@ -1504,18 +1368,12 @@ menu_source() {
set_option SOURCE $src set_option SOURCE $src
} }
menu_mirror() {
xmirror 2>$LOG && MIRROR_DONE=1
}
menu() { menu() {
local AFTER_HOSTNAME
if [ -z "$DEFITEM" ]; then if [ -z "$DEFITEM" ]; then
DEFITEM="Keyboard" DEFITEM="Keyboard"
fi fi
if xbps-uhelper arch | grep -qe '-musl$'; then if xbps-uhelper arch | grep -qe '-musl$'; then
AFTER_HOSTNAME="Timezone"
DIALOG --default-item $DEFITEM \ DIALOG --default-item $DEFITEM \
--extra-button --extra-label "Settings" \ --extra-button --extra-label "Settings" \
--title " Void Linux installation menu " \ --title " Void Linux installation menu " \
@ -1523,7 +1381,6 @@ menu() {
"Keyboard" "Set system keyboard" \ "Keyboard" "Set system keyboard" \
"Network" "Set up the network" \ "Network" "Set up the network" \
"Source" "Set source installation" \ "Source" "Set source installation" \
"Mirror" "Select XBPS mirror" \
"Hostname" "Set system hostname" \ "Hostname" "Set system hostname" \
"Timezone" "Set system time zone" \ "Timezone" "Set system time zone" \
"RootPassword" "Set system root password" \ "RootPassword" "Set system root password" \
@ -1534,7 +1391,6 @@ menu() {
"Install" "Start installation with saved settings" \ "Install" "Start installation with saved settings" \
"Exit" "Exit installation" "Exit" "Exit installation"
else else
AFTER_HOSTNAME="Locale"
DIALOG --default-item $DEFITEM \ DIALOG --default-item $DEFITEM \
--extra-button --extra-label "Settings" \ --extra-button --extra-label "Settings" \
--title " Void Linux installation menu " \ --title " Void Linux installation menu " \
@ -1542,7 +1398,6 @@ menu() {
"Keyboard" "Set system keyboard" \ "Keyboard" "Set system keyboard" \
"Network" "Set up the network" \ "Network" "Set up the network" \
"Source" "Set source installation" \ "Source" "Set source installation" \
"Mirror" "Select XBPS mirror" \
"Hostname" "Set system hostname" \ "Hostname" "Set system hostname" \
"Locale" "Set system locale" \ "Locale" "Set system locale" \
"Timezone" "Set system time zone" \ "Timezone" "Set system time zone" \
@ -1559,7 +1414,6 @@ menu() {
# Show settings # Show settings
cp $CONF_FILE /tmp/conf_hidden.$$; cp $CONF_FILE /tmp/conf_hidden.$$;
sed -i "s/^ROOTPASSWORD.*/ROOTPASSWORD <-hidden->/" /tmp/conf_hidden.$$ sed -i "s/^ROOTPASSWORD.*/ROOTPASSWORD <-hidden->/" /tmp/conf_hidden.$$
sed -i "s/^USERPASSWORD.*/USERPASSWORD <-hidden->/" /tmp/conf_hidden.$$
DIALOG --title "Saved settings for installation" --textbox /tmp/conf_hidden.$$ 14 60 DIALOG --title "Saved settings for installation" --textbox /tmp/conf_hidden.$$ 14 60
rm /tmp/conf_hidden.$$ rm /tmp/conf_hidden.$$
return return
@ -1568,13 +1422,12 @@ menu() {
case $(cat $ANSWER) in case $(cat $ANSWER) in
"Keyboard") menu_keymap && [ -n "$KEYBOARD_DONE" ] && DEFITEM="Network";; "Keyboard") menu_keymap && [ -n "$KEYBOARD_DONE" ] && DEFITEM="Network";;
"Network") menu_network && [ -n "$NETWORK_DONE" ] && DEFITEM="Source";; "Network") menu_network && [ -n "$NETWORK_DONE" ] && DEFITEM="Source";;
"Source") menu_source && [ -n "$SOURCE_DONE" ] && DEFITEM="Mirror";; "Source") menu_source && [ -n "$SOURCE_DONE" ] && DEFITEM="Hostname";;
"Mirror") menu_mirror && [ -n "$MIRROR_DONE" ] && DEFITEM="Hostname";; "Hostname") menu_hostname && [ -n "$HOSTNAME_DONE" ] && DEFITEM="Locale";;
"Hostname") menu_hostname && [ -n "$HOSTNAME_DONE" ] && DEFITEM="$AFTER_HOSTNAME";;
"Locale") menu_locale && [ -n "$LOCALE_DONE" ] && DEFITEM="Timezone";; "Locale") menu_locale && [ -n "$LOCALE_DONE" ] && DEFITEM="Timezone";;
"Timezone") menu_timezone && [ -n "$TIMEZONE_DONE" ] && DEFITEM="RootPassword";; "Timezone") menu_timezone && [ -n "$TIMEZONE_DONE" ] && DEFITEM="RootPassword";;
"RootPassword") menu_rootpassword && [ -n "$ROOTPASSWORD_DONE" ] && DEFITEM="UserAccount";; "RootPassword") menu_rootpassword && [ -n "$ROOTPASSWORD_DONE" ] && DEFITEM="UserAccount";;
"UserAccount") menu_useraccount && [ -n "$USERLOGIN_DONE" ] && [ -n "$USERPASSWORD_DONE" ] \ "UserAccount") menu_useraccount && [ -n "$USERNAME_DONE" ] && [ -n "$USERPASSWORD_DONE" ] \
&& DEFITEM="BootLoader";; && DEFITEM="BootLoader";;
"BootLoader") menu_bootloader && [ -n "$BOOTLOADER_DONE" ] && DEFITEM="Partition";; "BootLoader") menu_bootloader && [ -n "$BOOTLOADER_DONE" ] && DEFITEM="Partition";;
"Partition") menu_partitions && [ -n "$PARTITIONS_DONE" ] && DEFITEM="Filesystems";; "Partition") menu_partitions && [ -n "$PARTITIONS_DONE" ] && DEFITEM="Filesystems";;
@ -1603,7 +1456,7 @@ Welcome to the Void Linux installation. A simple and minimal \
Linux distribution made from scratch and built from the source package tree \ Linux distribution made from scratch and built from the source package tree \
available for XBPS, a new alternative binary package system.\n\n available for XBPS, a new alternative binary package system.\n\n
The installation should be pretty straightforward. If you are in trouble \ The installation should be pretty straightforward. If you are in trouble \
please join us at ${BOLD}#voidlinux${RESET} on ${BOLD}irc.libera.chat${RESET}.\n\n please join us at ${BOLD}#voidlinux${RESET} on ${BOLD}irc.freenode.org${RESET}.\n\n
${BOLD}https://www.voidlinux.org${RESET}\n\n" 16 80 ${BOLD}https://www.voidlinux.org${RESET}\n\n" 16 80
while true; do while true; do

View File

@ -1,6 +1,6 @@
UI vesamenu.c32 UI vesamenu.c32
PROMPT 0 PROMPT 0
TIMEOUT 150 TIMEOUT 100
ONTIMEOUT linux ONTIMEOUT linux
MENU TABMSG Press ENTER to boot or TAB to edit a menu entry MENU TABMSG Press ENTER to boot or TAB to edit a menu entry
@ -8,13 +8,13 @@ MENU AUTOBOOT BIOS default device boot in # second{,s}...
MENU BACKGROUND @@SPLASHIMAGE@@ MENU BACKGROUND @@SPLASHIMAGE@@
MENU WIDTH 78 MENU WIDTH 78
MENU MARGIN 1 MENU MARGIN 1
MENU ROWS 12 MENU ROWS 4
MENU VSHIFT 2 MENU VSHIFT 2
MENU TIMEOUTROW 13 MENU TIMEOUTROW 8
MENU TABMSGROW 2 MENU TABMSGROW 2
MENU CMDLINEROW 16 MENU CMDLINEROW 11
MENU HELPMSGROW 20 MENU HELPMSGROW 16
MENU HELPMSGENDROW 34 MENU HELPMSGENDROW 29
MENU COLOR title * #FF5255FF * MENU COLOR title * #FF5255FF *
MENU COLOR border * #00000000 #00000000 none MENU COLOR border * #00000000 #00000000 none
@ -24,45 +24,11 @@ LABEL linux
MENU LABEL @@BOOT_TITLE@@ @@KERNVER@@ @@ARCH@@ MENU LABEL @@BOOT_TITLE@@ @@KERNVER@@ @@ARCH@@
KERNEL /boot/vmlinuz KERNEL /boot/vmlinuz
APPEND initrd=/boot/initrd root=live:CDLABEL=VOID_LIVE init=/sbin/init ro rd.luks=0 rd.md=0 rd.dm=0 loglevel=4 vconsole.unicode=1 vconsole.keymap=@@KEYMAP@@ locale.LANG=@@LOCALE@@ @@BOOT_CMDLINE@@ APPEND initrd=/boot/initrd root=live:CDLABEL=VOID_LIVE init=/sbin/init ro rd.luks=0 rd.md=0 rd.dm=0 loglevel=4 vconsole.unicode=1 vconsole.keymap=@@KEYMAP@@ locale.LANG=@@LOCALE@@ @@BOOT_CMDLINE@@
LABEL linuxram LABEL linuxram
MENU LABEL @@BOOT_TITLE@@ @@KERNVER@@ @@ARCH@@ (RAM) MENU LABEL @@BOOT_TITLE@@ @@KERNVER@@ @@ARCH@@ (RAM)
KERNEL /boot/vmlinuz KERNEL /boot/vmlinuz
APPEND initrd=/boot/initrd root=live:CDLABEL=VOID_LIVE init=/sbin/init ro rd.luks=0 rd.md=0 rd.dm=0 loglevel=4 vconsole.unicode=1 vconsole.keymap=@@KEYMAP@@ locale.LANG=@@LOCALE@@ @@BOOT_CMDLINE@@ rd.live.ram APPEND initrd=/boot/initrd root=live:CDLABEL=VOID_LIVE init=/sbin/init ro rd.luks=0 rd.md=0 rd.dm=0 loglevel=4 vconsole.unicode=1 vconsole.keymap=@@KEYMAP@@ locale.LANG=@@LOCALE@@ @@BOOT_CMDLINE@@ rd.live.ram
LABEL linuxnogfx
MENU LABEL @@BOOT_TITLE@@ @@KERNVER@@ @@ARCH@@ (graphics disabled)
KERNEL /boot/vmlinuz
APPEND initrd=/boot/initrd root=live:CDLABEL=VOID_LIVE init=/sbin/init ro rd.luks=0 rd.md=0 rd.dm=0 loglevel=4 vconsole.unicode=1 vconsole.keymap=@@KEYMAP@@ locale.LANG=@@LOCALE@@ @@BOOT_CMDLINE@@ nomodeset
LABEL linuxa11y
MENU LABEL @@BOOT_TITLE@@ @@KERNVER@@ @@ARCH@@ with ^speech
KERNEL /boot/vmlinuz
APPEND initrd=/boot/initrd root=live:CDLABEL=VOID_LIVE init=/sbin/init ro rd.luks=0 rd.md=0 rd.dm=0 loglevel=4 vconsole.unicode=1 vconsole.keymap=@@KEYMAP@@ locale.LANG=@@LOCALE@@ @@BOOT_CMDLINE@@ live.accessibility live.autologin
LABEL linuxa11yram
MENU LABEL @@BOOT_TITLE@@ @@KERNVER@@ @@ARCH@@ with speech (^RAM)
KERNEL /boot/vmlinuz
APPEND initrd=/boot/initrd root=live:CDLABEL=VOID_LIVE init=/sbin/init ro rd.luks=0 rd.md=0 rd.dm=0 loglevel=4 vconsole.unicode=1 vconsole.keymap=@@KEYMAP@@ locale.LANG=@@LOCALE@@ @@BOOT_CMDLINE@@ live.accessibility live.autologin rd.live.ram
LABEL linuxa11ynogfx
MENU LABEL @@BOOT_TITLE@@ @@KERNVER@@ @@ARCH@@ with speech (^graphics disabled)
KERNEL /boot/vmlinuz
APPEND initrd=/boot/initrd root=live:CDLABEL=VOID_LIVE init=/sbin/init ro rd.luks=0 rd.md=0 rd.dm=0 loglevel=4 vconsole.unicode=1 vconsole.keymap=@@KEYMAP@@ locale.LANG=@@LOCALE@@ @@BOOT_CMDLINE@@ live.accessibility live.autologin nomodeset
LABEL c LABEL c
MENU LABEL Boot first HD found by BIOS MENU LABEL Boot first HD found by BIOS
COM32 chain.c32 COM32 chain.c32
APPEND hd0 APPEND hd0
LABEL memtest
MENU LABEL Run ^Memtest86+ (RAM test)
LINUX /boot/memtest.bin
LABEL reboot
MENU LABEL Re^boot
COM32 reboot.c32
LABEL poweroff
MENU LABEL ^Power Off
COM32 poweroff.c32

175
lib.sh → lib.sh.in Executable file → Normal file
View File

@ -6,39 +6,6 @@
readonly LIBTOOLS="cp echo cat printf which mountpoint mount umount modprobe" readonly LIBTOOLS="cp echo cat printf which mountpoint mount umount modprobe"
readonly HOSTARCH=$(xbps-uhelper arch) readonly HOSTARCH=$(xbps-uhelper arch)
is_target_native() {
# Because checking whether the target is runnable is ugly, stuff
# it into a single function. That makes it easy to check anywhere.
local target_arch
target_arch="$1"
# this will cover most
if [ "${target_arch%-musl}" = "${HOSTARCH%-musl}" ]; then
return 0
fi
case "$HOSTARCH" in
# ppc64le has no 32-bit variant, only runs its own stuff
ppc64le*) return 1 ;;
# x86_64 also runs i686
x86_64*) test -z "${target_arch##*86*}" ;;
# aarch64 also runs armv*
aarch64*) test -z "${target_arch##armv*}" ;;
# bigendian ppc64 also runs ppc
ppc64*) test "${target_arch%-musl}" = "ppc" ;;
# anything else is just their own
*) return 1 ;;
esac
return $?
}
version() (
set +u
[ -n "$PROGNAME" ] && printf "%s " "$PROGNAME"
echo "$(cat ./version) ${MKLIVE_REV:-"$(git -c safe.directory="$(pwd)" rev-parse --short HEAD 2> /dev/null)"}"
)
info_msg() { info_msg() {
# This function handles the printing that is bold within all # This function handles the printing that is bold within all
# scripts. This is a convenience function so that the rather ugly # scripts. This is a convenience function so that the rather ugly
@ -88,7 +55,7 @@ mount_pseudofs() {
# pseudofs isn't already mounted. If it already is then # pseudofs isn't already mounted. If it already is then
# this is virtually impossible to troubleshoot because it # this is virtually impossible to troubleshoot because it
# looks like the subsequent umount just isn't working. # looks like the subsequent umount just isn't working.
mount -r --rbind /$f "$ROOTFS/$f" --make-rslave mount -r --bind /$f "$ROOTFS/$f"
fi fi
done done
if ! mountpoint -q "$ROOTFS/tmp" ; then if ! mountpoint -q "$ROOTFS/tmp" ; then
@ -105,7 +72,7 @@ umount_pseudofs() {
# contingency where the psuedofs mounts are not present. # contingency where the psuedofs mounts are not present.
if [ -d "${ROOTFS}" ]; then if [ -d "${ROOTFS}" ]; then
for f in dev proc sys; do for f in dev proc sys; do
umount -R -f "$ROOTFS/$f" >/dev/null 2>&1 umount -f "$ROOTFS/$f" >/dev/null 2>&1
done done
fi fi
umount -f "$ROOTFS/tmp" >/dev/null 2>&1 umount -f "$ROOTFS/tmp" >/dev/null 2>&1
@ -113,7 +80,9 @@ umount_pseudofs() {
run_cmd_target() { run_cmd_target() {
info_msg "Running $* for target $XBPS_TARGET_ARCH ..." info_msg "Running $* for target $XBPS_TARGET_ARCH ..."
if is_target_native "$XBPS_TARGET_ARCH"; then if [ "$XBPS_TARGET_ARCH" = "${HOSTARCH}" ] ||
[ -z "${XBPS_TARGET_ARCH##*86*}" ] &&
[ -z "${HOSTARCH##*86*}" ] ; then
# This is being run on the same architecture as the host, # This is being run on the same architecture as the host,
# therefore we should set XBPS_ARCH. # therefore we should set XBPS_ARCH.
if ! eval XBPS_ARCH="$XBPS_TARGET_ARCH" "$@" ; then if ! eval XBPS_ARCH="$XBPS_TARGET_ARCH" "$@" ; then
@ -165,8 +134,15 @@ cleanup_chroot() {
# Un-Mount the pseudofs mounts if they were mounted # Un-Mount the pseudofs mounts if they were mounted
umount_pseudofs umount_pseudofs
# If a QEMU binary was copied in, remove that as well
if [ -x "$ROOTFS/usr/bin/$QEMU_BIN" ] ; then
rm "$ROOTFS/usr/bin/$QEMU_BIN"
fi
} }
# TODO: Figure out how to register the binfmt for x86_64 and for i686
# to facilitate building on alien build systems.
register_binfmt() { register_binfmt() {
# This function sets up everything that is needed to be able to # This function sets up everything that is needed to be able to
# chroot into a ROOTFS and be able to run commands there. This # chroot into a ROOTFS and be able to run commands there. This
@ -189,69 +165,60 @@ register_binfmt() {
set_target_arch_from_platform set_target_arch_from_platform
fi fi
# In the special case where the build is native we can return case "${XBPS_TARGET_ARCH}" in
# without doing anything else
# This is only a basic check for identical archs, with more careful
# checks below for cases like ppc64 -> ppc and x86_64 -> i686.
_hostarch="${HOSTARCH%-musl}"
_targetarch="${XBPS_TARGET_ARCH%-musl}"
if [ "$_hostarch" = "$_targetarch" ] ; then
return
fi
case "${_targetarch}" in
armv*) armv*)
# TODO: detect aarch64 hosts that run 32 bit ARM without qemu (some cannot)
if ( [ "${_targetarch}" = "armv6l" ] && [ "${_hostarch}" = "armv7l" ] ) ; then
return
fi
if [ "${_targetarch}" = "armv5tel" -a \
\( "${_hostarch}" = "armv6l" -o "${_hostarch}" = "armv7l" \) ] ; then
return
fi
_cpu=arm _cpu=arm
_magic="\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00"
_mask="\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff"
QEMU_BIN=qemu-arm-static
;; ;;
aarch64) aarch64*)
_cpu=aarch64 _cpu=aarch64
_magic="\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7"
_mask="\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff"
QEMU_BIN=qemu-aarch64-static
;; ;;
ppc64le) ppc64le*)
_cpu=ppc64le _cpu=ppc64le
_magic="\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15\x00"
_mask="\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\x00"
QEMU_BIN=qemu-ppc64le-static
;; ;;
ppc64) ppc64*)
_cpu=ppc64 _cpu=ppc64
_magic="\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15"
_mask="\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff"
QEMU_BIN=qemu-ppc64-static
;; ;;
ppc) ppc*)
if [ "$_hostarch" = "ppc64" ] ; then
return
fi
_cpu=ppc _cpu=ppc
_magic="\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14"
_mask="\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff"
QEMU_BIN=qemu-ppc-static
;; ;;
mipsel) mipsel*)
if [ "$_hostarch" = "mips64el" ] ; then
return
fi
_cpu=mipsel _cpu=mipsel
_magic="\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00"
_mask="\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff"
QEMU_BIN=qemu-mipsel-static
;; ;;
x86_64) *86*)
_cpu=x86_64 info_msg "FIXME: Assuming that x86 instructions are native"
;; QEMU_BIN=NATIVE
i686)
if [ "$_hostarch" = "x86_64" ] ; then
return
fi
_cpu=i386
;;
riscv64)
_cpu=riscv64
;; ;;
*) *)
die "Unknown target architecture!" die "Unknown target architecture!"
;; ;;
esac esac
# In the special case where the build is native we can return
# without doing anything else
if [ "$QEMU_BIN" = "NATIVE" ] ; then
return
fi
# For builds that do not match the host architecture, the correct # For builds that do not match the host architecture, the correct
# qemu binary will be required. # qemu binary will be required.
QEMU_BIN="qemu-${_cpu}"
if ! $QEMU_BIN -version >/dev/null 2>&1; then if ! $QEMU_BIN -version >/dev/null 2>&1; then
die "$QEMU_BIN binary is missing in your system, exiting." die "$QEMU_BIN binary is missing in your system, exiting."
fi fi
@ -265,10 +232,18 @@ register_binfmt() {
# Only register if the map is incomplete # Only register if the map is incomplete
if [ ! -f /proc/sys/fs/binfmt_misc/qemu-$_cpu ] ; then if [ ! -f /proc/sys/fs/binfmt_misc/qemu-$_cpu ] ; then
if ! command -v update-binfmts >/dev/null 2>&1; then echo ":qemu-$_cpu:M::$_magic:$_mask:/usr/bin/$QEMU_BIN:" > /proc/sys/fs/binfmt_misc/register 2>/dev/null
die "could not add binfmt: update-binfmts binary is missing in your system" fi
fi
update-binfmts --import "qemu-$_cpu" # If the static binary isn't in the chroot then the chroot will
# fail. The kernel knows about the map but without the static
# version there's no interpreter in the chroot, only the
# dynamically linked one in the host. To simplify things we just
# use the static one always and make sure it shows up at the same
# place in the host and the chroot.
if [ ! -x "$ROOTFS/usr/bin/$QEMU_BIN" ] ; then
install -m755 -D "$(which "$QEMU_BIN")" "$ROOTFS/usr/bin/$QEMU_BIN" ||
die "Could not install $QEMU_BIN to $ROOTFS/usr/bin/"
fi fi
} }
@ -278,16 +253,22 @@ set_target_arch_from_platform() {
# the target architecture, but don't necessarily need to know it # the target architecture, but don't necessarily need to know it
# internally (i.e. only run_cmd_chroot). # internally (i.e. only run_cmd_chroot).
case "$PLATFORM" in case "$PLATFORM" in
rpi-aarch64*) XBPS_TARGET_ARCH="aarch64";; bananapi*) XBPS_TARGET_ARCH="armv7l";;
rpi-armv7l*) XBPS_TARGET_ARCH="armv7l";; beaglebone*) XBPS_TARGET_ARCH="armv7l";;
rpi-armv6l*) XBPS_TARGET_ARCH="armv6l";; cubieboard2*|cubietruck*) XBPS_TARGET_ARCH="armv7l";;
dockstar*) XBPS_TARGET_ARCH="armv5tel";;
pogoplugv4*) XBPS_TARGET_ARCH="armv5tel" ;;
odroid-u2*) XBPS_TARGET_ARCH="armv7l";;
odroid-c2*) XBPS_TARGET_ARCH="aarch64";;
rpi3*) XBPS_TARGET_ARCH="aarch64";;
rpi2*) XBPS_TARGET_ARCH="armv7l";;
rpi*) XBPS_TARGET_ARCH="armv6l";;
usbarmory*) XBPS_TARGET_ARCH="armv7l";;
ci20*) XBPS_TARGET_ARCH="mipsel";;
i686*) XBPS_TARGET_ARCH="i686";; i686*) XBPS_TARGET_ARCH="i686";;
x86_64*) XBPS_TARGET_ARCH="x86_64";; x86_64*) XBPS_TARGET_ARCH="x86_64";;
GCP*) XBPS_TARGET_ARCH="x86_64";; GCP*) XBPS_TARGET_ARCH="x86_64";;
pinebookpro*) XBPS_TARGET_ARCH="aarch64";; pinebookpro*) XBPS_TARGET_ARCH="aarch64";;
pinephone*) XBPS_TARGET_ARCH="aarch64";;
rock64*) XBPS_TARGET_ARCH="aarch64";;
rockpro64*) XBPS_TARGET_ARCH="aarch64";;
*) die "$PROGNAME: Unable to compute target architecture from platform";; *) die "$PROGNAME: Unable to compute target architecture from platform";;
esac esac
@ -300,6 +281,7 @@ set_dracut_args_from_platform() {
# In rare cases it is necessary to set platform specific dracut # In rare cases it is necessary to set platform specific dracut
# args. This is mostly the case on ARM platforms. # args. This is mostly the case on ARM platforms.
case "$PLATFORM" in case "$PLATFORM" in
pogoplugv4*) dracut_args="-o 'btrfs drm i18n resume terminfo'" ;;
*) ;; *) ;;
esac esac
} }
@ -310,25 +292,20 @@ set_cachedir() {
: "${XBPS_CACHEDIR:=--cachedir=$PWD/xbps-cache/${XBPS_TARGET_ARCH}}" : "${XBPS_CACHEDIR:=--cachedir=$PWD/xbps-cache/${XBPS_TARGET_ARCH}}"
} }
rk33xx_flash_uboot() {
local dir="$1"
local dev="$2"
dd if="${dir}/idbloader.img" of="${dev}" seek=64 conv=notrunc,fsync >/dev/null 2>&1
dd if="${dir}/u-boot.itb" of="${dev}" seek=16384 conv=notrunc,fsync >/dev/null 2>&1
}
# These should all resolve even if they won't have the appropriate # These should all resolve even if they won't have the appropriate
# repodata files for the selected architecture. # repodata files for the selected architecture.
: "${XBPS_REPOSITORY:=--repository=https://repo-default.voidlinux.org/current \ : "${XBPS_REPOSITORY:=--repository=http://alpha.de.repo.voidlinux.org/current \
--repository=https://repo-default.voidlinux.org/current/musl \ --repository=http://alpha.de.repo.voidlinux.org/current/musl \
--repository=https://repo-default.voidlinux.org/current/aarch64}" --repository=http://alpha.de.repo.voidlinux.org/current/aarch64}"
# This library is the authoritative source of the platform map, # This library is the authoritative source of the platform map,
# because of this we may need to get this information from the command # because of this we may need to get this information from the command
# line. This select allows us to get that information out. This # line. This select allows us to get that information out. This
# fails silently if the toolname isn't known since this script is # fails silently if the toolname isn't known since this script is
# sourced. # sourced.
case "${1:-}" in case $1 in
platform2arch) platform2arch)
PLATFORM=$2 PLATFORM=$2
set_target_arch_from_platform set_target_arch_from_platform

265
mkimage.sh → mkimage.sh.in Executable file → Normal file
View File

@ -52,37 +52,41 @@ cleanup() {
[ -d "$ROOTFS" ] && rmdir "$ROOTFS" [ -d "$ROOTFS" ] && rmdir "$ROOTFS"
} }
# This script is designed to take in a complete platformfs and spit
# out an image that is suitable for writing with dd. The image is
# configurable in terms of the filesystem layout, but not in terms of
# the installed system itself. Customization to the installed system
# should be made during the mkplatformfs step.
usage() { usage() {
cat <<-EOH cat <<_EOF
Usage: $PROGNAME [options] <platformfs-tarball> Usage: $PROGNAME [options] <rootfs-tarball>
Generates a filesystem image suitable for writing with dd from a PLATFORMFS The <rootfs-tarball> argument expects a tarball generated by void-mkrootfs.
tarball generated by mkplatformfs.sh. The filesystem layout is configurable, The platform is guessed automatically by its name.
but customization of the installed system should be done when generating the
PLATFORMFS. The resulting image will have 2 partitions, /boot and /.
OPTIONS Accepted sizes suffixes: KiB, MiB, GiB, TiB, EiB.
-b <fstype> /boot filesystem type (default: vfat)
-B <bsize> /boot filesystem size (default: 256MiB)
-r <fstype> / filesystem type (default: ext4)
-s <totalsize> Total image size (default: 768MiB)
-o <output> Image filename (default: guessed automatically)
-x <num> Number of threads to use for image compression (default: dynamic)
-h Show this help and exit
-V Show version and exit
Accepted size suffixes: KiB, MiB, GiB, TiB, EiB. OPTIONS
-b <fstype> Set /boot filesystem type (defaults to FAT)
-B <bsize> Set /boot filesystem size (defaults to 64MiB)
-r <fstype> Set / filesystem type (defaults to EXT4)
-s <totalsize> Set total image size (defaults to 2GB)
-o <output> Set image filename (guessed automatically)
-x <num> Use <num> threads to compress the image (dynamic if unset)
-h Show this help
-V Show version
The <platformfs-tarball> argument expects a tarball generated by mkplatformfs.sh. Resulting image will have 2 partitions, /boot and /.
The platform is guessed automatically by its name. _EOF
EOH exit 0
} }
# ######################################## # ########################################
# SCRIPT EXECUTION STARTS HERE # SCRIPT EXECUTION STARTS HERE
# ######################################## # ########################################
while getopts "b:B:o:r:s:x:hV" opt; do while getopts "b:B:o:r:s:x:h:V" opt; do
case $opt in case $opt in
b) BOOT_FSTYPE="$OPTARG";; b) BOOT_FSTYPE="$OPTARG";;
B) BOOT_FSSIZE="$OPTARG";; B) BOOT_FSSIZE="$OPTARG";;
@ -90,18 +94,15 @@ while getopts "b:B:o:r:s:x:hV" opt; do
r) ROOT_FSTYPE="$OPTARG";; r) ROOT_FSTYPE="$OPTARG";;
s) IMGSIZE="$OPTARG";; s) IMGSIZE="$OPTARG";;
x) COMPRESSOR_THREADS="$OPTARG" ;; x) COMPRESSOR_THREADS="$OPTARG" ;;
V) version; exit 0;; V) echo "$PROGNAME @@MKLIVE_VERSION@@"; exit 0;;
h) usage; exit 0;; h) usage;;
*) usage >&2; exit 1;;
esac esac
done done
shift $((OPTIND - 1)) shift $((OPTIND - 1))
ROOTFS_TARBALL="$1" ROOTFS_TARBALL="$1"
if [ -z "$ROOTFS_TARBALL" ]; then if [ -z "$ROOTFS_TARBALL" ]; then
echo "$PROGNAME: no ROOTFS tarball specified" >&2 usage
usage >&2
exit 1
elif [ ! -r "$ROOTFS_TARBALL" ]; then elif [ ! -r "$ROOTFS_TARBALL" ]; then
# In rare cases the tarball can wind up owned by the wrong user. # In rare cases the tarball can wind up owned by the wrong user.
# This leads to confusing failures if execution is allowed to # This leads to confusing failures if execution is allowed to
@ -109,37 +110,24 @@ elif [ ! -r "$ROOTFS_TARBALL" ]; then
die "Cannot read rootfs tarball: $ROOTFS_TARBALL" die "Cannot read rootfs tarball: $ROOTFS_TARBALL"
fi fi
# Setup the platform variable. Here we want just the name and # By default we build all platform images with a 64MiB boot partition
# optionally -musl if this is the musl variant. # formated FAT16, and an approximately 1.9GiB root partition formated
PLATFORM="${ROOTFS_TARBALL#void-}"
PLATFORM="${PLATFORM%-PLATFORMFS*}"
# Be absolutely certain the platform is supported before continuing
case "$PLATFORM" in
rpi-armv6l|rpi-armv7l|rpi-aarch64|GCP|pinebookpro|pinephone|rock64|rockpro64|*-musl);;
*) die "The $PLATFORM is not supported, exiting..."
esac
# Default for bigger boot partion on rk33xx devices since it needs to
# fit at least 2 Kernels + initramfs
case "$PLATFORM" in
pinebookpro*|rock64*|rockpro64*)
: "${BOOT_FSSIZE:=512MiB}"
;;
esac
# By default we build all platform images with a 256MiB boot partition
# formated FAT16, and an approximately 512MiB root partition formatted
# ext4. More exotic combinations are of course possible, but this # ext4. More exotic combinations are of course possible, but this
# combination works on all known platforms. # combination works on all known platforms.
: "${IMGSIZE:=768M}" : "${IMGSIZE:=2G}"
: "${BOOT_FSTYPE:=vfat}" : "${BOOT_FSTYPE:=vfat}"
: "${BOOT_FSSIZE:=256MiB}" : "${BOOT_FSSIZE:=64MiB}"
: "${ROOT_FSTYPE:=ext4}" : "${ROOT_FSTYPE:=ext4}"
# Verify that the required tooling is available # Verify that the required tooling is available
readonly REQTOOLS="sfdisk partx losetup mount truncate mkfs.${BOOT_FSTYPE} mkfs.${ROOT_FSTYPE}" readonly REQTOOLS="sfdisk partx losetup mount truncate mkfs.${BOOT_FSTYPE} mkfs.${ROOT_FSTYPE}"
check_tools check_tools
# Setup the platform variable. Here we want just the name and
# optionally -musl if this is the musl variant.
PLATFORM="${ROOTFS_TARBALL#void-}"
PLATFORM="${PLATFORM%-PLATFORMFS*}"
# This is an awful hack since the script isn't using privesc # This is an awful hack since the script isn't using privesc
# mechanisms selectively. This is a TODO item. # mechanisms selectively. This is a TODO item.
if [ "$(id -u)" -ne 0 ]; then if [ "$(id -u)" -ne 0 ]; then
@ -150,9 +138,15 @@ fi
# will include the platform the image is being built for and the date # will include the platform the image is being built for and the date
# on which it was built. # on which it was built.
if [ -z "$FILENAME" ]; then if [ -z "$FILENAME" ]; then
FILENAME="void-${PLATFORM}-$(date -u +%Y%m%d).img" FILENAME="void-${PLATFORM}-$(date +%Y%m%d).img"
fi fi
# Be absolutely certain the platform is supported before continuing
case "$PLATFORM" in
bananapi|beaglebone|cubieboard2|cubietruck|odroid-c2|odroid-u2|rpi|rpi2|rpi3|usbarmory|GCP|pinebookpro|*-musl);;
*) die "The $PLATFORM is not supported, exiting..."
esac
# Create the base image. This was previously accomplished with dd, # Create the base image. This was previously accomplished with dd,
# but truncate is markedly faster. # but truncate is markedly faster.
info_msg "Creating disk image ($IMGSIZE) ..." info_msg "Creating disk image ($IMGSIZE) ..."
@ -171,55 +165,78 @@ if [ "$BOOT_FSTYPE" = "vfat" ]; then
_args="-I -F16" _args="-I -F16"
fi fi
# These platforms use a partition layout with a small boot BOOT_START=2048
# partition (256M by default) and the rest of the space as the ROOT_START=
# root filesystem. This is the generally preferred disk
# layout for new platforms.
case "$PLATFORM" in case "$PLATFORM" in
pinebookpro*|rock64*|rockpro64*) pinebookpro*)
# rk33xx devices use GPT and need more space reserved BOOT_START=32768
sfdisk "$FILENAME" <<_EOF # Without this, sfdisk creates root partition starting at
label: gpt # 2048, overlapping u-boot reserved space and boot partition.
unit: sectors ROOT_START=$BOOT_START
first-lba: 32768 ;;
name=BootFS, size=${BOOT_FSSIZE}, type=L, bootable, attrs="LegacyBIOSBootable" esac
name=RootFS, type=L
_EOF case "$PLATFORM" in
;; cubieboard2|cubietruck|ci20*|odroid-c2*)
*) # These platforms use a single partition for the entire filesystem.
# The rest use MBR and need less space reserved sfdisk "${FILENAME}" <<_EOF
sfdisk "${FILENAME}" <<_EOF
label: dos label: dos
2048,${BOOT_FSSIZE},b,* 2048,,L
,+,L
_EOF _EOF
;; LOOPDEV=$(losetup --show --find --partscan "$FILENAME")
mkfs.${ROOT_FSTYPE} -O '^64bit,^extra_isize,^has_journal' "${LOOPDEV}p1" >/dev/null 2>&1
mount "${LOOPDEV}p1" "$ROOTFS"
ROOT_UUID=$(blkid -o value -s UUID "${LOOPDEV}p1")
;;
*)
# These platforms use a partition layout with a small boot
# partition (64M by default) and the rest of the space as the
# root filesystem. This is the generally preferred disk
# layout for new platforms.
sfdisk "${FILENAME}" <<_EOF
label: dos
${BOOT_START},${BOOT_FSSIZE},b,*
${ROOT_START},+,L
_EOF
LOOPDEV=$(losetup --show --find --partscan "$FILENAME")
# Normally we need to quote to prevent argument splitting, but
# we explicitly want argument splitting here.
# shellcheck disable=SC2086
mkfs.${BOOT_FSTYPE} $_args "${LOOPDEV}p1" >/dev/null
case "$ROOT_FSTYPE" in
# Because the images produced by this script are generally
# either on single board computers using flash memory or
# in cloud environments that already provide disk
# durability, we shut off the journal for ext filesystems.
# For flash memory this greatly extends the life of the
# memory and for cloud images this lowers the overhead by
# a small amount.
ext[34]) disable_journal="-O ^has_journal";;
esac
mkfs.${ROOT_FSTYPE} "$disable_journal" "${LOOPDEV}p2" >/dev/null 2>&1
mount "${LOOPDEV}p2" "$ROOTFS"
mkdir -p "${ROOTFS}/boot"
mount "${LOOPDEV}p1" "${ROOTFS}/boot"
BOOT_UUID=$(blkid -o value -s UUID "${LOOPDEV}p1")
ROOT_UUID=$(blkid -o value -s UUID "${LOOPDEV}p2")
;;
esac esac
LOOPDEV=$(losetup --show --find --partscan "$FILENAME")
# Normally we need to quote to prevent argument splitting, but
# we explicitly want argument splitting here.
# shellcheck disable=SC2086
mkfs.${BOOT_FSTYPE} $_args "${LOOPDEV}p1" >/dev/null
case "$ROOT_FSTYPE" in
# Because the images produced by this script are generally
# either on single board computers using flash memory or
# in cloud environments that already provide disk
# durability, we shut off the journal for ext filesystems.
# For flash memory this greatly extends the life of the
# memory and for cloud images this lowers the overhead by
# a small amount.
ext[34]) disable_journal="-O ^has_journal";;
esac
mkfs.${ROOT_FSTYPE} ${disable_journal:+"$disable_journal"} "${LOOPDEV}p2" >/dev/null 2>&1
mount "${LOOPDEV}p2" "$ROOTFS"
mkdir -p "${ROOTFS}/boot"
mount "${LOOPDEV}p1" "${ROOTFS}/boot"
BOOT_UUID=$(blkid -o value -s UUID "${LOOPDEV}p1")
ROOT_UUID=$(blkid -o value -s UUID "${LOOPDEV}p2")
ROOT_PARTUUID=$(blkid -o value -s PARTUUID "${LOOPDEV}p2")
# This step unpacks the platformfs tarball made by mkplatformfs.sh. # This step unpacks the platformfs tarball made by mkplatformfs.sh.
info_msg "Unpacking rootfs tarball ..." info_msg "Unpacking rootfs tarball ..."
if [ "$PLATFORM" = "beaglebone" ]; then
# The beaglebone requires some special extra handling. The MLO
# program is a special first stage boot loader that brings up
# enough of the processor to then load u-boot which loads the rest
# of the system. The noauto option also prevents /boot from being
# mounted during system startup.
fstab_args=",noauto"
tar xfp "$ROOTFS_TARBALL" -C "$ROOTFS" ./boot/MLO
tar xfp "$ROOTFS_TARBALL" -C "$ROOTFS" ./boot/u-boot.img
touch "$ROOTFS/boot/uEnv.txt"
umount "$ROOTFS/boot"
fi
# In the general case, its enough to just unpack the ROOTFS_TARBALL # In the general case, its enough to just unpack the ROOTFS_TARBALL
# onto the ROOTFS. This will get a system that is ready to boot, save # onto the ROOTFS. This will get a system that is ready to boot, save
# for the bootloader which is handled later. # for the bootloader which is handled later.
@ -245,10 +262,6 @@ fi
# ensure ssh login is possible for headless setups. # ensure ssh login is possible for headless setups.
sed -i "${ROOTFS}/etc/ssh/sshd_config" -e 's|^#\(PermitRootLogin\) .*|\1 yes|g' sed -i "${ROOTFS}/etc/ssh/sshd_config" -e 's|^#\(PermitRootLogin\) .*|\1 yes|g'
# Grow rootfs to fill the media on boot
run_cmd_target "xbps-install -Syr $ROOTFS cloud-guest-utils"
sed -i "${ROOTFS}/etc/default/growpart" -e 's/#ENABLE/ENABLE/'
# This section does final configuration on the images. In the case of # This section does final configuration on the images. In the case of
# SBCs this writes the bootloader to the image or sets up other # SBCs this writes the bootloader to the image or sets up other
# required binaries to boot. In the case of images destined for a # required binaries to boot. In the case of images destined for a
@ -259,53 +272,33 @@ sed -i "${ROOTFS}/etc/default/growpart" -e 's/#ENABLE/ENABLE/'
# can be found. # can be found.
info_msg "Configuring image for platform $PLATFORM" info_msg "Configuring image for platform $PLATFORM"
case "$PLATFORM" in case "$PLATFORM" in
rpi*) bananapi*|cubieboard2*|cubietruck*)
# use PARTUUID to allow for non-mmc boot without configuration dd if="${ROOTFS}/boot/u-boot-sunxi-with-spl.bin" of="${LOOPDEV}" bs=1024 seek=8 >/dev/null 2>&1
sed -i "s/root=[^ ]*/root=PARTUUID=${ROOT_PARTUUID}/" "${ROOTFS}/boot/cmdline.txt"
;;
rock64*)
rk33xx_flash_uboot "${ROOTFS}/usr/lib/rock64-uboot" "$LOOPDEV"
# populate the extlinux.conf file
cat >"${ROOTFS}/etc/default/extlinux" <<_EOF
TIMEOUT=10
# Defaults to current kernel cmdline if left empty
CMDLINE="panic=10 coherent_pool=1M console=ttyS2,1500000 root=UUID=${ROOT_UUID} rw"
# set this to use a DEVICETREEDIR line in place of an FDT line
USE_DEVICETREEDIR="yes"
# relative dtb path supplied to FDT line, as long as above is unset
DTBPATH=""
_EOF
mkdir -p "${ROOTFS}/boot/extlinux"
run_cmd_chroot "${ROOTFS}" "/etc/kernel.d/post-install/60-extlinux"
cleanup_chroot
;; ;;
rockpro64*) odroid-c2*)
rk33xx_flash_uboot "${ROOTFS}/usr/lib/rockpro64-uboot" "$LOOPDEV" dd if="${ROOTFS}/boot/bl1.bin.hardkernel" of="${LOOPDEV}" bs=1 count=442 >/dev/null 2>&1
# populate the extlinux.conf file dd if="${ROOTFS}/boot/bl1.bin.hardkernel" of="${LOOPDEV}" bs=512 skip=1 seek=1 >/dev/null 2>&1
cat >"${ROOTFS}/etc/default/extlinux" <<_EOF dd if="${ROOTFS}/boot/u-boot.bin" of="${LOOPDEV}" bs=512 seek=97 >/dev/null 2>&1
TIMEOUT=10 ;;
# Defaults to current kernel cmdline if left empty odroid-u2*)
CMDLINE="panic=10 coherent_pool=1M console=ttyS2,115200 root=UUID=${ROOT_UUID} rw" dd if="${ROOTFS}/boot/E4412_S.bl1.HardKernel.bin" of="${LOOPDEV}" seek=1 >/dev/null 2>&1
# set this to use a DEVICETREEDIR line in place of an FDT line dd if="${ROOTFS}/boot/bl2.signed.bin" of="${LOOPDEV}" seek=31 >/dev/null 2>&1
USE_DEVICETREEDIR="yes" dd if="${ROOTFS}/boot/u-boot.bin" of="${LOOPDEV}" seek=63 >/dev/null 2>&1
# relative dtb path supplied to FDT line, as long as above is unset dd if="${ROOTFS}/boot/E4412_S.tzsw.signed.bin" of="${LOOPDEV}" seek=2111 >/dev/null 2>&1
DTBPATH="" ;;
_EOF usbarmory*)
mkdir -p "${ROOTFS}/boot/extlinux" dd if="${ROOTFS}/boot/u-boot.imx" of="${LOOPDEV}" bs=512 seek=2 conv=fsync >/dev/null 2>&1
run_cmd_chroot "${ROOTFS}" "/etc/kernel.d/post-install/60-extlinux" ;;
cleanup_chroot ci20*)
dd if="${ROOTFS}/boot/u-boot-spl.bin" of="${LOOPDEV}" obs=512 seek=1 >/dev/null 2>&1
dd if="${ROOTFS}/boot/u-boot.img" of="${LOOPDEV}" obs=1K seek=14 >/dev/null 2>&1
;; ;;
pinebookpro*) pinebookpro*)
rk33xx_flash_uboot "${ROOTFS}/usr/lib/pinebookpro-uboot" "$LOOPDEV" dd if="${ROOTFS}/boot/idbloader.img" of="${LOOPDEV}" seek=64 conv=notrunc,fsync >/dev/null 2>&1
dd if="${ROOTFS}/boot/u-boot.itb" of="${LOOPDEV}" seek=16384 conv=notrunc,fsync >/dev/null 2>&1
run_cmd_chroot "${ROOTFS}" "xbps-reconfigure -f pinebookpro-kernel" run_cmd_chroot "${ROOTFS}" "xbps-reconfigure -f pinebookpro-kernel"
cleanup_chroot cleanup_chroot
;; ;;
pinephone*)
sed -i "s/CMDLINE=\"\(.*\)\"\$/CMDLINE=\"\1 root=PARTUUID=${ROOT_PARTUUID}\"/" "${ROOTFS}/etc/default/pinephone-uboot-config"
dd if="${ROOTFS}/boot/u-boot-sunxi-with-spl.bin" of="${LOOPDEV}" bs=1024 seek=8 conv=notrunc,fsync >/dev/null 2>&1
run_cmd_chroot "${ROOTFS}" "xbps-reconfigure -f pinephone-kernel"
cleanup_chroot
;;
GCP*) GCP*)
# Google Cloud Platform image configuration for Google Cloud # Google Cloud Platform image configuration for Google Cloud
# Engine. The steps below are built in reference to the # Engine. The steps below are built in reference to the

194
mkiso.sh
View File

@ -1,194 +0,0 @@
#!/bin/sh
set -eu
. ./lib.sh
PROGNAME=$(basename "$0")
ARCH=$(uname -m)
IMAGES="base"
TRIPLET=
REPO=
DATE=$(date -u +%Y%m%d)
usage() {
cat <<-EOH
Usage: $PROGNAME [options ...] [-- mklive options ...]
Wrapper script around mklive.sh for several standard flavors of live images.
Adds void-installer and other helpful utilities to the generated images.
OPTIONS
-a <arch> Set XBPS_ARCH in the image
-b <variant> One of base, enlightenment, xfce, mate, cinnamon, gnome, kde,
lxde, or lxqt (default: base). May be specified multiple times
to build multiple variants
-d <date> Override the datestamp on the generated image (YYYYMMDD format)
-t <arch-date-variant>
Equivalent to setting -a, -b, and -d
-r <repo> Use this XBPS repository. May be specified multiple times
-h Show this help and exit
-V Show version and exit
Other options can be passed directly to mklive.sh by specifying them after the --.
See mklive.sh -h for more details.
EOH
}
while getopts "a:b:d:t:hr:V" opt; do
case $opt in
a) ARCH="$OPTARG";;
b) IMAGES="$OPTARG";;
d) DATE="$OPTARG";;
r) REPO="-r $OPTARG $REPO";;
t) TRIPLET="$OPTARG";;
V) version; exit 0;;
h) usage; exit 0;;
*) usage >&2; exit 1;;
esac
done
shift $((OPTIND - 1))
INCLUDEDIR=$(mktemp -d)
trap "cleanup" INT TERM
cleanup() {
rm -rf "$INCLUDEDIR"
}
include_installer() {
if [ -x installer.sh ]; then
MKLIVE_VERSION="$(PROGNAME='' version)"
installer=$(mktemp)
sed "s/@@MKLIVE_VERSION@@/${MKLIVE_VERSION}/" installer.sh > "$installer"
install -Dm755 "$installer" "$INCLUDEDIR"/usr/bin/void-installer
rm "$installer"
else
echo installer.sh not found >&2
exit 1
fi
}
setup_pipewire() {
PKGS="$PKGS pipewire alsa-pipewire"
mkdir -p "$INCLUDEDIR"/etc/xdg/autostart
ln -sf /usr/share/applications/pipewire.desktop "$INCLUDEDIR"/etc/xdg/autostart/
mkdir -p "$INCLUDEDIR"/etc/pipewire/pipewire.conf.d
ln -sf /usr/share/examples/wireplumber/10-wireplumber.conf "$INCLUDEDIR"/etc/pipewire/pipewire.conf.d/
ln -sf /usr/share/examples/pipewire/20-pipewire-pulse.conf "$INCLUDEDIR"/etc/pipewire/pipewire.conf.d/
mkdir -p "$INCLUDEDIR"/etc/alsa/conf.d
ln -sf /usr/share/alsa/alsa.conf.d/50-pipewire.conf "$INCLUDEDIR"/etc/alsa/conf.d
ln -sf /usr/share/alsa/alsa.conf.d/99-pipewire-default.conf "$INCLUDEDIR"/etc/alsa/conf.d
}
build_variant() {
variant="$1"
shift
IMG=void-live-${ARCH}-${DATE}-${variant}.iso
# el-cheapo installer is unsupported on arm because arm doesn't install a kernel by default
# and to work around that would add too much complexity to it
# thus everyone should just do a chroot install anyways
WANT_INSTALLER=no
case "$ARCH" in
x86_64*|i686*) GRUB_PKGS="grub-i386-efi grub-x86_64-efi"; WANT_INSTALLER=yes ;;
aarch64*) GRUB_PKGS="grub-arm64-efi" ;;
esac
A11Y_PKGS="espeakup void-live-audio brltty"
PKGS="dialog cryptsetup lvm2 mdadm void-docs-browse xtools-minimal xmirror chrony tmux $A11Y_PKGS $GRUB_PKGS"
XORG_PKGS="xorg-minimal xorg-input-drivers xorg-video-drivers setxkbmap xauth font-misc-misc terminus-font dejavu-fonts-ttf orca"
SERVICES="sshd chronyd"
LIGHTDM_SESSION=''
case $variant in
base)
SERVICES="$SERVICES dhcpcd wpa_supplicant acpid"
;;
enlightenment)
PKGS="$PKGS $XORG_PKGS lightdm lightdm-gtk3-greeter enlightenment terminology udisks2 firefox"
SERVICES="$SERVICES acpid dhcpcd wpa_supplicant lightdm dbus polkitd"
LIGHTDM_SESSION=enlightenment
;;
xfce)
PKGS="$PKGS $XORG_PKGS lightdm lightdm-gtk3-greeter xfce4 gnome-themes-standard gnome-keyring network-manager-applet gvfs-afc gvfs-mtp gvfs-smb udisks2 firefox xfce4-pulseaudio-plugin"
SERVICES="$SERVICES dbus lightdm NetworkManager polkitd"
LIGHTDM_SESSION=xfce
;;
mate)
PKGS="$PKGS $XORG_PKGS lightdm lightdm-gtk3-greeter mate mate-extra gnome-keyring network-manager-applet gvfs-afc gvfs-mtp gvfs-smb udisks2 firefox"
SERVICES="$SERVICES dbus lightdm NetworkManager polkitd"
LIGHTDM_SESSION=mate
;;
cinnamon)
PKGS="$PKGS $XORG_PKGS lightdm lightdm-gtk3-greeter cinnamon gnome-keyring colord gnome-terminal gvfs-afc gvfs-mtp gvfs-smb udisks2 firefox"
SERVICES="$SERVICES dbus lightdm NetworkManager polkitd"
LIGHTDM_SESSION=cinnamon
;;
gnome)
PKGS="$PKGS $XORG_PKGS gnome firefox"
SERVICES="$SERVICES dbus gdm NetworkManager polkitd"
;;
kde)
PKGS="$PKGS $XORG_PKGS kde5 konsole firefox dolphin NetworkManager"
SERVICES="$SERVICES dbus NetworkManager sddm"
;;
lxde)
PKGS="$PKGS $XORG_PKGS lxde lightdm lightdm-gtk3-greeter gvfs-afc gvfs-mtp gvfs-smb udisks2 firefox"
SERVICES="$SERVICES acpid dbus dhcpcd wpa_supplicant lightdm polkitd"
LIGHTDM_SESSION=LXDE
;;
lxqt)
PKGS="$PKGS $XORG_PKGS lxqt sddm gvfs-afc gvfs-mtp gvfs-smb udisks2 firefox"
SERVICES="$SERVICES dbus dhcpcd wpa_supplicant sddm polkitd"
;;
*)
>&2 echo "Unknown variant $variant"
exit 1
;;
esac
if [ -n "$LIGHTDM_SESSION" ]; then
mkdir -p "$INCLUDEDIR"/etc/lightdm
echo "$LIGHTDM_SESSION" > "$INCLUDEDIR"/etc/lightdm/.session
# needed to show the keyboard layout menu on the login screen
cat <<- EOF > "$INCLUDEDIR"/etc/lightdm/lightdm-gtk-greeter.conf
[greeter]
indicators = ~host;~spacer;~clock;~spacer;~layout;~session;~a11y;~power
EOF
fi
if [ "$WANT_INSTALLER" = yes ]; then
include_installer
else
mkdir -p "$INCLUDEDIR"/usr/bin
printf "#!/bin/sh\necho 'void-installer is not supported on this live image'\n" > "$INCLUDEDIR"/usr/bin/void-installer
chmod 755 "$INCLUDEDIR"/usr/bin/void-installer
fi
if [ "$variant" != base ]; then
setup_pipewire
fi
./mklive.sh -a "$ARCH" -o "$IMG" -p "$PKGS" -S "$SERVICES" -I "$INCLUDEDIR" ${REPO} "$@"
cleanup
}
if [ ! -x mklive.sh ]; then
echo mklive.sh not found >&2
exit 1
fi
if [ -n "$TRIPLET" ]; then
VARIANT="${TRIPLET##*-}"
REST="${TRIPLET%-*}"
DATE="${REST##*-}"
ARCH="${REST%-*}"
build_variant "$VARIANT" "$@"
else
for image in $IMAGES; do
build_variant "$image" "$@"
done
fi

701
mklive.sh
View File

@ -1,701 +0,0 @@
#!/bin/bash
#
#-
# Copyright (c) 2009-2015 Juan Romero Pardines.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#-
umask 022
. ./lib.sh
REQUIRED_PKGS=(base-files libgcc dash coreutils sed tar gawk squashfs-tools xorriso)
TARGET_PKGS=(base-files)
INITRAMFS_PKGS=(binutils xz device-mapper dhclient dracut-network openresolv)
PACKAGE_LIST=()
IGNORE_PKGS=()
PLATFORMS=()
readonly PROGNAME="$(basename "$0")"
declare -a INCLUDE_DIRS=()
die() {
info_msg "ERROR: $*"
error_out 1 $LINENO
}
print_step() {
CURRENT_STEP=$((CURRENT_STEP+1))
info_msg "[${CURRENT_STEP}/${STEP_COUNT}] $*"
}
mount_pseudofs() {
for f in sys dev proc; do
mkdir -p "$ROOTFS"/$f
mount --rbind /$f "$ROOTFS"/$f
done
}
umount_pseudofs() {
for f in sys dev proc; do
if [ -d "$ROOTFS/$f" ] && ! umount -R -f "$ROOTFS/$f"; then
info_msg "ERROR: failed to unmount $ROOTFS/$f/"
return 1
fi
done
}
error_out() {
trap - INT TERM 0
umount_pseudofs || exit "${1:-0}"
[ -d "$BUILDDIR" ] && [ -z "$KEEP_BUILDDIR" ] && rm -rf --one-file-system "$BUILDDIR"
exit "${1:-0}"
}
usage() {
cat <<-EOH
Usage: $PROGNAME [options]
Generates a basic live ISO image of Void Linux. This ISO image can be written
to a CD/DVD-ROM or any USB stick.
To generate a more complete live ISO image, use mkiso.sh.
OPTIONS
-a <arch> Set XBPS_ARCH in the ISO image
-b <system-pkg> Set an alternative base package (default: base-system)
-r <repo> Use this XBPS repository. May be specified multiple times
-c <cachedir> Use this XBPS cache directory (default: ./xbps-cachedir-<arch>)
-k <keymap> Default keymap to use (default: us)
-l <locale> Default locale to use (default: en_US.UTF-8)
-i <lz4|gzip|bzip2|xz>
Compression type for the initramfs image (default: xz)
-s <gzip|lzo|xz> Compression type for the squashfs image (default: xz)
-o <file> Output file name for the ISO image (default: automatic)
-p "<pkg> ..." Install additional packages in the ISO image
-g "<pkg> ..." Ignore packages when building the ISO image
-I <includedir> Include directory structure under given path in the ROOTFS
-S "<service> ..." Enable services in the ISO image
-e <shell> Default shell of the root user (must be absolute path).
Set the live.shell kernel argument to change the default shell of anon.
-C "<arg> ..." Add additional kernel command line arguments
-P "<platform> ..."
Platforms to enable for aarch64 EFI ISO images (available: pinebookpro, x13s)
-T <title> Modify the bootloader title (default: Void Linux)
-v linux<version> Install a custom Linux version on ISO image (default: linux metapackage).
Also accepts linux metapackages (linux-mainline, linux-lts).
-K Do not remove builddir
-h Show this help and exit
-V Show version and exit
EOH
}
copy_void_keys() {
mkdir -p "$1"/var/db/xbps/keys
cp keys/*.plist "$1"/var/db/xbps/keys
}
copy_dracut_files() {
mkdir -p "$1"/usr/lib/dracut/modules.d/01vmklive
cp dracut/vmklive/* "$1"/usr/lib/dracut/modules.d/01vmklive/
}
copy_autoinstaller_files() {
mkdir -p "$1"/usr/lib/dracut/modules.d/01autoinstaller
cp dracut/autoinstaller/* "$1"/usr/lib/dracut/modules.d/01autoinstaller/
}
install_prereqs() {
XBPS_ARCH=$HOST_ARCH "$XBPS_INSTALL_CMD" -r "$VOIDHOSTDIR" ${XBPS_REPOSITORY} \
-c "$XBPS_HOST_CACHEDIR" -y "${REQUIRED_PKGS[@]}"
[ $? -ne 0 ] && die "Failed to install required software, exiting..."
}
install_target_pkgs() {
XBPS_ARCH=$TARGET_ARCH "$XBPS_INSTALL_CMD" -r "$VOIDTARGETDIR" ${XBPS_REPOSITORY} \
-c "$XBPS_HOST_CACHEDIR" -y "${TARGET_PKGS[@]}"
[ $? -ne 0 ] && die "Failed to install required software, exiting..."
}
post_install_packages() {
# Cleanup and remove useless stuff.
rm -rf "$ROOTFS"/var/cache/* "$ROOTFS"/run/* "$ROOTFS"/var/run/*
# boot failure if disks have raid logical volumes and this isn't loaded
for f in "$ROOTFS/usr/lib/modules/$KERNELVERSION/kernel/drivers/md/dm-raid.ko".*; do
echo "dm-raid" > "$ROOTFS"/etc/modules-load.d/dm-raid.conf
break
done
}
install_packages() {
XBPS_ARCH=$TARGET_ARCH "${XBPS_INSTALL_CMD}" -r "$ROOTFS" \
${XBPS_REPOSITORY} -c "$XBPS_CACHEDIR" -yn "${PACKAGE_LIST[@]}" "${INITRAMFS_PKGS[@]}"
[ $? -ne 0 ] && die "Missing required binary packages, exiting..."
mount_pseudofs
LANG=C XBPS_TARGET_ARCH=$TARGET_ARCH "${XBPS_INSTALL_CMD}" -U -r "$ROOTFS" \
${XBPS_REPOSITORY} -c "$XBPS_CACHEDIR" -y "${PACKAGE_LIST[@]}" "${INITRAMFS_PKGS[@]}"
[ $? -ne 0 ] && die "Failed to install ${PACKAGE_LIST[*]} ${INITRAMFS_PKGS[*]}"
xbps-reconfigure -r "$ROOTFS" -f base-files >/dev/null 2>&1
chroot "$ROOTFS" env -i xbps-reconfigure -f base-files
# Enable choosen UTF-8 locale and generate it into the target rootfs.
if [ -f "$ROOTFS"/etc/default/libc-locales ]; then
sed -e "s/\#\(${LOCALE}.*\)/\1/g" -i "$ROOTFS"/etc/default/libc-locales
fi
if XBPS_ARCH=$BASE_ARCH "$XBPS_QUERY_CMD" -r "$ROOTFS" dkms >/dev/null 2>&1; then
# dkms modules alphabetically before dkms can't configure
# if dkms hasn't configured beforehand to create /var/lib/dkms
chroot "$ROOTFS" env -i xbps-reconfigure dkms
fi
chroot "$ROOTFS" env -i xbps-reconfigure -a
if XBPS_ARCH=$BASE_ARCH "$XBPS_QUERY_CMD" -r "$ROOTFS" dash >/dev/null 2>&1; then
# bash configures alphabetically before dash,
# so if it's installed we should ensure it's /bin/sh
chroot "$ROOTFS" env -i xbps-alternatives -s dash
fi
post_install_packages
}
ignore_packages() {
mkdir -p "$ROOTFS"/etc/xbps.d
for pkg in "${IGNORE_PKGS[@]}"; do
echo "ignorepkg=$pkg" >> "$ROOTFS"/etc/xbps.d/mklive-ignore.conf
done
}
enable_services() {
SERVICE_LIST="$*"
for service in $SERVICE_LIST; do
if ! [ -e $ROOTFS/etc/sv/$service ]; then
die "service $service not in /etc/sv"
fi
ln -sf /etc/sv/$service $ROOTFS/etc/runit/runsvdir/default/
done
}
change_shell() {
chroot "$ROOTFS" chsh -s "$ROOT_SHELL" root
[ $? -ne 0 ] && die "Failed to change the shell for root"
}
copy_include_directories() {
for includedir in "${INCLUDE_DIRS[@]}"; do
info_msg "=> copying include directory '$includedir' ..."
find "$includedir" -mindepth 1 -maxdepth 1 -exec cp -rfpPv {} "$ROOTFS"/ \;
done
}
generate_initramfs() {
local _args
copy_dracut_files "$ROOTFS"
copy_autoinstaller_files "$ROOTFS"
chroot "$ROOTFS" env -i /usr/bin/dracut -N --"${INITRAMFS_COMPRESSION}" \
--add-drivers "ahci" --force-add "vmklive autoinstaller" --omit systemd "/boot/initrd" $KERNELVERSION
[ $? -ne 0 ] && die "Failed to generate the initramfs"
mv "$ROOTFS"/boot/initrd "$BOOT_DIR"
case "$TARGET_ARCH" in
i686*|x86_64*) cp "$ROOTFS/boot/vmlinuz-$KERNELVERSION" "$BOOT_DIR"/vmlinuz ;;
aarch64*) cp "$ROOTFS/boot/vmlinux-$KERNELVERSION" "$BOOT_DIR"/vmlinux ;;
esac
}
cleanup_rootfs() {
for f in "${INITRAMFS_PKGS[@]}"; do
revdeps=$(xbps-query -r "$ROOTFS" -X $f)
if [ -n "$revdeps" ]; then
xbps-pkgdb -r "$ROOTFS" -m auto $f
else
xbps-remove -r "$ROOTFS" -Ry ${f} >/dev/null 2>&1
fi
done
rm -r "$ROOTFS"/usr/lib/dracut/modules.d/01vmklive
rm -r "$ROOTFS"/usr/lib/dracut/modules.d/01autoinstaller
}
generate_isolinux_boot() {
cp -f "$SYSLINUX_DATADIR"/isolinux.bin "$ISOLINUX_DIR"
cp -f "$SYSLINUX_DATADIR"/ldlinux.c32 "$ISOLINUX_DIR"
cp -f "$SYSLINUX_DATADIR"/libcom32.c32 "$ISOLINUX_DIR"
cp -f "$SYSLINUX_DATADIR"/vesamenu.c32 "$ISOLINUX_DIR"
cp -f "$SYSLINUX_DATADIR"/libutil.c32 "$ISOLINUX_DIR"
cp -f "$SYSLINUX_DATADIR"/chain.c32 "$ISOLINUX_DIR"
cp -f "$SYSLINUX_DATADIR"/reboot.c32 "$ISOLINUX_DIR"
cp -f "$SYSLINUX_DATADIR"/poweroff.c32 "$ISOLINUX_DIR"
cp -f isolinux/isolinux.cfg.in "$ISOLINUX_DIR"/isolinux.cfg
cp -f ${SPLASH_IMAGE} "$ISOLINUX_DIR"
sed -i -e "s|@@SPLASHIMAGE@@|$(basename "${SPLASH_IMAGE}")|" \
-e "s|@@KERNVER@@|${KERNELVERSION}|" \
-e "s|@@KEYMAP@@|${KEYMAP}|" \
-e "s|@@ARCH@@|$TARGET_ARCH|" \
-e "s|@@LOCALE@@|${LOCALE}|" \
-e "s|@@BOOT_TITLE@@|${BOOT_TITLE}|" \
-e "s|@@BOOT_CMDLINE@@|${BOOT_CMDLINE}|" \
"$ISOLINUX_DIR"/isolinux.cfg
# include memtest86+
if [ -e "$VOIDTARGETDIR"/boot/memtest86+/memtest.bin ]; then
cp "$VOIDTARGETDIR"/boot/memtest86+/memtest.bin "$BOOT_DIR"
fi
}
generate_grub_efi_boot() {
cp -f grub/grub.cfg "$GRUB_DIR"
cp -f "${SPLASH_IMAGE}" "$ISOLINUX_DIR"
cp -f grub/grub_void.cfg.pre "$GRUB_DIR"/grub_void.cfg
case "$TARGET_ARCH" in
i686*|x86_64*) KERNEL_IMG=vmlinuz; WANT_MEMTEST=yes ;;
aarch64*) KERNEL_IMG=vmlinux; WANT_MEMTEST=no ;;
esac
write_entry() {
local entrytitle="$1" id="$2" cmdline="$3" dtb="$4" hotkey="$5"
cat << EOF >> "$GRUB_DIR"/grub_void.cfg
menuentry "${entrytitle}" --id "${id}" ${hotkey:+--hotkey $hotkey} {
set gfxpayload="keep"
linux (\${voidlive})/boot/${KERNEL_IMG} \\
root=live:CDLABEL=VOID_LIVE ro init=/sbin/init \\
rd.luks=0 rd.md=0 rd.dm=0 loglevel=4 gpt add_efi_memmap \\
vconsole.unicode=1 vconsole.keymap=${KEYMAP} locale.LANG=${LOCALE} ${cmdline}
initrd (\${voidlive})/boot/initrd
EOF
if [ -n "${dtb}" ]; then
printf ' devicetree (${voidlive})/boot/dtbs/%s\n' "${dtb}" >> "$GRUB_DIR"/grub_void.cfg
fi
printf '}\n' >> "$GRUB_DIR"/grub_void.cfg
}
write_entries() {
local title_sfx="$1" id_sfx="$2" cmdline="$3" dtb="$4"
ENTRY_TITLE="${BOOT_TITLE} ${KERNELVERSION} ${title_sfx}(${TARGET_ARCH})"
write_entry "${ENTRY_TITLE}" "linux${id_sfx}" \
"$BOOT_CMDLINE $cmdline" "$dtb"
write_entry "${ENTRY_TITLE} (RAM)" "linuxram${id_sfx}" \
"rd.live.ram $BOOT_CMDLINE $cmdline" "$dtb"
write_entry "${ENTRY_TITLE} (graphics disabled)" "linuxnogfx${id_sfx}" \
"nomodeset $BOOT_CMDLINE $cmdline" "$dtb"
write_entry "${ENTRY_TITLE} with speech" "linuxa11y${id_sfx}" \
"live.accessibility live.autologin $BOOT_CMDLINE $cmdline" "$dtb" 's'
write_entry "${ENTRY_TITLE} with speech (RAM)" "linuxa11yram${id_sfx}" \
"live.accessibility live.autologin rd.live.ram $BOOT_CMDLINE $cmdline" "$dtb" 'r'
write_entry "${ENTRY_TITLE} with speech (graphics disabled)" "linuxa11ynogfx${id_sfx}" \
"live.accessibility live.autologin nomodeset $BOOT_CMDLINE $cmdline" "$dtb" 'g'
}
write_entries
for platform in "${PLATFORMS[@]}"; do
(
. "platforms/${platform}.sh"
if [ -n "$PLATFORM_DTB" ]; then
mkdir -p "${BOOT_DIR}/dtbs/${PLATFORM_DTB%/*}"
cp "${ROOTFS}/boot/dtbs/dtbs-${KERNVER}"*/"${PLATFORM_DTB}" "${BOOT_DIR}/dtbs/${PLATFORM_DTB}"
fi
printf 'submenu "%s" --id platform-%s {\n' \
"${BOOT_TITLE} for ${PLATFORM_NAME:-$platform} >" "${platform}" >> "$GRUB_DIR"/grub_void.cfg
write_entries "for ${PLATFORM_NAME:-$platform} " "-$platform" "$PLATFORM_CMDLINE" "${PLATFORM_DTB}"
printf '}\n' >> "$GRUB_DIR"/grub_void.cfg
)
done
if [ "$WANT_MEMTEST" = yes ]; then
cat << 'EOF' >> "$GRUB_DIR"/grub_void.cfg
if [ "${grub_platform}" == "efi" ]; then
menuentry "Run Memtest86+ (RAM test)" --id memtest {
set gfxpayload="keep"
linux (${voidlive})/boot/memtest.efi
}
else
menuentry "Run Memtest86+ (RAM test)" --id memtest {
set gfxpayload="keep"
linux (${voidlive})/boot/memtest.bin
}
fi
EOF
fi
cat << 'EOF' >> "$GRUB_DIR"/grub_void.cfg
if [ "${grub_platform}" == "efi" ]; then
menuentry 'UEFI Firmware Settings' --hotkey f --id uefifw {
fwsetup
}
fi
menuentry "System restart" --hotkey b --id restart {
echo "System rebooting..."
reboot
}
menuentry "System shutdown" --hotkey p --id poweroff {
echo "System shutting down..."
halt
}
EOF
cat grub/grub_void.cfg.post >> "$GRUB_DIR"/grub_void.cfg
sed -i -e "s|@@SPLASHIMAGE@@|$(basename "${SPLASH_IMAGE}")|" "$GRUB_DIR"/grub_void.cfg
mkdir -p "$GRUB_DIR"/fonts
cp -f "$GRUB_DATADIR"/unicode.pf2 "$GRUB_DIR"/fonts
modprobe -q loop || :
# Create EFI vfat image.
truncate -s 32M "$GRUB_DIR"/efiboot.img >/dev/null 2>&1
mkfs.vfat -F12 -S 512 -n "grub_uefi" "$GRUB_DIR/efiboot.img" >/dev/null 2>&1
GRUB_EFI_TMPDIR="$(mktemp --tmpdir="$BUILDDIR" -dt grub-efi.XXXXX)"
LOOP_DEVICE="$(losetup --show --find "${GRUB_DIR}"/efiboot.img)"
mount -o rw,flush -t vfat "${LOOP_DEVICE}" "${GRUB_EFI_TMPDIR}" >/dev/null 2>&1
build_grub_image() {
local GRUB_ARCH="$1" EFI_ARCH="$2"
xbps-uchroot "$VOIDTARGETDIR" grub-mkstandalone -- \
--directory="/usr/lib/grub/${GRUB_ARCH}-efi" \
--format="${GRUB_ARCH}-efi" \
--output="/tmp/boot${EFI_ARCH,,}.efi" \
"boot/grub/grub.cfg"
if [ $? -ne 0 ]; then
umount "$GRUB_EFI_TMPDIR"
losetup --detach "${LOOP_DEVICE}"
die "Failed to generate EFI loader"
fi
mkdir -p "${GRUB_EFI_TMPDIR}"/EFI/BOOT
cp -f "$VOIDTARGETDIR/tmp/boot${EFI_ARCH,,}.efi" "${GRUB_EFI_TMPDIR}/EFI/BOOT/BOOT${EFI_ARCH^^}.EFI"
}
cp -a "$IMAGEDIR"/boot "$VOIDTARGETDIR"
case "$TARGET_ARCH" in
i686*|x86_64*)
# XXX: why are both built on both arches?
build_grub_image i386 ia32
build_grub_image x86_64 x64
# include memtest86+
if [ -e "$VOIDTARGETDIR"/boot/memtest86+/memtest.efi ]; then
cp "$VOIDTARGETDIR"/boot/memtest86+/memtest.efi "$BOOT_DIR"
fi
;;
aarch64*)
build_grub_image arm64 aa64
;;
esac
umount "$GRUB_EFI_TMPDIR"
losetup --detach "${LOOP_DEVICE}"
rm -rf "$GRUB_EFI_TMPDIR"
}
generate_squashfs() {
umount_pseudofs || exit 1
# Find out required size for the rootfs and create an ext3fs image off it.
ROOTFS_SIZE=$(du --apparent-size -sm "$ROOTFS"|awk '{print $1}')
mkdir -p "$BUILDDIR/tmp/LiveOS"
truncate -s "$((ROOTFS_SIZE+ROOTFS_SIZE))M" \
"$BUILDDIR"/tmp/LiveOS/ext3fs.img >/dev/null 2>&1
mkdir -p "$BUILDDIR/tmp-rootfs"
mkfs.ext3 -F -m1 "$BUILDDIR/tmp/LiveOS/ext3fs.img" >/dev/null 2>&1
mount -o loop "$BUILDDIR/tmp/LiveOS/ext3fs.img" "$BUILDDIR/tmp-rootfs"
cp -a "$ROOTFS"/* "$BUILDDIR"/tmp-rootfs/
umount -f "$BUILDDIR/tmp-rootfs"
mkdir -p "$IMAGEDIR/LiveOS"
"$VOIDHOSTDIR"/usr/bin/mksquashfs "$BUILDDIR/tmp" "$IMAGEDIR/LiveOS/squashfs.img" \
-comp "${SQUASHFS_COMPRESSION}" || die "Failed to generate squashfs image"
chmod 444 "$IMAGEDIR/LiveOS/squashfs.img"
# Remove rootfs and temporary dirs, we don't need them anymore.
rm -rf "$ROOTFS" "$BUILDDIR/tmp-rootfs" "$BUILDDIR/tmp"
}
generate_iso_image() {
local bootloader n
XORRISO_ARGS=(
-iso-level 3 -rock -joliet -joliet-long -max-iso9660-filenames -omit-period
-omit-version-number -relaxed-filenames -allow-lowercase
-volid VOID_LIVE
)
if [ "$IMAGE_TYPE" = hybrid ]; then
XORRISO_ARGS+=(-isohybrid-mbr "$SYSLINUX_DATADIR"/isohdpfx.bin)
fi
n=1
for bootloader in "${BOOTLOADERS[@]}"; do
if (( n > 1 )); then
XORRISO_ARGS+=(-eltorito-alt-boot)
fi
case "${bootloader}" in
grub)
XORRISO_ARGS+=(
-e boot/grub/efiboot.img -no-emul-boot
-isohybrid-gpt-basdat -isohybrid-apm-hfsplus
)
;;
syslinux)
XORRISO_ARGS+=(
-eltorito-boot boot/isolinux/isolinux.bin
-eltorito-catalog boot/isolinux/boot.cat
-no-emul-boot -boot-load-size 4 -boot-info-table
)
;;
esac
n=$(( n + 1 ))
done
XORRISO_ARGS+=(
-output "$OUTPUT_FILE" "$IMAGEDIR"
)
"$VOIDHOSTDIR"/usr/bin/xorriso -as mkisofs "${XORRISO_ARGS[@]}" || die "Failed to generate ISO image"
}
#
# main()
#
while getopts "a:b:r:c:C:T:Kk:l:i:I:S:e:s:o:p:g:v:P:Vh" opt; do
case $opt in
a) TARGET_ARCH="$OPTARG";;
b) BASE_SYSTEM_PKG="$OPTARG";;
r) XBPS_REPOSITORY="--repository=$OPTARG $XBPS_REPOSITORY";;
c) XBPS_CACHEDIR="$OPTARG";;
g) IGNORE_PKGS+=($OPTARG) ;;
K) readonly KEEP_BUILDDIR=1;;
k) KEYMAP="$OPTARG";;
l) LOCALE="$OPTARG";;
i) INITRAMFS_COMPRESSION="$OPTARG";;
I) INCLUDE_DIRS+=("$OPTARG");;
S) SERVICE_LIST="$SERVICE_LIST $OPTARG";;
e) ROOT_SHELL="$OPTARG";;
s) SQUASHFS_COMPRESSION="$OPTARG";;
o) OUTPUT_FILE="$OPTARG";;
p) PACKAGE_LIST+=($OPTARG);;
P) PLATFORMS+=($OPTARG) ;;
C) BOOT_CMDLINE="$OPTARG";;
T) BOOT_TITLE="$OPTARG";;
v) LINUX_VERSION="$OPTARG";;
V) version; exit 0;;
h) usage; exit 0;;
*) usage >&2; exit 1;;
esac
done
shift $((OPTIND - 1))
XBPS_REPOSITORY="$XBPS_REPOSITORY --repository=https://repo-default.voidlinux.org/current --repository=https://repo-default.voidlinux.org/current/musl --repository=https://repo-default.voidlinux.org/current/aarch64"
# Configure dracut to use overlayfs for the writable overlay.
BOOT_CMDLINE="$BOOT_CMDLINE rd.live.overlay.overlayfs=1 "
HOST_ARCH=$(xbps-uhelper arch)
# Set defaults
: ${TARGET_ARCH:=$(xbps-uhelper arch 2>/dev/null || uname -m)}
: ${XBPS_CACHEDIR:="$(pwd -P)"/xbps-cachedir-${TARGET_ARCH}}
: ${XBPS_HOST_CACHEDIR:="$(pwd -P)"/xbps-cachedir-${HOST_ARCH}}
: ${KEYMAP:=us}
: ${LOCALE:=en_US.UTF-8}
: ${INITRAMFS_COMPRESSION:=xz}
: ${SQUASHFS_COMPRESSION:=xz}
: ${BASE_SYSTEM_PKG:=base-system}
: ${BOOT_TITLE:="Void Linux"}
: ${LINUX_VERSION:=linux}
XBPS_TARGET_ARCH="$TARGET_ARCH" register_binfmt
case "$TARGET_ARCH" in
x86_64*|i686*)
BOOTLOADERS=(syslinux grub)
IMAGE_TYPE='hybrid'
TARGET_PKGS+=(syslinux grub-i386-efi grub-x86_64-efi memtest86+)
PLATFORMS=() # arm only
;;
aarch64*)
BOOTLOADERS=(grub)
IMAGE_TYPE='efi'
TARGET_PKGS+=(grub-arm64-efi)
for platform in "${PLATFORMS[@]}"; do
if [ -r "platforms/${platform}.sh" ]; then
. "platforms/${platform}.sh"
else
die "unknown platform: ${platform}"
fi
PACKAGE_LIST+=("${PLATFORM_PKGS[@]}")
unset PLATFORM_PKGS PLATFORM_CMDLINE PLATFORM_DTB
done
;;
*) >&2 echo "architecture $TARGET_ARCH not supported by mklive.sh"; exit 1;;
esac
# Required packages in the image for a working system.
PACKAGE_LIST+=("$BASE_SYSTEM_PKG")
# Check for root permissions.
if [ "$(id -u)" -ne 0 ]; then
die "Must be run as root, exiting..."
fi
trap 'error_out $? $LINENO' INT TERM 0
if [ -n "$ROOTDIR" ]; then
BUILDDIR=$(mktemp --tmpdir="$ROOTDIR" -dt mklive-build.XXXXX)
else
BUILDDIR=$(mktemp --tmpdir="$(pwd -P)" -dt mklive-build.XXXXX)
fi
BUILDDIR=$(readlink -f "$BUILDDIR")
IMAGEDIR="$BUILDDIR/image"
ROOTFS="$IMAGEDIR/rootfs"
VOIDHOSTDIR="$BUILDDIR/void-host"
VOIDTARGETDIR="$BUILDDIR/void-target"
BOOT_DIR="$IMAGEDIR/boot"
ISOLINUX_DIR="$BOOT_DIR/isolinux"
GRUB_DIR="$BOOT_DIR/grub"
CURRENT_STEP=0
STEP_COUNT=10
[ "${IMAGE_TYPE}" = hybrid ] && STEP_COUNT=$((STEP_COUNT+1))
[ "${#INCLUDE_DIRS[@]}" -gt 0 ] && STEP_COUNT=$((STEP_COUNT+1))
[ "${#IGNORE_PKGS[@]}" -gt 0 ] && STEP_COUNT=$((STEP_COUNT+1))
[ -n "$ROOT_SHELL" ] && STEP_COUNT=$((STEP_COUNT+1))
: ${SYSLINUX_DATADIR:="$VOIDTARGETDIR"/usr/lib/syslinux}
: ${GRUB_DATADIR:="$VOIDTARGETDIR"/usr/share/grub}
: ${SPLASH_IMAGE:=data/splash.png}
: ${XBPS_INSTALL_CMD:=xbps-install}
: ${XBPS_REMOVE_CMD:=xbps-remove}
: ${XBPS_QUERY_CMD:=xbps-query}
: ${XBPS_RINDEX_CMD:=xbps-rindex}
: ${XBPS_UHELPER_CMD:=xbps-uhelper}
: ${XBPS_RECONFIGURE_CMD:=xbps-reconfigure}
mkdir -p "$ROOTFS" "$VOIDHOSTDIR" "$VOIDTARGETDIR" "$GRUB_DIR" "$ISOLINUX_DIR"
print_step "Synchronizing XBPS repository data..."
copy_void_keys "$ROOTFS"
XBPS_ARCH=$TARGET_ARCH $XBPS_INSTALL_CMD -r "$ROOTFS" ${XBPS_REPOSITORY} -S
copy_void_keys "$VOIDHOSTDIR"
XBPS_ARCH=$HOST_ARCH $XBPS_INSTALL_CMD -r "$VOIDHOSTDIR" ${XBPS_REPOSITORY} -S
copy_void_keys "$VOIDTARGETDIR"
XBPS_ARCH=$TARGET_ARCH $XBPS_INSTALL_CMD -r "$VOIDTARGETDIR" ${XBPS_REPOSITORY} -S
# Get linux version for ISO
# If linux version option specified use
shopt -s extglob
case "$LINUX_VERSION" in
linux+([0-9.]))
IGNORE_PKGS+=(linux)
PACKAGE_LIST+=("$LINUX_VERSION" linux-base)
;;
linux-@(mainline|lts))
IGNORE_PKGS+=(linux)
PACKAGE_LIST+=("$LINUX_VERSION")
LINUX_VERSION="$(XBPS_ARCH=$TARGET_ARCH $XBPS_QUERY_CMD -r "$ROOTFS" ${XBPS_REPOSITORY:=-R} -x "$LINUX_VERSION" | grep 'linux[0-9._]\+')"
;;
linux)
PACKAGE_LIST+=(linux)
LINUX_VERSION="$(XBPS_ARCH=$TARGET_ARCH $XBPS_QUERY_CMD -r "$ROOTFS" ${XBPS_REPOSITORY:=-R} -x linux | grep 'linux[0-9._]\+')"
;;
*)
die "-v option must be in format linux<version> or linux-<series>"
;;
esac
shopt -u extglob
_kver="$(XBPS_ARCH=$TARGET_ARCH $XBPS_QUERY_CMD -r "$ROOTFS" ${XBPS_REPOSITORY:=-R} -p pkgver $LINUX_VERSION)"
KERNELVERSION=$($XBPS_UHELPER_CMD getpkgversion ${_kver})
if [ "$?" -ne "0" ]; then
die "Failed to find kernel package version"
fi
: ${OUTPUT_FILE="void-live-${TARGET_ARCH}-${KERNELVERSION}-$(date -u +%Y%m%d).iso"}
print_step "Installing software to generate the image: ${REQUIRED_PKGS[*]} ..."
install_prereqs "${REQUIRED_PKGS[@]}"
print_step "Installing software to generate the image: ${TARGET_PKGS[*]} ..."
install_target_pkgs "${TARGET_PKGS[@]}"
mkdir -p "$ROOTFS"/etc
[ -s data/motd ] && cp data/motd "$ROOTFS"/etc
[ -s data/issue ] && cp data/issue "$ROOTFS"/etc
if [ "${#IGNORE_PKGS[@]}" -gt 0 ]; then
print_step "Ignoring packages in the rootfs: ${IGNORE_PKGS[*]} ..."
ignore_packages
fi
print_step "Installing void pkgs into the rootfs: ${PACKAGE_LIST[*]} ..."
install_packages
: ${DEFAULT_SERVICE_LIST:=agetty-tty1 agetty-tty2 agetty-tty3 agetty-tty4 agetty-tty5 agetty-tty6 udevd}
print_step "Enabling services: ${SERVICE_LIST} ..."
enable_services ${DEFAULT_SERVICE_LIST} ${SERVICE_LIST}
if [ -n "$ROOT_SHELL" ]; then
print_step "Changing the root shell ..."
change_shell
fi
if [ "${#INCLUDE_DIRS[@]}" -gt 0 ];then
print_step "Copying directory structures into the rootfs ..."
copy_include_directories
fi
print_step "Generating initramfs image ($INITRAMFS_COMPRESSION)..."
generate_initramfs
if [ "$IMAGE_TYPE" = hybrid ]; then
print_step "Generating isolinux support for PC-BIOS systems..."
generate_isolinux_boot
fi
print_step "Generating GRUB support for EFI systems..."
generate_grub_efi_boot
print_step "Cleaning up rootfs..."
cleanup_rootfs
print_step "Generating squashfs image ($SQUASHFS_COMPRESSION) from rootfs..."
generate_squashfs
print_step "Generating ISO image..."
generate_iso_image
hsize=$(du -sh "$OUTPUT_FILE"|awk '{print $1}')
info_msg "Created $(readlink -f "$OUTPUT_FILE") ($hsize) successfully."

433
mklive.sh.in Normal file
View File

@ -0,0 +1,433 @@
#!/bin/sh
#
# vim: set ts=4 sw=4 et:
#
#-
# Copyright (c) 2009-2015 Juan Romero Pardines.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#-
trap 'error_out $? $LINENO' INT TERM 0
umask 022
readonly REQUIRED_PKGS="base-files libgcc dash coreutils sed tar gawk syslinux grub-i386-efi grub-x86_64-efi squashfs-tools xorriso"
readonly INITRAMFS_PKGS="binutils xz device-mapper dhclient dracut-network openresolv"
readonly PROGNAME=$(basename "$0")
info_msg() {
printf "\033[1m$@\n\033[m"
}
die() {
info_msg "ERROR: $@"
error_out 1 $LINENO
}
print_step() {
CURRENT_STEP=$((CURRENT_STEP+1))
info_msg "[${CURRENT_STEP}/${STEP_COUNT}] $@"
}
mount_pseudofs() {
for f in sys dev proc; do
mkdir -p "$ROOTFS"/$f
mount --bind /$f "$ROOTFS"/$f
done
}
umount_pseudofs() {
umount -f "$ROOTFS"/sys >/dev/null 2>&1
umount -f "$ROOTFS"/dev >/dev/null 2>&1
umount -f "$ROOTFS"/proc >/dev/null 2>&1
}
error_out() {
umount_pseudofs
[ -d "$BUILDDIR" -a -z "$KEEP_BUILDDIR" ] && rm -rf "$BUILDDIR"
exit "${1:=0}"
}
usage() {
cat <<_EOF
Usage: $PROGNAME [options]
Options:
-a <xbps-arch> Set XBPS_ARCH (do not use it unless you know what it is)
-b <system-pkg> Set an alternative base-system package (defaults to base-system).
-r <repo-url> Use this XBPS repository (may be specified multiple times).
-c <cachedir> Use this XBPS cache directory (a subdirectory of current
directory if unset).
-k <keymap> Default keymap to use (us if unset)
-l <locale> Default locale to use (en_US.UTF-8 if unset).
-i <lz4|gzip|bzip2|xz> Compression type for the initramfs image (xz if unset).
-s <gzip|lzo|xz> Compression type for the squashfs image (xz if unset)
-o <file> Output file name for the ISO image (auto if unset).
-p "pkg pkgN ..." Install additional packages into the ISO image.
-I <includedir> Include directory structure under given path into rootfs
-C "cmdline args" Add additional kernel command line arguments.
-T "title" Modify the bootloader title.
-v linux<version> Install a custom Linux version on ISO image (linux meta-package if unset).
-K Do not remove builddir.
The $PROGNAME script generates a live image of the Void Linux distribution.
This ISO image can be written to a CD/DVD-ROM or any USB stick.
_EOF
exit 1
}
copy_void_keys() {
mkdir -p "$1"/var/db/xbps/keys
cp keys/*.plist "$1"/var/db/xbps/keys
}
copy_void_conf() {
install -Dm644 data/void-vpkgs.conf "$1"/usr/share/xbps.d/void-virtualpkgs.conf
}
copy_dracut_files() {
mkdir -p "$1"/usr/lib/dracut/modules.d/01vmklive
cp dracut/vmklive/* "$1"/usr/lib/dracut/modules.d/01vmklive/
}
copy_autoinstaller_files() {
mkdir -p "$1"/usr/lib/dracut/modules.d/01autoinstaller
cp dracut/autoinstaller/* "$1"/usr/lib/dracut/modules.d/01autoinstaller/
}
install_prereqs() {
copy_void_conf "$VOIDHOSTDIR"
XBPS_ARCH=$ARCH "$XBPS_INSTALL_CMD" -r "$VOIDHOSTDIR" ${XBPS_REPOSITORY} \
-c "$XBPS_HOST_CACHEDIR" -y $REQUIRED_PKGS
[ $? -ne 0 ] && die "Failed to install required software, exiting..."
}
install_packages() {
copy_void_conf "$ROOTFS"
XBPS_ARCH=$BASE_ARCH "${XBPS_INSTALL_CMD}" -r "$ROOTFS" \
${XBPS_REPOSITORY} -c "$XBPS_CACHEDIR" -yn $PACKAGE_LIST $INITRAMFS_PKGS
[ $? -ne 0 ] && die "Missing required binary packages, exiting..."
mount_pseudofs
LANG=C XBPS_ARCH=$BASE_ARCH "${XBPS_INSTALL_CMD}" -U -r "$ROOTFS" \
${XBPS_REPOSITORY} -c "$XBPS_CACHEDIR" -y $PACKAGE_LIST $INITRAMFS_PKGS
[ $? -ne 0 ] && die "Failed to install $PACKAGE_LIST"
xbps-reconfigure -r "$ROOTFS" -f base-files >/dev/null 2>&1
chroot "$ROOTFS" env -i xbps-reconfigure -f base-files
# Enable choosen UTF-8 locale and generate it into the target rootfs.
if [ -f "$ROOTFS"/etc/default/libc-locales ]; then
sed -e "s/\#\(${LOCALE}.*\)/\1/g" -i "$ROOTFS"/etc/default/libc-locales
fi
chroot "$ROOTFS" env -i xbps-reconfigure -a
if [ -x installer.sh ]; then
install -Dm755 installer.sh "$ROOTFS"/usr/sbin/void-installer
else
install -Dm755 /usr/sbin/void-installer "$ROOTFS"/usr/sbin/void-installer
fi
# Cleanup and remove useless stuff.
rm -rf "$ROOTFS"/var/cache/* "$ROOTFS"/run/* "$ROOTFS"/var/run/*
}
copy_include_directory() {
find "$INCLUDE_DIRECTORY" -mindepth 1 -maxdepth 1 -exec cp -rfpPv {} "$ROOTFS"/ \;
}
generate_initramfs() {
local _args
copy_dracut_files "$ROOTFS"
copy_autoinstaller_files "$ROOTFS"
chroot "$ROOTFS" env -i /usr/bin/dracut -N --"${INITRAMFS_COMPRESSION}" \
--add-drivers "ahci" --force-add "vmklive autoinstaller" --omit systemd "/boot/initrd" $KERNELVERSION
[ $? -ne 0 ] && die "Failed to generate the initramfs"
mv "$ROOTFS"/boot/initrd "$BOOT_DIR"
cp "$ROOTFS"/boot/vmlinuz-$KERNELVERSION "$BOOT_DIR"/vmlinuz
}
cleanup_rootfs() {
for f in ${INITRAMFS_PKGS}; do
revdeps=$(xbps-query -r "$ROOTFS" -X $f)
if [ -n "$revdeps" ]; then
xbps-pkgdb -r "$ROOTFS" -m auto $f
else
xbps-remove -r "$ROOTFS" -Ry ${f} >/dev/null 2>&1
fi
done
rm -r "$ROOTFS"/usr/lib/dracut/modules.d/01vmklive
rm -r "$ROOTFS"/usr/lib/dracut/modules.d/01autoinstaller
}
generate_isolinux_boot() {
cp -f "$SYSLINUX_DATADIR"/isolinux.bin "$ISOLINUX_DIR"
cp -f "$SYSLINUX_DATADIR"/ldlinux.c32 "$ISOLINUX_DIR"
cp -f "$SYSLINUX_DATADIR"/libcom32.c32 "$ISOLINUX_DIR"
cp -f "$SYSLINUX_DATADIR"/vesamenu.c32 "$ISOLINUX_DIR"
cp -f "$SYSLINUX_DATADIR"/libutil.c32 "$ISOLINUX_DIR"
cp -f "$SYSLINUX_DATADIR"/chain.c32 "$ISOLINUX_DIR"
cp -f isolinux/isolinux.cfg.in "$ISOLINUX_DIR"/isolinux.cfg
cp -f ${SPLASH_IMAGE} "$ISOLINUX_DIR"
sed -i -e "s|@@SPLASHIMAGE@@|$(basename "${SPLASH_IMAGE}")|" \
-e "s|@@KERNVER@@|${KERNELVERSION}|" \
-e "s|@@KEYMAP@@|${KEYMAP}|" \
-e "s|@@ARCH@@|$BASE_ARCH|" \
-e "s|@@LOCALE@@|${LOCALE}|" \
-e "s|@@BOOT_TITLE@@|${BOOT_TITLE}|" \
-e "s|@@BOOT_CMDLINE@@|${BOOT_CMDLINE}|" \
"$ISOLINUX_DIR"/isolinux.cfg
}
generate_grub_efi_boot() {
cp -f grub/grub.cfg "$GRUB_DIR"
cp -f grub/grub_void.cfg.in "$GRUB_DIR"/grub_void.cfg
sed -i -e "s|@@SPLASHIMAGE@@|$(basename "${SPLASH_IMAGE}")|" \
-e "s|@@KERNVER@@|${KERNELVERSION}|" \
-e "s|@@KEYMAP@@|${KEYMAP}|" \
-e "s|@@ARCH@@|$BASE_ARCH|" \
-e "s|@@BOOT_TITLE@@|${BOOT_TITLE}|" \
-e "s|@@BOOT_CMDLINE@@|${BOOT_CMDLINE}|" \
-e "s|@@LOCALE@@|${LOCALE}|" "$GRUB_DIR"/grub_void.cfg
mkdir -p "$GRUB_DIR"/fonts
cp -f "$GRUB_DATADIR"/unicode.pf2 "$GRUB_DIR"/fonts
modprobe -q loop || :
# Create EFI vfat image.
truncate -s 32M "$GRUB_DIR"/efiboot.img >/dev/null 2>&1
mkfs.vfat -F12 -S 512 -n "grub_uefi" "$GRUB_DIR/efiboot.img" >/dev/null 2>&1
GRUB_EFI_TMPDIR="$(mktemp --tmpdir="$HOME" -d)"
LOOP_DEVICE="$(losetup --show --find "${GRUB_DIR}"/efiboot.img)"
mount -o rw,flush -t vfat "${LOOP_DEVICE}" "${GRUB_EFI_TMPDIR}" >/dev/null 2>&1
cp -a "$IMAGEDIR"/boot "$VOIDHOSTDIR"
xbps-uchroot "$VOIDHOSTDIR" grub-mkstandalone -- \
--directory="/usr/lib/grub/i386-efi" \
--format="i386-efi" \
--output="/tmp/bootia32.efi" \
"boot/grub/grub.cfg"
if [ $? -ne 0 ]; then
umount "$GRUB_EFI_TMPDIR"
losetup --detach "${LOOP_DEVICE}"
die "Failed to generate EFI loader"
fi
mkdir -p "${GRUB_EFI_TMPDIR}"/EFI/BOOT
cp -f "$VOIDHOSTDIR"/tmp/bootia32.efi "${GRUB_EFI_TMPDIR}"/EFI/BOOT/BOOTIA32.EFI
xbps-uchroot "$VOIDHOSTDIR" grub-mkstandalone -- \
--directory="/usr/lib/grub/x86_64-efi" \
--format="x86_64-efi" \
--output="/tmp/bootx64.efi" \
"boot/grub/grub.cfg"
if [ $? -ne 0 ]; then
umount "$GRUB_EFI_TMPDIR"
losetup --detach "${LOOP_DEVICE}"
die "Failed to generate EFI loader"
fi
cp -f "$VOIDHOSTDIR"/tmp/bootx64.efi "${GRUB_EFI_TMPDIR}"/EFI/BOOT/BOOTX64.EFI
umount "$GRUB_EFI_TMPDIR"
losetup --detach "${LOOP_DEVICE}"
rm -rf "$GRUB_EFI_TMPDIR"
}
generate_squashfs() {
umount_pseudofs
# Find out required size for the rootfs and create an ext3fs image off it.
ROOTFS_SIZE=$(du -sm "$ROOTFS"|awk '{print $1}')
mkdir -p "$BUILDDIR/tmp/LiveOS"
truncate -s "$((ROOTFS_SIZE+ROOTFS_SIZE/6))M" \
"$BUILDDIR"/tmp/LiveOS/ext3fs.img >/dev/null 2>&1
mkdir -p "$BUILDDIR/tmp-rootfs"
mkfs.ext3 -F -m1 "$BUILDDIR/tmp/LiveOS/ext3fs.img" >/dev/null 2>&1
mount -o loop "$BUILDDIR/tmp/LiveOS/ext3fs.img" "$BUILDDIR/tmp-rootfs"
cp -a "$ROOTFS"/* "$BUILDDIR"/tmp-rootfs/
umount -f "$BUILDDIR/tmp-rootfs"
mkdir -p "$IMAGEDIR/LiveOS"
"$VOIDHOSTDIR"/usr/bin/mksquashfs "$BUILDDIR/tmp" "$IMAGEDIR/LiveOS/squashfs.img" \
-comp "${SQUASHFS_COMPRESSION}" || die "Failed to generate squashfs image"
chmod 444 "$IMAGEDIR/LiveOS/squashfs.img"
# Remove rootfs and temporary dirs, we don't need them anymore.
rm -rf "$ROOTFS" "$BUILDDIR/tmp-rootfs" "$BUILDDIR/tmp"
}
generate_iso_image() {
"$VOIDHOSTDIR"/usr/bin/xorriso -as mkisofs \
-iso-level 3 -rock -joliet \
-max-iso9660-filenames -omit-period \
-omit-version-number -relaxed-filenames -allow-lowercase \
-volid "VOID_LIVE" \
-eltorito-boot boot/isolinux/isolinux.bin \
-eltorito-catalog boot/isolinux/boot.cat \
-no-emul-boot -boot-load-size 4 -boot-info-table \
-eltorito-alt-boot -e boot/grub/efiboot.img -isohybrid-gpt-basdat -no-emul-boot \
-isohybrid-mbr "$SYSLINUX_DATADIR"/isohdpfx.bin \
-output "$OUTPUT_FILE" "$IMAGEDIR" || die "Failed to generate ISO image"
}
#
# main()
#
while getopts "a:b:r:c:C:T:Kk:l:i:I:s:S:o:p:v:h" opt; do
case $opt in
a) BASE_ARCH="$OPTARG";;
b) BASE_SYSTEM_PKG="$OPTARG";;
r) XBPS_REPOSITORY="--repository=$OPTARG $XBPS_REPOSITORY";;
c) XBPS_CACHEDIR="$OPTARG";;
K) readonly KEEP_BUILDDIR=1;;
k) KEYMAP="$OPTARG";;
l) LOCALE="$OPTARG";;
i) INITRAMFS_COMPRESSION="$OPTARG";;
I) INCLUDE_DIRECTORY="$OPTARG";;
s) SQUASHFS_COMPRESSION="$OPTARG";;
S) ROOTFS_FREESIZE="$OPTARG";;
o) OUTPUT_FILE="$OPTARG";;
p) PACKAGE_LIST="$OPTARG";;
C) BOOT_CMDLINE="$OPTARG";;
T) BOOT_TITLE="$OPTARG";;
v) LINUX_VERSION="$OPTARG";;
h) usage;;
*) usage;;
esac
done
shift $((OPTIND - 1))
XBPS_REPOSITORY="$XBPS_REPOSITORY --repository=http://alpha.de.repo.voidlinux.org/current --repository=http://alpha.de.repo.voidlinux.org/current/musl"
# Configure dracut to use overlayfs for the writable overlay.
BOOT_CMDLINE="$BOOT_CMDLINE rd.live.overlay.overlayfs=1 "
ARCH=$(xbps-uhelper arch)
# Set defaults
: ${BASE_ARCH:=$(xbps-uhelper arch 2>/dev/null || uname -m)}
: ${XBPS_CACHEDIR:="$(pwd -P)"/xbps-cachedir-${BASE_ARCH}}
: ${XBPS_HOST_CACHEDIR:="$(pwd -P)"/xbps-cachedir-${ARCH}}
: ${KEYMAP:=us}
: ${LOCALE:=en_US.UTF-8}
: ${INITRAMFS_COMPRESSION:=xz}
: ${SQUASHFS_COMPRESSION:=xz}
: ${BASE_SYSTEM_PKG:=base-system}
: ${BOOT_TITLE:="Void Linux"}
# Required packages in the image for a working system.
PACKAGE_LIST="$BASE_SYSTEM_PKG $PACKAGE_LIST"
# Check for root permissions.
if [ "$(id -u)" -ne 0 ]; then
die "Must be run as root, exiting..."
fi
if [ -n "$ROOTDIR" ]; then
BUILDDIR=$(mktemp --tmpdir="$ROOTDIR" -d)
else
BUILDDIR=$(mktemp --tmpdir="$(pwd -P)" -d)
fi
BUILDDIR=$(readlink -f "$BUILDDIR")
IMAGEDIR="$BUILDDIR/image"
ROOTFS="$IMAGEDIR/rootfs"
VOIDHOSTDIR="$BUILDDIR/void-host"
BOOT_DIR="$IMAGEDIR/boot"
ISOLINUX_DIR="$BOOT_DIR/isolinux"
GRUB_DIR="$BOOT_DIR/grub"
ISOLINUX_CFG="$ISOLINUX_DIR/isolinux.cfg"
CURRENT_STEP=0
STEP_COUNT=9
[ -n "${INCLUDE_DIRECTORY}" ] && STEP_COUNT=$((STEP_COUNT+1))
: ${SYSLINUX_DATADIR:="$VOIDHOSTDIR"/usr/lib/syslinux}
: ${GRUB_DATADIR:="$VOIDHOSTDIR"/usr/share/grub}
: ${SPLASH_IMAGE:=data/splash.png}
: ${XBPS_INSTALL_CMD:=xbps-install}
: ${XBPS_REMOVE_CMD:=xbps-remove}
: ${XBPS_QUERY_CMD:=xbps-query}
: ${XBPS_RINDEX_CMD:=xbps-rindex}
: ${XBPS_UHELPER_CMD:=xbps-uhelper}
: ${XBPS_RECONFIGURE_CMD:=xbps-reconfigure}
mkdir -p "$ROOTFS" "$VOIDHOSTDIR" "$ISOLINUX_DIR" "$GRUB_DIR"
print_step "Synchronizing XBPS repository data..."
copy_void_keys "$ROOTFS"
copy_void_keys "$VOIDHOSTDIR"
XBPS_ARCH=$BASE_ARCH $XBPS_INSTALL_CMD -r "$ROOTFS" ${XBPS_REPOSITORY} -S
XBPS_ARCH=$ARCH $XBPS_INSTALL_CMD -r "$VOIDHOSTDIR" ${XBPS_REPOSITORY} -S
# Get linux version for ISO
# If linux version option specified use
if [ -n "$LINUX_VERSION" ]; then
if ! echo "$LINUX_VERSION" | grep "linux[0-9._]*"; then
die "-v option must be in format linux<version>"
fi
_linux_series="$LINUX_VERSION"
PACKAGE_LIST="$PACKAGE_LIST $LINUX_VERSION"
else # Otherwise find latest stable version from linux meta-package
_linux_series=$(XBPS_ARCH=$BASE_ARCH $XBPS_QUERY_CMD -r "$ROOTFS" ${XBPS_REPOSITORY:=-R} -x linux|head -1)
fi
_kver=$(XBPS_ARCH=$BASE_ARCH $XBPS_QUERY_CMD -r "$ROOTFS" ${XBPS_REPOSITORY:=-R} -p pkgver ${_linux_series})
KERNELVERSION=$($XBPS_UHELPER_CMD getpkgversion ${_kver})
if [ "$?" -ne "0" ]; then
die "Failed to find kernel package version"
fi
: ${OUTPUT_FILE="void-live-${BASE_ARCH}-${KERNELVERSION}-$(date +%Y%m%d).iso"}
print_step "Installing software to generate the image: ${REQUIRED_PKGS} ..."
install_prereqs
mkdir -p "$ROOTFS"/etc
[ -s data/motd ] && cp data/motd "$ROOTFS"/etc
[ -s data/issue ] && cp data/issue "$ROOTFS"/etc
print_step "Installing void pkgs into the rootfs: ${PACKAGE_LIST} ..."
install_packages
if [ -n "${INCLUDE_DIRECTORY}" ];then
print_step "Copying directory structure into the rootfs: ${INCLUDE_DIRECTORY} ..."
copy_include_directory
fi
print_step "Generating initramfs image ($INITRAMFS_COMPRESSION)..."
generate_initramfs
print_step "Generating isolinux support for PC-BIOS systems..."
generate_isolinux_boot
print_step "Generating GRUB support for EFI systems..."
generate_grub_efi_boot
print_step "Cleaning up rootfs..."
cleanup_rootfs
print_step "Generating squashfs image ($SQUASHFS_COMPRESSION) from rootfs..."
generate_squashfs
print_step "Generating ISO image..."
generate_iso_image
hsize=$(du -sh "$OUTPUT_FILE"|awk '{print $1}')
info_msg "Created $(readlink -f "$OUTPUT_FILE") ($hsize) successfully."

48
mknet.sh → mknet.sh.in Executable file → Normal file
View File

@ -1,5 +1,7 @@
#!/bin/sh #!/bin/sh
# #
# vim: set ts=4 sw=4 et:
#
#- #-
# Copyright (c) 2009-2015 Juan Romero Pardines. # Copyright (c) 2009-2015 Juan Romero Pardines.
# All rights reserved. # All rights reserved.
@ -49,33 +51,33 @@ bailout() {
} }
usage() { usage() {
cat <<-EOH cat <<_EOF
Usage: $PROGNAME [options] <rootfs-tarball> Usage: $PROGNAME [options] <rootfs>
Generates a network-bootable tarball from a Void Linux ROOTFS generated by mkrootfs. Options:
-r <repo-url> Use this XBPS repository (may be specified multiple times).
-c <cachedir> Use this XBPS cache directory.
-i <lz4|gzip|bzip2|xz> Compression type for the initramfs image (xz if unset).
-o <file> Output file name for the netboot tarball (auto if unset).
-K <kernelpkg> Use <kernelpkg> instead of 'linux' to build the image.
OPTIONS -k <keymap> Console keymap to set (us if unset)
-r <repo> Use this XBPS repository. May be specified multiple times -l <locale> Locale to set (en_US.UTF-8 if unset)
-c <cachedir> Use this XBPS cache directory (default: )
-i <lz4|gzip|bzip2|xz> -C "cmdline args" Add additional kernel command line arguments.
Compression type for the initramfs image (default: xz) -T "title" Modify the bootloader title.
-o <file> Output file name for the netboot tarball (default: automatic) -S "splash image" Set a custom splash image for the bootloader
-K linux<version> Install a custom Linux version on ISO image (default: linux metapackage)
-k <keymap> Default keymap to use (default: us) The $PROGNAME script generates a network-bootable tarball of Void Linux
-l <locale> Default locale to use (default: en_US.UTF-8) _EOF
-C "<arg> ..." Add additional kernel command line arguments exit 1
-T <title> Modify the bootloader title (default: Void Linux)
-S <image> Set a custom splash image for the bootloader (default: data/splash.png)
-h Show this help and exit
-V Show version and exit
EOH
} }
# ######################################## # ########################################
# SCRIPT EXECUTION STARTS HERE # SCRIPT EXECUTION STARTS HERE
# ######################################## # ########################################
while getopts "r:c:C:T:K:i:o:k:l:S:Vh" opt; do while getopts "r:c:C:T:K:i:o:k:l:h" opt; do
case $opt in case $opt in
r) XBPS_REPOSITORY="--repository=$OPTARG $XBPS_REPOSITORY";; r) XBPS_REPOSITORY="--repository=$OPTARG $XBPS_REPOSITORY";;
c) XBPS_CACHEDIR="--cachedir=$OPTARG";; c) XBPS_CACHEDIR="--cachedir=$OPTARG";;
@ -86,10 +88,8 @@ while getopts "r:c:C:T:K:i:o:k:l:S:Vh" opt; do
l) LOCALE="$OPTARG";; l) LOCALE="$OPTARG";;
C) BOOT_CMDLINE="$OPTARG";; C) BOOT_CMDLINE="$OPTARG";;
T) BOOT_TITLE="$OPTARG";; T) BOOT_TITLE="$OPTARG";;
S) SPLASH_IMAGE="$OPTARG";; S) SPLASH_IMAGE="OPTARG";;
V) version; exit 0;; h) usage;;
h) usage; exit 0;;
*) usage >&2; exit 1;;
esac esac
done done
shift $((OPTIND - 1)) shift $((OPTIND - 1))
@ -261,7 +261,7 @@ else
fi fi
# Compress the artifacts for distribution # Compress the artifacts for distribution
OUTPUT_FILE="void-${XBPS_TARGET_ARCH}-NETBOOT-$(date -u +%Y%m%d).tar.gz" OUTPUT_FILE="void-${XBPS_TARGET_ARCH}-NETBOOT-$(date +%Y%m%d).tar.gz"
info_msg "Compressing results to $OUTPUT_FILE" info_msg "Compressing results to $OUTPUT_FILE"
cd "$BOOT_DIR" || die "Could not enter image dir" cd "$BOOT_DIR" || die "Could not enter image dir"
tar -zcvf "$CURDIR/$OUTPUT_FILE" . tar -zcvf "$CURDIR/$OUTPUT_FILE" .

75
mkplatformfs.sh → mkplatformfs.sh.in Executable file → Normal file
View File

@ -45,29 +45,27 @@ trap 'die "Interrupted! exiting..."' INT TERM HUP
# in the script, and it makes it easier to consume the contents of # in the script, and it makes it easier to consume the contents of
# these down the road in later scripts. # these down the road in later scripts.
usage() { usage() {
cat <<-EOH cat <<_EOF
Usage: $PROGNAME [options] <platform> <rootfs-tarball> Usage: $PROGNAME [options] <platform> <base-tarball>
Generates a platform-specific ROOTFS tarball from a generic Void Linux ROOTFS
generated by mkrootfs.sh.
Supported platforms: i686, x86_64, GCP, Supported platforms: i686, x86_64, GCP,
rpi-armv6l, rpi-armv7l, rpi-aarch64, dockstar, bananapi, beaglebone, cubieboard2, cubietruck,
pinebookpro, pinephone, rock64, rockpro64 odroid-c2, odroid-u2, rpi, rpi2 (armv7), rpi3 (aarch64),
usbarmory, ci20, pogoplugv4, pinebookpro
OPTIONS
-b <system-pkg> Set an alternative base-system package (default: base-system) Options
-c <cachedir> Set the XBPS cache directory (default: ./xbps-cachedir-<arch>) -b <syspkg> Set an alternative base-system package (defaults to base-system)
-C <file> Full path to the XBPS configuration file -p <pkgs> Additional packages to install into the rootfs (separated by blanks)
-k <cmd> Call '<cmd> <ROOTFSPATH>' after building the ROOTFS -k <cmd> Call "cmd <ROOTFSPATH>" after building the rootfs
-n Do not compress the image, instead print out the ROOTFS directory -c <dir> Set XBPS cache directory (defaults to \$PWD/xbps-cachedir-<arch>)
-o <file> Filename to write the PLATFORMFS archive to (default: automatic) -C <file> Full path to the XBPS configuration file
-p "<pkg> ..." Additional packages to install into the ROOTFS -r <repo> Set XBPS repository (may be set multiple times)
-r <repo> Use this XBPS repository. May be specified multiple times -x <num> Use <num> threads to compress the image (dynamic if unset)
-x <num> Number of threads to use for image compression (default: dynamic) -o <file> Filename to write the PLATFORMFS archive to
-h Show this help and exit -n Do not compress the image, instead print out the rootfs directory
-V Show version and exit -h Show this help
EOH -V Show version
_EOF
} }
# ######################################## # ########################################
@ -88,20 +86,14 @@ while getopts "b:p:k:c:C:r:x:o:nhV" opt; do
x) COMPRESSOR_THREADS="$OPTARG" ;; x) COMPRESSOR_THREADS="$OPTARG" ;;
o) FILENAME="$OPTARG" ;; o) FILENAME="$OPTARG" ;;
n) COMPRESSION="n" ;; n) COMPRESSION="n" ;;
V) version; exit 0;;
h) usage; exit 0 ;; h) usage; exit 0 ;;
*) usage >&2; exit 1 ;; V) echo "$PROGNAME @@MKLIVE_VERSION@@"; exit 0 ;;
esac esac
done done
shift $((OPTIND - 1)) shift $((OPTIND - 1))
PLATFORM="$1" PLATFORM="$1"
BASE_TARBALL="$2" BASE_TARBALL="$2"
if [ -z "$PLATFORM" ] || [ -z "$BASE_TARBALL" ]; then
usage >&2
exit 1
fi
# This is an aweful hack since the script isn't using privesc # This is an aweful hack since the script isn't using privesc
# mechanisms selectively. This is a TODO item. # mechanisms selectively. This is a TODO item.
if [ "$(id -u)" -ne 0 ]; then if [ "$(id -u)" -ne 0 ]; then
@ -120,14 +112,22 @@ check_tools
# noarch though, so we strip off the -musl extention if it was # noarch though, so we strip off the -musl extention if it was
# provided. # provided.
case "$PLATFORM" in case "$PLATFORM" in
rpi*) PKGS="$BASEPKG rpi-base" ;; bananapi*) PKGS="$BASEPKG ${PLATFORM%-*}-base" ;;
beaglebone*) PKGS="$BASEPKG ${PLATFORM%-*}-base" ;;
cubieboard2*|cubietruck*) PKGS="$BASEPKG ${PLATFORM%-*}-base" ;;
dockstar*) PKGS="$BASEPKG ${PLATFORM%-*}-base" ;;
odroid-u2*) PKGS="$BASEPKG ${PLATFORM%-*}-base" ;;
odroid-c2*) PKGS="$BASEPKG ${PLATFORM%-musl}-base" ;;
rpi3*) PKGS="$BASEPKG rpi-base" ;;
rpi2*) PKGS="$BASEPKG rpi-base" ;;
rpi*) PKGS="$BASEPKG ${PLATFORM%-*}-base" ;;
pogo*) PKGS="$BASEPKG ${PLATFORM%-*}-base" ;;
usbarmory*) PKGS="$BASEPKG ${PLATFORM%-*}-base" ;;
ci20*) PKGS="$BASEPKG ${PLATFORM%-*}-base" ;;
i686*) PKGS="$BASEPKG" ;; i686*) PKGS="$BASEPKG" ;;
x86_64*) PKGS="$BASEPKG" ;; x86_64*) PKGS="$BASEPKG" ;;
GCP*) PKGS="$BASEPKG ${PLATFORM%-*}-base" ;; GCP*) PKGS="$BASEPKG ${PLATFORM%-*}-base" ;;
pinebookpro*) PKGS="$BASEPKG ${PLATFORM%-*}-base" ;; pinebookpro*) PKGS="$BASEPKG ${PLATFORM%-*}-base" ;;
pinephone*) PKGS="$BASEPKG ${PLATFORM%-*}-base" ;;
rock64*) PKGS="$BASEPKG ${PLATFORM%-*}-base" ;;
rockpro64*) PKGS="$BASEPKG ${PLATFORM%-*}-base" ;;
*) die "$PROGNAME: invalid platform!";; *) die "$PROGNAME: invalid platform!";;
esac esac
@ -154,7 +154,7 @@ if [ ! -e "$BASE_TARBALL" ]; then
fi fi
info_msg "Expanding base tarball $BASE_TARBALL into $ROOTFS for $PLATFORM build." info_msg "Expanding base tarball $BASE_TARBALL into $ROOTFS for $PLATFORM build."
tar xf "$BASE_TARBALL" --xattrs --xattrs-include='*' -C "$ROOTFS" tar xf "$BASE_TARBALL" -C "$ROOTFS"
# This will install, but not configure, the packages specified by # This will install, but not configure, the packages specified by
# $PKGS. After this step we will do an xbps-reconfigure -f $PKGS # $PKGS. After this step we will do an xbps-reconfigure -f $PKGS
@ -216,7 +216,7 @@ rm -rf "$ROOTFS/var/cache/*" 2>/dev/null
# Now we can run the POST_CMD script. This user-supplied script gets the # Now we can run the POST_CMD script. This user-supplied script gets the
# $ROOTFS as a parameter. # $ROOTFS as a parameter.
if [ -n "$POST_CMD" ]; then if [ -n "$POST_CMD" ]; then
info_msg "Running user supplied command: $POST_CMD" info_msg "Running user supllied command: $POST_CMD"
run_cmd $POST_CMD $ROOTFS run_cmd $POST_CMD $ROOTFS
fi fi
@ -225,9 +225,8 @@ fi
if [ "$COMPRESSION" = "y" ]; then if [ "$COMPRESSION" = "y" ]; then
# Finally we can compress the tarball, the name will include the # Finally we can compress the tarball, the name will include the
# platform and the date on which the tarball was built. # platform and the date on which the tarball was built.
tarball=${FILENAME:-void-${PLATFORM}-PLATFORMFS-$(date -u '+%Y%m%d').tar.xz} tarball=${FILENAME:-void-${PLATFORM}-PLATFORMFS-$(date '+%Y%m%d').tar.xz}
run_cmd "tar cp --posix --xattrs --xattrs-include='*' -C $ROOTFS . | xz -T${COMPRESSOR_THREADS:-0} -9 > $tarball " run_cmd "tar -cp --posix --xattrs -C $ROOTFS . | xz -T${COMPRESSOR_THREADS:-0} -9 > $tarball "
[ $? -ne 0 ] && die "Failed to compress tarball"
# Now that we have the tarball we don't need the rootfs anymore, so we # Now that we have the tarball we don't need the rootfs anymore, so we
# can get rid of it. # can get rid of it.

70
mkrootfs.sh → mkrootfs.sh.in Executable file → Normal file
View File

@ -46,29 +46,27 @@ trap 'die "Interrupted! exiting..."' INT TERM HUP
# in the script, and it makes it easier to consume the contents of # in the script, and it makes it easier to consume the contents of
# these down the road in later scripts. # these down the road in later scripts.
usage() { usage() {
cat <<-EOH cat <<_EOF
Usage: $PROGNAME [options] <arch> Usage: $PROGNAME [options] <arch>
Generate a Void Linux ROOTFS tarball for the specified architecture. Supported architectures: i686, i686-musl, x86_64, x86_64-musl,
armv5tel, armv5tel-musl, armv6l, armv6l-musl, armv7l, armv7l-musl
aarch64, aarch64-musl,
mipsel, mipsel-musl
ppc, ppc-musl
ppc64le, ppc64le-musl, ppc64, ppc64-musl
Supported architectures:
i686, i686-musl, x86_64, x86_64-musl, Options
armv5tel, armv5tel-musl, armv6l, armv6l-musl, armv7l, armv7l-musl -b <syspkg> Set an alternative base-system package (defaults to base-voidstrap)
aarch64, aarch64-musl, -c <dir> Set XBPS cache directory (defaults to \$PWD/xbps-cachedir-<arch>)
mipsel, mipsel-musl, -C <file> Full path to the XBPS configuration file
ppc, ppc-musl, ppc64le, ppc64le-musl, ppc64, ppc64-musl -h Show this help
riscv64, riscv64-musl -r <repo> Set XBPS repository (may be set multiple times)
-x <num> Use <num> threads to compress the image (dynamic if unset)
OPTIONS -o <file> Filename to write the ROOTFS archive to
-b <system-pkg> Set an alternative base-system package (default: base-container-full) -V Show version
-c <cachedir> Set XBPS cache directory (default: ./xbps-cachedir-<arch>) _EOF
-C <file> Full path to the XBPS configuration file
-r <repo> Use this XBPS repository. May be specified multiple times
-o <file> Filename to write the ROOTFS to (default: automatic)
-x <num> Number of threads to use for image compression (default: dynamic)
-h Show this help and exit
-V Show version and exit
EOH
} }
# ######################################## # ########################################
@ -76,7 +74,7 @@ usage() {
# ######################################## # ########################################
# Set the default system package. # Set the default system package.
SYSPKG="base-container-full" SYSPKG="base-voidstrap"
# Boilerplate option parsing. This script supports the bare minimum # Boilerplate option parsing. This script supports the bare minimum
# needed to build an image. # needed to build an image.
@ -85,22 +83,16 @@ while getopts "b:C:c:hr:x:o:V" opt; do
b) SYSPKG="$OPTARG";; b) SYSPKG="$OPTARG";;
C) XBPS_CONFFILE="-C $OPTARG";; C) XBPS_CONFFILE="-C $OPTARG";;
c) XBPS_CACHEDIR="--cachedir=$OPTARG";; c) XBPS_CACHEDIR="--cachedir=$OPTARG";;
h) usage; exit 0;;
r) XBPS_REPOSITORY="$XBPS_REPOSITORY --repository=$OPTARG";; r) XBPS_REPOSITORY="$XBPS_REPOSITORY --repository=$OPTARG";;
x) COMPRESSOR_THREADS="$OPTARG" ;; x) COMPRESSOR_THREADS="$OPTARG" ;;
o) FILENAME="$OPTARG" ;; o) FILENAME="$OPTARG" ;;
V) version; exit 0;; V) echo "$PROGNAME @@MKLIVE_VERSION@@"; exit 0;;
h) usage; exit 0;;
*) usage >&2; exit 1;;
esac esac
done done
shift $((OPTIND - 1)) shift $((OPTIND - 1))
XBPS_TARGET_ARCH="$1" XBPS_TARGET_ARCH="$1"
if [ -z "$XBPS_TARGET_ARCH" ]; then
usage >&2
exit 1
fi
# Set the XBPS cache # Set the XBPS cache
set_cachedir set_cachedir
@ -119,7 +111,7 @@ check_tools
# script will work without knowing what we're trying to build for. # script will work without knowing what we're trying to build for.
if [ -z "$XBPS_TARGET_ARCH" ]; then if [ -z "$XBPS_TARGET_ARCH" ]; then
echo "$PROGNAME: arch was not set!" echo "$PROGNAME: arch was not set!"
usage >&2; exit 1 usage; exit 1
fi fi
# We need to operate on a tempdir, if this fails to create, it is # We need to operate on a tempdir, if this fails to create, it is
@ -176,9 +168,9 @@ info_msg "Reconfiguring packages for ${XBPS_TARGET_ARCH} ..."
# This step sets up enough of the base-files that the chroot will work # This step sets up enough of the base-files that the chroot will work
# and they can be reconfigured natively. Without this step there # and they can be reconfigured natively. Without this step there
# isn't enough configured for ld to work. This step runs as the host # isn't enough configured for ld to work. This step runs as the host
# architecture, but we may need to set up XBPS_ARCH for the target # architecture, but on x86 some special extra steps have to be taken
# architecture (but only when compatible). # to make this work.
if is_target_native "$XBPS_TARGET_ARCH"; then if [ -z "${XBPS_TARGET_ARCH##*86*}" ] && [ -z "${HOSTARCH##*86*}" ] ; then
run_cmd_target "xbps-reconfigure --rootdir $ROOTFS base-files" run_cmd_target "xbps-reconfigure --rootdir $ROOTFS base-files"
else else
run_cmd "xbps-reconfigure --rootdir $ROOTFS base-files" run_cmd "xbps-reconfigure --rootdir $ROOTFS base-files"
@ -189,6 +181,12 @@ fi
# pass, so this cleans up any issues that linger. # pass, so this cleans up any issues that linger.
run_cmd_chroot "$ROOTFS" "env -i xbps-reconfigure -f base-files" run_cmd_chroot "$ROOTFS" "env -i xbps-reconfigure -f base-files"
# TODO: determine why these lines are here. What is the harm in
# having them and what do they remove. Do they interact adversely
# with the alien build support discussed above.
rmdir "$ROOTFS/usr/lib32" 2>/dev/null
rm -f "$ROOTFS/lib32" "$ROOTFS/lib64" "$ROOTFS/usr/lib64"
# Once base-files is configured and functional its possible to # Once base-files is configured and functional its possible to
# configure the rest of the system. # configure the rest of the system.
run_cmd_chroot "$ROOTFS" "xbps-reconfigure -a" run_cmd_chroot "$ROOTFS" "xbps-reconfigure -a"
@ -218,8 +216,8 @@ rm -rf "$ROOTFS/var/cache/*" 2>/dev/null
# Finally we can compress the tarball, the name will include the # Finally we can compress the tarball, the name will include the
# architecture and the date on which the tarball was built. # architecture and the date on which the tarball was built.
: "${FILENAME:=void-${XBPS_TARGET_ARCH}-ROOTFS-$(date -u '+%Y%m%d').tar.xz}" : "${FILENAME:=void-${XBPS_TARGET_ARCH}-ROOTFS-$(date '+%Y%m%d').tar.xz}"
run_cmd "tar cp --posix --xattrs --xattrs-include='*' -C $ROOTFS . | xz -T${COMPRESSOR_THREADS:-0} -9 > $FILENAME " run_cmd "tar -cp --posix --xattrs -C $ROOTFS . | xz -T${COMPRESSOR_THREADS:-0} -9 > $FILENAME "
# Now that we have the tarball we don't need the rootfs anymore, so we # Now that we have the tarball we don't need the rootfs anymore, so we
# can get rid of it. # can get rid of it.

1
packer/.gitignore vendored
View File

@ -3,4 +3,3 @@ packer_cache
crash.log crash.log
*.box *.box
templates/ templates/
cloud-generic

15
packer/Makefile Normal file
View File

@ -0,0 +1,15 @@
TEMPLATES=templates/digitalocean-glibc64.json templates/vagrant-glibc64.json
all: $(TEMPLATES)
templates:
mkdir -p templates
templates/digitalocean-glibc64.json: templates fragments/base-qemu-glibc64.json fragments/provisioner-cloud.json fragments/platform-digitalocean.json
jq -s 'add' fragments/base-qemu-glibc64.json fragments/provisioner-cloud.json fragments/platform-digitalocean.json > templates/digitalocean-glibc64.json
templates/vagrant-glibc64.json: templates fragments/base-vbox-glibc64.json fragments/platform-vagrant.json
jq -s 'add' fragments/base-vbox-glibc64.json fragments/platform-vagrant.json > templates/vagrant-glibc64.json
templates/aws-glibc64.json: templates fragments/base-qemu-glibc64.json fragments/provisioner-cloud.json fragments/platform-digitalocean.json
jq -s 'add' fragments/base-qemu-glibc64.json fragments/provisioner-cloud.json fragments/platform-aws.json > templates/aws-glibc64.json

View File

@ -0,0 +1,25 @@
{
"builders": [
{
"accelerator": "kvm",
"boot_command": [
"<tab><wait>",
"auto autourl=http://{{ .HTTPIP }}:{{ .HTTPPort }}/cloud.cfg",
"<enter>"
],
"boot_wait": "5s",
"disk_interface": "virtio",
"disk_size": "1000M",
"format": "raw",
"vm_name": "void.raw",
"http_directory": "http",
"iso_checksum": "sha256:d95d40e1eb13a7776b5319a05660792fddd762662eaecee5df6b8feb3aa9b391",
"iso_url": "https://alpha.de.repo.voidlinux.org/live/20200722/void-live-x86_64-5.7.10_1-20200722.iso",
"shutdown_command": "echo 'void' | sudo -S shutdown -P now",
"ssh_password": "void",
"ssh_timeout": "20m",
"ssh_username": "void",
"type": "qemu"
}
]
}

View File

@ -0,0 +1,31 @@
{
"builders": [
{
"boot_command": [
"<tab><wait>",
"auto autourl=http://{{ .HTTPIP }}:{{ .HTTPPort }}/vagrant.cfg",
"<enter>"
],
"boot_wait": "5s",
"guest_additions_mode": "disable",
"guest_os_type": "Linux_64",
"http_directory": "http",
"iso_checksum": "sha256:d95d40e1eb13a7776b5319a05660792fddd762662eaecee5df6b8feb3aa9b391",
"iso_url": "https://alpha.de.repo.voidlinux.org/live/20200722/void-live-x86_64-5.7.10_1-20200722.iso",
"shutdown_command": "echo 'vagrant' | sudo -S shutdown -P now",
"ssh_password": "vagrant",
"ssh_timeout": "20m",
"ssh_username": "vagrant",
"type": "virtualbox-iso",
"vboxmanage": [
[
"modifyvm",
"{{.Name}}",
"--nictype1",
"virtio"
]
],
"virtualbox_version_file": ".vbox_version"
}
]
}

View File

@ -0,0 +1,12 @@
{
"post-processors": [
{
"type": "amazon-import",
"s3_bucket_name": "{{user `s3_bucket_name`}}",
"format": "raw"
}
],
"variables": {
"s3_bucket_name": "{{env `S3_BUCKET_NAME`}}"
}
}

View File

@ -0,0 +1,22 @@
{
"post-processors": [
{
"image_description": "Packer import {{timestamp}}",
"image_name": "void-linux-{{user `release`}}",
"image_regions": "{{user `image_regions`}}",
"image_tags": [
"custom",
"packer"
],
"space_name": "{{user `spaces_bucket`}}",
"spaces_region": "{{user `spaces_region`}}",
"type": "digitalocean-import"
}
],
"variables": {
"image_regions": "{{env `IMAGE_REGIONS`}}",
"spaces_bucket": "{{env `SPACES_BUCKET`}}",
"spaces_region": "{{env `SPACES_REGION`}}",
"release": "{{env `RELEASE`}}"
}
}

View File

@ -0,0 +1,24 @@
{
"post-processors": [
[
{
"type": "vagrant"
},
{
"box_tag": "voidlinux/glibc64",
"type": "vagrant-cloud",
"version": "{{user `version`}}"
}
]
],
"provisioners": [
{
"execute_command": "echo 'vagrant' | {{.Vars}} sudo -E -S bash '{{.Path}}'",
"script": "scripts/vagrant.sh",
"type": "shell"
}
],
"variables": {
"version": "{{env `RELEASE`}}"
}
}

View File

@ -0,0 +1,9 @@
{
"provisioners": [
{
"execute_command": "echo 'void' | {{.Vars}} sudo -E -S bash '{{.Path}}'",
"script": "scripts/cloud.sh",
"type": "shell"
}
]
}

View File

@ -1,37 +0,0 @@
build {
name = "cloud-generic-x86_64"
source "source.qemu.x86_64" {
boot_command = [
"<tab><wait>",
"auto autourl=http://{{.HTTPIP}}:{{.HTTPPort}}/x86_64.cfg",
"<enter>"
]
vm_name = "voidlinux-x86_64"
output_directory = "cloud-generic-x86_64"
}
provisioner "shell" {
script = "scripts/cloud.sh"
execute_command = "echo 'void' | {{.Vars}} sudo -E -S bash '{{.Path}}'"
}
}
build {
name = "cloud-generic-x86_64-musl"
source "source.qemu.x86_64" {
boot_command = [
"<tab><wait>",
"auto autourl=http://{{.HTTPIP}}:{{.HTTPPort}}/x86_64-musl.cfg",
"<enter>"
]
vm_name = "voidlinux-x86_64-musl"
output_directory = "cloud-generic-x86_64-musl"
}
provisioner "shell" {
script = "scripts/cloud.sh"
execute_command = "echo 'void' | {{.Vars}} sudo -E -S bash '{{.Path}}'"
}
}

View File

@ -1,45 +0,0 @@
build {
name = "vagrant-virtualbox-x86_64"
source "source.virtualbox-iso.x86_64" {
boot_command = [
"<tab><wait>",
"auto autourl=http://{{.HTTPIP}}:{{.HTTPPort}}/x86_64.cfg",
"<enter>"
]
vm_name = "voidlinux-x86_64"
output_directory = "vagrant-virtualbox-x86_64"
}
provisioner "shell" {
script = "scripts/vagrant.sh"
execute_command = "echo 'void' | {{.Vars}} sudo -E -S bash '{{.Path}}'"
}
post-processor "vagrant" {
output = "vagrant-virtualbox-x86_64.box"
}
}
build {
name = "vagrant-virtualbox-x86_64-musl"
source "source.virtualbox-iso.x86_64" {
boot_command = [
"<tab><wait>",
"auto autourl=http://{{.HTTPIP}}:{{.HTTPPort}}/x86_64-musl.cfg",
"<enter>"
]
vm_name = "voidlinux-x86_64-musl"
output_directory = "vagrant-virtualbox-x86_64-musl"
}
provisioner "shell" {
script = "scripts/vagrant.sh"
execute_command = "echo 'void' | {{.Vars}} sudo -E -S bash '{{.Path}}'"
}
post-processor "vagrant" {
output = "vagrant-virtualbox-x86_64-musl.box"
}
}

View File

@ -1,13 +0,0 @@
source "qemu" "x86_64" {
accelerator = "kvm"
boot_wait = "5s"
disk_interface = "virtio"
disk_size = "2000M"
format = "qcow2"
http_directory = "http"
iso_url = "https://repo-default.voidlinux.org/live/20240314/void-live-x86_64-20240314-base.iso"
iso_checksum = "sha256:c1a3c0aff363057132f8dab80287396df8a8b4d7cd7f7d8d3f0e2c3ee9e5be7d"
ssh_password = "void"
ssh_timeout = "20m"
ssh_username = "void"
}

View File

@ -1,16 +0,0 @@
source "virtualbox-iso" "x86_64" {
guest_os_type = "Linux_64"
iso_url = "https://repo-default.voidlinux.org/live/20240314/void-live-x86_64-20240314-base.iso"
iso_checksum = "sha256:c1a3c0aff363057132f8dab80287396df8a8b4d7cd7f7d8d3f0e2c3ee9e5be7d"
ssh_username = "void"
ssh_password = "void"
http_directory = "http"
ssh_timeout = "20m"
guest_additions_mode = "disable"
vboxmanage = [
["modifyvm", "{{.Name}}", "--nictype1", "virtio"],
]
boot_wait = "5s"
}

View File

@ -1 +0,0 @@
../build-vagrant.pkr.hcl

View File

@ -1 +0,0 @@
../source-virtualbox-ose.pkr.hcl

20
packer/http/vagrant.cfg Normal file
View File

@ -0,0 +1,20 @@
#!/bin/sh
# Void Linux Automatic Install Configuration
export username="vagrant"
export password="vagrant"
export end_action=func
end_function() {
printf "Linking default services"
chroot "$target" ln -s /etc/sv/dhcpcd /etc/runit/runsvdir/default/dhcpcd
chroot "$target" ln -s /etc/sv/sshd /etc/runit/runsvdir/default/sshd
xbps-install -r "$target" -Sy dbus virtualbox-ose-guest
chroot "$target" ln -s /etc/sv/dbus /etc/runit/runsvdir/default/dbus
chroot "$target" ln -s /etc/sv/vboxservice /etc/runit/runsvdir/default/vboxservice
sync
reboot -f
}

View File

@ -1,42 +0,0 @@
#!/bin/sh
# Void Linux Automatic Install Configuration
export username="void"
export password="void"
export XBPS_ARCH=x86_64-musl
export xbpsrepository=https://repo-default.voidlinux.org/current/musl
export end_action=func
end_function() {
printf "Linking default services"
chroot "$target" ln -s /etc/sv/dhcpcd /etc/runit/runsvdir/default/dhcpcd
chroot "$target" ln -s /etc/sv/sshd /etc/runit/runsvdir/default/sshd
sync
reboot -f
}
VAI_partition_disk() {
# Paritition Disk
sfdisk "${disk}" <<EOF
;
EOF
}
VAI_format_disk() {
# Make Filesystems
mkfs.ext4 -F "${disk}1"
}
VAI_mount_target() {
# Mount targetfs
mkdir -p "${target}"
mount "${disk}1" "${target}"
}
VAI_configure_fstab() {
uuid1="$(blkid -s UUID -o value "${disk}1")"
echo "UUID=$uuid1 / ext4 defaults,errors=remount-ro 0 1" >> "${target}/etc/fstab"
}

View File

@ -1,39 +0,0 @@
#!/bin/sh
# Void Linux Automatic Install Configuration
export username="void"
export password="void"
export end_action=func
end_function() {
printf "Linking default services"
chroot "$target" ln -s /etc/sv/dhcpcd /etc/runit/runsvdir/default/dhcpcd
chroot "$target" ln -s /etc/sv/sshd /etc/runit/runsvdir/default/sshd
sync
reboot -f
}
VAI_partition_disk() {
# Paritition Disk
sfdisk "${disk}" <<EOF
;
EOF
}
VAI_format_disk() {
# Make Filesystems
mkfs.ext4 -F "${disk}1"
}
VAI_mount_target() {
# Mount targetfs
mkdir -p "${target}"
mount "${disk}1" "${target}"
}
VAI_configure_fstab() {
uuid1="$(blkid -s UUID -o value "${disk}1")"
echo "UUID=$uuid1 / ext4 defaults,errors=remount-ro 0 1" >> "${target}/etc/fstab"
}

View File

@ -0,0 +1,19 @@
{
"builds": [
{
"name": "qemu",
"builder_type": "qemu",
"build_time": 1598776155,
"files": [
{
"name": "output-qemu/packer-qemu",
"size": 1048576000
}
],
"artifact_id": "VM",
"packer_run_uuid": "bef5beb0-c26f-2680-495d-6a04ca26e636",
"custom_data": null
}
],
"last_run_uuid": "bef5beb0-c26f-2680-495d-6a04ca26e636"
}

View File

@ -1,16 +0,0 @@
packer {
required_plugins {
qemu = {
version = "~> 1"
source = "github.com/hashicorp/qemu"
}
vagrant = {
version = "~> 1"
source = "github.com/hashicorp/vagrant"
}
virtualbox = {
version = "~> 1"
source = "github.com/hashicorp/virtualbox"
}
}
}

View File

@ -1,19 +1,26 @@
#!/bin/bash #!/bin/bash
echo "void ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers.d/99-void echo "void ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/99-void
echo "Defaults:void !requiretty" >> /etc/sudoers.d/99-void echo "Defaults:void !requiretty" >> /etc/sudoers.d/99-void
chmod 0440 /etc/sudoers.d/99-void chmod 0440 /etc/sudoers.d/99-void
mv /etc/sudoers.d/{,10-}wheel mv /etc/sudoers.d/{,10-}wheel
xbps-install -Sy util-linux coreutils sed shinit cloud-guest-utils xbps-fetch -o /usr/bin/growpart https://raw.githubusercontent.com/canonical/cloud-utils/ubuntu/0.31-22-g37d4e32a-0ubuntu1/bin/growpart
chmod +x /usr/bin/growpart
xbps-install -y util-linux coreutils sed shinit
ln -s /etc/sv/shinit /var/service/ ln -s /etc/sv/shinit /var/service/
sed -i -e 's/#ENABLE/ENABLE/' /etc/default/growpart cat <<'EOF' > /etc/runit/core-services/10-resize-root.sh
#!/bin/sh
rpart=$(findmnt -r -o SOURCE -v -n /)
rnum=$(cat /sys/class/block/$(basename $rpart)/partition)
/usr/bin/growpart ${rpart%%$rnum} $rnum
resize2fs $rpart
EOF
passwd -dl void passwd -dl void
passwd -dl root passwd -dl root
rm -rf /var/cache/xbps rm -rf /var/cache/xbps
rm -f /etc/ssh/ssh_host*
shutdown -P now

View File

@ -0,0 +1,10 @@
#!/bin/sh
df -h
rm -rf /var/cache/xbps/
df -h
echo 'ignorepkg=linux' > /etc/xbps.d/90-ignore-linux.conf
xbps-remove -Ry linux
rm -fv /boot/"*$(uname -r)*"
xbps-install -y linux-lts

View File

@ -1,9 +1,7 @@
#!/bin/bash #!/bin/bash
useradd -m -s /bin/bash vagrant
# Set up sudo # Set up sudo
echo '%vagrant ALL=(ALL:ALL) NOPASSWD:ALL' > /etc/sudoers.d/vagrant echo '%vagrant ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/vagrant
echo 'Defaults:vagrant !requiretty' >> /etc/sudoers.d/vagrant echo 'Defaults:vagrant !requiretty' >> /etc/sudoers.d/vagrant
chmod 0440 /etc/sudoers.d/vagrant chmod 0440 /etc/sudoers.d/vagrant
@ -21,11 +19,3 @@ chown -R vagrant /home/vagrant/.ssh
# Install NFS for Vagrant # Install NFS for Vagrant
xbps-install -Sy nfs-utils xbps-install -Sy nfs-utils
passwd -dl vagrant
passwd -dl void
passwd -dl root
rm -rf /var/cache/xbps
shutdown -P now

View File

@ -1,22 +0,0 @@
## mklive platforms
To allow for platform-specific customization (and platform-specific/generic
images all-in-one) on aarch64, `mklive.sh -P "platform1 platform2 ..."` can be
used. That will, in turn, source `platform1.sh` and `platform2.sh` from this
directory to do a few things:
1. add packages to the image
2. add menu entries in GRUB
### File format
```bash
# an optional pretty name
PLATFORM_NAME="Thinkpad X13s"
# any additional packages to add (bash array)
PLATFORM_PKGS=(x13s-base)
# any special kernel cmdline arguments
PLATFORM_CMDLINE="rd.driver.blacklist=qcom_q6v5_pas arm64.nopauth clk_ignore_unused pd_ignore_unused"
# device tree (path relative to /boot/dtbs/dtbs-$version/)
PLATFORM_DTB="qcom/sc8280xp-lenovo-thinkpad-x13s.dtb"
```

View File

@ -1,4 +0,0 @@
PLATFORM_NAME="Pinebook Pro"
PLATFORM_PKGS=(pinebookpro-base)
PLATFORM_CMDLINE="console=ttyS2,115200 video=eDP-1:1920x1080x60"
PLATFORM_DTB="rockchip/rk3399-pinebook-pro.dtb"

View File

@ -1,4 +0,0 @@
PLATFORM_NAME="Thinkpad X13s"
PLATFORM_PKGS=(x13s-base)
PLATFORM_CMDLINE="rd.driver.blacklist=qcom_q6v5_pas arm64.nopauth clk_ignore_unused pd_ignore_unused"
PLATFORM_DTB="qcom/sc8280xp-lenovo-thinkpad-x13s.dtb"

View File

@ -1,88 +0,0 @@
#!/bin/bash
set -e
usage() {
echo "release.sh start [-l LIVE_ARCHS] [-f LIVE_VARIANTS] [-a ROOTFS_ARCHS]"
echo " [-p PLATFORMS] [-i SBC_IMGS] [-d DATE] [-r REPOSITORY] -- [gh args...]"
echo "release.sh dl [run id] -- [gh args...]"
echo "release.sh sign DATE SHASUMFILE"
exit 1
}
check_programs() {
for prog; do
if ! type $prog &>/dev/null; then
echo "missing program: $prog"
exit 1
fi
done
}
start_build() {
check_programs gh
ARGS=()
while getopts "a:d:f:i:l:p:r:" opt; do
case $opt in
a) ARGS+=(-f rootfs="$OPTARG") ;;
d) ARGS+=(-f datecode="$OPTARG") ;;
f) ARGS+=(-f live_flavors="$OPTARG") ;;
i) ARGS+=(-f sbc_imgs="$OPTARG") ;;
l) ARGS+=(-f live_archs="$OPTARG") ;;
p) ARGS+=(-f platformfs="$OPTARG") ;;
r) ARGS+=(-f mirror="$OPTARG") ;;
?) usage;;
esac
done
shift $((OPTIND - 1))
gh workflow run gen-images.yml "${ARGS[@]}" "$@"
}
# this assumes that the latest successful build is the one to download
# wish it could be better but alas:
# https://github.com/cli/cli/issues/4001
download_build() {
local run
check_programs gh
if [ -n "$1" ] && [ "$1" != "--" ]; then
run="$1"
shift
else
run="$(gh run list -s success -w gen-images.yml --json databaseId -q '.[].databaseId' "$@" | sort -r | head -1)"
fi
if [ -n "$1" ] && [ "$1" != "--" ]; then
usage
elif [ "$1" == "--" ]; then
shift
fi
echo "Downloading artifacts from run ${run} [this may take a while] ..."
gh run download "$run" -p 'void-live*' "$@"
echo "Done."
}
sign_build() {
check_programs pwgen minisign
DATECODE="$1"
SUMFILE="$2"
mkdir -p release
echo "Creating key..."
pwgen -cny 25 1 > "release/void-release-$DATECODE.key"
minisign -G -p "release/void-release-$DATECODE.pub" \
-s "release/void-release-$DATECODE.sec" \
-c "This key is only valid for images with date $DATECODE." \
< <(cat "release/void-release-$DATECODE.key" "release/void-release-$DATECODE.key")
echo "Signing $SUMFILE..."
minisign -S -x "${SUMFILE//txt/sig}" -s "release/void-release-$DATECODE.sec" \
-c "This key is only valid for images with date $DATECODE." \
-t "This key is only valid for images with date $DATECODE." \
-m "$SUMFILE" < "release/void-release-$DATECODE.key"
}
case "$1" in
st*) shift; start_build "$@" ;;
d*) shift; download_build "$@" ;;
si*) shift; sign_build "$@" ;;
*) usage ;;
esac

37
release.sh.in Normal file
View File

@ -0,0 +1,37 @@
#!/bin/bash
REPOSITORY="/hostdir/binpkgs /hostdir/binpkgs/musl /hostdir/binpkgs/aarch64"
DATECODE=$(date "+%Y%m%d")
make
ARCHS="$(echo x86_64{,-musl} armv{6,7}l{,-musl} aarch64{,-musl})"
PLATFORMS="$(echo rpi{,2,3}{,-musl} beaglebone{,-musl} cubieboard2{,-musl} odroid-c2{,-musl})"
SBC_IMGS="$(echo rpi{,2,3}{,-musl} beaglebone{,-musl} cubieboard2{,-musl} odroid-c2{,-musl})"
make rootfs-all ARCHS="$ARCHS" REPOSITORY="$REPOSITORY" DATECODE="$DATECODE"
make platformfs-all PLATFORMS="$PLATFORMS" REPOSITORY="$REPOSITORY" DATECODE="$DATECODE"
make images-all-sbc SBC_IMGS="$SBC_IMGS" REPOSITORY="$REPOSITORY" DATECODE="$DATECODE"
make pxe-all REPOSITORY="$REPOSITORY"
MKLIVE_REPO=(-r /hostdir/binpkgs -r /hostdir/binpkgs/nonfree -r /hostdir/musl -r /hostdir/binpkgs/musl/nonfree)
./build-x86-images.sh -a i686 -b base "${MKLIVE_REPO[@]}"
./build-x86-images.sh -a i686 -b xfce "${MKLIVE_REPO[@]}"
./build-x86-images.sh -a x86_64 -b base "${MKLIVE_REPO[@]}"
./build-x86-images.sh -a x86_64 -b xfce "${MKLIVE_REPO[@]}"
./build-x86-images.sh -a x86_64 -b cinnamon "${MKLIVE_REPO[@]}"
./build-x86-images.sh -a x86_64 -b lxde "${MKLIVE_REPO[@]}"
./build-x86-images.sh -a x86_64-musl -b base "${MKLIVE_REPO[@]}"
./build-x86-images.sh -a x86_64-musl -b xfce "${MKLIVE_REPO[@]}"
./build-x86-images.sh -a x86_64-musl -b cinnamon "${MKLIVE_REPO[@]}"
./build-x86-images.sh -a x86_64-musl -b lxde "${MKLIVE_REPO[@]}"
mkdir "$DATECODE"
mv "*${DATECODE}*.xz" "$DATECODE/"
mv "*${DATECODE}*.gz" "$DATECODE/"
mv "*${DATECODE}*.iso" "$DATECODE/"
cd "$DATECODE" || exit 1
sha256sum -- * > sha256sums.txt

View File

@ -1 +0,0 @@
0.25