diff --git a/README.md b/README.md index e858c149b..58a1951e6 100644 --- a/README.md +++ b/README.md @@ -253,3 +253,5 @@ OPTIONS -V Show version and exit ``` + +If you like the project, don't forget to give the repository a star! :) diff --git a/include/usr/share/applications/void-installer.desktop b/include/usr/share/applications/void-installer.desktop new file mode 100644 index 000000000..68e773c8b --- /dev/null +++ b/include/usr/share/applications/void-installer.desktop @@ -0,0 +1,37 @@ +[Desktop Entry] +Version=1.0 +Type=Application + + +Name=Void Linux Installer +Name[pt_BR]=Instalador do Void Linux +Name[es]=Instalador de Void Linux +Name[fr]=Installateur de Void Linux +Name[de]=Void-Installer +Name[it]=Programma di installazione di Void Linux + +Comment=Install Void Linux from a terminal-based interface +Comment[pt_BR]=Instale o Void Linux a partir de uma interface no terminal +Comment[es]=Instala Void Linux desde una interfaz basada en terminal +Comment[fr]=Installez Void Linux via une interface en terminal +Comment[de]=Installiere Void Linux über eine terminalbasierte Oberfläche +Comment[it]=Installa Void Linux da un'interfaccia terminale + + +Exec=sudo /usr/sbin/void-installer + +# Exec=sudo /usr/local/bin/installer.sh + +# Icon=system-software-install +Icon=/usr/share/icons/hicolor/48x48/apps/void-logo.png + +Terminal=true +Categories=System; + +Keywords=installer;void;linux;setup;system; +Keywords[pt_BR]=instalador;void;linux;instalação;sistema; +Keywords[es]=instalador;void;linux;configuración;sistema; +Keywords[fr]=installateur;void;linux;installation;système; +Keywords[de]=installateur;void;linux;installation;system; +Keywords[it]=installatore;void;linux;installazione;sistema; + diff --git a/include/usr/share/applications/voidlinux-docs.desktop b/include/usr/share/applications/voidlinux-docs.desktop new file mode 100644 index 000000000..a5e566b0e --- /dev/null +++ b/include/usr/share/applications/voidlinux-docs.desktop @@ -0,0 +1,31 @@ +[Desktop Entry] +Version=1.0 +Type=Application +Name=Void Linux Docs +Name[pt]=Documentação do Void Linux +Name[es]=Documentación de Void Linux +Name[fr]=Documentation de Void Linux +Name[de]=Void Linux Dokumentation +Comment=Access the official Void Linux documentation +Comment[pt]=Acesse a documentação oficial do Void Linux +Comment[es]=Accede a la documentación oficial de Void Linux +Comment[fr]=Accédez à la documentation officielle de Void Linux +Comment[de]=Greifen Sie auf die offizielle Void Linux-Dokumentation zu + +Exec=xdg-open https://docs.voidlinux.org/ + +# Icon=internet-web-browser +Icon=/usr/share/icons/extras/void.svg + +Terminal=false + +# Categories=System;Network; +Categories=System; + +Keywords=Void;Linux;Documentation;Manual;Help;Docs; +Keywords[pt]=Void;Linux;Documentação;Manual;Ajuda;Docs; +Keywords[es]=Void;Linux;Documentación;Manual;Ayuda;Docs; +Keywords[fr]=Void;Linux;Documentation;Manuel;Aide;Docs; +Keywords[de]=Void;Linux;Dokumentation;Handbuch;Hilfe;Docs; +StartupNotify=true + diff --git a/include/usr/share/applications/xbps-update.desktop b/include/usr/share/applications/xbps-update.desktop new file mode 100644 index 000000000..42db1765d --- /dev/null +++ b/include/usr/share/applications/xbps-update.desktop @@ -0,0 +1,29 @@ +[Desktop Entry] +Version=1.0 +Type=Application + +Name=Atualizar Sistema +Name[en]=System Update +Name[es]=Actualizar Sistema +Name[fr]=Mise à jour du système + +Comment=Atualiza todos os pacotes do sistema com xbps +Comment[en]=Updates all system packages using xbps +Comment[es]=Actualiza todos los paquetes del sistema con xbps +Comment[fr]=Met à jour tous les paquets du système avec xbps + +Exec=pkexec /bin/bash -c 'clear && echo -e "\nAtualizando o sistema...\n" && xbps-install -Suvy && echo -e "\nRemovendo pacotes órfãos...\n" && xbps-remove -Ooy && sleep 30' + +# Icon=system-software-update +Icon=/usr/share/icons/extras/void.svg + +StartupNotify=true +Terminal=true +Categories=System; + +Keywords=update;upgrade;xbps;void;atualizar;atualização;actualizar;mise à jour; +Keywords[en]=update;upgrade;xbps;void;system; +Keywords[es]=actualizar;upgrade;xbps;void;sistema; +Keywords[fr]=mise à jour;upgrade;xbps;void;système; + + diff --git a/include/usr/share/locale/pt_BR/LC_MESSAGES/installer.mo b/include/usr/share/locale/pt_BR/LC_MESSAGES/installer.mo new file mode 100644 index 000000000..69a7e36f9 Binary files /dev/null and b/include/usr/share/locale/pt_BR/LC_MESSAGES/installer.mo differ diff --git a/include/usr/share/locale/pt_BR/LC_MESSAGES/lib.mo b/include/usr/share/locale/pt_BR/LC_MESSAGES/lib.mo new file mode 100644 index 000000000..7fb7cee69 Binary files /dev/null and b/include/usr/share/locale/pt_BR/LC_MESSAGES/lib.mo differ diff --git a/include/usr/share/locale/pt_BR/LC_MESSAGES/mkimage.mo b/include/usr/share/locale/pt_BR/LC_MESSAGES/mkimage.mo new file mode 100644 index 000000000..1333e202d Binary files /dev/null and b/include/usr/share/locale/pt_BR/LC_MESSAGES/mkimage.mo differ diff --git a/include/usr/share/locale/pt_BR/LC_MESSAGES/mkiso.mo b/include/usr/share/locale/pt_BR/LC_MESSAGES/mkiso.mo new file mode 100644 index 000000000..866c186a0 Binary files /dev/null and b/include/usr/share/locale/pt_BR/LC_MESSAGES/mkiso.mo differ diff --git a/include/usr/share/locale/pt_BR/LC_MESSAGES/mklive.mo b/include/usr/share/locale/pt_BR/LC_MESSAGES/mklive.mo new file mode 100644 index 000000000..b66ee8de0 Binary files /dev/null and b/include/usr/share/locale/pt_BR/LC_MESSAGES/mklive.mo differ diff --git a/include/usr/share/locale/pt_BR/LC_MESSAGES/mknet.mo b/include/usr/share/locale/pt_BR/LC_MESSAGES/mknet.mo new file mode 100644 index 000000000..a7bc0abbb Binary files /dev/null and b/include/usr/share/locale/pt_BR/LC_MESSAGES/mknet.mo differ diff --git a/include/usr/share/locale/pt_BR/LC_MESSAGES/mkplatformfs.mo b/include/usr/share/locale/pt_BR/LC_MESSAGES/mkplatformfs.mo new file mode 100644 index 000000000..2024b632c Binary files /dev/null and b/include/usr/share/locale/pt_BR/LC_MESSAGES/mkplatformfs.mo differ diff --git a/include/usr/share/locale/pt_BR/LC_MESSAGES/mkrootfs.mo b/include/usr/share/locale/pt_BR/LC_MESSAGES/mkrootfs.mo new file mode 100644 index 000000000..83ad7026e Binary files /dev/null and b/include/usr/share/locale/pt_BR/LC_MESSAGES/mkrootfs.mo differ diff --git a/include/usr/share/locale/pt_BR/LC_MESSAGES/release.mo b/include/usr/share/locale/pt_BR/LC_MESSAGES/release.mo new file mode 100644 index 000000000..bd90a58ce Binary files /dev/null and b/include/usr/share/locale/pt_BR/LC_MESSAGES/release.mo differ diff --git a/include/usr/usr/share/backgrounds/VoidBR-1.png b/include/usr/usr/share/backgrounds/VoidBR-1.png new file mode 100644 index 000000000..fa41dc29e Binary files /dev/null and b/include/usr/usr/share/backgrounds/VoidBR-1.png differ diff --git a/include/usr/usr/share/backgrounds/xfce/xfce-x.svg b/include/usr/usr/share/backgrounds/xfce/xfce-x.svg new file mode 100644 index 000000000..a2f5a7ec4 --- /dev/null +++ b/include/usr/usr/share/backgrounds/xfce/xfce-x.svg @@ -0,0 +1,24 @@ + + + + + + + + + diff --git a/installer.sh b/installer.sh index c41affcb9..8284b5c7a 100755 --- a/installer.sh +++ b/installer.sh @@ -25,6 +25,34 @@ # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #- + +# https://github.com/void-linux/void-mklive +# https://www.vivaolinux.com.br/artigo/Introducao-ao-Void-Linux?pagina=2 +# https://edpsblog.wordpress.com/2019/09/02/how-to-void-linux-mate/ + + +clear + +# ---------------------------------------------------------------------------------------- + +export TEXTDOMAIN=installer + +# export TEXTDOMAINDIR=./locale + +# A variável de ambiente TEXTDOMAINDIR deve apontar para o diretório raiz onde ficam os +# subdiretórios de idiomas, como /usr/share/locale. + +export TEXTDOMAINDIR=/usr/share/locale + +# ---------------------------------------------------------------------------------------- + +# Detectar idioma atual do sistema + +LANG=${LANG:-en_US} + +# ---------------------------------------------------------------------------------------- + + # Make sure we don't inherit these from env. SOURCE_DONE= HOSTNAME_DONE= @@ -86,29 +114,69 @@ UNDERLINE="\Zu" RESET="\Zn" # Properties shared per widget. -MENULABEL="${BOLD}Use UP and DOWN keys to navigate \ -menus. Use TAB to switch between buttons and ENTER to select.${RESET}" +MENULABEL="${BOLD}$(gettext "Use UP and DOWN keys to navigate menus. +Use TAB to switch between buttons and ENTER to select.")${RESET}" MENUSIZE="14 60 0" INPUTSIZE="8 60" MSGBOXSIZE="8 70" YESNOSIZE="$INPUTSIZE" WIDGET_SIZE="10 70" + +# Com problema + +# VERSION=$(git ls-remote https://github.com/void-linux/void-mklive.git HEAD | awk '{print substr($1,1,7)}') + +# VERSION=$(cat commit.txt) + +# MKLIVE="$(cat version)" + + + +# Se quiser tornar isso padrão em todos os diálogos com "yesno", pode alterar a função +# DIALOG() para aceitar esses labels por padrão. + +# DIALOG() { + +# rm -f $ANSWER + +# dialog --colors --keep-tite --no-shadow --no-mouse \ +# --backtitle "${BOLD}${WHITE}$(printf "$(gettext "Void Linux installation -- https://www.voidlinux.org (%s)")" "@@MKLIVE_VERSION@@")${RESET}" \ +# --cancel-label "$(gettext "Back")" --aspect 20 "$@" 2>$ANSWER + +# return $? +# } + + + DIALOG() { + rm -f $ANSWER + dialog --colors --keep-tite --no-shadow --no-mouse \ - --backtitle "${BOLD}${WHITE}Void Linux installation -- https://www.voidlinux.org (@@MKLIVE_VERSION@@)${RESET}" \ - --cancel-label "Back" --aspect 20 "$@" 2>$ANSWER + --backtitle "${BOLD}${WHITE}$(printf "$(gettext "Void Linux installation -- https://www.voidlinux.org (%s)")" "@@MKLIVE_VERSION@@")${RESET}" \ + --cancel-label "$(gettext "Back")" \ + --yes-label "$(gettext "Yes")" \ + --no-label "$(gettext "No")" \ + --aspect 20 "$@" 2>$ANSWER + return $? } + + INFOBOX() { + # Note: dialog --infobox and --keep-tite don't work together + dialog --colors --no-shadow --no-mouse \ - --backtitle "${BOLD}${WHITE}Void Linux installation -- https://www.voidlinux.org (@@MKLIVE_VERSION@@)${RESET}" \ + --backtitle "${BOLD}${WHITE}$(printf "$(gettext "Void Linux installation -- https://www.voidlinux.org (%s)")" "@@MKLIVE_VERSION@@")${RESET}" \ --title "${TITLE}" --aspect 20 --infobox "$@" } + + + DIE() { rval=$1 [ -z "$rval" ] && rval=0 @@ -133,7 +201,9 @@ get_option() { grep -E "^${1} .*" $CONF_FILE | sed -e "s|^${1} ||" } + # ISO-639 language names for locales + iso639_language() { case "$1" in aa) echo "Afar" ;; @@ -437,19 +507,19 @@ menu_filesystems() { local dev fstype fssize mntpoint reformat while true; do - DIALOG --ok-label "Change" --cancel-label "Done" \ - --title " Select the partition to edit " --menu "$MENULABEL" \ + DIALOG --ok-label "$(gettext "Change")" --cancel-label "$(gettext "Done")" \ + --title "$(gettext " Select the partition to edit ")" --menu "$MENULABEL" \ ${MENUSIZE} $(show_partitions) [ $? -ne 0 ] && return dev=$(cat $ANSWER) - DIALOG --title " Select the filesystem type for $dev " \ + DIALOG --title " $(printf "$(gettext "Select the filesystem type for %s")" "$dev") " \ --menu "$MENULABEL" ${MENUSIZE} \ "btrfs" "Oracle's Btrfs" \ "ext2" "Linux ext2 (no journaling)" \ "ext3" "Linux ext3 (journal)" \ "ext4" "Linux ext4 (journal)" \ - "f2fs" "Flash-Friendly Filesystem" \ + "f2fs" "$(gettext "Flash-Friendly Filesystem")" \ "swap" "Linux swap" \ "vfat" "FAT32" \ "xfs" "SGI's XFS" @@ -459,7 +529,7 @@ menu_filesystems() { continue fi if [ "$fstype" != "swap" ]; then - DIALOG --inputbox "Please specify the mount point for $dev:" ${INPUTSIZE} + DIALOG --inputbox "$(printf "$(gettext "Please specify the mount point for %s:")" "$dev")" ${INPUTSIZE} if [ $? -eq 0 ]; then mntpoint=$(cat $ANSWER) elif [ $? -eq 1 ]; then @@ -468,7 +538,7 @@ menu_filesystems() { else mntpoint=swap fi - DIALOG --yesno "Do you want to create a new filesystem on $dev?" ${YESNOSIZE} + DIALOG --yesno "$(printf "$(gettext "Do you want to create a new filesystem on %s?")" "$dev")" ${YESNOSIZE} if [ $? -eq 0 ]; then reformat=1 elif [ $? -eq 1 ]; then @@ -493,33 +563,41 @@ menu_filesystems() { } menu_partitions() { - DIALOG --title " Select the disk to partition " \ + DIALOG --title "$(gettext " Select the disk to partition ")" \ --menu "$MENULABEL" ${MENUSIZE} $(show_disks) if [ $? -eq 0 ]; then local device=$(cat $ANSWER) - DIALOG --title " Select the software for partitioning " \ + DIALOG --title "$(gettext " Select the software for partitioning ")" \ --menu "$MENULABEL" ${MENUSIZE} \ - "cfdisk" "Easy to use" \ - "fdisk" "More advanced" + "cfdisk" "$(gettext "Easy to use")" \ + "fdisk" "$(gettext "More advanced")" if [ $? -eq 0 ]; then local software=$(cat $ANSWER) - DIALOG --title "Modify Partition Table on $device" --msgbox "\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 -on PC BIOS systems, an empty partition of 1MB must be added at the first\n -2GB of the disk with the partition type \`BIOS Boot'.\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 -must be created with the partition type \`EFI System'. This will be used as\n -the EFI System Partition. This partition must have the mountpoint \`/boot/efi'.\n\n -At least 1 partition is required for the rootfs (/). For this partition,\n -at least 2GB is required, but more is recommended. The rootfs partition\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 -${RESET}\n" 23 80 + + DIALOG --title "$(printf "$(gettext "Modify Partition Table on %s")" "$device")" --msgbox "$(printf "$(gettext " +%s%s will be executed in disk %s.%s + +For BIOS systems, MBR or GPT partition tables are supported. To use GPT +on PC BIOS systems, an empty partition of 1MB must be added at the first +2GB of the disk with the partition type BIOS Boot. + +%sNOTE: you don't need this on EFI systems.%s + +For EFI systems, GPT is mandatory and a FAT32 partition with at least 100MB +must be created with the partition type EFI System. This will be used as +the EFI System Partition. This partition must have the mountpoint /boot/efi. + +At least 1 partition is required for the rootfs (/). For this partition, +at least 2GB is required, but more is recommended. The rootfs partition +should have the partition type Linux Filesystem. For swap, RAM*2 +should be enough and the partition type Linux swap should be used. + +%sWARNING: /usr is not supported as a separate partition.%s +%s +")" "${BOLD}" "${software}" "$device" "${RESET}" "${BOLD}" "${RESET}" "${BOLD}" "${RESET}" "${RESET}")" 27 90 + if [ $? -eq 0 ]; then while true; do clear; $software $device; PARTITIONS_DONE=1 @@ -540,7 +618,7 @@ menu_keymap() { _KEYMAPS="${_KEYMAPS} ${f} -" done while true; do - DIALOG --title " Select your keymap " --menu "$MENULABEL" 14 70 14 ${_KEYMAPS} + DIALOG --title "$(gettext " Select your keymap ")" --menu "$MENULABEL" 14 70 14 ${_KEYMAPS} if [ $? -eq 0 ]; then set_option KEYMAP "$(cat $ANSWER)" loadkeys "$(cat $ANSWER)" @@ -566,7 +644,7 @@ menu_locale() { local _locales="$(grep -E '\.UTF-8' /etc/default/libc-locales|awk '{print $1}'|sed -e 's/^#//')" local LOCALES ISO639 ISO3166 local TMPFILE=$(mktemp -t vinstall-XXXXXXXX || exit 1) - INFOBOX "Scanning locales ..." 4 60 + INFOBOX "$(gettext "Scanning locales ...")" 4 60 for f in ${_locales}; do eval $(echo $f | awk 'BEGIN { FS="." } \ { FS="_"; split($1, a); printf "ISO639=%s ISO3166=%s\n", a[1], a[2] }') @@ -577,7 +655,7 @@ menu_locale() { LOCALES=$(sort -t '|' -k 2 < $TMPFILE | xargs | sed -e's/| /|/g') rm -f $TMPFILE while true; do - (IFS="|"; DIALOG --title " Select your locale " --menu "$MENULABEL" 18 70 18 ${LOCALES}) + (IFS="|"; DIALOG --title "$(gettext " Select your locale ")" --menu "$MENULABEL" 18 70 18 ${LOCALES}) if [ $? -eq 0 ]; then set_option LOCALE "$(cat $ANSWER)" LOCALE_DONE=1 @@ -595,7 +673,7 @@ set_locale() { sed -i -e "s|LANG=.*|LANG=$LOCALE|g" $TARGETDIR/etc/locale.conf # Uncomment locale from /etc/default/libc-locales and regenerate it. sed -e "/${LOCALE}/s/^\#//" -i $TARGETDIR/etc/default/libc-locales - echo "Running xbps-reconfigure -f glibc-locales ..." >$LOG + echo "$(gettext "Running xbps-reconfigure -f glibc-locales ...")" >$LOG chroot $TARGETDIR xbps-reconfigure -f glibc-locales >$LOG 2>&1 fi } @@ -604,10 +682,10 @@ menu_timezone() { local areas=(Africa America Antarctica Arctic Asia Atlantic Australia Europe Indian Pacific) local area locations location - while (IFS='|'; DIALOG ${area:+--default-item|"$area"} --title " Select area " --menu "$MENULABEL" 19 51 19 $(printf '%s||' "${areas[@]}")); do + while (IFS='|'; DIALOG ${area:+--default-item|"$area"} --title "$(gettext " Select area ")" --menu "$MENULABEL" 19 51 19 $(printf '%s||' "${areas[@]}")); do area=$(cat $ANSWER) read -a locations -d '\n' < <(find /usr/share/zoneinfo/$area -type f -printf '%P\n' | sort) - if (IFS='|'; DIALOG --title " Select location (${area}) " --menu "$MENULABEL" 19 51 19 $(printf '%s||' "${locations[@]//_/ }")); then + if (IFS='|'; DIALOG --title " $(printf "$(gettext "Select location (%s)")" "${area}") " --menu "$MENULABEL" 19 51 19 $(printf '%s||' "${locations[@]//_/ }")); then location=$(tr ' ' '_' < $ANSWER) set_option TIMEZONE "$area/$location" TIMEZONE_DONE=1 @@ -627,7 +705,7 @@ set_timezone() { menu_hostname() { while true; do - DIALOG --inputbox "Set the machine hostname:" ${INPUTSIZE} + DIALOG --inputbox "$(gettext "Set the machine hostname"):" ${INPUTSIZE} if [ $? -eq 0 ]; then set_option HOSTNAME "$(cat $ANSWER)" HOSTNAME_DONE=1 @@ -648,9 +726,9 @@ menu_rootpassword() { while true; do if [ -z "${_firstpass}" ]; then - _desc="Enter the root password" + _desc="$(gettext "Enter the root password")" else - _again=" again" + _again=" $(gettext "again")" fi DIALOG --insecure --passwordbox "${_desc}${_again}" ${INPUTSIZE} if [ $? -eq 0 ]; then @@ -661,7 +739,7 @@ menu_rootpassword() { fi if [ -n "${_firstpass}" -a -n "${_secondpass}" ]; then if [ "${_firstpass}" != "${_secondpass}" ]; then - INFOBOX "Passwords do not match! Please enter again." 6 60 + INFOBOX "$(gettext "Passwords do not match! Please enter again.")" 6 60 unset _firstpass _secondpass _again sleep 2 && clear && continue fi @@ -687,7 +765,7 @@ menu_useraccount() { while true; do _preset=$(get_option USERLOGIN) [ -z "$_preset" ] && _preset="void" - DIALOG --inputbox "Enter a primary login name:" ${INPUTSIZE} "$_preset" + DIALOG --inputbox "$(gettext "Enter a primary login name"):" ${INPUTSIZE} "$_preset" if [ $? -eq 0 ]; then _userlogin="$(cat $ANSWER)" # based on useradd(8) § Caveats @@ -696,7 +774,7 @@ menu_useraccount() { USERLOGIN_DONE=1 break else - INFOBOX "Invalid login name! Please try again." 6 60 + INFOBOX "$(gettext "Invalid login name! Please try again.")" 6 60 unset _userlogin sleep 2 && clear && continue fi @@ -707,8 +785,8 @@ menu_useraccount() { while true; do _preset=$(get_option USERNAME) - [ -z "$_preset" ] && _preset="Void User" - DIALOG --inputbox "Enter a display name for login '$(get_option USERLOGIN)' :" \ + [ -z "$_preset" ] && _preset="$(gettext "Void User")" + DIALOG --inputbox "$(gettext "Enter a display name for login") '$(get_option USERLOGIN)' :" \ ${INPUTSIZE} "$_preset" if [ $? -eq 0 ]; then set_option USERNAME "$(cat $ANSWER)" @@ -721,9 +799,9 @@ menu_useraccount() { while true; do if [ -z "${_firstpass}" ]; then - _desc="Enter the password for login '$(get_option USERLOGIN)'" + _desc="$(gettext "Enter the password for login") '$(get_option USERLOGIN)'" else - _again=" again" + _again=" $(gettext "again")" fi DIALOG --insecure --passwordbox "${_desc}${_again}" ${INPUTSIZE} if [ $? -eq 0 ]; then @@ -734,7 +812,7 @@ menu_useraccount() { fi if [ -n "${_firstpass}" -a -n "${_secondpass}" ]; then if [ "${_firstpass}" != "${_secondpass}" ]; then - INFOBOX "Passwords do not match! Please enter again." 6 60 + INFOBOX "$(gettext "Passwords do not match! Please enter again.")" 6 60 unset _firstpass _secondpass _again sleep 2 && clear && continue fi @@ -749,7 +827,7 @@ menu_useraccount() { _groups="wheel,audio,video,floppy,cdrom,optical,kvm,users,xbuilder" while true; do - _desc="Select group membership for login '$(get_option USERLOGIN)':" + _desc="$(gettext "Select group membership for login") '$(get_option USERLOGIN)':" for _group in $(cat /etc/group); do _gid="$(echo ${_group} | cut -d: -f3)" _group="$(echo ${_group} | cut -d: -f1)" @@ -790,7 +868,7 @@ set_useraccount() { menu_bootloader() { while true; do - DIALOG --title " Select the disk to install the bootloader" \ + DIALOG --title "$(gettext " Select the disk to install the bootloader")" \ --menu "$MENULABEL" ${MENUSIZE} $(show_disks) none "Manage bootloader otherwise" if [ $? -eq 0 ]; then set_option BOOTLOADER "$(cat $ANSWER)" @@ -801,7 +879,7 @@ menu_bootloader() { fi done while true; do - DIALOG --yesno "Use a graphical terminal for the boot loader?" ${YESNOSIZE} + DIALOG --yesno "$(gettext "Use a graphical terminal for the boot loader?")" ${YESNOSIZE} if [ $? -eq 0 ]; then set_option TEXTCONSOLE 0 break @@ -823,18 +901,18 @@ set_bootloader() { if [ -n "$EFI_SYSTEM" ]; then grub_args="--target=$EFI_TARGET --efi-directory=/boot/efi --bootloader-id=void_grub --recheck" fi - echo "Running grub-install $grub_args $dev..." >$LOG + echo "$(printf "$(gettext "Running grub-install %s %s...")" "$grub_args" "$dev")" >$LOG chroot $TARGETDIR grub-install $grub_args $dev >$LOG 2>&1 if [ $? -ne 0 ]; then - DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \ -failed to install GRUB to $dev!\nCheck $LOG for errors." ${MSGBOXSIZE} + DIALOG --msgbox "${BOLD}${RED}$(gettext "ERROR"):${RESET} \ +$(printf "$(gettext "failed to install GRUB to %s!\nCheck %s for errors.")" "$dev" "$LOG")" ${MSGBOXSIZE} DIE 1 fi - echo "Running grub-mkconfig on $TARGETDIR..." >$LOG + echo "$(printf "$(gettext "Running grub-mkconfig on %s...")" "$TARGETDIR")" >$LOG chroot $TARGETDIR grub-mkconfig -o /boot/grub/grub.cfg >$LOG 2>&1 if [ $? -ne 0 ]; then - DIALOG --msgbox "${BOLD}${RED}ERROR${RESET}: \ -failed to run grub-mkconfig!\nCheck $LOG for errors." ${MSGBOXSIZE} + DIALOG --msgbox "${BOLD}${RED}$(gettext "ERROR")${RESET}: \ +$(printf "$(gettext "failed to run grub-mkconfig!\nCheck %s for errors.")" "$LOG")" ${MSGBOXSIZE} DIE 1 fi } @@ -849,35 +927,35 @@ test_network() { rm -f otime if [ "$status" -eq 0 ]; then - DIALOG --msgbox "Network is working properly!" ${MSGBOXSIZE} + DIALOG --msgbox "$(gettext "Network is working properly!")" ${MSGBOXSIZE} NETWORK_DONE=1 return 1 fi if [ "$1" = "nm" ]; then - 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} + DIALOG --msgbox "$(gettext "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} + DIALOG --msgbox "$(gettext "Network is inaccessible, please set it up properly.")" ${MSGBOXSIZE} fi } configure_wifi() { local dev="$1" ssid enc pass _wpasupconf=/etc/wpa_supplicant/wpa_supplicant.conf - DIALOG --form "Wireless configuration for ${dev}\n(encryption type: wep or wpa)" 0 0 0 \ - "SSID:" 1 1 "" 1 16 30 0 \ - "Encryption:" 2 1 "" 2 16 4 3 \ - "Password:" 3 1 "" 3 16 63 0 || return 1 + DIALOG --form "$(printf "$(gettext "Wireless configuration for %s\n(encryption type: wep or wpa)")" "${dev}")" 0 0 0 \ + "$(gettext "SSID"):" 1 1 "" 1 16 30 0 \ + "$(gettext "Encryption"):" 2 1 "" 2 16 4 3 \ + "$(gettext "Password"):" 3 1 "" 3 16 63 0 || return 1 readarray -t values <<<$(cat $ANSWER) ssid="${values[0]}"; enc="${values[1]}"; pass="${values[2]}" if [ -z "$ssid" ]; then - DIALOG --msgbox "Invalid SSID." ${MSGBOXSIZE} + DIALOG --msgbox "$(gettext "Invalid SSID.")" ${MSGBOXSIZE} return 1 elif [ -z "$enc" -o "$enc" != "wep" -a "$enc" != "wpa" ]; then - DIALOG --msgbox "Invalid encryption type (possible values: wep or wpa)." ${MSGBOXSIZE} + DIALOG --msgbox "$(gettext "Invalid encryption type (possible values: wep or wpa).")" ${MSGBOXSIZE} return 1 elif [ -z "$pass" ]; then - DIALOG --msgbox "Invalid AP password." ${MSGBOXSIZE} + DIALOG --msgbox "$(gettext "Invalid AP password.")" ${MSGBOXSIZE} fi # reset the configuration to the default, if necessary @@ -908,7 +986,7 @@ EOF configure_net() { local dev="$1" rval - DIALOG --yesno "Do you want to use DHCP for $dev?" ${YESNOSIZE} + DIALOG --yesno "$(printf "$(gettext "Do you want to use DHCP for %s?")" "$dev")" ${YESNOSIZE} rval=$? if [ $rval -eq 0 ]; then configure_net_dhcp $dev @@ -928,15 +1006,15 @@ configure_net_dhcp() { iface_setup $dev if [ $? -eq 1 ]; then sv restart dhcpcd 2>&1 | tee $LOG | \ - DIALOG --progressbox "Initializing $dev via DHCP..." ${WIDGET_SIZE} + DIALOG --progressbox "$(printf "$(gettext "Initializing %s via DHCP...")" "$dev")" ${WIDGET_SIZE} if [ $? -ne 0 ]; then - DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} failed to run dhcpcd. See $LOG for details." ${MSGBOXSIZE} + DIALOG --msgbox "${BOLD}${RED}$(gettext "ERROR"):${RESET} $(printf "$(gettext "failed to run dhcpcd. See %s for details.")" "$LOG")" ${MSGBOXSIZE} return 1 fi export -f iface_setup timeout 10s bash -c "while true; do iface_setup $dev; sleep 0.25; done" if [ $? -eq 1 ]; then - DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} DHCP request failed for $dev. Check $LOG for errors." ${MSGBOXSIZE} + DIALOG --msgbox "${BOLD}${RED}$(gettext "ERROR"):${RESET} $(printf "$(gettext "DHCP request failed for %s. Check %s for errors.")" "$dev" "$LOG")" ${MSGBOXSIZE} return 1 fi fi @@ -949,29 +1027,29 @@ configure_net_dhcp() { configure_net_static() { local ip gw dns1 dns2 dev=$1 - DIALOG --form "Static IP configuration for $dev:" 0 0 0 \ - "IP address:" 1 1 "192.168.0.2" 1 21 20 0 \ - "Gateway:" 2 1 "192.168.0.1" 2 21 20 0 \ - "DNS Primary" 3 1 "8.8.8.8" 3 21 20 0 \ - "DNS Secondary" 4 1 "8.8.4.4" 4 21 20 0 || return 1 + DIALOG --form "$(printf "$(gettext "Static IP configuration for %s:")" "$dev")" 0 0 0 \ + "$(gettext "IP address"):" 1 1 "192.168.0.2" 1 21 20 0 \ + "$(gettext "Gateway"):" 2 1 "192.168.0.1" 2 21 20 0 \ + "$(gettext "DNS Primary")" 3 1 "8.8.8.8" 3 21 20 0 \ + "$(gettext "DNS Secondary")" 4 1 "8.8.4.4" 4 21 20 0 || return 1 set -- $(cat $ANSWER) ip=$1; gw=$2; dns1=$3; dns2=$4 - echo "running: ip link set dev $dev up" >$LOG + echo "$(printf "$(gettext "running: ip link set dev %s up")" "$dev")" >$LOG ip link set dev $dev up >$LOG 2>&1 if [ $? -ne 0 ]; then - DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} Failed to bring $dev interface." ${MSGBOXSIZE} + DIALOG --msgbox "${BOLD}${RED}$(gettext "ERROR"):${RESET} $(printf "$(gettext "Failed to bring %s interface.")" "$dev")" ${MSGBOXSIZE} return 1 fi - echo "running: ip addr add $ip dev $dev" >$LOG + echo "$(printf "$(gettext "running: ip addr add %s dev %s")" "$ip" "$dev")" >$LOG ip addr add $ip dev $dev >$LOG 2>&1 if [ $? -ne 0 ]; then - DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} Failed to set ip to the $dev interface." ${MSGBOXSIZE} + DIALOG --msgbox "${BOLD}${RED}$(gettext "ERROR"):${RESET} $(printf "$(gettext "Failed to set ip to the %s interface.")" "$dev")" ${MSGBOXSIZE} return 1 fi ip route add default via $gw >$LOG 2>&1 if [ $? -ne 0 ]; then - DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} failed to setup your gateway." ${MSGBOXSIZE} + DIALOG --msgbox "${BOLD}${RED}$(gettext "ERROR"):${RESET} $(gettext "failed to setup your gateway.")" ${MSGBOXSIZE} return 1 fi echo "nameserver $dns1" >/etc/resolv.conf @@ -995,7 +1073,7 @@ menu_network() { addr=$(cat /sys/class/net/$f/address) DEVICES="$DEVICES $f $addr" done - DIALOG --title " Select the network interface to configure " \ + DIALOG --title "$(gettext " Select the network interface to configure ")" \ --menu "$MENULABEL" ${MENUSIZE} ${DEVICES} if [ $? -eq 0 ]; then dev=$(cat $ANSWER) @@ -1048,17 +1126,17 @@ validate_filesystems() { fi done if [ -z "$rootfound" ]; then - DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \ -the mount point for the root filesystem (/) has not yet been configured." ${MSGBOXSIZE} + DIALOG --msgbox "${BOLD}${RED}$(gettext "ERROR"):${RESET} \ +$(gettext "the mount point for the root filesystem (/) has not yet been configured.")" ${MSGBOXSIZE} return 1 elif [ -n "$usrfound" ]; then - DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \ -/usr mount point has been configured but is not supported, please remove it to continue." ${MSGBOXSIZE} + DIALOG --msgbox "${BOLD}${RED}$(gettext "ERROR"):${RESET} \ +$(gettext "/usr mount point has been configured but is not supported, please remove it to continue.")" ${MSGBOXSIZE} return 1 elif [ -n "$EFI_SYSTEM" -a "$bootdev" != "none" -a -z "$efi_system_partition" ]; then - DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \ -The EFI System Partition has not yet been configured, please create it\n -as FAT32, mountpoint /boot/efi and at least with 100MB of size." ${MSGBOXSIZE} + DIALOG --msgbox "${BOLD}${RED}$(gettext "ERROR"):${RESET} \ +$(gettext "The EFI System Partition has not yet been configured, please create it\n +as FAT32, mountpoint /boot/efi and at least with 100MB of size.")" ${MSGBOXSIZE} return 1 fi FILESYSTEMS_DONE=1 @@ -1079,15 +1157,15 @@ create_filesystems() { if [ "$mkfs" -eq 1 ]; then mkswap $dev >$LOG 2>&1 if [ $? -ne 0 ]; then - DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \ -failed to create swap on ${dev}!\ncheck $LOG for errors." ${MSGBOXSIZE} + DIALOG --msgbox "${BOLD}${RED}$(gettext "ERROR"):${RESET} \ +$(printf "$(gettext "failed to create swap on %s!\ncheck %s for errors.")" "${dev}" "$LOG")" ${MSGBOXSIZE} DIE 1 fi fi swapon $dev >$LOG 2>&1 if [ $? -ne 0 ]; then - DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \ -failed to activate swap on $dev!\ncheck $LOG for errors." ${MSGBOXSIZE} + DIALOG --msgbox "${BOLD}${RED}$(gettext "ERROR"):${RESET} \ +$(printf "$(gettext "failed to activate swap on %s!\ncheck %s for errors.")" "$dev" "$LOG")" ${MSGBOXSIZE} DIE 1 fi # Add entry for target fstab @@ -1106,24 +1184,24 @@ failed to activate swap on $dev!\ncheck $LOG for errors." ${MSGBOXSIZE} vfat) MKFS="mkfs.vfat -F32"; modprobe vfat >$LOG 2>&1;; xfs) MKFS="mkfs.xfs -f -i sparse=0"; modprobe xfs >$LOG 2>&1;; esac - TITLE="Check $LOG for details ..." - INFOBOX "Creating filesystem $fstype on $dev for $mntpt ..." 8 60 - echo "Running $MKFS $dev..." >$LOG + TITLE="$(printf "$(gettext "Check %s for details ...")" "$LOG")" + INFOBOX "$(printf "$(gettext "Creating filesystem %s on %s for %s ...")" "$fstype" "$dev" "$mntpt")" 8 60 + echo "$(printf "$(gettext "Running %s %s...")" "$MKFS" "$dev")" >$LOG $MKFS $dev >$LOG 2>&1; rv=$? if [ $rv -ne 0 ]; then - DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \ -failed to create filesystem $fstype on $dev!\ncheck $LOG for errors." ${MSGBOXSIZE} + DIALOG --msgbox "${BOLD}${RED}$(gettext "ERROR"):${RESET} \ +$(printf "$(gettext "failed to create filesystem %s on %s!\ncheck %s for errors.")" "$fstype" "$dev" "$LOG")" ${MSGBOXSIZE} DIE 1 fi fi # Mount rootfs the first one. [ "$mntpt" != "/" ] && continue mkdir -p $TARGETDIR - echo "Mounting $dev on $mntpt ($fstype)..." >$LOG + echo "$(printf "$(gettext "Mounting %s on %s (%s)...")" "$dev" "$mntpt" "$fstype")" >$LOG mount -t $fstype $dev $TARGETDIR >$LOG 2>&1 if [ $? -ne 0 ]; then - DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \ -failed to mount $dev on ${mntpt}! check $LOG for errors." ${MSGBOXSIZE} + DIALOG --msgbox "${BOLD}${RED}$(gettext "ERROR"):${RESET} \ +$(printf "$(gettext "failed to mount %s on %s! check %s for errors.")" "$dev" "${mntpt}" "$LOG")" ${MSGBOXSIZE} DIE 1 fi # Add entry to target fstab @@ -1144,11 +1222,11 @@ failed to mount $dev on ${mntpt}! check $LOG for errors." ${MSGBOXSIZE} shift 6 [ "$mntpt" = "/" -o "$fstype" = "swap" ] && continue mkdir -p ${TARGETDIR}${mntpt} - echo "Mounting $dev on $mntpt ($fstype)..." >$LOG + echo "$(printf "$(gettext "Mounting %s on %s (%s)...")" "$dev" "$mntpt" "$fstype")" >$LOG mount -t $fstype $dev ${TARGETDIR}${mntpt} >$LOG 2>&1 if [ $? -ne 0 ]; then - DIALOG --msgbox "${BOLD}${RED}ERROR:${RESET} \ -failed to mount $dev on $mntpt! check $LOG for errors." ${MSGBOXSIZE} + DIALOG --msgbox "${BOLD}${RED}$(gettext "ERROR"):${RESET} \ +$(printf "$(gettext "failed to mount %s on %s! check %s for errors.")" "$dev" "$mntpt" "$LOG")" ${MSGBOXSIZE} DIE fi # Add entry to target fstab @@ -1165,7 +1243,7 @@ failed to mount $dev on $mntpt! check $LOG for errors." ${MSGBOXSIZE} mount_filesystems() { for f in sys proc dev; do [ ! -d $TARGETDIR/$f ] && mkdir $TARGETDIR/$f - echo "Mounting $TARGETDIR/$f..." >$LOG + echo "$(printf "$(gettext "Mounting %s/%s...")" "$TARGETDIR" "$f")" >$LOG mount --rbind /$f $TARGETDIR/$f >$LOG 2>&1 done } @@ -1177,12 +1255,12 @@ umount_filesystems() { local dev=$2; local fstype=$3 shift 6 if [ "$fstype" = "swap" ]; then - echo "Disabling swap space on $dev..." >$LOG + echo "$(printf "$(gettext "Disabling swap space on %s...")" "$dev")" >$LOG swapoff $dev >$LOG 2>&1 continue fi done - echo "Unmounting $TARGETDIR..." >$LOG + echo "$(printf "$(gettext "Unmounting %s...")" "$TARGETDIR")" >$LOG umount -R $TARGETDIR >$LOG 2>&1 } @@ -1195,7 +1273,7 @@ log_and_count() { if [ "$progress" != "$copy_progress" ]; then whole=$((progress / 10)) tenth=$((progress % 10)) - printf "Progress: %d.%d%% (%d of %d files)\n" $whole $tenth $copy_count $copy_total + printf "$(gettext "Progress: %d.%d%% (%d of %d files)")\n" $whole $tenth $copy_count $copy_total copy_progress=$progress fi done @@ -1203,8 +1281,8 @@ log_and_count() { copy_rootfs() { local tar_in="--create --one-file-system --xattrs" - TITLE="Check $LOG for details ..." - INFOBOX "Counting files, please be patient ..." 4 60 + TITLE="$(printf "$(gettext "Check %s for details ...")" "$LOG")" + INFOBOX "$(gettext "Counting files, please be patient ...")" 4 60 copy_total=$(tar ${tar_in} -v -f /dev/null / 2>/dev/null | wc -l) export copy_total copy_count=0 copy_progress= clear @@ -1212,7 +1290,7 @@ copy_rootfs() { tar --extract --xattrs --xattrs-include='*' --preserve-permissions -v -f - -C $TARGETDIR | \ log_and_count | \ DIALOG --title "${TITLE}" \ - --progressbox "Copying live image to target rootfs." 5 60 + --progressbox "$(gettext "Copying live image to target rootfs.")" 5 60 if [ $? -ne 0 ]; then DIE 1 fi @@ -1249,14 +1327,14 @@ install_packages() { stdbuf -oL env XBPS_ARCH=${_arch} \ xbps-install -r $TARGETDIR -SyU ${_syspkg} ${_grub} 2>&1 | \ - DIALOG --title "Installing base system packages..." \ + DIALOG --title "$(gettext "Installing base system packages...")" \ --programbox 24 80 if [ $? -ne 0 ]; then DIE 1 fi xbps-reconfigure -r $TARGETDIR -f base-files >/dev/null 2>&1 stdbuf -oL chroot $TARGETDIR xbps-reconfigure -a 2>&1 | \ - DIALOG --title "Configuring base system packages..." --programbox 24 80 + DIALOG --title "$(gettext "Configuring base system packages...")" --programbox 24 80 if [ $? -ne 0 ]; then DIE 1 fi @@ -1279,7 +1357,7 @@ menu_services() { _checklist+=" ${sv} ${sv} ${_status}" fi done < <(find $TARGETDIR/etc/sv -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | grep -Ev "$sv_ignore" | sort -u) - DIALOG --no-tags --checklist "Select services to enable:" 20 60 18 ${_checklist} + DIALOG --no-tags --checklist "$(gettext "Select services to enable"):" 20 60 18 ${_checklist} if [ $? -eq 0 ]; then comm -13 "$TARGET_SERVICES" <(cat "$ANSWER" | tr ' ' '\n') | while read -r sv; do enable_service "$sv" @@ -1307,12 +1385,12 @@ menu_install() { BOOTLOADER_DONE="$(get_option BOOTLOADER)" if [ -z "$ROOTPASSWORD_DONE" ]; then - DIALOG --msgbox "${BOLD}The root password has not been configured, \ -please do so before starting the installation.${RESET}" ${MSGBOXSIZE} + DIALOG --msgbox "${BOLD}$(gettext "The root password has not been configured, \ +please do so before starting the installation.")${RESET}" ${MSGBOXSIZE} return 1 elif [ -z "$BOOTLOADER_DONE" ]; then - DIALOG --msgbox "${BOLD}The disk to install the bootloader has not been \ -configured, please do so before starting the installation.${RESET}" ${MSGBOXSIZE} + DIALOG --msgbox "${BOLD}$(gettext "The disk to install the bootloader has not been \ +configured, please do so before starting the installation.")${RESET}" ${MSGBOXSIZE} return 1 fi @@ -1321,8 +1399,8 @@ configured, please do so before starting the installation.${RESET}" ${MSGBOXSIZE validate_filesystems || return 1 if [ -z "$FILESYSTEMS_DONE" ]; then - DIALOG --msgbox "${BOLD}Required filesystems were not configured, \ -please do so before starting the installation.${RESET}" ${MSGBOXSIZE} + DIALOG --msgbox "${BOLD}$(gettext "Required filesystems were not configured, \ +please do so before starting the installation.")${RESET}" ${MSGBOXSIZE} return 1 fi @@ -1330,17 +1408,22 @@ please do so before starting the installation.${RESET}" ${MSGBOXSIZE} 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 + + DIALOG --yesno "$(printf "$(gettext "%sThe user account is not set up properly.%s + +%s%sWARNING: no user will be created. You will only be able to login with the root user in your new system.%s + +%sDo you want to continue?%s")" "${BOLD}" "${RESET}" "${BOLD}" "${RED}" "${RESET}" "${BOLD}" "${RESET}")" 15 60 || return + fi - DIALOG --yesno "${BOLD}The following operations will be executed:${RESET}\n\n -${BOLD}${TARGETFS}${RESET}\n -${BOLD}${RED}WARNING: data on partitions will be COMPLETELY DESTROYED for new \ -filesystems.${RESET}\n\n -${BOLD}Do you want to continue?${RESET}" 20 80 || return + DIALOG --yesno "$(printf "$(gettext "%sThe following operations will be executed:%s + +%s%s%s +%s%sWARNING: data on partitions will be COMPLETELY DESTROYED for new filesystems.%s + +%sDo you want to continue?%s")" "${BOLD}" "${RESET}" "${BOLD}" "${TARGETFS}" "${RESET}" "${BOLD}" "${RED}" "${RESET}" "${BOLD}" "${RESET}")" 20 80 || return + unset TARGETFS # Create and mount filesystems @@ -1354,21 +1437,26 @@ ${BOLD}Do you want to continue?${RESET}" 20 80 || return rm -f $TARGETDIR/etc/motd rm -f $TARGETDIR/etc/issue rm -f $TARGETDIR/usr/sbin/void-installer + + rm -f $TARGETDIR/usr/share/locale/pt_BR/LC_MESSAGES/installer.mo + rm -f $TARGETDIR/usr/share/applications/void-installer.desktop + rm -f $TARGETDIR/etc/skel/Desktop/void-installer.desktop + # Remove modified sddm.conf to let sddm use the defaults. rm -f $TARGETDIR/etc/sddm.conf # Remove live user. - echo "Removing $USERNAME live user from targetdir ..." >$LOG + echo "$(printf "$(gettext "Removing %s live user from targetdir ...")" "$USERNAME")" >$LOG chroot $TARGETDIR userdel -r $USERNAME >$LOG 2>&1 rm -f $TARGETDIR/etc/sudoers.d/99-void-live sed -i "s,GETTY_ARGS=\"--noclear -a $USERNAME\",GETTY_ARGS=\"--noclear\",g" $TARGETDIR/etc/sv/agetty-tty1/conf - TITLE="Check $LOG for details ..." - INFOBOX "Rebuilding initramfs for target ..." 4 60 - echo "Rebuilding initramfs for target ..." >$LOG + TITLE="$(printf "$(gettext "Check %s for details ...")" "$LOG")" + INFOBOX "$(gettext "Rebuilding initramfs for target ...")" 4 60 + echo "$(gettext "Rebuilding initramfs for target ...")" >$LOG # mount required fs mount_filesystems chroot $TARGETDIR dracut --no-hostonly --add-drivers "ahci" --force >>$LOG 2>&1 - INFOBOX "Removing temporary packages from target ..." 4 60 - echo "Removing temporary packages from target ..." >$LOG + INFOBOX "$(gettext "Removing temporary packages from target ...")" 4 60 + echo "$(gettext "Removing temporary packages from target ...")" >$LOG TO_REMOVE="dialog xtools-minimal xmirror" # only remove espeakup and brltty if it wasn't enabled in the live environment if ! [ -e "/var/service/espeakup" ]; then @@ -1392,7 +1480,7 @@ ${BOLD}Do you want to continue?${RESET}" 20 80 || return install_packages fi - INFOBOX "Applying installer settings..." 4 60 + INFOBOX "$(gettext "Applying installer settings...")" 4 60 # copy target fstab. install -Dm644 $TARGET_FSTAB $TARGETDIR/etc/fstab @@ -1429,7 +1517,7 @@ ${BOLD}Do you want to continue?${RESET}" 20 80 || return elif [ -n "$_dev" -a "$_type" = "static" ]; then # static IP through dhcpcd. mv $TARGETDIR/etc/dhcpcd.conf $TARGETDIR/etc/dhcpcd.conf.orig - echo "# Static IP configuration set by the void-installer for $_dev." \ + echo "# $(printf "$(gettext "Static IP configuration set by the void-installer for %s.")" "$_dev")" \ >$TARGETDIR/etc/dhcpcd.conf echo "interface $_dev" >>$TARGETDIR/etc/dhcpcd.conf echo "static ip_address=$_ip" >>$TARGETDIR/etc/dhcpcd.conf @@ -1443,7 +1531,7 @@ ${BOLD}Do you want to continue?${RESET}" 20 80 || return USERLOGIN="$(get_option USERLOGIN)" 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 - echo "# Enable sudo for login '$USERLOGIN'" > "$TARGETDIR/etc/sudoers.d/$USERLOGIN" + echo "# $(printf "$(gettext "Enable sudo for login '%s'")" "$USERLOGIN")" > "$TARGETDIR/etc/sudoers.d/$USERLOGIN" echo "$USERLOGIN ALL=(ALL:ALL) ALL" >> "$TARGETDIR/etc/sudoers.d/$USERLOGIN" else # enable the sudoers entry for members of group wheel @@ -1474,8 +1562,8 @@ ${BOLD}Do you want to continue?${RESET}" 20 80 || return umount_filesystems # installed successfully. - DIALOG --yesno "${BOLD}Void Linux has been installed successfully!${RESET}\n -Do you want to reboot the system?" ${YESNOSIZE} + DIALOG --yesno "${BOLD}$(gettext "Void Linux has been installed successfully!")${RESET}\n +$(gettext "Do you want to reboot the system?")" ${YESNOSIZE} if [ $? -eq 0 ]; then shutdown -r now else @@ -1486,10 +1574,10 @@ Do you want to reboot the system?" ${YESNOSIZE} menu_source() { local src= - DIALOG --title " Select installation source " \ + DIALOG --title "$(gettext " Select installation source ")" \ --menu "$MENULABEL" 8 70 0 \ - "Local" "Packages from ISO image" \ - "Network" "Base system only, downloaded from official repository" + "Local" "$(gettext "Packages from ISO image")" \ + "Network" "$(gettext "Base system only, downloaded from official repository")" case "$(cat $ANSWER)" in "Local") src="local";; "Network") src="net"; @@ -1517,42 +1605,42 @@ menu() { if xbps-uhelper arch | grep -qe '-musl$'; then AFTER_HOSTNAME="Timezone" DIALOG --default-item $DEFITEM \ - --extra-button --extra-label "Settings" \ - --title " Void Linux installation menu " \ + --extra-button --extra-label "$(gettext "Settings")" \ + --title "$(gettext " Void Linux installation menu ")" \ --menu "$MENULABEL" 10 70 0 \ - "Keyboard" "Set system keyboard" \ - "Network" "Set up the network" \ - "Source" "Set source installation" \ - "Mirror" "Select XBPS mirror" \ - "Hostname" "Set system hostname" \ - "Timezone" "Set system time zone" \ - "RootPassword" "Set system root password" \ - "UserAccount" "Set primary user name and password" \ - "BootLoader" "Set disk to install bootloader" \ - "Partition" "Partition disk(s)" \ - "Filesystems" "Configure filesystems and mount points" \ - "Install" "Start installation with saved settings" \ - "Exit" "Exit installation" + "Keyboard" "$(gettext "Set system keyboard")" \ + "Network" "$(gettext "Set up the network")" \ + "Source" "$(gettext "Set source installation")" \ + "Mirror" "$(gettext "Select XBPS mirror")" \ + "Hostname" "$(gettext "Set system hostname")" \ + "Timezone" "$(gettext "Set system time zone")" \ + "RootPassword" "$(gettext "Set system root password")" \ + "UserAccount" "$(gettext "Set primary user name and password")" \ + "BootLoader" "$(gettext "Set disk to install bootloader")" \ + "Partition" "$(gettext "Partition disk(s)")" \ + "Filesystems" "$(gettext "Configure filesystems and mount points")" \ + "Install" "$(gettext "Start installation with saved settings")" \ + "Exit" "$(gettext "Exit installation")" else AFTER_HOSTNAME="Locale" DIALOG --default-item $DEFITEM \ - --extra-button --extra-label "Settings" \ - --title " Void Linux installation menu " \ + --extra-button --extra-label "$(gettext "Settings")" \ + --title "$(gettext " Void Linux installation menu ")" \ --menu "$MENULABEL" 10 70 0 \ - "Keyboard" "Set system keyboard" \ - "Network" "Set up the network" \ - "Source" "Set source installation" \ - "Mirror" "Select XBPS mirror" \ - "Hostname" "Set system hostname" \ - "Locale" "Set system locale" \ - "Timezone" "Set system time zone" \ - "RootPassword" "Set system root password" \ - "UserAccount" "Set primary user name and password" \ - "BootLoader" "Set disk to install bootloader" \ - "Partition" "Partition disk(s)" \ - "Filesystems" "Configure filesystems and mount points" \ - "Install" "Start installation with saved settings" \ - "Exit" "Exit installation" + "Keyboard" "$(gettext "Set system keyboard")" \ + "Network" "$(gettext "Set up the network")" \ + "Source" "$(gettext "Set source installation")" \ + "Mirror" "$(gettext "Select XBPS mirror")" \ + "Hostname" "$(gettext "Set system hostname")" \ + "Locale" "$(gettext "Set system locale")" \ + "Timezone" "$(gettext "Set system time zone")" \ + "RootPassword" "$(gettext "Set system root password")" \ + "UserAccount" "$(gettext "Set primary user name and password")" \ + "BootLoader" "$(gettext "Set disk to install bootloader")" \ + "Partition" "$(gettext "Partition disk(s)")" \ + "Filesystems" "$(gettext "Configure filesystems and mount points")" \ + "Install" "$(gettext "Start installation with saved settings")" \ + "Exit" "$(gettext "Exit installation")" fi if [ $? -eq 3 ]; then @@ -1560,7 +1648,24 @@ menu() { cp $CONF_FILE /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 + + + +sed -i \ + -e "s/^KEYMAP/$(gettext "KEYMAP"):/" \ + -e "s/^SOURCE/$(gettext "SOURCE"):/" \ + -e "s/^HOSTNAME/$(gettext "HOSTNAME"):/" \ + -e "s/^TIMEZONE/$(gettext "TIMEZONE"):/" \ + -e "s/^ROOTPASSWORD/$(gettext "ROOTPASSWORD"):/" \ + -e "s/^USERLOGIN/$(gettext "USERLOGIN"):/" \ + -e "s/^USERNAME/$(gettext "USERNAME"):/" \ + -e "s/^USERPASSWORD/$(gettext "USERPASSWORD"):/" \ + -e "s/^USERGROUPS/$(gettext "USERGROUPS"):/" \ + /tmp/conf_hidden.$$ + + + DIALOG --title "$(gettext "Saved settings for installation")" --exit-label "$(gettext "EXIT")" --textbox /tmp/conf_hidden.$$ 14 60 + rm /tmp/conf_hidden.$$ return fi @@ -1581,34 +1686,50 @@ menu() { "Filesystems") menu_filesystems && [ -n "$FILESYSTEMS_DONE" ] && DEFITEM="Install";; "Install") menu_install;; "Exit") DIE;; - *) DIALOG --yesno "Abort Installation?" ${YESNOSIZE} && DIE + + *) + + DIALOG --yes-label "$(gettext "Yes")" --no-label "$(gettext "No")" --yesno "$(gettext "Abort Installation?")" ${YESNOSIZE} && DIE + esac } if ! command -v dialog >/dev/null; then - echo "ERROR: missing dialog command, exiting..." + echo "$(gettext "ERROR: missing dialog command, exiting...")" exit 1 fi if [ "$(id -u)" != "0" ]; then - echo "void-installer must run as root" 1>&2 + echo "$(gettext "void-installer must run as root")" 1>&2 exit 1 fi # # main() # -DIALOG --title "${BOLD}${RED} Enter the void ... ${RESET}" --msgbox "\n +DIALOG --title "${BOLD}${RED}$(gettext " Enter the void ... ")${RESET}" --msgbox "$(printf "$(gettext " Welcome to the Void Linux installation. A simple and minimal \ 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. + + 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 -${BOLD}https://www.voidlinux.org${RESET}\n\n" 16 80 +please join us at %s#voidlinux%s on %sirc.libera.chat%s. + + +%shttps://www.voidlinux.org%s + +")" "${BOLD}" "${RESET}" "${BOLD}" "${RESET}" "${BOLD}" "${RESET}")" 16 80 + + + while true; do menu done exit 0 + # vim: set ts=4 sw=4 et: + + diff --git a/lib.sh b/lib.sh index 96c3e337e..b944d6517 100755 --- a/lib.sh +++ b/lib.sh @@ -1,4 +1,25 @@ -#!/bin/sh +#!/bin/bash + +# clear + +# ---------------------------------------------------------------------------------------- + +# Quando os export estão dentro do lib.sh, os outros arquivos .sh não usa as traduções dos +# seus aequivos .mo, mas sim as de lib. + +# Ou seja, o lib "sobrepõe" os outros arquivos. + +# export TEXTDOMAIN=lib +# export TEXTDOMAINDIR=./locale + +# ---------------------------------------------------------------------------------------- + +# Detectar idioma atual do sistema + +LANG=${LANG:-en_US} + +# ---------------------------------------------------------------------------------------- + # This contains the COMPLETE list of binaries that this script needs # to function. The only exception is the QEMU binary since it is not @@ -46,39 +67,59 @@ info_msg() { printf "\033[1m%s\n\033[m" "$@" } + die() { + # This function is registered in all the scripts to make sure that # the important mounts get cleaned up and the $ROOTFS location is # removed. - printf "FATAL: %s\n" "$@" + + # Esta função é usada em todos os scripts para garantir que + # os mounts importantes sejam desmontados e o local $ROOTFS seja removido. + + # printf "$(gettext 'FATAL'): %s\n" "$@" + + printf '%s: %s\n' "$(gettext "FATAL")" "$@" + umount_pseudofs + [ -d "$ROOTFS" ] && rm -rf "$ROOTFS" + exit 1 } + check_tools() { # All scripts within mklive declare the tools they will use in a # variable called "REQTOOLS". This function checks that these # tools are available and prints out the path to each tool that # will be used. This can be useful to figure out what is broken # if a different version of something is used than was expected. + for tool in $LIBTOOLS $REQTOOLS ; do + if ! which "$tool" > /dev/null ; then - die "Required tool $tool is not available on this system!" + + die "$(printf "$(gettext "Required tool %s is not available on this system!")" "$tool" )" + fi + done - info_msg "The following tools will be used:" + info_msg "$(gettext "The following tools will be used:")" + for tool in $LIBTOOLS $REQTOOLS ; do which "$tool" done } mount_pseudofs() { + # This function ensures that the psuedofs mountpoints are present # in the chroot. Strictly they are not necessary to have for many # commands, but bind-mounts are cheap and it isn't too bad to just # mount them all the time. + for f in dev proc sys; do # In a naked chroot there is nothing to bind the mounts to, so # we need to create directories for these first. @@ -91,6 +132,7 @@ mount_pseudofs() { mount -r --rbind /$f "$ROOTFS/$f" --make-rslave fi done + if ! mountpoint -q "$ROOTFS/tmp" ; then mkdir -p "$ROOTFS/tmp" mount -o mode=0755,nosuid,nodev -t tmpfs tmpfs "$ROOTFS/tmp" @@ -98,11 +140,13 @@ mount_pseudofs() { } umount_pseudofs() { + # This function cleans up the mounts in the chroot. Failure to # clean up these mounts will prevent the tmpdir from being # deletable instead throwing the error "Device or Resource Busy". # The '-f' option is passed to umount to account for the # contingency where the psuedofs mounts are not present. + if [ -d "${ROOTFS}" ]; then for f in dev proc sys; do umount -R -f "$ROOTFS/$f" >/dev/null 2>&1 @@ -112,19 +156,19 @@ umount_pseudofs() { } run_cmd_target() { - info_msg "Running $* for target $XBPS_TARGET_ARCH ..." + info_msg "$(printf "$(gettext "Running %s for target %s ...")" "$*" "$XBPS_TARGET_ARCH")" if is_target_native "$XBPS_TARGET_ARCH"; then # This is being run on the same architecture as the host, # therefore we should set XBPS_ARCH. if ! eval XBPS_ARCH="$XBPS_TARGET_ARCH" "$@" ; then - die "Could not run command $*" + die "$(printf "$(gettext "Could not run command %s")" "$*" )" fi else # This is being run on a foriegn arch, therefore we should set # XBPS_TARGET_ARCH. In this case XBPS will not attempt # certain actions and will require reconfiguration later. if ! eval XBPS_TARGET_ARCH="$XBPS_TARGET_ARCH" "$@" ; then - die "Could not run command $*" + die "$(printf "$(gettext "Could not run command %s")" "$*" )" fi fi } @@ -134,11 +178,12 @@ run_cmd() { # may wish to see. For example its useful to see the tar/xz # pipeline to not need to delve into the scripts to see what # options its set up with. - info_msg "Running $*" + info_msg "$(printf "$(gettext "Running %s")" "$*" )" eval "$@" } run_cmd_chroot() { + # General purpose chroot function which makes sure the chroot is # prepared. This function takes 2 arguments, the location to # chroot to and the command to run. @@ -159,6 +204,7 @@ run_cmd_chroot() { } cleanup_chroot() { + # This function cleans up the chroot shims that are used by QEMU # to allow builds on alien platforms. It takes no arguments but # expects the global $ROOTFS variable to be set. @@ -168,6 +214,7 @@ cleanup_chroot() { } register_binfmt() { + # This function sets up everything that is needed to be able to # chroot into a ROOTFS and be able to run commands there. This # really matters on platforms where the host architecture is @@ -185,6 +232,7 @@ register_binfmt() { # If the XBPS_TARGET_ARCH is unset but the PLATFORM is known, it # may be possible to set the architecture from the static # platforms map. + if [ -z "$XBPS_TARGET_ARCH" ] && [ ! -z "$PLATFORM" ] ; then set_target_arch_from_platform fi @@ -193,6 +241,7 @@ register_binfmt() { # 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 @@ -245,7 +294,7 @@ register_binfmt() { _cpu=riscv64 ;; *) - die "Unknown target architecture!" + die "$(gettext "Unknown target architecture!")" ;; esac @@ -253,7 +302,7 @@ register_binfmt() { # qemu binary will be required. QEMU_BIN="qemu-${_cpu}" if ! $QEMU_BIN -version >/dev/null 2>&1; then - die "$QEMU_BIN binary is missing in your system, exiting." + die "$(printf "$(gettext "%s binary is missing in your system, exiting.")" "$QEMU_BIN" )" fi # In order to use the binfmt system the binfmt_misc mountpoint @@ -265,18 +314,22 @@ register_binfmt() { # Only register if the map is incomplete if [ ! -f /proc/sys/fs/binfmt_misc/qemu-$_cpu ] ; then + if ! command -v update-binfmts >/dev/null 2>&1; then - die "could not add binfmt: update-binfmts binary is missing in your system" + die "$(gettext "could not add binfmt: update-binfmts binary is missing in your system")" fi + update-binfmts --import "qemu-$_cpu" fi } set_target_arch_from_platform() { + # This function maintains a lookup from platform to target # architecture. This is required for scripts that need to know # the target architecture, but don't necessarily need to know it # internally (i.e. only run_cmd_chroot). + case "$PLATFORM" in rpi-aarch64*) XBPS_TARGET_ARCH="aarch64";; rpi-armv7l*) XBPS_TARGET_ARCH="armv7l";; @@ -289,7 +342,8 @@ set_target_arch_from_platform() { rock64*) XBPS_TARGET_ARCH="aarch64";; rockpro64*) XBPS_TARGET_ARCH="aarch64";; asahi*) XBPS_TARGET_ARCH="aarch64";; - *) die "$PROGNAME: Unable to compute target architecture from platform";; + + *) die "$(printf "$(gettext "%s: Unable to compute target architecture from platform")" "$PROGNAME" )";; esac if [ -z "${PLATFORM##*-musl}" ] ; then @@ -298,16 +352,20 @@ set_target_arch_from_platform() { } set_dracut_args_from_platform() { + # In rare cases it is necessary to set platform specific dracut # args. This is mostly the case on ARM platforms. + case "$PLATFORM" in *) ;; esac } set_cachedir() { + # The package artifacts are cacheable, but they need to be isolated # from the host cache. + : "${XBPS_CACHEDIR:=--cachedir=$PWD/xbps-cache/${XBPS_TARGET_ARCH}}" } @@ -329,6 +387,7 @@ rk33xx_flash_uboot() { # line. This select allows us to get that information out. This # fails silently if the toolname isn't known since this script is # sourced. + case "${1:-}" in platform2arch) PLATFORM=$2 @@ -336,3 +395,4 @@ case "${1:-}" in echo "$XBPS_TARGET_ARCH" ;; esac + diff --git a/locale/pt_BR/LC_MESSAGES/installer.mo b/locale/pt_BR/LC_MESSAGES/installer.mo new file mode 100644 index 000000000..69a7e36f9 Binary files /dev/null and b/locale/pt_BR/LC_MESSAGES/installer.mo differ diff --git a/locale/pt_BR/LC_MESSAGES/lib.mo b/locale/pt_BR/LC_MESSAGES/lib.mo new file mode 100644 index 000000000..7fb7cee69 Binary files /dev/null and b/locale/pt_BR/LC_MESSAGES/lib.mo differ diff --git a/locale/pt_BR/LC_MESSAGES/mkimage.mo b/locale/pt_BR/LC_MESSAGES/mkimage.mo new file mode 100644 index 000000000..1333e202d Binary files /dev/null and b/locale/pt_BR/LC_MESSAGES/mkimage.mo differ diff --git a/locale/pt_BR/LC_MESSAGES/mkiso.mo b/locale/pt_BR/LC_MESSAGES/mkiso.mo new file mode 100644 index 000000000..866c186a0 Binary files /dev/null and b/locale/pt_BR/LC_MESSAGES/mkiso.mo differ diff --git a/locale/pt_BR/LC_MESSAGES/mklive.mo b/locale/pt_BR/LC_MESSAGES/mklive.mo new file mode 100644 index 000000000..b66ee8de0 Binary files /dev/null and b/locale/pt_BR/LC_MESSAGES/mklive.mo differ diff --git a/locale/pt_BR/LC_MESSAGES/mknet.mo b/locale/pt_BR/LC_MESSAGES/mknet.mo new file mode 100644 index 000000000..a7bc0abbb Binary files /dev/null and b/locale/pt_BR/LC_MESSAGES/mknet.mo differ diff --git a/locale/pt_BR/LC_MESSAGES/mkplatformfs.mo b/locale/pt_BR/LC_MESSAGES/mkplatformfs.mo new file mode 100644 index 000000000..2024b632c Binary files /dev/null and b/locale/pt_BR/LC_MESSAGES/mkplatformfs.mo differ diff --git a/locale/pt_BR/LC_MESSAGES/mkrootfs.mo b/locale/pt_BR/LC_MESSAGES/mkrootfs.mo new file mode 100644 index 000000000..83ad7026e Binary files /dev/null and b/locale/pt_BR/LC_MESSAGES/mkrootfs.mo differ diff --git a/locale/pt_BR/LC_MESSAGES/release.mo b/locale/pt_BR/LC_MESSAGES/release.mo new file mode 100644 index 000000000..bd90a58ce Binary files /dev/null and b/locale/pt_BR/LC_MESSAGES/release.mo differ diff --git a/locale/pt_BR/LC_MESSAGES/void_mklive.mo b/locale/pt_BR/LC_MESSAGES/void_mklive.mo new file mode 100644 index 000000000..982d64f24 Binary files /dev/null and b/locale/pt_BR/LC_MESSAGES/void_mklive.mo differ diff --git a/mkimage.sh b/mkimage.sh index eea156da7..3048657af 100755 --- a/mkimage.sh +++ b/mkimage.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash #- # Copyright (c) 2013-2016 Juan Romero Pardines. # Copyright (c) 2017 Google @@ -25,10 +25,28 @@ # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #- + +clear + +# ---------------------------------------------------------------------------------------- + +export TEXTDOMAIN=mkimage +export TEXTDOMAINDIR=./locale + +# ---------------------------------------------------------------------------------------- + +# Detectar idioma atual do sistema + +LANG=${LANG:-en_US} + +# echo $LANG + +# ---------------------------------------------------------------------------------------- + readonly PROGNAME=$(basename "$0") readonly ARCH=$(uname -m) -trap 'printf "\nInterrupted! exiting...\n"; cleanup; exit 0' INT TERM HUP +trap 'printf "\n$(gettext "Interrupted! exiting...")\n"; cleanup; exit 0' INT TERM HUP # This source pulls in all the functions from lib.sh. This set of # functions makes it much easier to work with chroots and abstracts @@ -40,6 +58,7 @@ trap 'printf "\nInterrupted! exiting...\n"; cleanup; exit 0' INT TERM HUP # unmount the rootfs as mounted on a loop device. This function is # defined after sourcing the library functions to ensure it is the # last one defined. + cleanup() { umount_pseudofs umount -f "${ROOTFS}/boot" 2>/dev/null @@ -53,28 +72,32 @@ cleanup() { } usage() { + cat <<-EOH - Usage: $PROGNAME [options] - - 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 /boot filesystem type (default: vfat) - -B /boot filesystem size (default: 256MiB) - -r / filesystem type (default: ext4) - -s Total image size (default: 900MiB) - -o Image filename (default: guessed automatically) - -x 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 argument expects a tarball generated by mkplatformfs.sh. - The platform is guessed automatically by its name. + + $(printf "$(gettext "Usage: %s [options] ")" "$PROGNAME") + + $(gettext "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 /.") + + $(gettext "OPTIONS") + + -b $(gettext "/boot filesystem type (default: vfat)") + -B $(gettext "/boot filesystem size (default: 256MiB)") + -r $(gettext "/ filesystem type (default: ext4)") + -s <$(gettext "totalsize")> $(gettext "Total image size (default: 900MiB)") + -o <$(gettext "output")> $(gettext "Image filename (default: guessed automatically)") + -x $(gettext "Number of threads to use for image compression (default: dynamic)") + -h $(gettext "Show this help and exit") + -V $(gettext "Show version and exit") + + $(gettext "Accepted size suffixes: KiB, MiB, GiB, TiB, EiB.") + + $(gettext "The argument expects a tarball generated by mkplatformfs.sh.") + $(gettext "The platform is guessed automatically by its name.") + EOH } @@ -99,14 +122,20 @@ shift $((OPTIND - 1)) ROOTFS_TARBALL="$1" if [ -z "$ROOTFS_TARBALL" ]; then - echo "$PROGNAME: no ROOTFS tarball specified" >&2 + + echo "$(printf "$(gettext "%s: no ROOTFS tarball specified")" "$PROGNAME")" >&2 + usage >&2 + exit 1 + elif [ ! -r "$ROOTFS_TARBALL" ]; then + # In rare cases the tarball can wind up owned by the wrong user. # This leads to confusing failures if execution is allowed to # proceed. - die "Cannot read rootfs tarball: $ROOTFS_TARBALL" + + die "$(printf "$(gettext "Cannot read rootfs tarball: %s")" "$ROOTFS_TARBALL")" fi # Setup the platform variable. Here we want just the name and @@ -117,7 +146,7 @@ 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|asahi|*-musl);; - *) die "The $PLATFORM is not supported, exiting..." + *) die "$(printf "$(gettext "The %s is not supported, exiting...")" "$PLATFORM")" esac # Default for bigger boot partion on rk33xx devices since it needs to @@ -143,7 +172,7 @@ check_tools # This is an awful hack since the script isn't using privesc # mechanisms selectively. This is a TODO item. if [ "$(id -u)" -ne 0 ]; then - die "need root perms to continue, exiting." + die "$(gettext "need root perms to continue, exiting.")" fi # Set the default filename if none was provided above. The default @@ -155,14 +184,16 @@ fi # Create the base image. This was previously accomplished with dd, # but truncate is markedly faster. -info_msg "Creating disk image ($IMGSIZE) ..." + +info_msg "$(printf "$(gettext "Creating disk image (%s) ...")" "$IMGSIZE")" + truncate -s "${IMGSIZE}" "$FILENAME" >/dev/null 2>&1 # Grab a tmpdir for the rootfs. If this fails we need to halt now # because otherwise things will go very badly for the host system. -ROOTFS=$(mktemp -d) || die "Could not create tmpdir for ROOTFS" +ROOTFS=$(mktemp -d) || die "$(gettext "Could not create tmpdir for ROOTFS")" -info_msg "Creating disk image partitions/filesystems ..." +info_msg "$(gettext "Creating disk image partitions/filesystems ...")" if [ "$BOOT_FSTYPE" = "vfat" ]; then # The mkfs.vfat program tries to make some "intelligent" choices # about the type of filesystem it creates. Instead we set options @@ -210,7 +241,9 @@ case "$ROOT_FSTYPE" in # 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" @@ -219,7 +252,8 @@ 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. -info_msg "Unpacking rootfs tarball ..." +info_msg "$(gettext "Unpacking 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 # for the bootloader which is handled later. @@ -257,7 +291,9 @@ sed -i "${ROOTFS}/etc/default/growpart" -e 's/#ENABLE/ENABLE/' # please add a comment explaining what the steps you are adding do, # and where information about your specific platform's boot process # can be found. -info_msg "Configuring image for platform $PLATFORM" + +info_msg "$(printf "$(gettext "Configuring image for platform %s")" "$PLATFORM")" + case "$PLATFORM" in rpi*) # use PARTUUID to allow for non-mmc boot without configuration @@ -377,16 +413,24 @@ case "$PLATFORM" in # This filename is mandated by the Google Cloud Engine import # process, the archive name is not. mv "$FILENAME" disk.raw - info_msg "Compressing disk.raw" + + info_msg "$(gettext "Compressing disk.raw")" + tar Sczf "${FILENAME%.img}.tar.gz" disk.raw # Since this process just produces something that can be # uploaded, we remove the original disk image. rm disk.raw - info_msg "Sucessfully created ${FILENAME%.img}.tar.gz image." + + info_msg "$(printf "$(gettext "Sucessfully created %s.tar.gz image.")" "${FILENAME%.img}")" ;; *) - info_msg "Compressing $FILENAME with xz (level 9 compression)" + + info_msg "$(printf "$(gettext "Compressing %s with xz (level 9 compression)")" "$FILENAME")" + xz "-T${COMPRESSOR_THREADS:-0}" -9 "$FILENAME" - info_msg "Successfully created $FILENAME image." + + info_msg "$(printf "$(gettext "Successfully created %s image.")" "$FILENAME")" + ;; esac + diff --git a/mkiso.sh b/mkiso.sh index 1da70415e..3349159d7 100755 --- a/mkiso.sh +++ b/mkiso.sh @@ -1,5 +1,21 @@ #!/bin/bash + +clear + +# ---------------------------------------------------------------------------------------- + +export TEXTDOMAIN=mkiso +export TEXTDOMAINDIR=./locale + +# ---------------------------------------------------------------------------------------- + +# Detectar idioma atual do sistema + +LANG=${LANG:-en_US} + +# ---------------------------------------------------------------------------------------- + set -eu . ./lib.sh @@ -13,25 +29,29 @@ 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. + $(printf "$(gettext "Usage: %s [options ...] [-- mklive options ...]")" "$PROGNAME") - OPTIONS - -a Set architecture (or platform) in the image - -b One of base, enlightenment, xfce, mate, cinnamon, gnome, kde, + $(gettext "Wrapper script around mklive.sh for several standard flavors of live images.") + $(gettext "Adds void-installer and other helpful utilities to the generated images.") + + + $(gettext "OPTIONS") + + $(gettext " -a Set architecture (or platform) in the image") + $(gettext " -b One of base, enlightenment, xfce, mate, cinnamon, gnome, kde, lxde, lxqt, or xfce-wayland (default: base). May be specified multiple times - to build multiple variants - -d Override the datestamp on the generated image (YYYYMMDD format) - -t - Equivalent to setting -a, -b, and -d - -r 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. + to build multiple variants") + $(gettext " -d Override the datestamp on the generated image (YYYYMMDD format)") + $(gettext " -t Equivalent to setting -a, -b, and -d") + $(gettext " -r Use this XBPS repository. May be specified multiple times") + $(gettext " -h Show this help and exit") + $(gettext " -V Show version and exit") + + $(gettext "Other options can be passed directly to mklive.sh by specifying them after the --.") + + $(gettext "See mklive.sh -h for more details.") + EOH } @@ -64,7 +84,7 @@ include_installer() { install -Dm755 "$installer" "$INCLUDEDIR"/usr/bin/void-installer rm "$installer" else - echo installer.sh not found >&2 + echo $(gettext "installer.sh not found") >&2 exit 1 fi } @@ -117,7 +137,7 @@ build_variant() { KERNEL_PKG="linux-asahi" TARGET_ARCH="aarch64${ARCH#asahi}" if [ "$variant" = xfce ]; then - info_msg "xfce is not supported on asahi, switching to xfce-wayland" + info_msg "$(gettext "xfce is not supported on asahi, switching to xfce-wayland")" variant="xfce-wayland" fi ;; @@ -142,7 +162,7 @@ build_variant() { LIGHTDM_SESSION=enlightenment ;; xfce*) - PKGS="$PKGS $XORG_PKGS lightdm lightdm-gtk-greeter xfce4 gnome-themes-standard gnome-keyring network-manager-applet gvfs-afc gvfs-mtp gvfs-smb udisks2 firefox xfce4-pulseaudio-plugin" + PKGS="$PKGS $XORG_PKGS lightdm lightdm-gtk-greeter xfce4 gnome-themes-standard gnome-keyring network-manager-applet gvfs-afc gvfs-mtp gvfs-smb udisks2 firefox-esr xfce4-pulseaudio-plugin" SERVICES="$SERVICES dbus lightdm NetworkManager polkitd" LIGHTDM_SESSION=xfce @@ -179,7 +199,7 @@ build_variant() { SERVICES="$SERVICES dbus dhcpcd wpa_supplicant sddm polkitd" ;; *) - >&2 echo "Unknown variant $variant" + >&2 echo "$(printf "$(gettext "Unknown variant %s")" "$variant" )" exit 1 ;; esac @@ -198,7 +218,7 @@ EOF 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 + printf "#!/bin/sh\necho '$(gettext "void-installer is not supported on this live image")'\n" > "$INCLUDEDIR"/usr/bin/void-installer chmod 755 "$INCLUDEDIR"/usr/bin/void-installer fi @@ -213,7 +233,7 @@ EOF } if [ ! -x mklive.sh ]; then - echo mklive.sh not found >&2 + echo $(gettext "mklive.sh not found") >&2 exit 1 fi @@ -225,3 +245,4 @@ else build_variant "$image" "$@" done fi + diff --git a/mklive.sh b/mklive.sh index 3c1adb600..805b51f4e 100755 --- a/mklive.sh +++ b/mklive.sh @@ -24,6 +24,168 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #- + +# git clone https://github.com/void-linux/void-mklive.git + +# LANG=en_US.UTF-8 ./mklive.sh -h +# LANG=pt_BR.UTF-8 ./mklive.sh -h + +# Traduzir para o Espanhol + + +# Parei no arquivo installer.sh + +# https://www.youtube.com/watch?v=378rU-wpLX4&t=348s + +# script (addvm.sh) para gera maquina virtual + +# https://youtu.be/378rU-wpLX4?t=657 + + +# $ xbps-query -L +# 14641 https://repo-default.voidlinux.org/current (RSA signed) +# 5993 https://repo-default.voidlinux.org/current/multilib (RSA signed) +# 62 https://repo-default.voidlinux.org/current/nonfree (RSA signed) + + +# unrar rar nmap p7zip-unrar trans firefox-esr firefox-esr-i18n-pt-BR + +# $ echo $SHELL +# /bin/bash + + +# setxkbmap -query +# rules: evdev +# model: pc105 +# layout: br +# variant: thinkpad + +# -l pt_BR.UTF-8 -k br + +# https://repo-default.voidlinux.org/current/multilib https://repo-default.voidlinux.org/current/nonfree + + +# Software para gerenciar máquinas virtuais: + +# VirtualBox +# QEMU +# virsh + + +# https://youtu.be/378rU-wpLX4?t=957 +# https://www.youtube.com/watch?v=378rU-wpLX4&t=348s +# Instalador void funcionando: https://www.youtube.com/watch?v=378rU-wpLX4&t=348s + + +# Crear live iso personal con void-mklive + +# https://youtu.be/qLurRFQhMbs?t=193 +# https://www.youtube.com/watch?v=qLurRFQhMbs + + +# https://www.youtube.com/results?search_query=iso+void-mklive +# https://www.youtube.com/results?search_query=void-mklive + +# void-mklive - Linux selber machen +# https://www.youtube.com/watch?v=oe53VL7pl7c + + +# Papel de parede + +# ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-desktop.xml + +# Experimento | usando void-mklive +# https://www.youtube.com/watch?v=kLn_vtnkick + + +# Na tela de boot da ISO (Live GRUB/syslinux menu) + +# Quando a ISO iniciar e aparecer o menu: + +# Pressione a tecla e (no GRUB) ou TAB (no syslinux) + +# Vá até a linha que começa com linux ou vmlinuz + +# Adicione no final: + +# locale.LANG=pt_BR.UTF-8 vconsole.keymap=br-abnt2 + +# ou + +# locale.LANG=pt_BR.UTF-8 vconsole.keymap=br + + +clear + +# ---------------------------------------------------------------------------------------- + +export TEXTDOMAIN=mklive +export TEXTDOMAINDIR=./locale + +# ---------------------------------------------------------------------------------------- + +# Detectar idioma atual do sistema + +LANG=${LANG:-en_US} + +# echo $LANG + +# ---------------------------------------------------------------------------------------- + +check_pacote(){ + + +# Lista de pacotes individuais + +packages=(git make dialog jq xz dash sed tar gawk xorriso xz dhclient) + +# Verificar pacotes individuais + +for pkg in "${packages[@]}"; do + if command -v "$pkg" 1> /dev/null 2> /dev/null ; then + + echo "$(gettext "Package installed"): $pkg" + else + + echo "$(gettext "Package not installed"): $pkg" + + exit 1 + fi +done + + +# Lista de pacotes individuais + +# Esse padrão (20181003_2) pode se um problema para identificar o pacote instalado. + +packages=(base-devel-20181003_2 base-files-0.145_1 libgcc-14.2.1+20250405_2 coreutils-9.4_3 squashfs-tools-4.7_1 binutils-2.44_2 device-mapper-2.03.29_1 dracut-network-107_1 openresolv-3.17.0_1) + +installed=$(xbps-query -l | awk '{print $2}') + +for pkg in "${packages[@]}"; do + if echo "$installed" | grep -qx "$pkg"; then + echo "$(gettext "Package installed"): $pkg" + else + echo "$(gettext "Package not installed"): $pkg" + + exit 1 + fi +done + + +echo -e "\n\n" + +sleep 2 + +clear + +} + +# check_pacote + +# ---------------------------------------------------------------------------------------- + + umask 022 . ./lib.sh @@ -38,7 +200,7 @@ readonly PROGNAME="$(basename "$0")" declare -a INCLUDE_DIRS=() die() { - info_msg "ERROR: $*" + info_msg "$(gettext "ERROR"): $*" error_out 1 $LINENO } @@ -57,7 +219,7 @@ mount_pseudofs() { 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/" + info_msg "$(printf "$(gettext "ERROR: failed to unmount %s")" "$ROOTFS/$f/")" return 1 fi done @@ -72,39 +234,39 @@ error_out() { 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 Set XBPS_ARCH in the ISO image - -b Set an alternative base package (default: base-system) - -r Use this XBPS repository. May be specified multiple times - -c Use this XBPS cache directory (default: ./xbps-cachedir-) - -k Default keymap to use (default: us) - -l Default locale to use (default: en_US.UTF-8) - -i - Compression type for the initramfs image (default: xz) - -s Compression type for the squashfs image (default: xz) - -o Output file name for the ISO image (default: automatic) - -p " ..." Install additional packages in the ISO image - -g " ..." Ignore packages when building the ISO image - -I Include directory structure under given path in the ROOTFS - -S " ..." Enable services in the ISO image - -e Default shell of the root user (must be absolute path). - Set the live.shell kernel argument to change the default shell of anon. - -C " ..." Add additional kernel command line arguments - -P " ..." - Platforms to enable for aarch64 EFI ISO images (available: pinebookpro, x13s) - -T 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 + $(printf "$(gettext "Usage: %s [options]")" "$PROGNAME") + + $(gettext "Generates a basic live ISO image of Void Linux. This ISO image can be written") + $(gettext "to a CD/DVD-ROM or any USB stick.") + + $(gettext "To generate a more complete live ISO image, use mkiso.sh.") + + $(gettext "OPTIONS") + $(gettext " -a <arch> Set XBPS_ARCH in the ISO image") + $(gettext " -b <system-pkg> Set an alternative base package (default: base-system)") + $(gettext " -r <repo> Use this XBPS repository. May be specified multiple times") + $(gettext " -c <cachedir> Use this XBPS cache directory (default: ./xbps-cachedir-<arch>)") + $(gettext " -k <keymap> Default keymap to use (default: us)") + $(gettext " -l <locale> Default locale to use (default: en_US.UTF-8)") + $(gettext " -i <lz4|gzip|bzip2|xz>") + $(gettext " Compression type for the initramfs image (default: xz)") + $(gettext " -s <gzip|lzo|xz> Compression type for the squashfs image (default: xz)") + $(gettext " -o <file> Output file name for the ISO image (default: automatic)") + $(gettext ' -p "<pkg> ..." Install additional packages in the ISO image') + $(gettext ' -g "<pkg> ..." Ignore packages when building the ISO image') + $(gettext " -I <includedir> Include directory structure under given path in the ROOTFS") + $(gettext ' -S "<service> ..." Enable services in the ISO image') + $(gettext " -e <shell> Default shell of the root user (must be absolute path).") + $(gettext " Set the live.shell kernel argument to change the default shell of anon.") + $(gettext ' -C "<arg> ..." Add additional kernel command line arguments') + $(gettext ' -P "<platform> ..."') + $(gettext " Platforms to enable for aarch64 EFI ISO images (available: pinebookpro, x13s)") + $(gettext " -T <title> Modify the bootloader title (default: Void Linux)") + $(gettext " -v linux<version> Install a custom Linux version on ISO image (default: linux metapackage).") + $(gettext " Also accepts linux metapackages (linux-mainline, linux-lts).") + $(gettext " -K Do not remove builddir") + $(gettext " -h Show this help and exit") + $(gettext " -V Show version and exit") EOH } @@ -126,13 +288,13 @@ copy_autoinstaller_files() { 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..." + [ $? -ne 0 ] && die "$(gettext "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..." + [ $? -ne 0 ] && die "$(gettext "Failed to install required software, exiting...")" } post_install_packages() { @@ -149,13 +311,13 @@ post_install_packages() { 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..." + [ $? -ne 0 ] && die "$(gettext "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[*]}" + [ $? -ne 0 ] && die "printf "$(gettext "Failed to install: %s %s\n")" "${PACKAGE_LIST[*]}" "${INITRAMFS_PKGS[*]}" " xbps-reconfigure -r "$ROOTFS" -f base-files >/dev/null 2>&1 chroot "$ROOTFS" env -i xbps-reconfigure -f base-files @@ -193,7 +355,7 @@ enable_services() { SERVICE_LIST="$*" for service in $SERVICE_LIST; do if ! [ -e $ROOTFS/etc/sv/$service ]; then - die "service $service not in /etc/sv" + die "$(printf "$(gettext "service %s not in /etc/sv \n")" "$service")" fi ln -sf /etc/sv/$service $ROOTFS/etc/runit/runsvdir/default/ done @@ -201,12 +363,13 @@ enable_services() { change_shell() { chroot "$ROOTFS" chsh -s "$ROOT_SHELL" root - [ $? -ne 0 ] && die "Failed to change the shell for root" + [ $? -ne 0 ] && die "$(gettext "Failed to change the shell for root")" } copy_include_directories() { for includedir in "${INCLUDE_DIRS[@]}"; do - info_msg "=> copying include directory '$includedir' ..." + info_msg "=> "$(printf "$(gettext "copying include directory '%s' ...")" "$includedir")"" + find "$includedir" -mindepth 1 -maxdepth 1 -exec cp -rfpPv {} "$ROOTFS"/ \; done } @@ -218,7 +381,7 @@ generate_initramfs() { 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" + [ $? -ne 0 ] && die "$(gettext "Failed to generate the initramfs")" mv "$ROOTFS"/boot/initrd "$BOOT_DIR" case "$TARGET_ARCH" in @@ -492,7 +655,7 @@ generate_iso_image() { -output "$OUTPUT_FILE" "$IMAGEDIR" ) - "$VOIDHOSTDIR"/usr/bin/xorriso -as mkisofs "${XORRISO_ARGS[@]}" || die "Failed to generate ISO image" + "$VOIDHOSTDIR"/usr/bin/xorriso -as mkisofs "${XORRISO_ARGS[@]}" || die "$(gettext "Failed to generate ISO image")" } # @@ -561,14 +724,14 @@ case "$TARGET_ARCH" in if [ -r "platforms/${platform}.sh" ]; then . "platforms/${platform}.sh" else - die "unknown platform: ${platform}" + die "$(printf "$(gettext "unknown platform: %s")" "${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;; + *) >&2 echo "$(printf "$(gettext "architecture %s not supported by mklive.sh")" "$TARGET_ARCH" )" ; exit 1;; esac # Required packages in the image for a working system. @@ -576,7 +739,7 @@ PACKAGE_LIST+=("$BASE_SYSTEM_PKG") # Check for root permissions. if [ "$(id -u)" -ne 0 ]; then - die "Must be run as root, exiting..." + die "$(gettext "Must be run as root, exiting...")" fi trap 'error_out $? $LINENO' INT TERM 0 @@ -613,7 +776,7 @@ STEP_COUNT=10 mkdir -p "$ROOTFS" "$VOIDHOSTDIR" "$VOIDTARGETDIR" "$GRUB_DIR" "$ISOLINUX_DIR" -print_step "Synchronizing XBPS repository data..." +print_step "$(gettext "Synchronizing XBPS repository data...")" copy_void_keys "$ROOTFS" XBPS_ARCH=$TARGET_ARCH $XBPS_INSTALL_CMD -r "$ROOTFS" ${XBPS_REPOSITORY} -S copy_void_keys "$VOIDHOSTDIR" @@ -643,7 +806,7 @@ case "$LINUX_VERSION" in 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>" + die "$(gettext "-v option must be in format linux<version> or linux-<series>")" ;; esac shopt -u extglob @@ -656,15 +819,15 @@ if [ "$LINUX_VERSION" = linux-asahi ]; then fi if [ "$?" -ne "0" ]; then - die "Failed to find kernel package version" + die "$(gettext "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[*]} ..." +print_step "$(printf "$(gettext "Installing software to generate the image: %s ...")" "${REQUIRED_PKGS[*]}" )" install_prereqs "${REQUIRED_PKGS[@]}" -print_step "Installing software to generate the image: ${TARGET_PKGS[*]} ..." +print_step "$(printf "$(gettext "Installing software to generate the image: %s ...")" "${TARGET_PKGS[*]}" )" install_target_pkgs "${TARGET_PKGS[@]}" mkdir -p "$ROOTFS"/etc @@ -672,46 +835,47 @@ mkdir -p "$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[*]} ..." + print_step "$(printf "$(gettext "Ignoring packages in the rootfs: %s ...")" "${IGNORE_PKGS[*]}" )" ignore_packages fi -print_step "Installing void pkgs into the rootfs: ${PACKAGE_LIST[*]} ..." +print_step "$(printf "$(gettext "Installing void pkgs into the rootfs: %s ...")" "${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} ..." +print_step "$(printf "$(gettext "Enabling services: %s ...")" "${SERVICE_LIST}" ) " enable_services ${DEFAULT_SERVICE_LIST} ${SERVICE_LIST} if [ -n "$ROOT_SHELL" ]; then - print_step "Changing the root shell ..." + print_step "$(gettext "Changing the root shell ...")" change_shell fi if [ "${#INCLUDE_DIRS[@]}" -gt 0 ];then - print_step "Copying directory structures into the rootfs ..." + print_step "$(gettext "Copying directory structures into the rootfs ...")" copy_include_directories fi -print_step "Generating initramfs image ($INITRAMFS_COMPRESSION)..." +print_step "$(printf "$(gettext "Generating initramfs image (%s)...")" "$INITRAMFS_COMPRESSION" )" generate_initramfs if [ "$IMAGE_TYPE" = hybrid ]; then - print_step "Generating isolinux support for PC-BIOS systems..." + print_step "$(gettext "Generating isolinux support for PC-BIOS systems...")" generate_isolinux_boot fi -print_step "Generating GRUB support for EFI systems..." +print_step "$(gettext "Generating GRUB support for EFI systems...")" generate_grub_efi_boot -print_step "Cleaning up rootfs..." +print_step "$(gettext "Cleaning up rootfs...")" cleanup_rootfs -print_step "Generating squashfs image ($SQUASHFS_COMPRESSION) from rootfs..." +print_step "$(printf "$(gettext "Generating squashfs image (%s) from rootfs...")" "$SQUASHFS_COMPRESSION" )" generate_squashfs -print_step "Generating ISO image..." +print_step "$(gettext "Generating ISO image...")" generate_iso_image hsize=$(du -sh "$OUTPUT_FILE"|awk '{print $1}') -info_msg "Created $(readlink -f "$OUTPUT_FILE") ($hsize) successfully." +info_msg "$(printf "$(gettext "Created %s (%s) successfully.")" "$(readlink -f "$OUTPUT_FILE")" "$hsize")" + diff --git a/mknet.sh b/mknet.sh index aa5152a44..927b6b420 100755 --- a/mknet.sh +++ b/mknet.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # #- # Copyright (c) 2009-2015 Juan Romero Pardines. @@ -25,6 +25,75 @@ # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #- +clear + +# ---------------------------------------------------------------------------------------- + +export TEXTDOMAIN=mknet +export TEXTDOMAINDIR=./locale + +# ---------------------------------------------------------------------------------------- + +# Detectar idioma atual do sistema + +LANG=${LANG:-en_US} + +# echo $LANG + +# ---------------------------------------------------------------------------------------- + +check_pacote(){ + + +# Lista de pacotes individuais + +packages=(xbps-install tar jq dialog) + +# Verificar pacotes individuais + +for pkg in "${packages[@]}"; do + if command -v "$pkg" 1> /dev/null 2> /dev/null ; then + + echo "$(gettext "Package installed"): $pkg" + else + + echo "$(gettext "Package not installed"): $pkg" + + exit 1 + fi +done + + +# Lista de pacotes individuais + + +packages=(dracut-network-107_1 binutils-2.44_2 dracut-107_1) + +installed=$(xbps-query -l | awk '{print $2}') + +for pkg in "${packages[@]}"; do + if echo "$installed" | grep -qx "$pkg"; then + echo "$(gettext "Package installed"): $pkg" + else + echo "$(gettext "Package not installed"): $pkg" + + exit 1 + fi +done + + +echo -e "\n\n" + +sleep 2 + +clear + +} + +# check_pacote + +# ---------------------------------------------------------------------------------------- + readonly PROGNAME=$(basename "$0") readonly REQTOOLS="xbps-install tar" @@ -41,36 +110,42 @@ readonly CURDIR="$(pwd)" # Die is a function provided in lib.sh which handles the cleanup of # the mounts and removal of temporary directories if the running # program exists unexpectedly. -trap 'bailout' INT TERM +trap '$(gettext "bailout")' INT TERM bailout() { + [ -d "$BOOT_DIR" ] && rm -rf "$BOOT_DIR" - die "An unchecked exception has occured!" + + die "$(gettext "An unchecked exception has occured!")" + } usage() { cat <<-EOH - Usage: $PROGNAME [options] <rootfs-tarball> + $(printf "$(gettext "Usage: %s [options] <rootfs-tarball>")" "$PROGNAME") + + $(gettext "Generates a network-bootable tarball from a Void Linux ROOTFS generated by mkrootfs.") - Generates a network-bootable tarball from a Void Linux ROOTFS generated by mkrootfs. + $(gettext "OPTIONS") - OPTIONS - -r <repo> Use this XBPS repository. May be specified multiple times - -c <cachedir> Use this XBPS cache directory (default: ) + -r <$(gettext "repo")> $(gettext "Use this XBPS repository. May be specified multiple times") + -c <cachedir> $(gettext "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 + $(gettext "Compression type for the initramfs image (default: xz)") + -o <$(gettext "file")> $(gettext "Output file name for the netboot tarball (default: automatic)") + -K linux<$(gettext "version")> $(gettext "Install a custom Linux version on ISO image (default: linux metapackage)") + -k <keymap> $(gettext "Default keymap to use (default: us)") + -l <locale> $(gettext "Default locale to use (default: en_US.UTF-8)") + -C "<arg> ..." $(gettext "Add additional kernel command line arguments") + -T <$(gettext "title")> $(gettext "Modify the bootloader title (default: Void Linux)") + -S <$(gettext "image")> $(gettext "Set a custom splash image for the bootloader (default: data/splash.png)") + -h $(gettext "Show this help and exit") + -V $(gettext "Show version and exit") + EOH } + # ######################################## # SCRIPT EXECUTION STARTS HERE # ######################################## @@ -92,6 +167,7 @@ while getopts "r:c:C:T:K:i:o:k:l:S:Vh" opt; do *) usage >&2; exit 1;; esac done + shift $((OPTIND - 1)) BASE_TARBALL="$1" @@ -110,8 +186,11 @@ set_cachedir # This is an aweful hack since the script isn't using privesc # mechanisms selectively. This is a TODO item. + if [ "$(id -u)" -ne 0 ]; then - die "need root perms to continue, exiting." + + die "$(gettext "need root perms to continue, exiting.")" + fi # Before going any further, check that the tools that are needed are @@ -122,16 +201,19 @@ check_tools # We need to operate on a tempdir, if this fails to create, it is # absolutely crucial to bail out so that we don't hose the system that # is running the script. -ROOTFS=$(mktemp -d) || die "failed to create ROOTFS tempdir, exiting..." -BOOT_DIR=$(mktemp -d) || die "failed to create BOOT_DIR tempdir, exiting..." +ROOTFS=$(mktemp -d) || die "$(gettext "failed to create ROOTFS tempdir, exiting...")" +BOOT_DIR=$(mktemp -d) || die "$(gettext "failed to create BOOT_DIR tempdir, exiting...")" PXELINUX_DIR="$BOOT_DIR/pxelinux.cfg" # Now that we have a directory for the ROOTFS, we can expand the # existing base filesystem into the directory -info_msg "Expanding base tarball $BASE_TARBALL into $ROOTFS for $PLATFORM build." + +info_msg "$(printf "$(gettext "Expanding base tarball %s into %s for %s build.")" "$BASE_TARBALL" "$ROOTFS" "$PLATFORM")" + tar xf "$BASE_TARBALL" -C "$ROOTFS" -info_msg "Install additional dracut modules" +info_msg "$(gettext "Install additional dracut modules")" + # This section sets up the dracut modules that need to be present on # the ROOTFS to build the PXE tarball. This includes the netmenu # module and the autoinstaller @@ -151,25 +233,32 @@ cp installer.sh "$ROOTFS/usr/lib/dracut/modules.d/05netmenu/" mkdir -p "$ROOTFS/usr/lib/dracut/modules.d/01autoinstaller" cp dracut/autoinstaller/* "$ROOTFS/usr/lib/dracut/modules.d/01autoinstaller/" -info_msg "Install kernel and additional required netboot packages" +info_msg "$(gettext "Install kernel and additional required netboot packages")" + # The rootfs has no kernel in it, so it needs to have at the very # least dracut, syslinux, and linux installed. binutils provides # /usr/bin/strip which lets us shrink down the size of the initrd # dracut-network provides the in-initrd network stack dialog is needed # by the install environment. ${INITRAMFS_COMPRESSION} is the name of # the compressor we want to use (lz4 by default). + if [ -z "${XBPS_TARGET_ARCH##*86*}" ] ; then # This platform is x86 or compatible, we should use # syslinux/pxelinux to boot the system. - info_msg "Selecting syslinux bootloader" + + info_msg "$(gettext "Selecting syslinux bootloader")" + bootloader_pkg=syslinux else # This is likely an arm platform of some kind. In general these # either have u-boot or a u-boot compatible loader, so we'll use # that to produce a uImage and a uInitrd - info_msg "Selecting u-boot bootloader" + + info_msg "$(gettext "Selecting u-boot bootloader")" + bootloader_pkg=uboot-mkimage fi + run_cmd_target "xbps-install $XBPS_CONFFILE $XBPS_CACHEDIR $XBPS_REPOSITORY -r $ROOTFS -Sy ${KERNELPKG-linux} dracut binutils dracut-network dialog jq ${INITRAMFS_COMPRESSION-xz} ${bootloader_pkg}" run_cmd_chroot "$ROOTFS" "xbps-reconfigure -a" @@ -184,7 +273,9 @@ KERNELVERSION=$(ls "$ROOTFS/usr/lib/modules/") # This will pretty much step through the normal process to build # initrd with the exception that the autoinstaller and netmenu are # force added since no module depends on them. -info_msg "Building initrd for kernel version $KERNELVERSION" + +info_msg "$(printf "$(gettext "Building initrd for kernel version %s")" "$KERNELVERSION")" + run_cmd_chroot "$ROOTFS" "env -i /usr/bin/dracut \ -N \ --${INITRAMFS_COMPRESSION-xz} \ @@ -193,14 +284,18 @@ run_cmd_chroot "$ROOTFS" "env -i /usr/bin/dracut \ --omit systemd \ /boot/initrd \ $KERNELVERSION" -[ $? -ne 0 ] && die "Failed to generate the initramfs" -info_msg "Collect netboot components" +[ $? -ne 0 ] && die "$(gettext "Failed to generate the initramfs")" + +info_msg "$(gettext "Collect netboot components")" + if [ ${bootloader_pkg} = "syslinux" ] ; then + # The whole point of this endeavor is to get the files needed for PXE. # Now that they have been generated, we copy them out of the doomed # ROOTFS and into the $BOOT_DIR where we're staging the rest of the # tarball + mv -v "$ROOTFS/boot/initrd" "$BOOT_DIR" cp -v "$ROOTFS/boot/vmlinuz-$KERNELVERSION" "$BOOT_DIR/vmlinuz" @@ -213,19 +308,25 @@ if [ ${bootloader_pkg} = "syslinux" ] ; then # Some of these are always required, some of these are canonical, and # some of this list is from trial and error. Either way, this is the # minimum needed to get Void up and booting on metal from the network. + for prog in pxelinux.0 ldlinux.c32 libcom32.c32 vesamenu.c32 libutil.c32 chain.c32 ; do + cp -v "$ROOTFS/usr/lib/syslinux/$prog" "$BOOT_DIR" + done # Lastly we need the default pxelinux config and the splash image. # This is user configurable, but if that isn't set then we'll use the # one from data/splash.png instead + mkdir -p "$PXELINUX_DIR" cp -f pxelinux.cfg/pxelinux.cfg.in "$PXELINUX_DIR/default" cp -f "${SPLASH_IMAGE-data/splash.png}" "$BOOT_DIR" # This sets all the variables in the default config file - info_msg "Configuring pxelinux.0 default boot menu" + + info_msg "$(gettext "Configuring pxelinux.0 default boot menu")" + sed -i -e "s|@@SPLASHIMAGE@@|$(basename "${SPLASH_IMAGE-splash.png}")|" \ -e "s|@@KERNVER@@|${KERNELVERSION}|" \ -e "s|@@KEYMAP@@|${KEYMAP-us}|" \ @@ -262,13 +363,21 @@ fi # Compress the artifacts for distribution OUTPUT_FILE="void-${XBPS_TARGET_ARCH}-NETBOOT-$(date -u +%Y%m%d).tar.gz" -info_msg "Compressing results to $OUTPUT_FILE" -cd "$BOOT_DIR" || die "Could not enter image dir" + +info_msg "$(printf "$(gettext "Compressing results to %s")" "$OUTPUT_FILE")" + +cd "$BOOT_DIR" || die "$(gettext "Could not enter image dir")" + tar -zcvf "$CURDIR/$OUTPUT_FILE" . -cd "$CURDIR" || die "Could not return to working directory" + +cd "$CURDIR" || die "$(gettext "Could not return to working directory")" # As a final cleanup step, remove the ROOTFS and the expanded BOOT_DIR -info_msg "Cleaning up and removing build directories" + +info_msg "$(gettext "Cleaning up and removing build directories")" + cleanup_chroot + [ -d "$ROOTFS" ] && rm -rf "$ROOTFS" [ -d "$BOOT_DIR" ] && rm -rf "$BOOT_DIR" + diff --git a/mkplatformfs.sh b/mkplatformfs.sh index d85d870a0..7b112c680 100755 --- a/mkplatformfs.sh +++ b/mkplatformfs.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash #- # Copyright (c) 2017 Google # All rights reserved. @@ -24,6 +24,24 @@ # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #- +clear + +# ---------------------------------------------------------------------------------------- + +export TEXTDOMAIN=mkplatformfs +export TEXTDOMAINDIR=./locale + +# ---------------------------------------------------------------------------------------- + +# Detectar idioma atual do sistema + +LANG=${LANG:-en_US} + +# echo $LANG + +# ---------------------------------------------------------------------------------------- + + readonly PROGNAME=$(basename "$0") readonly ARCH=$(uname -m) readonly REQTOOLS="xbps-install xbps-reconfigure tar xz" @@ -37,36 +55,43 @@ readonly REQTOOLS="xbps-install xbps-reconfigure tar xz" # Die is a function provided in lib.sh which handles the cleanup of # the mounts and removal of temporary directories if the running # program exists unexpectedly. -trap 'die "Interrupted! exiting..."' INT TERM HUP + +trap 'die "$(gettext "Interrupted! exiting...")"' INT TERM HUP # Even though we only support really one target for most of these # architectures this lets us refer to these quickly and easily by # XBPS_ARCH. This makes it a lot more obvious what is happening later # in the script, and it makes it easier to consume the contents of # these down the road in later scripts. + + usage() { + cat <<-EOH - Usage: $PROGNAME [options] <platform> <rootfs-tarball> + + $(printf "$(gettext "Usage: %s [options] <platform> <rootfs-tarball>")" "$PROGNAME") - Generates a platform-specific ROOTFS tarball from a generic Void Linux ROOTFS - generated by mkrootfs.sh. + $(gettext "Generates a platform-specific ROOTFS tarball from a generic Void Linux ROOTFS") + $(gettext "generated by mkrootfs.sh.") - Supported platforms: i686, x86_64, GCP, + $(gettext "Supported platforms:") i686, x86_64, GCP, rpi-armv6l, rpi-armv7l, rpi-aarch64, pinebookpro, pinephone, rock64, rockpro64, asahi - 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 + $(gettext "OPTIONS") + + -b <system-pkg> $(gettext "Set an alternative base-system package (default: base-system)") + -c <cachedir> $(gettext "Set the XBPS cache directory (default: ./xbps-cachedir-<arch>)") + -C <$(gettext "file")> $(gettext "Full path to the XBPS configuration file") + -k <cmd> $(gettext "Call '<cmd> <ROOTFSPATH>' after building the ROOTFS") + -n $(gettext "Do not compress the image, instead print out the ROOTFS directory") + -o <$(gettext "file")> $(gettext "Filename to write the PLATFORMFS archive to (default: automatic)") + -p "<$(gettext "pkg")> ..." $(gettext "Additional packages to install into the ROOTFS") + -r <$(gettext "repo")> $(gettext "Use this XBPS repository. May be specified multiple times") + -x <num> $(gettext "Number of threads to use for image compression (default: dynamic)") + -h $(gettext "Show this help and exit") + -V $(gettext "Show version and exit") + EOH } @@ -93,6 +118,7 @@ while getopts "b:p:k:c:C:r:x:o:nhV" opt; do *) usage >&2; exit 1 ;; esac done + shift $((OPTIND - 1)) PLATFORM="$1" BASE_TARBALL="$2" @@ -104,8 +130,11 @@ fi # This is an aweful hack since the script isn't using privesc # mechanisms selectively. This is a TODO item. + if [ "$(id -u)" -ne 0 ]; then - die "need root perms to continue, exiting." + + die "$(gettext "need root perms to continue, exiting.")" + fi # Before going any further, check that the tools that are needed are @@ -119,6 +148,7 @@ check_tools # SSH keys and user accounts. The base platform packages are always # noarch though, so we strip off the -musl extention if it was # provided. + case "$PLATFORM" in rpi*) PKGS="$BASEPKG rpi-base" ;; i686*) PKGS="$BASEPKG" ;; @@ -129,7 +159,7 @@ case "$PLATFORM" in rock64*) PKGS="$BASEPKG ${PLATFORM%-*}-base" ;; rockpro64*) PKGS="$BASEPKG ${PLATFORM%-*}-base" ;; asahi*) PKGS="$BASEPKG asahi-base asahi-scripts grub-arm64-efi dracut" ;; - *) die "$PROGNAME: invalid platform!";; + *) die "$(printf "$(gettext "%s: invalid platform!")" "$PROGNAME")";; esac # Derive the target architecture using the static map @@ -139,6 +169,7 @@ set_target_arch_from_platform set_cachedir # Append any additional packages if they were requested + if [ -n "$EXTRA_PKGS" ] ; then PKGS="$PKGS $EXTRA_PKGS" fi @@ -146,27 +177,34 @@ fi # We need to operate on a tempdir, if this fails to create, it is # absolutely crucial to bail out so that we don't hose the system that # is running the script. -ROOTFS=$(mktemp -d) || die "failed to create tempdir, exiting..." + +ROOTFS=$(mktemp -d) || die "$(gettext "failed to create tempdir, exiting...")" # Now that we have a directory for the ROOTFS, we can expand the # existing base filesystem into the directory + if [ ! -e "$BASE_TARBALL" ]; then - die "no valid base tarball given, exiting." + + die "$(gettext "no valid base tarball given, exiting.")" + fi -info_msg "Expanding base tarball $BASE_TARBALL into $ROOTFS for $PLATFORM build." +info_msg "$(printf "$(gettext "Expanding base tarball %s into %s for %s build.")" "$BASE_TARBALL" "$ROOTFS" "$PLATFORM")" + tar xf "$BASE_TARBALL" --xattrs --xattrs-include='*' -C "$ROOTFS" # This will install, but not configure, the packages specified by # $PKGS. After this step we will do an xbps-reconfigure -f $PKGS # under the correct architecture to ensure the system is setup # correctly. + run_cmd_target "xbps-install -SU $XBPS_CONFFILE $XBPS_CACHEDIR $XBPS_REPOSITORY -r $ROOTFS -y $PKGS" # Now that the packages are installed, we need to chroot in and # reconfigure. This needs to be done as the right architecture. # Since this is the only thing we're doing in the chroot, we clean up # right after. + run_cmd_chroot "$ROOTFS" "xbps-reconfigure -a" # Before final cleanup the ROOTFS needs to be checked to make sure it @@ -178,6 +216,7 @@ run_cmd_chroot "$ROOTFS" "xbps-reconfigure -a" # using post unpacking steps for platforms that consume the x86 # tarballs. This check is very specific and ensures that applicable # tooling is present before proceeding. + if [ ! -f "$ROOTFS/boot/uInitrd" ] || [ ! -f "$ROOTFS/boot/initrd" ] && [ -z "${XBPS_TARGET_ARCH##*arm*}" ] && @@ -200,9 +239,12 @@ if [ ! -f "$ROOTFS/boot/uInitrd" ] || # This will pretty much step through the normal process to build # initrd with the exception that the autoinstaller and netmenu are # force added since no module depends on them. - info_msg "Building initrd for kernel version $KERNELVERSION" + + info_msg "$(printf "$(gettext "Building initrd for kernel version %s")" "$KERNELVERSION")" + run_cmd_chroot "$ROOTFS" "env -i /usr/bin/dracut $dracut_args /boot/initrd $KERNELVERSION" - [ $? -ne 0 ] && die "Failed to generate the initramfs" + + [ $? -ne 0 ] && die "$(gettext "Failed to generate the initramfs")" run_cmd_chroot "$ROOTFS" "env -i /usr/bin/mkimage -A arm -O linux -T ramdisk -C gzip -a 0 -e 0 -n 'Void Linux' -d /boot/initrd /boot/uInitrd" fi @@ -212,23 +254,29 @@ cleanup_chroot # The cache isn't that useful since by the time the ROOTFS will be # used it is likely to be out of date. Rather than shipping it around # only for it to be out of date, we remove it now. + rm -rf "$ROOTFS/var/cache/*" 2>/dev/null # Now we can run the POST_CMD script. This user-supplied script gets the # $ROOTFS as a parameter. + if [ -n "$POST_CMD" ]; then - info_msg "Running user supplied command: $POST_CMD" + + info_msg "$(printf "$(gettext "Running user supplied command: %s")" "$POST_CMD")" + run_cmd $POST_CMD $ROOTFS fi # Compress the tarball or just print out the path? + if [ "$COMPRESSION" = "y" ]; then # Finally we can compress the tarball, the name will include the # platform and the date on which the tarball was built. tarball=${FILENAME:-void-${PLATFORM}-PLATFORMFS-$(date -u '+%Y%m%d').tar.xz} run_cmd "tar cp --posix --xattrs --xattrs-include='*' -C $ROOTFS . | xz -T${COMPRESSOR_THREADS:-0} -9 > $tarball " - [ $? -ne 0 ] && die "Failed to compress tarball" + + [ $? -ne 0 ] && die "$(gettext "Failed to compress tarball")" # Now that we have the tarball we don't need the rootfs anymore, so we # can get rid of it. @@ -238,8 +286,15 @@ if [ "$COMPRESSION" = "y" ]; then # this succeeded. This also ensures that there's something visible # that the user can look for at the end of the script, which can make # it easier to see what's going on if something above failed. - info_msg "Successfully created $tarball ($PLATFORM)" + + info_msg "$(printf "$(gettext "Successfully created %s (%s)")" "$tarball" "$PLATFORM")" + else + # User requested just printing out the path to the rootfs, here it comes. - info_msg "Successfully created rootfs under $ROOTFS" + + info_msg "$(printf "$(gettext "Successfully created rootfs under %s")" "$ROOTFS")" + fi + + diff --git a/mkrootfs.sh b/mkrootfs.sh index 54e101b7e..6d1ee2ee5 100755 --- a/mkrootfs.sh +++ b/mkrootfs.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash #- # Copyright (c) 2013-2015 Juan Romero Pardines. # Copyright (c) 2017 Google @@ -25,50 +25,150 @@ # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #- +clear + +# ---------------------------------------------------------------------------------------- + +export TEXTDOMAIN=mkrootfs +export TEXTDOMAINDIR=./locale + +# ---------------------------------------------------------------------------------------- + +# Detectar idioma atual do sistema + +LANG=${LANG:-en_US} + +# echo $LANG + +# ---------------------------------------------------------------------------------------- + +check_pacote(){ + + +# Lista de pacotes individuais + +packages=(gettext xbps-install xbps-reconfigure cp tar chpasswd xz) + +# Verificar pacotes individuais + +for pkg in "${packages[@]}"; do + + if command -v "$pkg" 1> /dev/null 2> /dev/null ; then + + echo "$(gettext "Package installed"): $pkg" + else + + echo "$(gettext "Package not installed"): $pkg" + + exit 1 + fi + +done + + +# Lista de pacotes individuais + +packages=(base-container-full-0.11_3) + +installed=$(xbps-query -l | awk '{print $2}') + +for pkg in "${packages[@]}"; do + + if echo "$installed" | grep -qx "$pkg"; then + echo "$(gettext "Package installed"): $pkg" + else + echo "$(gettext "Package not installed"): $pkg" + + exit 1 + fi + +done + + +echo -e "\n\n" + +sleep 2 + +clear + +} + +# check_pacote + +# ---------------------------------------------------------------------------------------- + + readonly PROGNAME=$(basename "$0") readonly ARCH=$(uname -m) readonly REQTOOLS="xbps-install xbps-reconfigure tar xz" +echo -e "\n$(gettext "Run the lib.sh script...")\n" + # This source pulls in all the functions from lib.sh. This set of # functions makes it much easier to work with chroots and abstracts # away all the problems with running binaries with QEMU. # shellcheck source=./lib.sh + +# Este código-fonte extrai todas as funções de lib.sh. Este conjunto de +# funções facilita muito o trabalho com chroots e abstrações +# elimina todos os problemas de execução de binários com o QEMU. +# shellcheck source=./lib.sh + . ./lib.sh +sleep 1 +clear + +# ---------------------------------------------------------------------------------------- + + # Die is a function provided in lib.sh which handles the cleanup of # the mounts and removal of temporary directories if the running # program exists unexpectedly. -trap 'die "Interrupted! exiting..."' INT TERM HUP + +# Die é uma função fornecida em lib.sh que lida com a limpeza de +# montagens e remoção de diretórios temporários se o programa em execução +# existir inesperadamente. + +trap 'die "$(gettext "Interrupted! exiting...")"' INT TERM HUP + + # Even though we only support really one target for most of these # architectures this lets us refer to these quickly and easily by # XBPS_ARCH. This makes it a lot more obvious what is happening later # in the script, and it makes it easier to consume the contents of # these down the road in later scripts. + usage() { - cat <<-EOH - 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 - 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 - EOH + + # Substituido cat <<-EOH (heredoc indentado com tab) por echo + + + echo $(printf "$(gettext "Usage: %s [options] <%s>")" "$PROGNAME" "arch") + echo + echo $(gettext "Generate a Void Linux ROOTFS tarball for the specified architecture.") + echo + echo $(gettext "Supported architectures:") + echo + echo " i686, i686-musl, x86_64, x86_64-musl," + echo " armv5tel, armv5tel-musl, armv6l, armv6l-musl, armv7l, armv7l-musl" + echo " aarch64, aarch64-musl," + echo " mipsel, mipsel-musl," + echo " ppc, ppc-musl, ppc64le, ppc64le-musl, ppc64, ppc64-musl" + echo " riscv64, riscv64-musl" + echo + echo $(gettext "OPTIONS") + echo + echo " -b <system-pkg> $(gettext "Set an alternative base-system package (default: base-container-full)")" + echo " -c <cachedir> $(gettext "Set XBPS cache directory (default: ./xbps-cachedir-<arch>)")" + echo " -C <$(gettext "file")> $(gettext "Full path to the XBPS configuration file")" + echo " -r <repo> $(gettext "Use this XBPS repository. May be specified multiple times")" + echo " -o <$(gettext "file")> $(gettext "Filename to write the ROOTFS to (default: automatic)")" + echo " -x <num> $(gettext "Number of threads to use for image compression (default: dynamic)")" + echo " -h $(gettext "Show this help and exit")" + echo " -V $(gettext "Show version and exit")" + echo } # ######################################## @@ -93,6 +193,7 @@ while getopts "b:C:c:hr:x:o:V" opt; do *) usage >&2; exit 1;; esac done + shift $((OPTIND - 1)) XBPS_TARGET_ARCH="$1" @@ -106,8 +207,11 @@ set_cachedir # This is an aweful hack since the script isn't using privesc # mechanisms selectively. This is a TODO item. + if [ "$(id -u)" -ne 0 ]; then - die "need root perms to continue, exiting." + + die "$(gettext "need root perms to continue, exiting.")" + fi # Before going any further, check that the tools that are needed are @@ -117,15 +221,18 @@ check_tools # If the arch wasn't set let's bail out now, nothing else in this # script will work without knowing what we're trying to build for. + if [ -z "$XBPS_TARGET_ARCH" ]; then - echo "$PROGNAME: arch was not set!" + + echo -e "\n$(printf "$(gettext "%s: arch was not set!")" "$PROGNAME") \n" + usage >&2; exit 1 fi # We need to operate on a tempdir, if this fails to create, it is # absolutely crucial to bail out so that we don't hose the system that # is running the script. -ROOTFS=$(mktemp -d) || die "failed to create tempdir, exiting..." +ROOTFS=$(mktemp -d) || die "$(gettext "failed to create tempdir, exiting...")" # This maintains the chain of trust, the keys in the repo are known to # be good and so we copy those. Why don't we just use the ones on the @@ -164,14 +271,17 @@ run_cmd_target "xbps-install -SU $XBPS_CONFFILE $XBPS_CACHEDIR $XBPS_REPOSITORY # language at least enough to enable thier preferred locale. If this # truly becomes an issue in the future this hack can be revisited. if [ -e "$ROOTFS/etc/default/libc-locales" ]; then - LOCALE=en_US.UTF-8 + + # LOCALE=en_US.UTF-8 + LOCALE=${LANG:-en_US.UTF-8} + sed -e "s/\#\(${LOCALE}.*\)/\1/g" -i "$ROOTFS/etc/default/libc-locales" fi # The reconfigure step needs to execute code that's been compiled for # the target architecture. Since the target isn't garanteed to be the # same as the host, this needs to be done via qemu. -info_msg "Reconfiguring packages for ${XBPS_TARGET_ARCH} ..." +info_msg "$(printf "$(gettext "Reconfiguring packages for %s ...")" "${XBPS_TARGET_ARCH}")" # This step sets up enough of the base-files that the chroot will work # and they can be reconfigured natively. Without this step there @@ -189,6 +299,7 @@ fi # pass, so this cleans up any issues that linger. run_cmd_chroot "$ROOTFS" "env -i xbps-reconfigure -f base-files" + # Once base-files is configured and functional its possible to # configure the rest of the system. run_cmd_chroot "$ROOTFS" "xbps-reconfigure -a" @@ -199,11 +310,15 @@ run_cmd_chroot "$ROOTFS" "xbps-reconfigure -a" # chrooted. We also remove the lock file in this step to clean up the # lock on the passwd database, lest it be left in the system and # propogated to other points. -info_msg "Setting the default root password ('voidlinux')" + +info_msg "$(gettext "Setting the default root password ('voidlinux')")" + if [ ! -f "$ROOTFS/etc/shadow" ] ; then run_cmd_chroot "$ROOTFS" pwconv fi -echo root:voidlinux | run_cmd_chroot "$ROOTFS" "chpasswd -c SHA512" || die "Could not set default credentials" + +echo root:voidlinux | run_cmd_chroot "$ROOTFS" "chpasswd -c SHA512" || die "$(gettext "Could not set default credentials")" + rm -f "$ROOTFS/etc/.pwd.lock" # At this point we're done running things in the chroot and we can @@ -229,4 +344,7 @@ rm -rf "$ROOTFS" # this succeeded. This also ensures that there's something visible # that the user can look for at the end of the script, which can make # it easier to see what's going on if something above failed. -info_msg "Successfully created $FILENAME ($XBPS_TARGET_ARCH)" + +info_msg "$(printf "$(gettext "Successfully created %s (%s)")" "$FILENAME" "$XBPS_TARGET_ARCH")" + + diff --git a/release.sh b/release.sh index f10b418e1..24e9bd1cd 100755 --- a/release.sh +++ b/release.sh @@ -1,5 +1,22 @@ #!/bin/bash +# clear + +# ---------------------------------------------------------------------------------------- + +export TEXTDOMAIN=release +export TEXTDOMAINDIR=./locale + +# ---------------------------------------------------------------------------------------- + +# Detectar idioma atual do sistema + +LANG=${LANG:-en_US} + +# echo $LANG + +# ---------------------------------------------------------------------------------------- + set -e usage() { @@ -13,7 +30,7 @@ usage() { check_programs() { for prog; do if ! type $prog &>/dev/null; then - echo "missing program: $prog" + echo "$(printf "$(gettext "missing program: %s")" "$prog")" exit 1 fi done @@ -41,6 +58,7 @@ start_build() { # 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 @@ -55,9 +73,12 @@ download_build() { elif [ "$1" == "--" ]; then shift fi - echo "Downloading artifacts from run ${run} [this may take a while] ..." + + echo "$(printf "$(gettext "Downloading artifacts from run %s [this may take a while] ...")" "${run}")" + gh run download "$run" -p 'void-live*' "$@" - echo "Done." + + echo "$(gettext "Done.")" } sign_build() { @@ -66,14 +87,16 @@ sign_build() { SUMFILE="$2" mkdir -p release - echo "Creating key..." + echo "$(gettext "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..." + echo "$(printf "$(gettext "Signing %s...")" "$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." \ @@ -86,3 +109,4 @@ case "$1" in si*) shift; sign_build "$@" ;; *) usage ;; esac +