From 8b06a299c97cd4cbda3f51418a10dddfc57cf3f0 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Tue, 26 Apr 2016 11:00:14 +0200 Subject: mkrootfs: added ci20 platform support (MIPS CI20 Creator). --- mkrootfs.sh.in | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mkrootfs.sh.in b/mkrootfs.sh.in index 583044c..f4e06a1 100644 --- a/mkrootfs.sh.in +++ b/mkrootfs.sh.in @@ -47,7 +47,7 @@ Usage: $PROGNAME [options] Supported platforms: i686, i686-musl, x86_64, x86_64-musl, dockstar, bananapi, beaglebone, cubieboard2, cubietruck, - odroid-u2, rpi, rpi2 (armv7), usbarmory + odroid-u2, rpi, rpi2 (armv7), usbarmory, ci20 Options -b Set an alternative base-system package (defaults to base-system) @@ -97,12 +97,15 @@ register_binfmt() { case "${_ARCH}" in armv*) echo ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-arm-static:' > /proc/sys/fs/binfmt_misc/register - cp -f $(which qemu-arm-static) $rootfs/usr/bin || die "failed to copy qemu-arm-static to the rootfs" + ;; + mipsel*) + echo ':mipsel:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-mipsel-static:' > /proc/sys/fs/binfmt_misc/register ;; *) die "Unknown target architecture!" ;; esac + cp -f $(which $QEMU_BIN) $rootfs/usr/bin || die "failed to copy $QEMU_BIN to the rootfs" } # @@ -131,6 +134,8 @@ case "$PLATFORM" in dockstar) _TARGET_ARCH="armv5tel"; _ARCH="armv5tel";; rpi-musl) _TARGET_ARCH="armv6l-musl"; _ARCH="armv6l";; rpi) _TARGET_ARCH="armv6l"; _ARCH="armv6l";; + ci20-musl) _TARGET_ARCH="mipselhf-musl"; _ARCH="mipsel-musl";; + ci20) _TARGET_ARCH="mipselhf"; _ARCH="mipsel";; *-musl) _TARGET_ARCH="armv7l-musl"; _ARCH="armv7l";; *) _TARGET_ARCH="armv7l"; _ARCH="armv7l";; esac @@ -157,6 +162,7 @@ case "$PLATFORM" in rpi2*) SUBPLATFORM=rpi; QEMU_BIN=qemu-arm-static;; rpi*) SUBPLATFORM=${PLATFORM%-*}; QEMU_BIN=qemu-arm-static;; usbarmory*) SUBPLATFORM=${PLATFORM%-*}; QEMU_BIN=qemu-arm-static;; + ci20*) SUBPLATFORM=${PLATFORM%-*}; QEMU_BIN=qemu-mipsel-static;; i686*) QEMU_BIN=qemu-i386-static;; x86_64*) QEMU_BIN=qemu-x86_64-static;; *) die "$PROGNAME: invalid platform!";; -- cgit 1.4.1 From ffe9572e3fc5bd1947932b061c11a39f9ac4f59b Mon Sep 17 00:00:00 2001 From: Juan RP Date: Tue, 26 Apr 2016 11:20:14 +0200 Subject: mkimage: added ci20 platform support (MIPS CI20 Creator). --- mkimage.sh.in | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mkimage.sh.in b/mkimage.sh.in index 26007dd..367c455 100644 --- a/mkimage.sh.in +++ b/mkimage.sh.in @@ -200,6 +200,10 @@ odroid-u2) usbarmory) dd if=${ROOTFSDIR}/boot/u-boot.imx of=${LOOPDEV} bs=512 seek=2 conv=fsync >/dev/null 2>&1 ;; +ci20) + dd if=${ROOTFSDIR}/boot/u-boot-spl.bin of=${LOOPDEV} obs=512 seek=1 >/dev/null 2>&1 + dd if=${ROOTFSDIR}/boot/u-boot.img of=${LOOPDEV} obs=1K seek=14 >/dev/null 2>&1 + ;; esac mountpoint -q ${ROOTFSDIR}/boot && umount ${ROOTFSDIR}/boot -- cgit 1.4.1 From be2251492f536bb5ae974c049c02ddb834bc0630 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Tue, 26 Apr 2016 11:45:37 +0200 Subject: mkimage: ci20 just needs a single partition and expects the kernel in /vmlinux.img. --- mkimage.sh.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mkimage.sh.in b/mkimage.sh.in index 367c455..86bf45e 100644 --- a/mkimage.sh.in +++ b/mkimage.sh.in @@ -142,7 +142,7 @@ if [ "$BOOT_FSTYPE" = "vfat" ]; then _args="-I -F16" fi case "$PLATFORM" in -cubieboard2|cubietruck) +cubieboard2|cubietruck|ci20*) parted $FILENAME mkpart primary ext2 2048s ${ROOT_FSSIZE} 100% parted $FILENAME toggle 1 boot LOOPDEV=$(losetup --show --find --partscan $FILENAME) @@ -201,6 +201,7 @@ usbarmory) dd if=${ROOTFSDIR}/boot/u-boot.imx of=${LOOPDEV} bs=512 seek=2 conv=fsync >/dev/null 2>&1 ;; ci20) + ln -sf /boot/uImage ${ROOTFSDIR}/vmlinux.img dd if=${ROOTFSDIR}/boot/u-boot-spl.bin of=${LOOPDEV} obs=512 seek=1 >/dev/null 2>&1 dd if=${ROOTFSDIR}/boot/u-boot.img of=${LOOPDEV} obs=1K seek=14 >/dev/null 2>&1 ;; -- cgit 1.4.1 From 6372530837387454c9837901c51748d0ae96cbeb Mon Sep 17 00:00:00 2001 From: Juan RP Date: Tue, 26 Apr 2016 15:00:55 +0200 Subject: mkimage: get rid of parted; use sfdisk(8). --- README.md | 1 - mkimage.sh.in | 24 +++++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 7498034..aa22405 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,6 @@ This repository contains utilities for Void Linux: #### Dependencies * xbps>=0.45 - * parted (for mkimage) * qemu-user-static binaries (for mkrootfs) #### Usage diff --git a/mkimage.sh.in b/mkimage.sh.in index 86bf45e..ef30c5f 100644 --- a/mkimage.sh.in +++ b/mkimage.sh.in @@ -1,6 +1,6 @@ #!/bin/sh #- -# Copyright (c) 2013-2015 Juan Romero Pardines. +# Copyright (c) 2013-2016 Juan Romero Pardines. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -56,11 +56,11 @@ Usage: $PROGNAME [options] The argument expects a tarball generated by void-mkrootfs. The platform is guessed automatically by its name. -Accepted sizes suffixes: K, M, G, T, E. +Accepted sizes suffixes: KiB, MiB, GiB, TiB, EiB. OPTIONS -b Set /boot filesystem type (defaults to FAT) - -B Set /boot filesystem size (defaults to 64MB) + -B Set /boot filesystem size (defaults to 64MiB) -r Set / filesystem type (defaults to EXT4) -s Set total image size (defaults to 2GB) -o Set image filename (guessed automatically) @@ -104,7 +104,7 @@ fi : ${IMGSIZE:=2G} : ${BOOT_FSTYPE:=vfat} -: ${BOOT_FSSIZE:=64M} +: ${BOOT_FSSIZE:=64MiB} : ${ROOT_FSTYPE:=ext4} if [ -z "$FILENAME" ]; then @@ -117,7 +117,7 @@ case "$PLATFORM" in *) die "The $PLATFORM is not supported, exiting..." esac -for f in parted partx losetup mount mkfs.${BOOT_FSTYPE} mkfs.${ROOT_FSTYPE}; do +for f in sfdisk partx losetup mount mkfs.${BOOT_FSTYPE} mkfs.${ROOT_FSTYPE}; do if ! which ${f} >/dev/null; then die "Cannot find ${f}, exiting." fi @@ -143,17 +143,19 @@ if [ "$BOOT_FSTYPE" = "vfat" ]; then fi case "$PLATFORM" in cubieboard2|cubietruck|ci20*) - parted $FILENAME mkpart primary ext2 2048s ${ROOT_FSSIZE} 100% - parted $FILENAME toggle 1 boot + sfdisk ${FILENAME} <<_EOF +2048,,L +_EOF LOOPDEV=$(losetup --show --find --partscan $FILENAME) mkfs.${ROOT_FSTYPE} $disable_journal ${LOOPDEV}p1 >/dev/null 2>&1 mount ${LOOPDEV}p1 $ROOTFSDIR ROOT_UUID=$(blkid -o value -s UUID ${LOOPDEV}p1) ;; *) - parted $FILENAME mkpart primary ${_btype} 2048s ${BOOT_FSSIZE} - parted $FILENAME mkpart primary ext2 ${BOOT_FSSIZE} 100% - parted $FILENAME toggle 1 boot + sfdisk ${FILENAME} <<_EOF +2048,${BOOT_FSSIZE},b +${BOOT_SIZE},+,L,* +_EOF LOOPDEV=$(losetup --show --find --partscan $FILENAME) mkfs.${BOOT_FSTYPE} $_args ${LOOPDEV}p1 >/dev/null case "$ROOT_FSTYPE" in @@ -201,7 +203,7 @@ usbarmory) dd if=${ROOTFSDIR}/boot/u-boot.imx of=${LOOPDEV} bs=512 seek=2 conv=fsync >/dev/null 2>&1 ;; ci20) - ln -sf /boot/uImage ${ROOTFSDIR}/vmlinux.img + cp -f ${ROOTFSDIR}/boot/uImage ${ROOTFSDIR}/boot/vmlinux.img dd if=${ROOTFSDIR}/boot/u-boot-spl.bin of=${LOOPDEV} obs=512 seek=1 >/dev/null 2>&1 dd if=${ROOTFSDIR}/boot/u-boot.img of=${LOOPDEV} obs=1K seek=14 >/dev/null 2>&1 ;; -- cgit 1.4.1 From 687cd4e53628d695da2969510f63e04104b93aa1 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Tue, 26 Apr 2016 15:47:56 +0200 Subject: mkimage: match any platform (glibc and musl). --- mkimage.sh.in | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mkimage.sh.in b/mkimage.sh.in index ef30c5f..2e76251 100644 --- a/mkimage.sh.in +++ b/mkimage.sh.in @@ -190,19 +190,19 @@ if [ -n "$BOOT_UUID" ]; then fi case "$PLATFORM" in -bananapi|cubieboard2|cubietruck) +bananapi*|cubieboard2*|cubietruck*) dd if=${ROOTFSDIR}/boot/u-boot-sunxi-with-spl.bin of=${LOOPDEV} bs=1024 seek=8 >/dev/null 2>&1 ;; -odroid-u2) +odroid-u2*) dd if=${ROOTFSDIR}/boot/E4412_S.bl1.HardKernel.bin of=${LOOPDEV} seek=1 >/dev/null 2>&1 dd if=${ROOTFSDIR}/boot/bl2.signed.bin of=${LOOPDEV} seek=31 >/dev/null 2>&1 dd if=${ROOTFSDIR}/boot/u-boot.bin of=${LOOPDEV} seek=63 >/dev/null 2>&1 dd if=${ROOTFSDIR}/boot/E4412_S.tzsw.signed.bin of=${LOOPDEV} seek=2111 >/dev/null 2>&1 ;; -usbarmory) +usbarmory*) dd if=${ROOTFSDIR}/boot/u-boot.imx of=${LOOPDEV} bs=512 seek=2 conv=fsync >/dev/null 2>&1 ;; -ci20) +ci20*) cp -f ${ROOTFSDIR}/boot/uImage ${ROOTFSDIR}/boot/vmlinux.img dd if=${ROOTFSDIR}/boot/u-boot-spl.bin of=${LOOPDEV} obs=512 seek=1 >/dev/null 2>&1 dd if=${ROOTFSDIR}/boot/u-boot.img of=${LOOPDEV} obs=1K seek=14 >/dev/null 2>&1 -- cgit 1.4.1 From 3debfb21deb9d5e091cacc55d8d523cc932efd40 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Wed, 27 Apr 2016 12:48:46 +0200 Subject: mkimage: ci20 uboot does not need /boot/vmlinux.img; looks for uImage. --- mkimage.sh.in | 1 - 1 file changed, 1 deletion(-) diff --git a/mkimage.sh.in b/mkimage.sh.in index 2e76251..1dee456 100644 --- a/mkimage.sh.in +++ b/mkimage.sh.in @@ -203,7 +203,6 @@ usbarmory*) dd if=${ROOTFSDIR}/boot/u-boot.imx of=${LOOPDEV} bs=512 seek=2 conv=fsync >/dev/null 2>&1 ;; ci20*) - cp -f ${ROOTFSDIR}/boot/uImage ${ROOTFSDIR}/boot/vmlinux.img dd if=${ROOTFSDIR}/boot/u-boot-spl.bin of=${LOOPDEV} obs=512 seek=1 >/dev/null 2>&1 dd if=${ROOTFSDIR}/boot/u-boot.img of=${LOOPDEV} obs=1K seek=14 >/dev/null 2>&1 ;; -- cgit 1.4.1 From 9d66fae1c047857cad2cbf45dcf41f07fcc44ef0 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Fri, 29 Apr 2016 09:23:38 +0200 Subject: mkrootfs: ignore rmdir error output. --- mkrootfs.sh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkrootfs.sh.in b/mkrootfs.sh.in index f4e06a1..096d6e8 100644 --- a/mkrootfs.sh.in +++ b/mkrootfs.sh.in @@ -227,7 +227,7 @@ if [ -n "${_ARCH}" ]; then register_binfmt run_cmd "xbps-reconfigure -r $rootfs base-files" run_cmd "chroot $rootfs env -i xbps-reconfigure -f base-files" - rmdir $rootfs/usr/lib32 + rmdir $rootfs/usr/lib32 2>/dev/null rm -f $rootfs/lib32 $rootfs/lib64 $rootfs/usr/lib64 ;; esac -- cgit 1.4.1 From 7e21c2f151b4363ae1704306125b495ab528c2cd Mon Sep 17 00:00:00 2001 From: Juan RP Date: Fri, 29 Apr 2016 09:24:01 +0200 Subject: dracut/adduser.sh: remove double whitespace from sudoers. This lets the installer remove the anon rule from etc/sudoers. --- dracut/adduser.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dracut/adduser.sh b/dracut/adduser.sh index f006424..dbcbd35 100644 --- a/dracut/adduser.sh +++ b/dracut/adduser.sh @@ -32,7 +32,7 @@ chroot ${NEWROOT} sh -c "echo "$USERNAME:voidlinux" | chpasswd -c SHA512" # Enable sudo permission by default. if [ -f ${NEWROOT}/etc/sudoers ]; then - echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> ${NEWROOT}/etc/sudoers + echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> ${NEWROOT}/etc/sudoers fi if [ -d ${NEWROOT}/etc/polkit-1 ]; then -- cgit 1.4.1 From d6f949d6403b309aa918e2779b8efe920935a7ae Mon Sep 17 00:00:00 2001 From: Juan RP Date: Fri, 29 Apr 2016 14:17:49 +0200 Subject: mkimage: get rid of parted completely (missed this in previous). --- mkimage.sh.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mkimage.sh.in b/mkimage.sh.in index 1dee456..5729c9d 100644 --- a/mkimage.sh.in +++ b/mkimage.sh.in @@ -136,7 +136,6 @@ truncate -s "${IMGSIZE}" $FILENAME >/dev/null 2>&1 ROOTFSDIR=$(mktemp -d) info_msg "Creating disk image partitions/filesystems ..." -parted $FILENAME mktable msdos if [ "$BOOT_FSTYPE" = "vfat" ]; then _btype="fat32" _args="-I -F16" @@ -144,6 +143,7 @@ fi case "$PLATFORM" in cubieboard2|cubietruck|ci20*) sfdisk ${FILENAME} <<_EOF +label: dos 2048,,L _EOF LOOPDEV=$(losetup --show --find --partscan $FILENAME) @@ -153,6 +153,7 @@ _EOF ;; *) sfdisk ${FILENAME} <<_EOF +label: dos 2048,${BOOT_FSSIZE},b ${BOOT_SIZE},+,L,* _EOF -- cgit 1.4.1 From b7e8732b04c1296e778e161ecabc7a69304ba1ee Mon Sep 17 00:00:00 2001 From: Michael Aldridge Date: Sat, 30 Apr 2016 23:12:44 -0500 Subject: Add *.iso to .gitignore (#69) --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 20af4c3..7d5c9a8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.sh *.img *.xz +*.iso xbps-cachedir* -- cgit 1.4.1 From d1e633fc12db2fff07b8b64d9b0e6f9cd84b9b88 Mon Sep 17 00:00:00 2001 From: Christian Neukirchen Date: Fri, 29 Apr 2016 15:38:21 +0200 Subject: mkrootfs.sh.in: add odroid-c2. --- mkrootfs.sh.in | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mkrootfs.sh.in b/mkrootfs.sh.in index 096d6e8..9425d0b 100644 --- a/mkrootfs.sh.in +++ b/mkrootfs.sh.in @@ -47,7 +47,7 @@ Usage: $PROGNAME [options] Supported platforms: i686, i686-musl, x86_64, x86_64-musl, dockstar, bananapi, beaglebone, cubieboard2, cubietruck, - odroid-u2, rpi, rpi2 (armv7), usbarmory, ci20 + odroid-c2, odroid-u2, rpi, rpi2 (armv7), usbarmory, ci20 Options -b Set an alternative base-system package (defaults to base-system) @@ -98,6 +98,9 @@ register_binfmt() { armv*) echo ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-arm-static:' > /proc/sys/fs/binfmt_misc/register ;; + aarch*) + echo ':qemu-arm64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-aarch64-static:' > /proc/sys/fs/binfmt_misc/register + ;; mipsel*) echo ':mipsel:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-mipsel-static:' > /proc/sys/fs/binfmt_misc/register ;; @@ -136,6 +139,8 @@ case "$PLATFORM" in rpi) _TARGET_ARCH="armv6l"; _ARCH="armv6l";; ci20-musl) _TARGET_ARCH="mipselhf-musl"; _ARCH="mipsel-musl";; ci20) _TARGET_ARCH="mipselhf"; _ARCH="mipsel";; + odroid-c2-musl) _TARGET_ARCH="aarch64-musl"; _ARCH="aarch64";; + odroid-c2) _TARGET_ARCH="aarch64"; _ARCH="aarch64";; *-musl) _TARGET_ARCH="armv7l-musl"; _ARCH="armv7l";; *) _TARGET_ARCH="armv7l"; _ARCH="armv7l";; esac @@ -163,6 +168,7 @@ case "$PLATFORM" in rpi*) SUBPLATFORM=${PLATFORM%-*}; QEMU_BIN=qemu-arm-static;; usbarmory*) SUBPLATFORM=${PLATFORM%-*}; QEMU_BIN=qemu-arm-static;; ci20*) SUBPLATFORM=${PLATFORM%-*}; QEMU_BIN=qemu-mipsel-static;; + odroid-c2*) SUBPLATFORM=${PLATFORM%-*}; QEMU_BIN=qemu-aarch64-static;; i686*) QEMU_BIN=qemu-i386-static;; x86_64*) QEMU_BIN=qemu-x86_64-static;; *) die "$PROGNAME: invalid platform!";; -- cgit 1.4.1 From b2415b015d2146e80e255987a5eddb224aea1c3c Mon Sep 17 00:00:00 2001 From: Christian Neukirchen Date: Fri, 6 May 2016 14:41:04 +0200 Subject: mkimage.sh.in: add odroid-c2. --- mkimage.sh.in | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mkimage.sh.in b/mkimage.sh.in index 5729c9d..ed6b6e4 100644 --- a/mkimage.sh.in +++ b/mkimage.sh.in @@ -113,7 +113,7 @@ fi # double check PLATFORM is supported... case "$PLATFORM" in - bananapi|beaglebone|cubieboard2|cubietruck|odroid-u2|rpi|rpi2|usbarmory|*-musl);; + bananapi|beaglebone|cubieboard2|cubietruck|odroid-c2|odroid-u2|rpi|rpi2|usbarmory|*-musl);; *) die "The $PLATFORM is not supported, exiting..." esac @@ -141,7 +141,7 @@ if [ "$BOOT_FSTYPE" = "vfat" ]; then _args="-I -F16" fi case "$PLATFORM" in -cubieboard2|cubietruck|ci20*) +cubieboard2|cubietruck|ci20*|odroid-c2*) sfdisk ${FILENAME} <<_EOF label: dos 2048,,L @@ -194,6 +194,11 @@ case "$PLATFORM" in bananapi*|cubieboard2*|cubietruck*) dd if=${ROOTFSDIR}/boot/u-boot-sunxi-with-spl.bin of=${LOOPDEV} bs=1024 seek=8 >/dev/null 2>&1 ;; +odroid-c2*) + dd if=${ROOTFSDIR}/boot/bl1.bin.hardkernel of=${LOOPDEV} bs=1 count=442 >/dev/null 2>&1 + dd if=${ROOTFSDIR}/boot/bl1.bin.hardkernel of=${LOOPDEV} bs=512 skip=1 seek=1 >/dev/null 2>&1 + dd if=${ROOTFSDIR}/boot/u-boot.bin of=${LOOPDEV} bs=512 seek=97 >/dev/null 2>&1 + ;; odroid-u2*) dd if=${ROOTFSDIR}/boot/E4412_S.bl1.HardKernel.bin of=${LOOPDEV} seek=1 >/dev/null 2>&1 dd if=${ROOTFSDIR}/boot/bl2.signed.bin of=${LOOPDEV} seek=31 >/dev/null 2>&1 -- cgit 1.4.1 From de4c52a4a6ea274ea84e30a876a8ac5430355634 Mon Sep 17 00:00:00 2001 From: Jürgen Buchmüller Date: Thu, 12 May 2016 08:13:56 +0200 Subject: installer.sh.in: add ISO-639 and ISO-3166 tables (#71) The locale selection now has user friendly names for language and country. This time without bashisms. --- installer.sh.in | 211 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 207 insertions(+), 4 deletions(-) diff --git a/installer.sh.in b/installer.sh.in index ce2ba00..c1e4407 100644 --- a/installer.sh.in +++ b/installer.sh.in @@ -117,6 +117,202 @@ get_option() { echo $(grep -E "^${1}.*" $CONF_FILE|sed -e "s|${1}||") } +# ISO-639 language names for locales +iso639_language() { + case "$1" in + aa) echo "Afar" ;; + af) echo "Afrikaans" ;; + an) echo "Aragonese" ;; + ar) echo "Arabic" ;; + ast) echo "Asturian" ;; + be) echo "Belgian" ;; + bg) echo "Bulgarian" ;; + bhb) echo "Bhili" ;; + br) echo "Breton" ;; + bs) echo "Bosnian" ;; + ca) echo "Catalan" ;; + cs) echo "Czech" ;; + cy) echo "Welsh" ;; + da) echo "Danish" ;; + de) echo "German" ;; + el) echo "Greek" ;; + en) echo "English" ;; + es) echo "Spanish" ;; + et) echo "Estonian" ;; + eu) echo "Basque" ;; + fi) echo "Finnish" ;; + fo) echo "Faroese" ;; + fr) echo "French" ;; + ga) echo "Irish" ;; + gd) echo "Scottish Gaelic" ;; + gl) echo "Galician" ;; + gv) echo "Manx" ;; + he) echo "Hebrew" ;; + hr) echo "Croatian" ;; + hsb) echo "Upper Sorbian" ;; + hu) echo "Hungarian" ;; + id) echo "Indonesian" ;; + is) echo "Icelandic" ;; + it) echo "Italian" ;; + iw) echo "Hebrew" ;; + ja) echo "Japanese" ;; + ka) echo "Georgian" ;; + kk) echo "Kazakh" ;; + kl) echo "Kalaallisut" ;; + ko) echo "Korean" ;; + ku) echo "Kurdish" ;; + kw) echo "Cornish" ;; + lg) echo "Ganda" ;; + lt) echo "Lithuanian" ;; + lv) echo "Latvian" ;; + mg) echo "Malagasy" ;; + mi) echo "Maori" ;; + mk) echo "Macedonian" ;; + ms) echo "Malay" ;; + mt) echo "Maltese" ;; + nb) echo "Norwegian Bokmål" ;; + nl) echo "Dutch" ;; + nn) echo "Norwegian Nynorsk" ;; + oc) echo "Occitan" ;; + om) echo "Oromo" ;; + pl) echo "Polish" ;; + pt) echo "Portugese" ;; + ro) echo "Romanian" ;; + ru) echo "Russian" ;; + sk) echo "Slovak" ;; + sl) echo "Slovenian" ;; + so) echo "Somali" ;; + sq) echo "Albanian" ;; + st) echo "Southern Sotho" ;; + sv) echo "Swedish" ;; + tcy) echo "Tulu" ;; + tg) echo "Tajik" ;; + th) echo "Thai" ;; + tl) echo "Tagalog" ;; + tr) echo "Turkish" ;; + uk) echo "Ukrainian" ;; + uz) echo "Uzbek" ;; + wa) echo "Walloon" ;; + xh) echo "Xhosa" ;; + yi) echo "Yiddish" ;; + zh) echo "Chinese" ;; + zu) echo "Zulu" ;; + *) echo "$1" ;; + esac +} + +# ISO-3166 country codes for locales +iso3166_country() { + case "$1" in + AD) echo "Andorra" ;; + AE) echo "United Arab Emirates" ;; + AL) echo "Albania" ;; + AR) echo "Argentina" ;; + AT) echo "Austria" ;; + AU) echo "Australia" ;; + BA) echo "Bonsia and Herzegovina" ;; + BE) echo "Belgium" ;; + BG) echo "Bulgaria" ;; + BH) echo "Bahrain" ;; + BO) echo "Bolivia" ;; + BR) echo "Brazil" ;; + BW) echo "Botswana" ;; + BY) echo "Belarus" ;; + CA) echo "Canada" ;; + CH) echo "Switzerland" ;; + CL) echo "Chile" ;; + CN) echo "China" ;; + CO) echo "Colombia" ;; + CR) echo "Costa Rica" ;; + CY) echo "Cyprus" ;; + CZ) echo "Czech Republic" ;; + DE) echo "Germany" ;; + DJ) echo "Djibouti" ;; + DK) echo "Denmark" ;; + DO) echo "Dominican Republic" ;; + DZ) echo "Algeria" ;; + EC) echo "Ecuador" ;; + EE) echo "Estonia" ;; + EG) echo "Egypt" ;; + ES) echo "Spain" ;; + FI) echo "Finland" ;; + FO) echo "Faroe Islands" ;; + FR) echo "France" ;; + GB) echo "Great Britain" ;; + GE) echo "Georgia" ;; + GL) echo "Greenland" ;; + GR) echo "Greece" ;; + GT) echo "Guatemala" ;; + HK) echo "Hong Kong" ;; + HN) echo "Honduras" ;; + HR) echo "Croatia" ;; + HU) echo "Hungary" ;; + ID) echo "Indonesia" ;; + IE) echo "Ireland" ;; + IL) echo "Israel" ;; + IN) echo "India" ;; + IQ) echo "Iraq" ;; + IS) echo "Iceland" ;; + IT) echo "Italy" ;; + JO) echo "Jordan" ;; + JP) echo "Japan" ;; + KE) echo "Kenya" ;; + KR) echo "Korea, Republic of" ;; + KW) echo "Kuwait" ;; + KZ) echo "Kazakhstan" ;; + LB) echo "Lebanon" ;; + LT) echo "Lithuania" ;; + LU) echo "Luxembourg" ;; + LV) echo "Latvia" ;; + LY) echo "Libya" ;; + MA) echo "Morocco" ;; + MG) echo "Madagascar" ;; + MK) echo "Macedonia" ;; + MT) echo "Malta" ;; + MX) echo "Mexico" ;; + MY) echo "Malaysia" ;; + NI) echo "Nicaragua" ;; + NL) echo "Netherlands" ;; + NO) echo "Norway" ;; + NZ) echo "New Zealand" ;; + OM) echo "Oman" ;; + PA) echo "Panama" ;; + PE) echo "Peru" ;; + PH) echo "Philippines" ;; + PL) echo "Poland" ;; + PR) echo "Puerto Rico" ;; + PT) echo "Portugal" ;; + PY) echo "Paraguay" ;; + QA) echo "Qatar" ;; + RO) echo "Romania" ;; + RU) echo "Russian Federation" ;; + SA) echo "Saudi Arabia" ;; + SD) echo "Sudan" ;; + SE) echo "Sweden" ;; + SG) echo "Singapore" ;; + SI) echo "Slovenia" ;; + SK) echo "Slovakia" ;; + SO) echo "Somalia" ;; + SV) echo "El Salvador" ;; + SY) echo "Syria" ;; + TH) echo "Thailand" ;; + TJ) echo "Tajikistan" ;; + TN) echo "Tunisia" ;; + TR) echo "Turkey" ;; + TW) echo "Taiwan" ;; + UA) echo "Ukraine" ;; + UG) echo "Uganda" ;; + US) echo "United States of America" ;; + UY) echo "Uruguay" ;; + UZ) echo "Uzbekistan" ;; + VE) echo "Venezuela" ;; + YE) echo "Yemen" ;; + ZA) echo "South Africa" ;; + ZW) echo "Zimbabwe" ;; + *) echo "$1" ;; + esac +} + show_disks() { local dev size sectorsize gbytes @@ -319,13 +515,20 @@ set_keymap() { menu_locale() { local _locales="$(grep -E '\.UTF-8' /etc/default/libc-locales|awk '{print $1}'|sed -e 's/^#//')" - local _LOCALES= + local LOCALES ISO639 ISO3166 + local TMPFILE=$(mktemp -t vinstall-XXXXXXXX || exit 1) + echo "Scanning locales..." for f in ${_locales}; do - _LOCALES="${_LOCALES} ${f} -" + eval $(echo $f | awk 'BEGIN { FS="." } \ + { FS="_"; split($1, a); printf "ISO639=%s ISO3166=%s\n", a[1], a[2] }') + echo "$f|$(iso639_language $ISO639) ($(iso3166_country $ISO3166))|" >> $TMPFILE done + # Sort by ISO-639 language names + LOCALES=$(sort -t '|' -k 2 < $TMPFILE | xargs | sed -e's/| /|/g') + rm -f $TMPFILE while true; do - DIALOG --title " Select your locale " --menu "$MENULABEL" 14 70 14 ${_LOCALES} + (IFS="|"; DIALOG --title " Select your locale " --menu "$MENULABEL" 18 70 18 ${LOCALES}) if [ $? -eq 0 ]; then set_option LOCALE "$(cat $ANSWER)" LOCALE_DONE=1 @@ -1129,7 +1332,7 @@ menu() { "Timezone") menu_timezone && [ -n "$TIMEZONE_DONE" ] && DEFITEM="RootPassword";; "RootPassword") menu_rootpassword && [ -n "$ROOTPASSWORD_DONE" ] && DEFITEM="UserAccount";; "UserAccount") menu_useraccount && [ -n "$USERNAME_DONE" ] && [ -n "$USERPASSWORD_DONE" ] \ - && DEFITEM="BootLoader";; + && DEFITEM="BootLoader";; "BootLoader") menu_bootloader && [ -n "$BOOTLOADER_DONE" ] && DEFITEM="Partition";; "Partition") menu_partitions && [ -n "$PARTITIONS_DONE" ] && DEFITEM="Filesystems";; "Filesystems") menu_filesystems && [ -n "$FILESYSTEMS_DONE" ] && DEFITEM="Install";; -- cgit 1.4.1