Add extra options
This commit is contained in:
parent
10e6e4e4bc
commit
a01c0973a3
4 changed files with 155 additions and 10 deletions
63
Makefile
63
Makefile
|
@ -1,15 +1,36 @@
|
|||
# Name of image
|
||||
IMAGE ?= d.xr.to/base
|
||||
IMAGE?=d.xr.to/base
|
||||
# Arch to be used
|
||||
ARCH ?= x86_64-musl
|
||||
ARCH?=x86_64-musl
|
||||
# Repo root url to be used (/musl will be appended in case of musl based arch)
|
||||
REPO_ROOT ?= https://alpha.de.repo.voidlinux.org/current
|
||||
REPO_ROOT?=https://alpha.de.repo.voidlinux.org/current
|
||||
# Absolute repo url
|
||||
REPO ?= $(REPO_ROOT)$(if $(findstring musl, $(ARCH)),/musl)
|
||||
REPO?=$(REPO_ROOT)$(if $(findstring musl, $(ARCH)),/musl)
|
||||
# Toolbox to be used (toybox, busybox, none or default)
|
||||
TOOLBOX?=toybox
|
||||
# Packages to install
|
||||
PACKAGES ?= toybox xbps bash ncurses-base
|
||||
PACKAGES?=xbps bash ncurses-base
|
||||
# Directory where chroot should be build
|
||||
BUILDDIR ?= $(PWD)/build
|
||||
BUILDDIR?=$(PWD)/build
|
||||
ifeq ($(TOOLBOX),none)
|
||||
VALID_TOOLBOX?=1
|
||||
endif
|
||||
ifeq ($(TOOLBOX),)
|
||||
override TOOLBOX=none
|
||||
VALID_TOOLBOX?=1
|
||||
endif
|
||||
ifeq ($(TOOLBOX),toybox)
|
||||
override PACKAGES += toybox
|
||||
VALID_TOOLBOX?=1
|
||||
endif
|
||||
ifeq ($(TOOLBOX),busybox)
|
||||
override PACKAGES += busybox
|
||||
VALID_TOOLBOX?=1
|
||||
endif
|
||||
ifeq ($(TOOLBOX),default)
|
||||
override PACKAGES += findutils coreutils diffutils gawk which sed gzip file grep
|
||||
VALID_TOOLBOX?=1
|
||||
endif
|
||||
|
||||
default: all
|
||||
|
||||
|
@ -18,10 +39,18 @@ vars:
|
|||
@echo ARCH=$(ARCH)
|
||||
@echo REPO_ROOT=$(REPO_ROOT)
|
||||
@echo REPO=$(REPO)
|
||||
@echo TOOLBOX=$(TOOLBOX)
|
||||
@echo VALID_TOOLBOX=$(VALID_TOOLBOX)
|
||||
@echo PACKAGES=$(PACKAGES)
|
||||
@echo BUILDDIR=$(BUILDDIR)
|
||||
|
||||
build:
|
||||
ensure-toolbox:
|
||||
ifneq ($(VALID_TOOLBOX),1)
|
||||
@echo "Please make sure TOOLBOX is none, toybox (default option), busybox or default"
|
||||
exit 1
|
||||
endif
|
||||
|
||||
build: ensure-toolbox
|
||||
# Create build directory
|
||||
mkdir $(BUILDDIR)
|
||||
# Create keys database directory
|
||||
|
@ -34,13 +63,27 @@ build:
|
|||
for dir in lib lib32 sbin bin; do [ -e $(BUILDDIR)/$$dir ] || ln -s usr/$$dir $(BUILDDIR)/$$dir; done
|
||||
ln -s usr/lib $(BUILDDIR)/lib64
|
||||
# Create default directories expected by void
|
||||
for dir in proc sys dev; do [ -d $(BUILDDIR)/$$dir ] || mkdir $(BUILDDIR)/$$dir; done
|
||||
for dir in proc sys dev tmp; do [ -d $(BUILDDIR)/$$dir ] || mkdir $(BUILDDIR)/$$dir; done
|
||||
ifeq ($(TOOLBOX),toybox)
|
||||
# Create toybox symlinks
|
||||
xbps-uchroot $(BUILDDIR) /bin/toybox | sed 's:\s:\n:g' | grep -v '^$$' | while read i; do [ -e $(BUILDDIR)/usr/bin/$$i ] || ln -s /bin/toybox $(BUILDDIR)/usr/bin/$$i; done
|
||||
# Remove xbps cache dir
|
||||
endif
|
||||
ifeq ($(TOOLBOX),busybox)
|
||||
# Create busybox symlinks
|
||||
xbps-uchroot $(BUILDDIR) /bin/busybox -- --list | while read i; do [ -e $(BUILDDIR)/usr/bin/$$i ] || ln -s /bin/busybox $(BUILDDIR)/usr/bin/$$i; done
|
||||
endif
|
||||
# Remove xbps cache dir
|
||||
rm -rf $(BUILDDIR)/var/cache/xbps
|
||||
# Import custom bashrc
|
||||
cp bashrc.bash $(BUILDDIR)/etc/bash/bashrc.d/docker.sh
|
||||
cp files/bashrc.bash $(BUILDDIR)/etc/bash/bashrc.d/docker.sh
|
||||
# Create os-release file
|
||||
cp files/os-release $(BUILDDIR)/etc/os-release
|
||||
# Create lsb_release file
|
||||
cp files/lsb_release $(BUILDDIR)/bin/lsb_release
|
||||
chmod +x $(BUILDDIR)/bin/lsb_release
|
||||
# Create passwd and group file
|
||||
echo 'root:x:0:0:root:/:/bin/bash' >> $(BUILDDIR)/etc/passwd
|
||||
echo 'root:x:0:' >> $(BUILDDIR)/etc/group
|
||||
|
||||
install: build
|
||||
# Import directory as tar (owned by root) into docker
|
||||
|
|
98
files/lsb_release
Executable file
98
files/lsb_release
Executable file
|
@ -0,0 +1,98 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Compatibility script for FSG lsb_release v1.4 or newer
|
||||
#
|
||||
version="1.0"
|
||||
distributor_id="VoidLinux"
|
||||
description="Void Linux"
|
||||
release="rolling"
|
||||
codename="void"
|
||||
options=""
|
||||
short=0
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
-v|--version) options="${options} version" ;;
|
||||
-i|--id) options="${options} distributor_id" ;;
|
||||
-d|--description) options="${options} description" ;;
|
||||
-r|--release) options="${options} release" ;;
|
||||
-c|--codename) options="${options} codename" ;;
|
||||
-a|--all) options="version distributor_id description release codename" ;;
|
||||
-s|--short) short=1 ;;
|
||||
-h|--help) cat << _EOF
|
||||
SYNOPSIS
|
||||
lsb_release [OPTION]...
|
||||
OPTIONS
|
||||
−v, −−version
|
||||
Display the version of the LSB specification against which the distribution is compliant.
|
||||
|
||||
−i, −−id
|
||||
Display the string id of the distributor.
|
||||
|
||||
−d, −−description
|
||||
Display the single line text description of the distribution.
|
||||
|
||||
−r, −−release
|
||||
Display the release number of the distribution.
|
||||
|
||||
−c, −−codename
|
||||
Display the codename according to the distribution release.
|
||||
|
||||
−a, −−all
|
||||
Display all of the above information.
|
||||
|
||||
−s, −−short
|
||||
Display all of the above information in short output format.
|
||||
|
||||
−h, −−help
|
||||
Display this message.
|
||||
_EOF
|
||||
;;
|
||||
-*) # Multiple options in one parameter
|
||||
opt=$(echo $1 | cut -c2-)
|
||||
while [ ! -z "$opt" ]; do
|
||||
o=$(echo $opt | cut -c1)
|
||||
case "$o" in
|
||||
v) options="${options} version" ;;
|
||||
i) options="${options} distributor_id" ;;
|
||||
d) options="${options} description" ;;
|
||||
r) options="${options} release" ;;
|
||||
c) options="${options} codename" ;;
|
||||
a) options="version distributor_id description release codename" ;;
|
||||
s) short=1 ;;
|
||||
esac
|
||||
opt=$(echo $opt | cut -c2-)
|
||||
done
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
[ -z "$options" ] && options="version"
|
||||
|
||||
if [ "$short" -eq 1 ]; then
|
||||
space=""
|
||||
for opt in $options; do
|
||||
case "$opt" in
|
||||
version) printf "${space}${version}" ;;
|
||||
distributor_id) printf "${space}${distributor_id}" ;;
|
||||
description) printf "${space}\"${description}\"" ;;
|
||||
release) printf "${space}${release}" ;;
|
||||
codename) printf "${space}${codename}" ;;
|
||||
esac
|
||||
space=" "
|
||||
done
|
||||
printf "\n"
|
||||
else
|
||||
for opt in $options; do
|
||||
case "$opt" in
|
||||
version) printf "LSB Version:\t${version}\n" ;;
|
||||
distributor_id) printf "Distributor ID:\t${distributor_id}\n" ;;
|
||||
description) printf "Description:\t${description}\n" ;;
|
||||
release) printf "Release:\t${release}\n" ;;
|
||||
codename) printf "Codename:\t${codename}\n" ;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
exit 0
|
4
files/os-release
Normal file
4
files/os-release
Normal file
|
@ -0,0 +1,4 @@
|
|||
NAME="void"
|
||||
ID="void"
|
||||
DISTRIB_ID="void"
|
||||
PRETTY_NAME="void"
|
Loading…
Reference in a new issue