From c8aa47a6a0ff467a11a9d5fccc0866f708e739a3 Mon Sep 17 00:00:00 2001 From: chinyakao Date: Mon, 12 Jul 2021 17:33:59 +0800 Subject: [PATCH 01/27] mainly SC1901 and SC2086 --- casper/hooks/dell-bootstrap | 11 +- casper/scripts/99dell_bootstrap | 16 +-- debian/dell-recovery-bootloader.postinst | 1 + debian/dell-recovery-bootloader.postrm | 2 +- debian/dell-recovery.postinst | 1 + debian/dell-recovery.preinst | 1 + late/chroot_scripts/02-grub.sh | 2 + late/chroot_scripts/03-ubuntu-drivers.sh | 4 +- late/chroot_scripts/04-disable-hibernate.sh | 2 +- late/chroot_scripts/05-enable-oem-config.sh | 2 + late/chroot_scripts/95-set_UTC_TZ.sh | 6 +- late/scripts/FAIL-SCRIPT | 18 ++-- late/scripts/SUCCESS-SCRIPT | 26 ++--- late/scripts/chroot.sh | 2 + late/scripts/fifuncs | 15 +-- late/scripts/pool.sh | 3 +- late/scripts/secure-boot.sh | 13 +-- po/dell-recovery.pot | 110 ++++++++++---------- po/import.sh | 10 +- tests/grub-binaries | 5 +- ubiquity/dell-bootstrap | 1 + 21 files changed, 139 insertions(+), 112 deletions(-) diff --git a/casper/hooks/dell-bootstrap b/casper/hooks/dell-bootstrap index feae5ece..7bc39833 100755 --- a/casper/hooks/dell-bootstrap +++ b/casper/hooks/dell-bootstrap @@ -16,17 +16,18 @@ case "$1" in ;; esac +# shellcheck disable=SC1091 . /usr/share/initramfs-tools/hook-functions -cp /usr/share/dell/scripts/pool.sh $DESTDIR/scripts -if [ ! -f $DESTDIR/scripts/casper-bottom/99dell_bootstrap ]; then - cp /usr/share/dell/casper/scripts/99dell_bootstrap $DESTDIR/scripts/casper-bottom +cp /usr/share/dell/scripts/pool.sh "$DESTDIR"/scripts +if [ ! -f "$DESTDIR"/scripts/casper-bottom/99dell_bootstrap ]; then + cp /usr/share/dell/casper/scripts/99dell_bootstrap "$DESTDIR"/scripts/casper-bottom fi #invoked from dell-recovery if [ -n "$INJECT" ]; then - if ! grep 99dell_bootstrap $DESTDIR/scripts/casper-bottom/ORDER >/dev/null; then - cat >> $DESTDIR/scripts/casper-bottom/ORDER << EOF + if ! grep 99dell_bootstrap "$DESTDIR"/scripts/casper-bottom/ORDER >/dev/null; then + cat >> "$DESTDIR"/scripts/casper-bottom/ORDER << EOF /scripts/casper-bottom/99dell_bootstrap "\$@" [ -e /conf/param.conf ] && . /conf/param.conf EOF diff --git a/casper/scripts/99dell_bootstrap b/casper/scripts/99dell_bootstrap index 09af940e..cbc8968c 100755 --- a/casper/scripts/99dell_bootstrap +++ b/casper/scripts/99dell_bootstrap @@ -44,6 +44,7 @@ prereqs) ;; esac +# shellcheck disable=SC1091 . /scripts/casper-functions load_confmodule @@ -54,6 +55,7 @@ export DEBCONF_REDIR= export DEBIAN_FRONTEND=noninteractive # Early emergency installer fix +# shellcheck disable=SC1091 if [ -e /root/cdrom/scripts/emergency.sh ]; then . /root/cdrom/scripts/emergency.sh elif [ -e /root/isodevice/scripts/emergency.sh ]; then @@ -61,19 +63,19 @@ elif [ -e /root/isodevice/scripts/emergency.sh ]; then fi if [ -d /root/isodevice ]; then - if [ -f /root/isodevice/.disk/info.recovery -a ! -f /root/isodevice/.disk/info ]; then + if [ -f /root/isodevice/.disk/info.recovery ] && [ ! -f /root/isodevice/.disk/info ]; then mount -o remount,rw /root/isodevice cp /root/isodevice/.disk/info.recovery /root/isodevice/.disk/info mount -o remount,ro /root/isodevice fi -elif [ -f /root/cdrom/.disk/info.recovery -a ! -f /root/cdrom/.disk/info ]; then +elif [ -f /root/cdrom/.disk/info.recovery ] && [ ! -f /root/cdrom/.disk/info ]; then mount -o remount,rw /root/cdrom cp /root/cdrom/.disk/info.recovery /root/cdrom/.disk/info mount -o remount,ro /root/cdrom fi #Force ubiquity to run in automatic regardless if there are ubiquity options in /proc/cmdline (except single user mode) -if ! grep -q "single" /proc/cmdline 2>&1 >/dev/null; then +if ! grep -q "single" /proc/cmdline >/dev/null 2>&1; then sed -i "s/ubiquity=\$/ubiquity=1/; s/\$automatic\ \$choose/--automatic/" /root/etc/init/ubiquity.conf fi #if they use a ubiquity icon it needs to run in automatic @@ -134,7 +136,7 @@ ln -s /dev/null /root/etc/systemd/system/snapd.service KERNELS=$(find /root/cdrom/kernel -maxdepth 1 -type d 2>/dev/null | sed "s,/root,,; /\/cdrom\/kernel\/$/d") if [ -n "$KERNELS" ]; then for KERNEL in $KERNELS; do - ln -s $KERNEL /root/lib/modules + ln -s "$KERNEL" /root/lib/modules done fi @@ -143,12 +145,14 @@ rm -f /root/var/cache/debconf/*.dat-old # Later emergency installer fixes if [ -d /root/cdrom/scripts/emergency-scripts ]; then + # shellcheck source=/dev/null for script in /root/cdrom/scripts/emergency-scripts/[0-9]*; do - . $script + . "$script" done elif [ -d /root/isodevice/scripts/emergency-scripts ]; then + # shellcheck source=/dev/null for script in /root/isodevice/scripts/emergency-scripts/[0-9]*; do - . $script + . "$script" done fi diff --git a/debian/dell-recovery-bootloader.postinst b/debian/dell-recovery-bootloader.postinst index eca917d6..06af0f07 100644 --- a/debian/dell-recovery-bootloader.postinst +++ b/debian/dell-recovery-bootloader.postinst @@ -1,5 +1,6 @@ #!/bin/sh -e +# shellcheck disable=SC1091 . /usr/share/debconf/confmodule case "$1" in diff --git a/debian/dell-recovery-bootloader.postrm b/debian/dell-recovery-bootloader.postrm index 28853fb6..a24b8ce9 100644 --- a/debian/dell-recovery-bootloader.postrm +++ b/debian/dell-recovery-bootloader.postrm @@ -6,7 +6,7 @@ if [ "$1" = "purge" ]; then TARGET=/var/lib/dell-recovery FILES="boot.img core.img grub.cfg grubenv grubx64.efi grub-setup.exe" for file in $FILES; do - rm -f $TARGET/$file + rm -f $TARGET/"$file" done rm -rf $TARGET/iso fi diff --git a/debian/dell-recovery.postinst b/debian/dell-recovery.postinst index 3b2e0024..7fb711fd 100644 --- a/debian/dell-recovery.postinst +++ b/debian/dell-recovery.postinst @@ -1,5 +1,6 @@ #!/bin/sh -e +# shellcheck disable=SC1091 . /usr/share/debconf/confmodule case "$1" in diff --git a/debian/dell-recovery.preinst b/debian/dell-recovery.preinst index 6c133c7e..15b49ac6 100644 --- a/debian/dell-recovery.preinst +++ b/debian/dell-recovery.preinst @@ -1,4 +1,5 @@ #!/bin/sh +# TODO set -e # Remove a no-longer used conffile (from http://wiki.debian.org/DpkgConffileHandling) diff --git a/late/chroot_scripts/02-grub.sh b/late/chroot_scripts/02-grub.sh index b69365cc..97374641 100755 --- a/late/chroot_scripts/02-grub.sh +++ b/late/chroot_scripts/02-grub.sh @@ -1,4 +1,5 @@ #!/bin/sh +# TODO # # <02-grub> # @@ -23,6 +24,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. +# shellcheck disable=SC1091 . /usr/share/dell/scripts/fifuncs "" IFHALT "Rerun GRUB update" diff --git a/late/chroot_scripts/03-ubuntu-drivers.sh b/late/chroot_scripts/03-ubuntu-drivers.sh index 0b979d19..eb0da681 100755 --- a/late/chroot_scripts/03-ubuntu-drivers.sh +++ b/late/chroot_scripts/03-ubuntu-drivers.sh @@ -1,5 +1,7 @@ #!/bin/bash +# TODO +# shellcheck disable=SC1091 . /usr/share/dell/scripts/fifuncs "" export DEBIAN_FRONTEND=noninteractive @@ -7,7 +9,7 @@ export DEBIAN_FRONTEND=noninteractive IFHALT "Run ubuntu-drivers autoinstall" echo 'APT::Get::AllowUnauthenticated "true";' > /etc/apt/apt.conf.d/99disable_authentication for blacklist in $(find /cdrom/scripts/chroot-scripts/blacklist /isodevice/scripts/chroot-scripts/blacklist -type f 2>/dev/null); do - UBUNTU_DRIVERS_BLACKLIST="$UBUNTU_DRIVERS_BLACKLIST $(cat $blacklist)" + UBUNTU_DRIVERS_BLACKLIST="$UBUNTU_DRIVERS_BLACKLIST $(cat "$blacklist")" done if [ -n "$UBUNTU_DRIVERS_BLACKLIST" ]; then echo "UBUNTU_DRIVERS_BLACKLIST: $UBUNTU_DRIVERS_BLACKLIST" diff --git a/late/chroot_scripts/04-disable-hibernate.sh b/late/chroot_scripts/04-disable-hibernate.sh index 552a080d..7dd8c925 100755 --- a/late/chroot_scripts/04-disable-hibernate.sh +++ b/late/chroot_scripts/04-disable-hibernate.sh @@ -3,7 +3,7 @@ # Disable hibernate (S4) if RAM >= 4GB. (LP: #1284474) for i in $(dmidecode -t 17 | grep Size | cut -d ':' -f 2 | cut -d ' ' -f 2); do - memsize=$((${memsize:-0} + $i)) + memsize=$((${memsize:-0} + i)) done if [ ${memsize:-0} -ge 4096 ]; then diff --git a/late/chroot_scripts/05-enable-oem-config.sh b/late/chroot_scripts/05-enable-oem-config.sh index 0856e0e6..4e82f62e 100755 --- a/late/chroot_scripts/05-enable-oem-config.sh +++ b/late/chroot_scripts/05-enable-oem-config.sh @@ -1,4 +1,5 @@ #!/bin/sh +# TODO # # <05-enable-oem-config> # @@ -23,6 +24,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. +# shellcheck disable=SC1091 . /usr/share/dell/scripts/fifuncs "" IFHALT "Enable oem-config" diff --git a/late/chroot_scripts/95-set_UTC_TZ.sh b/late/chroot_scripts/95-set_UTC_TZ.sh index 5336d10a..9a2e32fc 100755 --- a/late/chroot_scripts/95-set_UTC_TZ.sh +++ b/late/chroot_scripts/95-set_UTC_TZ.sh @@ -1,4 +1,5 @@ #!/bin/sh +# TODO # # <95-set_UTC_TZ.sh> # @@ -33,10 +34,9 @@ # the time offset for ICC tz_offset.py was adjusted # from 5:30 to 5 # ==== Do we need to change this??? - for arg in $(cat /proc/cmdline); do - if echo $arg | grep "MFGSITE=" 2>&1 >/dev/null; then - SITE=$(echo $arg | cut -d'=' -f2) + if echo "$arg" | grep "MFGSITE=" >/dev/null 2>&1; then + SITE=$(echo "$arg" | cut -d'=' -f2) fi done diff --git a/late/scripts/FAIL-SCRIPT b/late/scripts/FAIL-SCRIPT index b8d14b18..e58bcd74 100755 --- a/late/scripts/FAIL-SCRIPT +++ b/late/scripts/FAIL-SCRIPT @@ -1,4 +1,5 @@ #!/bin/sh +# TODO # # # @@ -27,6 +28,7 @@ # BE AWARE THAT THIS SCRIPT IS CALLED FROM OUTSIDE THE CHROOT. # The OS is mounted under $TARGET +# shellcheck disable=SC1091 . /usr/share/dell/scripts/fifuncs "target" set -x @@ -38,7 +40,7 @@ if [ "$BOOTDEV" = "$TARGETDEV" ]; then #cleanup potentially stale mount points for mountpoint in $MOUNT_CLEANUP; do - umount -l $mountpoint + umount -l "$mountpoint" done if [ -d "/isodevice" ]; then @@ -50,8 +52,8 @@ if [ "$BOOTDEV" = "$TARGETDEV" ]; then fistlog="/tmp/fist.err" if [ -f $RP/SDR ]; then - dualos=`sed -n '/DUALOS/=' $RP/SDR` - if [ $dualos ]; then + dualos=$(sed -n '/DUALOS/=' $RP/SDR) + if [ "$dualos" ]; then fistlog="/tmp/DUALOS_FIST.ERR" fi fi @@ -61,18 +63,18 @@ if [ "$BOOTDEV" = "$TARGETDEV" ]; then grub-editenv $RP/factory/grubenv set recordfail=1 # create a dmesg.log file to record the dmesg info - touch $TARGET/$LOG/dmesg.log 2>&1 - chattr +a $TARGET/$LOG/dmesg.log - dmesg >> $TARGET/$LOG/dmesg.log + touch "$TARGET"/"$LOG"/dmesg.log 2>&1 + chattr +a "$TARGET"/"$LOG"/dmesg.log + dmesg >> "$TARGET"/"$LOG"/dmesg.log if [ -x /dell/fist/tal ]; then IFHALT "Reporting logs to DMP" - cp -f $TARGET/$LOG/chroot.sh.log $fistlog + cp -f "$TARGET"/"$LOG"/chroot.sh.log $fistlog /dell/fist/tal PutFiles $fistlog /dell/fist/tal PutFiles "$TARGET/$LOG/dmesg.log" sync elif [ ! -d /sys/firmware/efi ]; then - grub-setup -d $RP/factory $BOOTDEV + grub-setup -d $RP/factory "$BOOTDEV" fi #If we have another script to run, do it diff --git a/late/scripts/SUCCESS-SCRIPT b/late/scripts/SUCCESS-SCRIPT index f266d1ee..5c0ac957 100755 --- a/late/scripts/SUCCESS-SCRIPT +++ b/late/scripts/SUCCESS-SCRIPT @@ -1,4 +1,5 @@ #!/bin/sh +# TODO # # # @@ -27,20 +28,21 @@ # BE AWARE THAT THIS SCRIPT IS CALLED FROM OUTSIDE THE CHROOT. # The OS is mounted under $TARGET +# shellcheck disable=SC1091 . /usr/share/dell/scripts/fifuncs "target" set -x set -e IFHALT "(SUCCESS) Clean-Up .." -chroot $TARGET /usr/share/dell/scripts/pool.sh cleanup +chroot "$TARGET" /usr/share/dell/scripts/pool.sh cleanup #Fixup APT how we want it for a successful oem-config run -rm -f $TARGET/var/lib/apt/lists/*Packages -rm -f $TARGET/etc/apt/sources.list.d/dell.list +rm -f "$TARGET"/var/lib/apt/lists/*Packages +rm -f "$TARGET"/etc/apt/sources.list.d/dell.list #https://bugs.launchpad.net/ubuntu/+source/choose-mirror/+bug/550694 if [ -f "$TARGET/etc/apt/sources.list" ]; then - sed -i "s/http:\/\/.*.archive.ubuntu.com/http:\/\/archive.ubuntu.com/" $TARGET/etc/apt/sources.list + sed -i "s/http:\/\/.*.archive.ubuntu.com/http:\/\/archive.ubuntu.com/" "$TARGET"/etc/apt/sources.list fi #The script below was removed because we use a package based solution in @@ -49,7 +51,7 @@ fi #We disabled Ethernet in phase 1 and 2 of installation, now enable it back. (LP: #1329148) if [ -f "$TARGET/etc/init/network-manager.conf.orig" ]; then - mv $TARGET/etc/init/network-manager.conf.orig $TARGET/etc/init/network-manager.conf + mv "$TARGET"/etc/init/network-manager.conf.orig "$TARGET"/etc/init/network-manager.conf fi if [ "$BOOTDEV" = "$TARGETDEV" ]; then @@ -63,7 +65,7 @@ if [ "$BOOTDEV" = "$TARGETDEV" ]; then # Bypass the grub2-signed issue. (LP: #1482514) IFHALT "Renaming .disk/info to .disk/info.recovery" - if [ -f "$RP/.disk/info.recovery" -a -f "$RP/.disk/info" ]; then + if [ -f "$RP/.disk/info.recovery" ] && [ -f "$RP/.disk/info" ]; then rm -fr $RP/.disk/info elif [ -f "$RP/.disk/info" ]; then mv $RP/.disk/info $RP/.disk/info.recovery @@ -71,8 +73,8 @@ if [ "$BOOTDEV" = "$TARGETDEV" ]; then fistlog="/tmp/fist.log" if [ -f $RP/SDR ]; then - dualos=`sed -n '/DUALOS/=' $RP/SDR` - if [ $dualos ]; then + dualos=$(sed -n '/DUALOS/=' $RP/SDR) + if [ "$dualos" ]; then fistlog="/tmp/DUALOS_FIST.LOG" fi fi @@ -104,12 +106,12 @@ EOF IFHALT "Report the LOG..." # create a dmesg.log file to record the dmesg info - touch $TARGET/$LOG/dmesg.log 2>&1 - chattr +a $TARGET/$LOG/dmesg.log - dmesg >> $TARGET/$LOG/dmesg.log + touch "$TARGET"/"$LOG"/dmesg.log 2>&1 + chattr +a "$TARGET"/"$LOG"/dmesg.log + dmesg >> "$TARGET"/"$LOG"/dmesg.log if [ -f /dell/fist/tal ]; then - cp $TARGET/$LOG/chroot.sh.log $fistlog + cp "$TARGET"/"$LOG"/chroot.sh.log $fistlog /dell/fist/tal PutFiles $fistlog /dell/fist/tal PutFiles "$TARGET/$LOG/dmesg.log" rm -rf /cdrom/debs/fist diff --git a/late/scripts/chroot.sh b/late/scripts/chroot.sh index 05db1a5c..4eb13452 100755 --- a/late/scripts/chroot.sh +++ b/late/scripts/chroot.sh @@ -64,6 +64,7 @@ if [ -x /dell/fist/tal ]; then /dell/fist/tal nobulate 0 fi +# shellcheck disable=SC1091 if [ "$1" != "success" ]; then . /usr/share/dell/scripts/FAIL-SCRIPT exit 1 @@ -181,4 +182,5 @@ fi # reset traps, as we are now exiting normally trap - TERM INT HUP EXIT QUIT +# shellcheck disable=SC1091 . /usr/share/dell/scripts/SUCCESS-SCRIPT diff --git a/late/scripts/fifuncs b/late/scripts/fifuncs index 50f70bfc..302340d2 100755 --- a/late/scripts/fifuncs +++ b/late/scripts/fifuncs @@ -1,4 +1,5 @@ #!/bin/sh +# TODO # # # @@ -27,13 +28,13 @@ wd=""$1"" screenmsg() { - echo $* > /dev/ttyprintk 2>&1 + echo "$*" > /dev/ttyprintk 2>&1 } IFHALT() { - if [ -f /$wd/tmp/superhalt.flg ]; then + if [ -f /"$wd"/tmp/superhalt.flg ]; then touch /tmp/halt.flg - screenmsg "Halting ---> "$1 + screenmsg "Halting ---> $1" set +x while [ -f /tmp/halt.flg ]; do sleep 2 @@ -60,11 +61,11 @@ match_system_device() echo "Need Vendor and Product arguments" return 1 fi - DEVICES=$(find -L /sys/bus/$1/devices -maxdepth 2 -name $DEVICE_FILE) + DEVICES=$(find -L /sys/bus/"$1"/devices -maxdepth 2 -name $DEVICE_FILE) for file in $DEVICES; do - CHECK_DEVICE=$(cat $file) - DIRECTORY=$(dirname $file) - CHECK_VENDOR=$(cat $DIRECTORY/$VENDOR_FILE) + CHECK_DEVICE=$(cat "$file") + DIRECTORY=$(dirname "$file") + CHECK_VENDOR=$(cat "$DIRECTORY"/$VENDOR_FILE) if [ "$CHECK_VENDOR" != "$2" ] && [ "$CHECK_VENDOR" != "0x$2" ]; then continue fi diff --git a/late/scripts/pool.sh b/late/scripts/pool.sh index 8318a4a6..993477d0 100755 --- a/late/scripts/pool.sh +++ b/late/scripts/pool.sh @@ -1,4 +1,5 @@ #!/bin/sh +# TODO # # # @@ -67,7 +68,7 @@ if [ ! -f /etc/apt/sources.list.d/dell.list ]; then for dir in /cdrom/debs /isodevice/debs /dell/debs; do if [ -d "$dir" ]; then - cd $dir + cd $dir || exit apt-ftparchive packages ../../$dir | sed "s/^Filename:\ ..\//Filename:\ .\//" >> /Packages fi done diff --git a/late/scripts/secure-boot.sh b/late/scripts/secure-boot.sh index ebf6ea34..d2bb7f6f 100644 --- a/late/scripts/secure-boot.sh +++ b/late/scripts/secure-boot.sh @@ -1,4 +1,5 @@ #!/bin/sh +# TODO EFI_APP=/usr/lib/dell/x86_64/MokSBStateSet.efi @@ -7,7 +8,7 @@ efi_vars_dir=/sys/firmware/efi/vars EFI_GLOBAL_VARIABLE=8be4df61-93ca-11d2-aa0d-00e098032b8c SB="$efi_vars_dir/SecureBoot-$EFI_GLOBAL_VARIABLE/data" if [ -e "$SB" ] && \ - [ "$(( $(printf 0x%x \'"$(cat $SB | cut -b1)") & 1 ))" = 1 ]; then + [ "$(( $(printf 0x%x \'"$(< $SB cut -b1)") & 1 ))" = 1 ]; then SECURE_BOOT="1" fi @@ -16,11 +17,11 @@ fi if [ -z "$SECURE_BOOT" ] && [ -f "$EFI_APP" ]; then cp -v "$EFI_APP" /boot/efi/EFI/ubuntu/ PARTITION_NODE=$(mount | sed '/\/boot\/efi/!d; s, .*,,; s,/dev/,,;') - DEVICE=$(readlink /sys/class/block/$PARTITION_NODE | sed "s,/$PARTITION_NODE,,; s,.*/,,") - PARTITION_NUMBER=$(cat /sys/class/block/$PARTITION_NODE/partition) - efibootmgr -C -l '\EFI\ubuntu\MokSBStateSet.efi' -L 'MokSBStateSet' -d /dev/$DEVICE -p $PARTITION_NUMBER + DEVICE=$(readlink /sys/class/block/"$PARTITION_NODE" | sed "s,/$PARTITION_NODE,,; s,.*/,,") + PARTITION_NUMBER=$(cat /sys/class/block/"$PARTITION_NODE"/partition) + efibootmgr -C -l '\EFI\ubuntu\MokSBStateSet.efi' -L 'MokSBStateSet' -d /dev/"$DEVICE" -p "$PARTITION_NUMBER" BOOTNUM=$(efibootmgr | sed '/MokSBStateSet/!d; s,\* .*,,; s,Boot,,') BOOTORDER=$(efibootmgr | sed '/BootOrder/!d; s/BootOrder: //') - efibootmgr -o $BOOTORDER,$BOOTNUM - efibootmgr -v -n $BOOTNUM + efibootmgr -o "$BOOTORDER","$BOOTNUM" + efibootmgr -v -n "$BOOTNUM" fi diff --git a/po/dell-recovery.pot b/po/dell-recovery.pot index b91abf08..fc137211 100644 --- a/po/dell-recovery.pot +++ b/po/dell-recovery.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-09-06 14:23-0500\n" +"POT-Creation-Date: 2021-07-12 11:40+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,24 +17,24 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: ../Dell/recovery_gtk.py:104 +#: ../Dell/recovery_gtk.py:108 msgid "Cannot connect to dbus" msgstr "" -#: ../Dell/recovery_gtk.py:106 +#: ../Dell/recovery_gtk.py:110 msgid "Permission Denied" msgstr "" -#: ../Dell/recovery_gtk.py:113 +#: ../Dell/recovery_gtk.py:117 msgid "Exception" msgstr "" -#: ../Dell/recovery_gtk.py:158 ../gtk/dell-recovery-media.desktop.in.h:1 +#: ../Dell/recovery_gtk.py:173 ../gtk/dell-recovery-media.desktop.in.h:1 #: ../gtk/tool_selector.ui.h:2 msgid "Dell Recovery" msgstr "" -#: ../Dell/recovery_gtk.py:159 +#: ../Dell/recovery_gtk.py:174 msgid "Copyright 2008-2012 Dell Inc." msgstr "" @@ -50,51 +50,51 @@ msgstr "" msgid "Building Base image" msgstr "" -#: ../Dell/recovery_basic_gtk.py:179 +#: ../Dell/recovery_basic_gtk.py:181 msgid "Opening Burner" msgstr "" -#: ../Dell/recovery_basic_gtk.py:204 +#: ../Dell/recovery_basic_gtk.py:206 msgid "Recovery Media Creation Process Complete" msgstr "" -#: ../Dell/recovery_basic_gtk.py:205 +#: ../Dell/recovery_basic_gtk.py:207 msgid "" "If you would like to archive another copy, the generated image has been " "stored under the filename:\n" msgstr "" -#: ../Dell/recovery_basic_gtk.py:219 +#: ../Dell/recovery_basic_gtk.py:221 msgid "Unable to proceed" msgstr "" -#: ../Dell/recovery_basic_gtk.py:220 +#: ../Dell/recovery_basic_gtk.py:222 msgid "" "System does not appear to contain Dell factory installed partition layout." msgstr "" -#: ../Dell/recovery_basic_gtk.py:331 +#: ../Dell/recovery_basic_gtk.py:334 msgid "Image File" msgstr "" -#: ../Dell/recovery_basic_gtk.py:333 +#: ../Dell/recovery_basic_gtk.py:336 msgid "Media Type: " msgstr "" -#: ../Dell/recovery_basic_gtk.py:336 ../Dell/recovery_basic_gtk.py:339 +#: ../Dell/recovery_basic_gtk.py:339 ../Dell/recovery_basic_gtk.py:342 msgid "Recovery Partition: " msgstr "" -#: ../Dell/recovery_basic_gtk.py:340 +#: ../Dell/recovery_basic_gtk.py:343 msgid "Included" msgstr "" #. wizard.resize(400,400) -#: ../Dell/recovery_advanced_gtk.py:69 +#: ../Dell/recovery_advanced_gtk.py:63 msgid " (BTO Image Builder Mode)" msgstr "" -#: ../Dell/recovery_advanced_gtk.py:71 +#: ../Dell/recovery_advanced_gtk.py:65 msgid "" "This will integrate a Dell OEM FID framework & driver package set into a " "customized OS media image. You will have the option to create an USB key or " @@ -102,84 +102,84 @@ msgid "" msgstr "" #. insert builder pages in reverse order -#: ../Dell/recovery_advanced_gtk.py:90 +#: ../Dell/recovery_advanced_gtk.py:84 msgid "Application Packages" msgstr "" -#: ../Dell/recovery_advanced_gtk.py:91 +#: ../Dell/recovery_advanced_gtk.py:85 msgid "Driver Packages" msgstr "" -#: ../Dell/recovery_advanced_gtk.py:92 +#: ../Dell/recovery_advanced_gtk.py:86 msgid "FID Content" msgstr "" -#: ../Dell/recovery_advanced_gtk.py:93 +#: ../Dell/recovery_advanced_gtk.py:87 msgid "Base OS Image" msgstr "" -#: ../Dell/recovery_advanced_gtk.py:167 +#: ../Dell/recovery_advanced_gtk.py:161 msgid "Builder Summary" msgstr "" -#: ../Dell/recovery_advanced_gtk.py:168 +#: ../Dell/recovery_advanced_gtk.py:162 msgid "Base Image Distributor" msgstr "" -#: ../Dell/recovery_advanced_gtk.py:170 +#: ../Dell/recovery_advanced_gtk.py:164 msgid "Base Image Release" msgstr "" -#: ../Dell/recovery_advanced_gtk.py:173 +#: ../Dell/recovery_advanced_gtk.py:167 msgid "BTO Base Image" msgstr "" -#: ../Dell/recovery_advanced_gtk.py:176 +#: ../Dell/recovery_advanced_gtk.py:170 msgid "Base Image" msgstr "" -#: ../Dell/recovery_advanced_gtk.py:179 +#: ../Dell/recovery_advanced_gtk.py:173 msgid "Application" msgstr "" -#: ../Dell/recovery_advanced_gtk.py:180 +#: ../Dell/recovery_advanced_gtk.py:174 msgid "Driver" msgstr "" -#: ../Dell/recovery_advanced_gtk.py:186 +#: ../Dell/recovery_advanced_gtk.py:180 msgid "Packages" msgstr "" -#: ../Dell/recovery_advanced_gtk.py:192 +#: ../Dell/recovery_advanced_gtk.py:186 msgid "Inject Dell Recovery Package" msgstr "" #. update gui -#: ../Dell/recovery_advanced_gtk.py:202 +#: ../Dell/recovery_advanced_gtk.py:196 msgid "Assembling Image Components" msgstr "" -#: ../Dell/recovery_advanced_gtk.py:442 +#: ../Dell/recovery_advanced_gtk.py:431 msgid "All SRVs must be filled to proceed." msgstr "" -#: ../Dell/recovery_backend.py:346 +#: ../Dell/recovery_backend.py:368 msgid "Processing FISH packages" msgstr "" -#: ../Dell/recovery_backend.py:469 +#: ../Dell/recovery_backend.py:492 msgid "Adding in base image" msgstr "" -#: ../Dell/recovery_backend.py:1034 +#: ../Dell/recovery_backend.py:947 msgid "Preparing nested image" msgstr "" -#: ../Dell/recovery_backend.py:1105 +#: ../Dell/recovery_backend.py:1051 msgid "Regenerating UUID / Rebuilding initramfs" msgstr "" -#: ../Dell/recovery_backend.py:1206 +#: ../Dell/recovery_backend.py:1177 msgid "Building ISO" msgstr "" @@ -231,10 +231,6 @@ msgstr "" msgid "System policy prohibits changing network without user consent" msgstr "" -#: ../gtk/dell-driver-installer.desktop.in.h:1 -msgid "Dell Driver Installer" -msgstr "" - #: ../gtk/recovery_media_creator.ui.h:1 msgid "Cancel Recovery Media Creator" msgstr "" @@ -342,39 +338,35 @@ msgid "Build dell-recovery package from this system" msgstr "" #: ../gtk/builder.ui.h:16 -msgid "Install dpkg-repack" -msgstr "" - -#: ../gtk/builder.ui.h:17 msgid "" "Any add-on drivers or applications that need to be integrated into the image " "can be added here." msgstr "" -#: ../gtk/builder.ui.h:18 +#: ../gtk/builder.ui.h:17 msgid "" "The BTO FID framework is the first thing injected into a base vanilla " "image. If you are generating from an existing BTO compatible image, you may " "use the built-in framework." msgstr "" -#: ../gtk/builder.ui.h:19 +#: ../gtk/builder.ui.h:18 msgid "FID framework built into BTO image" msgstr "" -#: ../gtk/builder.ui.h:20 +#: ../gtk/builder.ui.h:19 msgid "FID Framework enclosed in debian package" msgstr "" -#: ../gtk/builder.ui.h:21 +#: ../gtk/builder.ui.h:20 msgid "Selected Overlay Details:" msgstr "" -#: ../gtk/builder.ui.h:22 +#: ../gtk/builder.ui.h:21 msgid "SRV Entry" msgstr "" -#: ../gtk/builder.ui.h:23 +#: ../gtk/builder.ui.h:22 msgid "Please enter the SRV to use:" msgstr "" @@ -396,20 +388,30 @@ msgid "" msgstr "" #: ../gtk/tool_selector.ui.h:6 -msgid "Build OS Media" +msgid "" +"This will restore the system with Dell Hybrid Client to the factory shipped " +"state using the recovery partition stored on the hard drive." msgstr "" #: ../gtk/tool_selector.ui.h:7 -msgid "Restore System" +msgid "Build OS Media" msgstr "" #: ../gtk/tool_selector.ui.h:8 +msgid "Restore System" +msgstr "" + +#: ../gtk/tool_selector.ui.h:9 +msgid "Restore Dell Hybrid Client" +msgstr "" + +#: ../gtk/tool_selector.ui.h:10 msgid "" "This will install a Dell driver package that you downloaded from the " "Internet." msgstr "" -#: ../gtk/tool_selector.ui.h:9 +#: ../gtk/tool_selector.ui.h:11 msgid "Install Drivers" msgstr "" diff --git a/po/import.sh b/po/import.sh index 6dc36c86..3f6b9eec 100755 --- a/po/import.sh +++ b/po/import.sh @@ -1,21 +1,21 @@ #!/bin/sh FILE=launchpad-export.tar.gz if [ -n "$1" ]; then - if echo $1 | grep "launchpadlibrarian.net" 2>/dev/null; then + if echo "$1" | grep "launchpadlibrarian.net" 2>/dev/null; then wget "$1" -O $FILE else FILE="$1" fi fi -if [ ! -f $FILE ]; then +if [ ! -f "$FILE" ]; then echo "Missing file: $FILE" exit 1 fi -tar xzzf $FILE +tar xzzf "$FILE" mv dell-recovery/*.po . rm -rf dell-recovery for x in dell-recovery-*.po ; do - echo $x ; - mv $x ${x#dell-recovery-} ; + echo "$x" ; + mv "$x" "${x#dell-recovery-}" ; done diff --git a/tests/grub-binaries b/tests/grub-binaries index fb872295..80c1291a 100755 --- a/tests/grub-binaries +++ b/tests/grub-binaries @@ -1,6 +1,7 @@ #!/bin/sh -e +# TODO export TARGET=$(mktemp -d) -export SOURCE_GRUBDIR=`pwd`/grub/ +export SOURCE_GRUBDIR=$(pwd)/grub/ grub/build-binaries.sh -rm -rf $TARGET +rm -rf "$TARGET" echo "No problems building grub binaries." diff --git a/ubiquity/dell-bootstrap b/ubiquity/dell-bootstrap index c2cbd16b..543101c1 100755 --- a/ubiquity/dell-bootstrap +++ b/ubiquity/dell-bootstrap @@ -1,5 +1,6 @@ #!/bin/sh -e +# shellcheck disable=SC1091 . /usr/share/debconf/confmodule db_input high dell-recovery/recovery_type || true From 4c64b5a8080fee150dc8851058384dcf6401b165 Mon Sep 17 00:00:00 2001 From: chinyakao Date: Thu, 15 Jul 2021 10:06:17 +0800 Subject: [PATCH 02/27] test action --- .github/workflows/main_test.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/main_test.yml diff --git a/.github/workflows/main_test.yml b/.github/workflows/main_test.yml new file mode 100644 index 00000000..b033a806 --- /dev/null +++ b/.github/workflows/main_test.yml @@ -0,0 +1,30 @@ +name: Continuous Integration +on: + push: + branches: + pull_request: + branches: + +jobs: + build: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Refresh dependencies + run: sudo apt update + - name: Install dependencies + run: DEBIAN_FRONTEND=noninteractive sudo apt-get install -yq --no-install-recommends build-essential debhelper dh-python dpkg-dev python3 python3-distutils-extra po-debconf pyflakes3 lsb-release gnu-efi + - name: Build package + run: dpkg-buildpackage --no-sign + shellcheck: + name: Shellcheck + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - name: Run ShellCheck + uses: ludeeus/action-shellcheck@master + env: + SHELLCHECK_OPTS: -e SC1091 -e SC2086 -e SC1090 + From daf0e689145fae666bfc571e6ac005603d173f8f Mon Sep 17 00:00:00 2001 From: chinyakao Date: Thu, 15 Jul 2021 14:47:06 +0800 Subject: [PATCH 03/27] correct shellcheck --- .github/workflows/main_test.yml | 2 +- casper/hooks/dell-bootstrap | 1 - casper/scripts/99dell_bootstrap | 2 - debian/dell-recovery-bootloader.postinst | 1 - debian/dell-recovery.postinst | 1 - debian/dell-recovery.preinst | 1 - late/chroot_scripts/02-grub.sh | 4 +- late/chroot_scripts/03-ubuntu-drivers.sh | 2 - late/chroot_scripts/05-enable-oem-config.sh | 4 +- late/chroot_scripts/95-set_UTC_TZ.sh | 8 +-- late/scripts/CLEANUP-SCRIPT | 6 +-- late/scripts/FAIL-SCRIPT | 4 +- late/scripts/SUCCESS-SCRIPT | 8 ++- late/scripts/chroot.sh | 2 - late/scripts/fetch_logs.sh | 58 ++++++++++----------- late/scripts/fifuncs | 3 +- late/scripts/pool.sh | 1 - late/scripts/secure-boot.sh | 1 - late/scripts/target_chroot.sh | 5 +- tests/grub-binaries | 7 +-- ubiquity/dell-bootstrap | 1 - 21 files changed, 52 insertions(+), 70 deletions(-) diff --git a/.github/workflows/main_test.yml b/.github/workflows/main_test.yml index b033a806..a5c520bd 100644 --- a/.github/workflows/main_test.yml +++ b/.github/workflows/main_test.yml @@ -26,5 +26,5 @@ jobs: - name: Run ShellCheck uses: ludeeus/action-shellcheck@master env: - SHELLCHECK_OPTS: -e SC1091 -e SC2086 -e SC1090 + SHELLCHECK_OPTS: -e SC1091 diff --git a/casper/hooks/dell-bootstrap b/casper/hooks/dell-bootstrap index 7bc39833..c54b8a26 100755 --- a/casper/hooks/dell-bootstrap +++ b/casper/hooks/dell-bootstrap @@ -16,7 +16,6 @@ case "$1" in ;; esac -# shellcheck disable=SC1091 . /usr/share/initramfs-tools/hook-functions cp /usr/share/dell/scripts/pool.sh "$DESTDIR"/scripts diff --git a/casper/scripts/99dell_bootstrap b/casper/scripts/99dell_bootstrap index cbc8968c..40071cd2 100755 --- a/casper/scripts/99dell_bootstrap +++ b/casper/scripts/99dell_bootstrap @@ -44,7 +44,6 @@ prereqs) ;; esac -# shellcheck disable=SC1091 . /scripts/casper-functions load_confmodule @@ -55,7 +54,6 @@ export DEBCONF_REDIR= export DEBIAN_FRONTEND=noninteractive # Early emergency installer fix -# shellcheck disable=SC1091 if [ -e /root/cdrom/scripts/emergency.sh ]; then . /root/cdrom/scripts/emergency.sh elif [ -e /root/isodevice/scripts/emergency.sh ]; then diff --git a/debian/dell-recovery-bootloader.postinst b/debian/dell-recovery-bootloader.postinst index 06af0f07..eca917d6 100644 --- a/debian/dell-recovery-bootloader.postinst +++ b/debian/dell-recovery-bootloader.postinst @@ -1,6 +1,5 @@ #!/bin/sh -e -# shellcheck disable=SC1091 . /usr/share/debconf/confmodule case "$1" in diff --git a/debian/dell-recovery.postinst b/debian/dell-recovery.postinst index 7fb711fd..3b2e0024 100644 --- a/debian/dell-recovery.postinst +++ b/debian/dell-recovery.postinst @@ -1,6 +1,5 @@ #!/bin/sh -e -# shellcheck disable=SC1091 . /usr/share/debconf/confmodule case "$1" in diff --git a/debian/dell-recovery.preinst b/debian/dell-recovery.preinst index 15b49ac6..6c133c7e 100644 --- a/debian/dell-recovery.preinst +++ b/debian/dell-recovery.preinst @@ -1,5 +1,4 @@ #!/bin/sh -# TODO set -e # Remove a no-longer used conffile (from http://wiki.debian.org/DpkgConffileHandling) diff --git a/late/chroot_scripts/02-grub.sh b/late/chroot_scripts/02-grub.sh index 97374641..b20178a5 100755 --- a/late/chroot_scripts/02-grub.sh +++ b/late/chroot_scripts/02-grub.sh @@ -1,5 +1,4 @@ #!/bin/sh -# TODO # # <02-grub> # @@ -24,8 +23,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. -# shellcheck disable=SC1091 -. /usr/share/dell/scripts/fifuncs "" +str="" . /usr/share/dell/scripts/fifuncs IFHALT "Rerun GRUB update" /usr/sbin/update-grub diff --git a/late/chroot_scripts/03-ubuntu-drivers.sh b/late/chroot_scripts/03-ubuntu-drivers.sh index eb0da681..4ac936a3 100755 --- a/late/chroot_scripts/03-ubuntu-drivers.sh +++ b/late/chroot_scripts/03-ubuntu-drivers.sh @@ -1,7 +1,5 @@ #!/bin/bash -# TODO -# shellcheck disable=SC1091 . /usr/share/dell/scripts/fifuncs "" export DEBIAN_FRONTEND=noninteractive diff --git a/late/chroot_scripts/05-enable-oem-config.sh b/late/chroot_scripts/05-enable-oem-config.sh index 4e82f62e..3024b3ff 100755 --- a/late/chroot_scripts/05-enable-oem-config.sh +++ b/late/chroot_scripts/05-enable-oem-config.sh @@ -1,5 +1,4 @@ #!/bin/sh -# TODO # # <05-enable-oem-config> # @@ -24,8 +23,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. -# shellcheck disable=SC1091 -. /usr/share/dell/scripts/fifuncs "" +str="" . /usr/share/dell/scripts/fifuncs IFHALT "Enable oem-config" oem-config-prepare --quiet diff --git a/late/chroot_scripts/95-set_UTC_TZ.sh b/late/chroot_scripts/95-set_UTC_TZ.sh index 9a2e32fc..75e952be 100755 --- a/late/chroot_scripts/95-set_UTC_TZ.sh +++ b/late/chroot_scripts/95-set_UTC_TZ.sh @@ -1,5 +1,4 @@ #!/bin/sh -# TODO # # <95-set_UTC_TZ.sh> # @@ -34,11 +33,14 @@ # the time offset for ICC tz_offset.py was adjusted # from 5:30 to 5 # ==== Do we need to change this??? -for arg in $(cat /proc/cmdline); do +mkfifo mypipe +/proc/cmdline > mypipe & +while IFS= read -r arg; do if echo "$arg" | grep "MFGSITE=" >/dev/null 2>&1; then SITE=$(echo "$arg" | cut -d'=' -f2) fi -done +done < mypipe +rm mypipe if [ -n "$SITE" ]; then cat > /etc/init.d/run-tz-fix </dev/null -if [ $? -eq 0 ];then +# mount | grep "/mnt" 2>/dev/null +if mount | grep -q "/mnt" 2>/dev/null;then umount /mnt fi #revert the mount points -mount -o remount,$MOUNT_PROPERTY /cdrom +mount -o remount,"$MOUNT_PROPERTY" /cdrom diff --git a/late/scripts/FAIL-SCRIPT b/late/scripts/FAIL-SCRIPT index e58bcd74..023db3a5 100755 --- a/late/scripts/FAIL-SCRIPT +++ b/late/scripts/FAIL-SCRIPT @@ -1,5 +1,4 @@ #!/bin/sh -# TODO # # # @@ -28,8 +27,7 @@ # BE AWARE THAT THIS SCRIPT IS CALLED FROM OUTSIDE THE CHROOT. # The OS is mounted under $TARGET -# shellcheck disable=SC1091 -. /usr/share/dell/scripts/fifuncs "target" +target="target" . /usr/share/dell/scripts/fifuncs set -x set -e diff --git a/late/scripts/SUCCESS-SCRIPT b/late/scripts/SUCCESS-SCRIPT index 5c0ac957..70e7bf38 100755 --- a/late/scripts/SUCCESS-SCRIPT +++ b/late/scripts/SUCCESS-SCRIPT @@ -1,5 +1,4 @@ #!/bin/sh -# TODO # # # @@ -28,8 +27,7 @@ # BE AWARE THAT THIS SCRIPT IS CALLED FROM OUTSIDE THE CHROOT. # The OS is mounted under $TARGET -# shellcheck disable=SC1091 -. /usr/share/dell/scripts/fifuncs "target" +target="target" . /usr/share/dell/scripts/fifuncs set -x set -e @@ -98,11 +96,11 @@ if [ "$BOOTDEV" = "$TARGETDEV" ]; then rm -rf $RP/.disk/casper-uuid* IFHALT "Regenerate md5sum.txt at the end..." - $(python3 << EOF + eval "$(python3 << EOF from Dell.recovery_common import regenerate_md5sum regenerate_md5sum("$RP") EOF -) +)" IFHALT "Report the LOG..." # create a dmesg.log file to record the dmesg info diff --git a/late/scripts/chroot.sh b/late/scripts/chroot.sh index 4eb13452..05db1a5c 100755 --- a/late/scripts/chroot.sh +++ b/late/scripts/chroot.sh @@ -64,7 +64,6 @@ if [ -x /dell/fist/tal ]; then /dell/fist/tal nobulate 0 fi -# shellcheck disable=SC1091 if [ "$1" != "success" ]; then . /usr/share/dell/scripts/FAIL-SCRIPT exit 1 @@ -182,5 +181,4 @@ fi # reset traps, as we are now exiting normally trap - TERM INT HUP EXIT QUIT -# shellcheck disable=SC1091 . /usr/share/dell/scripts/SUCCESS-SCRIPT diff --git a/late/scripts/fetch_logs.sh b/late/scripts/fetch_logs.sh index c35169f2..f5dae003 100755 --- a/late/scripts/fetch_logs.sh +++ b/late/scripts/fetch_logs.sh @@ -17,28 +17,28 @@ dump_MFG() { ESP="" BD="" - BDD="" + # BDD="" # check to see if it's already mounted, if not mount it - readlink /dev/disk/by-label/OS | grep "sd" - if [ $? -eq 0 ]; then - BD=`readlink /dev/disk/by-label/OS | cut -c7-9` + # readlink /dev/disk/by-label/OS | grep "sd" + if readlink /dev/disk/by-label/OS | grep -q "sd"; then + BD=$(readlink /dev/disk/by-label/OS | cut -c7-9) drive="/dev/${BD}1" - BDD="/dev/${BD}" + # BDD="/dev/${BD}" echo "Find boot disk ${drive}" else - readlink /dev/disk/by-label/OS | grep "mmc" - if [ $? -eq 0 ]; then - BD=`readlink /dev/disk/by-label/OS | cut -c7-13` + # readlink /dev/disk/by-label/OS | grep "mmc" + if readlink /dev/disk/by-label/OS | grep -q "mmc"; then + BD=$(readlink /dev/disk/by-label/OS | cut -c7-13) drive="/dev/${BD}p1" - BDD="/dev/${BD}" + # BDD="/dev/${BD}" log "Find boot disk ${drive}" echo "Find boot disk ${drive}" else - readlink /dev/disk/by-label/OS | grep "nvme" - if [ $? -eq 0 ]; then - BD=`readlink /dev/disk/by-label/OS | cut -c7-13` + # readlink /dev/disk/by-label/OS | grep "nvme" + if readlink /dev/disk/by-label/OS | grep -q "nvme"; then + BD=$(readlink /dev/disk/by-label/OS | cut -c7-13) drive="/dev/${BD}p1" - BDD="/dev/${BD}" + # BDD="/dev/${BD}" echo "Find boot disk ${drive}" else echo "Fail to find boot disk !!!" @@ -46,29 +46,29 @@ dump_MFG() fi fi fi - mount | grep -iqs "$drive" - if [ $? -gt 0 ]; then + # mount | grep -iqs "$drive" + if ! mount | grep -iqs "$drive"; then echo "Mounting EFI System Partition" if [ ! -d /mnt/efi ]; then mkdir /mnt/efi fi - mount $drive /mnt/efi + mount "$drive" /mnt/efi ESP="/mnt/efi" else - ESP=`mount | grep -is "$drive" | cut -d" " -f3` + ESP=$(mount | grep -is "$drive" | cut -d" " -f3) fi ################################################################## if [ "$ESP" = "" ]; then echo "Unable to find EFI System Partition which holds MFGMEDIA" fi # this code will account for case sensitivity of MFGMEDIA path - MFGMEDIA=`ls ${ESP} | grep -i "MFGMEDIA"` + MFGMEDIA=$(ls "${ESP}"/*"MFGMEDIA"*) if [ "$MFGMEDIA" = "" ]; then echo "Missing MFGMEDIA folder from EFI System Partition" else # copy the file - cp -rf ${ESP}/${MFGMEDIA} ./ - if [ $? -gt 0 ]; then + # cp -rf "${ESP}"/"${MFGMEDIA}" ./ + if ! cp -rf "${ESP}"/"${MFGMEDIA}" ./; then echo "Failed to copy MFGMEDIA" return 255 else @@ -79,8 +79,8 @@ dump_MFG() } #find the usb key mount point -usb_part=`mount | grep "/cdrom" | cut -d ' ' -f 1` -if [ $? -ne 0 ]; then +# usb_part=$(mount | grep "/cdrom" | cut -d ' ' -f 1) +if ! mount | grep "/cdrom" | cut -d ' ' -f 1; then echo "Can't find the USB key!!" exit 1 fi @@ -94,18 +94,18 @@ fi mkdir /cdrom/OSLogs STICKY=$(mount | sed '/\/cdrom/!d; s,\(.*\) on .*,\1,;') -linux_part=`fdisk -l | grep "Linux filesystem" | grep -v "$STICKY" | cut -d ' ' -f 1` +linux_part=$(fdisk -l | grep "Linux filesystem" | grep -v "$STICKY" | cut -d ' ' -f 1) #check the mount partition -if [ -z $linux_part ];then +if [ -z "$linux_part" ];then #store the disk layout info lsblk > /cdrom/OSLogs/disk_part echo "This disk has not parted yet!!" exit 1 fi #mount the partition -mount | grep "/mnt" 2>/dev/null -if [ $? -ne 0 ];then - mount $linux_part /mnt +# mount | grep "/mnt" 2>/dev/null +if ! mount | grep "/mnt" 2>/dev/null;then + mount "$linux_part" /mnt fi #copy the FI logs if installation happens during FI mfglog='' @@ -120,8 +120,8 @@ if [ -d /mnt/var/log ];then touch dmesg.log 2>&1 chattr +a dmesg.log dmesg >> dmesg.log - tar -zcf "/cdrom/OSLogs/ubuntu.log.tar.gz" /mnt/var/log/ dmesg.log $mfglog 2>/dev/null - if [ $? -eq 0 ];then + # tar -zcf "/cdrom/OSLogs/ubuntu.log.tar.gz" /mnt/var/log/ dmesg.log $mfglog 2>/dev/null + if tar -zcf "/cdrom/OSLogs/ubuntu.log.tar.gz" /mnt/var/log/ dmesg.log $mfglog 2>/dev/null;then echo "Finish copying the OS installation logs!" fi else diff --git a/late/scripts/fifuncs b/late/scripts/fifuncs index 302340d2..948a9210 100755 --- a/late/scripts/fifuncs +++ b/late/scripts/fifuncs @@ -1,5 +1,4 @@ #!/bin/sh -# TODO # # # @@ -25,7 +24,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. -wd=""$1"" +wd="""$1""" screenmsg() { echo "$*" > /dev/ttyprintk 2>&1 diff --git a/late/scripts/pool.sh b/late/scripts/pool.sh index 993477d0..0d671ff6 100755 --- a/late/scripts/pool.sh +++ b/late/scripts/pool.sh @@ -1,5 +1,4 @@ #!/bin/sh -# TODO # # # diff --git a/late/scripts/secure-boot.sh b/late/scripts/secure-boot.sh index d2bb7f6f..59c1f31e 100644 --- a/late/scripts/secure-boot.sh +++ b/late/scripts/secure-boot.sh @@ -1,5 +1,4 @@ #!/bin/sh -# TODO EFI_APP=/usr/lib/dell/x86_64/MokSBStateSet.efi diff --git a/late/scripts/target_chroot.sh b/late/scripts/target_chroot.sh index e979dce1..56b03412 100755 --- a/late/scripts/target_chroot.sh +++ b/late/scripts/target_chroot.sh @@ -47,8 +47,9 @@ do for i in $(find $d -type f -executable | sort); do echo "running chroot script: $i" > /dev/tty12 - IFHALT $i - ext=`echo $i | sed 's/^.*\.//'` + IFHALT "$i" + # ext=`echo $i | sed 's/^.*\.//'` + echo "${i//^.*\.//}" $i done fi diff --git a/tests/grub-binaries b/tests/grub-binaries index 80c1291a..12b0a1c1 100755 --- a/tests/grub-binaries +++ b/tests/grub-binaries @@ -1,7 +1,8 @@ #!/bin/sh -e -# TODO -export TARGET=$(mktemp -d) -export SOURCE_GRUBDIR=$(pwd)/grub/ +TARGET=$(mktemp -d) +export TARGET +SOURCE_GRUBDIR=$(pwd)/grub/ +export SOURCE_GRUBDIR grub/build-binaries.sh rm -rf "$TARGET" echo "No problems building grub binaries." diff --git a/ubiquity/dell-bootstrap b/ubiquity/dell-bootstrap index 543101c1..c2cbd16b 100755 --- a/ubiquity/dell-bootstrap +++ b/ubiquity/dell-bootstrap @@ -1,6 +1,5 @@ #!/bin/sh -e -# shellcheck disable=SC1091 . /usr/share/debconf/confmodule db_input high dell-recovery/recovery_type || true From 4a3a5f94b71dff766eaab44c6fb83d644ad2af87 Mon Sep 17 00:00:00 2001 From: chinyakao Date: Thu, 15 Jul 2021 14:55:55 +0800 Subject: [PATCH 04/27] fix shellcheck --- grub/99_dell_recovery | 2 +- late/chroot_scripts/03-ubuntu-drivers.sh | 5 +++-- late/scripts/fetch_logs.sh | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/grub/99_dell_recovery b/grub/99_dell_recovery index 669690e6..5d869412 100755 --- a/grub/99_dell_recovery +++ b/grub/99_dell_recovery @@ -31,7 +31,7 @@ menuentry "#RECOVERY_TEXT#" { fi kernel=/casper/vmlinuz - if [ ! -f $kernel ]; then + if [ ! -f $(kernel) ]; then kernel=/casper/vmlinuz.efi fi linux \$kernel dell-recovery/recovery_type=#REC_TYPE# \$uuid_options \$options diff --git a/late/chroot_scripts/03-ubuntu-drivers.sh b/late/chroot_scripts/03-ubuntu-drivers.sh index 4ac936a3..eb4896f1 100755 --- a/late/chroot_scripts/03-ubuntu-drivers.sh +++ b/late/chroot_scripts/03-ubuntu-drivers.sh @@ -6,9 +6,10 @@ export DEBIAN_FRONTEND=noninteractive IFHALT "Run ubuntu-drivers autoinstall" echo 'APT::Get::AllowUnauthenticated "true";' > /etc/apt/apt.conf.d/99disable_authentication -for blacklist in $(find /cdrom/scripts/chroot-scripts/blacklist /isodevice/scripts/chroot-scripts/blacklist -type f 2>/dev/null); do +# for blacklist in $(find /cdrom/scripts/chroot-scripts/blacklist /isodevice/scripts/chroot-scripts/blacklist -type f 2>/dev/null); do +while IFS= read -r -d '' blacklist; do UBUNTU_DRIVERS_BLACKLIST="$UBUNTU_DRIVERS_BLACKLIST $(cat "$blacklist")" -done +done < <(find /cdrom/scripts/chroot-scripts/blacklist /isodevice/scripts/chroot-scripts/blacklist -type f 2>/dev/null) if [ -n "$UBUNTU_DRIVERS_BLACKLIST" ]; then echo "UBUNTU_DRIVERS_BLACKLIST: $UBUNTU_DRIVERS_BLACKLIST" fi diff --git a/late/scripts/fetch_logs.sh b/late/scripts/fetch_logs.sh index f5dae003..8ac01205 100755 --- a/late/scripts/fetch_logs.sh +++ b/late/scripts/fetch_logs.sh @@ -121,7 +121,7 @@ if [ -d /mnt/var/log ];then chattr +a dmesg.log dmesg >> dmesg.log # tar -zcf "/cdrom/OSLogs/ubuntu.log.tar.gz" /mnt/var/log/ dmesg.log $mfglog 2>/dev/null - if tar -zcf "/cdrom/OSLogs/ubuntu.log.tar.gz" /mnt/var/log/ dmesg.log $mfglog 2>/dev/null;then + if tar -zcf "/cdrom/OSLogs/ubuntu.log.tar.gz" /mnt/var/log/ dmesg.log "$mfglog" 2>/dev/null;then echo "Finish copying the OS installation logs!" fi else From 06b9eeb2e77f9b6595be085e479ddd3418134b04 Mon Sep 17 00:00:00 2001 From: chinyakao Date: Thu, 15 Jul 2021 15:16:46 +0800 Subject: [PATCH 05/27] fix for loop in build package --- .github/workflows/main_test.yml | 2 +- late/chroot_scripts/03-ubuntu-drivers.sh | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main_test.yml b/.github/workflows/main_test.yml index a5c520bd..1306439f 100644 --- a/.github/workflows/main_test.yml +++ b/.github/workflows/main_test.yml @@ -26,5 +26,5 @@ jobs: - name: Run ShellCheck uses: ludeeus/action-shellcheck@master env: - SHELLCHECK_OPTS: -e SC1091 + SHELLCHECK_OPTS: -e SC1091 SC2044 diff --git a/late/chroot_scripts/03-ubuntu-drivers.sh b/late/chroot_scripts/03-ubuntu-drivers.sh index eb4896f1..614cd0b5 100755 --- a/late/chroot_scripts/03-ubuntu-drivers.sh +++ b/late/chroot_scripts/03-ubuntu-drivers.sh @@ -6,10 +6,12 @@ export DEBIAN_FRONTEND=noninteractive IFHALT "Run ubuntu-drivers autoinstall" echo 'APT::Get::AllowUnauthenticated "true";' > /etc/apt/apt.conf.d/99disable_authentication -# for blacklist in $(find /cdrom/scripts/chroot-scripts/blacklist /isodevice/scripts/chroot-scripts/blacklist -type f 2>/dev/null); do -while IFS= read -r -d '' blacklist; do +# while IFS= read -r -d '' blacklist; do +# UBUNTU_DRIVERS_BLACKLIST="$UBUNTU_DRIVERS_BLACKLIST $(cat "$blacklist")" +# done < <(find /cdrom/scripts/chroot-scripts/blacklist /isodevice/scripts/chroot-scripts/blacklist -type f -print0 2>/dev/null) +for blacklist in $(find /cdrom/scripts/chroot-scripts/blacklist /isodevice/scripts/chroot-scripts/blacklist -type f 2>/dev/null); do UBUNTU_DRIVERS_BLACKLIST="$UBUNTU_DRIVERS_BLACKLIST $(cat "$blacklist")" -done < <(find /cdrom/scripts/chroot-scripts/blacklist /isodevice/scripts/chroot-scripts/blacklist -type f 2>/dev/null) +done if [ -n "$UBUNTU_DRIVERS_BLACKLIST" ]; then echo "UBUNTU_DRIVERS_BLACKLIST: $UBUNTU_DRIVERS_BLACKLIST" fi From 4e0484253330a4e84277f83547720a046a28d6bc Mon Sep 17 00:00:00 2001 From: chinyakao Date: Thu, 15 Jul 2021 15:17:56 +0800 Subject: [PATCH 06/27] main test yml typo --- .github/workflows/main_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main_test.yml b/.github/workflows/main_test.yml index 1306439f..ff538514 100644 --- a/.github/workflows/main_test.yml +++ b/.github/workflows/main_test.yml @@ -26,5 +26,5 @@ jobs: - name: Run ShellCheck uses: ludeeus/action-shellcheck@master env: - SHELLCHECK_OPTS: -e SC1091 SC2044 + SHELLCHECK_OPTS: -e SC1091 -e SC2044 From ada615389f9253cbbe5468f837831db1a19f0913 Mon Sep 17 00:00:00 2001 From: chinyakao Date: Thu, 15 Jul 2021 15:21:22 +0800 Subject: [PATCH 07/27] change the disable SC2044 section --- .github/workflows/main_test.yml | 2 +- late/chroot_scripts/03-ubuntu-drivers.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main_test.yml b/.github/workflows/main_test.yml index ff538514..a5c520bd 100644 --- a/.github/workflows/main_test.yml +++ b/.github/workflows/main_test.yml @@ -26,5 +26,5 @@ jobs: - name: Run ShellCheck uses: ludeeus/action-shellcheck@master env: - SHELLCHECK_OPTS: -e SC1091 -e SC2044 + SHELLCHECK_OPTS: -e SC1091 diff --git a/late/chroot_scripts/03-ubuntu-drivers.sh b/late/chroot_scripts/03-ubuntu-drivers.sh index 614cd0b5..ff815862 100755 --- a/late/chroot_scripts/03-ubuntu-drivers.sh +++ b/late/chroot_scripts/03-ubuntu-drivers.sh @@ -9,6 +9,7 @@ echo 'APT::Get::AllowUnauthenticated "true";' > /etc/apt/apt.conf.d/99disable_au # while IFS= read -r -d '' blacklist; do # UBUNTU_DRIVERS_BLACKLIST="$UBUNTU_DRIVERS_BLACKLIST $(cat "$blacklist")" # done < <(find /cdrom/scripts/chroot-scripts/blacklist /isodevice/scripts/chroot-scripts/blacklist -type f -print0 2>/dev/null) +# shellcheck disable=SC2044 for blacklist in $(find /cdrom/scripts/chroot-scripts/blacklist /isodevice/scripts/chroot-scripts/blacklist -type f 2>/dev/null); do UBUNTU_DRIVERS_BLACKLIST="$UBUNTU_DRIVERS_BLACKLIST $(cat "$blacklist")" done From 1375e8d6b4ce8c12a94758b6cfadda65d76e3c91 Mon Sep 17 00:00:00 2001 From: chinyakao Date: Mon, 19 Jul 2021 09:27:51 +0800 Subject: [PATCH 08/27] pre-commit setup --- .pre-commit-config.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..1924ee43 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,8 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files From 2bb72bd06cd1ef4649b16bb49100ee85adf89a60 Mon Sep 17 00:00:00 2001 From: chinyakao Date: Mon, 19 Jul 2021 09:31:44 +0800 Subject: [PATCH 09/27] pre-commit setup shellcheck --- .pre-commit-config.yaml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1924ee43..6457a89e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,8 +1,6 @@ repos: -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.2.0 +- repo: git://github.com/detailyang/pre-commit-shell + rev: v1.0.6 hooks: - - id: trailing-whitespace - - id: end-of-file-fixer - - id: check-yaml - - id: check-added-large-files + - id: shell-lint + args: [--format=json] \ No newline at end of file From b53ffd20bfef8a9d5daf97ba2ca2842b53955ef5 Mon Sep 17 00:00:00 2001 From: chinyakao Date: Mon, 19 Jul 2021 10:54:26 +0800 Subject: [PATCH 10/27] fix pre-commit shellcheck --- .pre-commit-hooks.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .pre-commit-hooks.yaml diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml new file mode 100644 index 00000000..99250898 --- /dev/null +++ b/.pre-commit-hooks.yaml @@ -0,0 +1,15 @@ +--- +# This file tells https://pre-commit.com/ +# which hooks are provided by this repo +# for use by other git repos. + +- id: shellcheck + name: Test shell scripts with shellcheck + description: | + A static analysis tool for shell scripts + https://www.shellcheck.net + language: system + entry: shellcheck + args: [--exclude, SC1091] # do not fail when source script is not checked. or use [--external-sources] + types: [shell] + additional_dependencies: [shellcheck] \ No newline at end of file From eacbe1dd0803b06ea6e8c15503570da21f1d7c5a Mon Sep 17 00:00:00 2001 From: chinyakao Date: Mon, 19 Jul 2021 12:29:09 +0800 Subject: [PATCH 11/27] fix shellcheck pre-commit with new hooks --- .pre-commit-config.yaml | 7 +++---- .pre-commit-hooks.yaml | 15 --------------- 2 files changed, 3 insertions(+), 19 deletions(-) delete mode 100644 .pre-commit-hooks.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6457a89e..9b5d5f0b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,5 @@ repos: -- repo: git://github.com/detailyang/pre-commit-shell - rev: v1.0.6 +- repo: https://github.com/shellcheck-py/shellcheck-py + rev: v0.7.2.1 hooks: - - id: shell-lint - args: [--format=json] \ No newline at end of file + - id: shellcheck \ No newline at end of file diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml deleted file mode 100644 index 99250898..00000000 --- a/.pre-commit-hooks.yaml +++ /dev/null @@ -1,15 +0,0 @@ ---- -# This file tells https://pre-commit.com/ -# which hooks are provided by this repo -# for use by other git repos. - -- id: shellcheck - name: Test shell scripts with shellcheck - description: | - A static analysis tool for shell scripts - https://www.shellcheck.net - language: system - entry: shellcheck - args: [--exclude, SC1091] # do not fail when source script is not checked. or use [--external-sources] - types: [shell] - additional_dependencies: [shellcheck] \ No newline at end of file From e6dfbf895ac8eea705ab35d05e5ee038160efcf8 Mon Sep 17 00:00:00 2001 From: chinyakao Date: Mon, 19 Jul 2021 12:50:29 +0800 Subject: [PATCH 12/27] pre-commit shellcheck exclude SC1091 --- .pre-commit-config.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9b5d5f0b..e82887d0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,4 +2,5 @@ repos: - repo: https://github.com/shellcheck-py/shellcheck-py rev: v0.7.2.1 hooks: - - id: shellcheck \ No newline at end of file + - id: shellcheck + args: [--exclude, SC1091] \ No newline at end of file From 88d094c2ea38cd45652e3a5a7f68e87d07080d9b Mon Sep 17 00:00:00 2001 From: chinyakao Date: Wed, 21 Jul 2021 08:54:26 +0800 Subject: [PATCH 13/27] test new commit --- new_test.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 new_test.sh diff --git a/new_test.sh b/new_test.sh new file mode 100644 index 00000000..ff815862 --- /dev/null +++ b/new_test.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +. /usr/share/dell/scripts/fifuncs "" + +export DEBIAN_FRONTEND=noninteractive + +IFHALT "Run ubuntu-drivers autoinstall" +echo 'APT::Get::AllowUnauthenticated "true";' > /etc/apt/apt.conf.d/99disable_authentication +# while IFS= read -r -d '' blacklist; do +# UBUNTU_DRIVERS_BLACKLIST="$UBUNTU_DRIVERS_BLACKLIST $(cat "$blacklist")" +# done < <(find /cdrom/scripts/chroot-scripts/blacklist /isodevice/scripts/chroot-scripts/blacklist -type f -print0 2>/dev/null) +# shellcheck disable=SC2044 +for blacklist in $(find /cdrom/scripts/chroot-scripts/blacklist /isodevice/scripts/chroot-scripts/blacklist -type f 2>/dev/null); do + UBUNTU_DRIVERS_BLACKLIST="$UBUNTU_DRIVERS_BLACKLIST $(cat "$blacklist")" +done +if [ -n "$UBUNTU_DRIVERS_BLACKLIST" ]; then + echo "UBUNTU_DRIVERS_BLACKLIST: $UBUNTU_DRIVERS_BLACKLIST" +fi +# Use the i2c device's subsystem ID as the BIOS ID. +BIOSID=$(cut -c 3-6 < "$(dirname "$(find /sys -name modalias -exec echo {} \; -exec cat {} \; | grep bc0Csc05 -B 1 | head -n 1)")/subsystem_device") +for pkg in $(ubuntu-drivers list | awk -F'[ ,]' '{print $1}'); do + if apt-cache show "$pkg" | grep ^Modaliases | grep -i "sv00001028sd0000$BIOSID" >/dev/null 2>&1; then + factory="${pkg/oem-somerville/oem-somerville-factory}" + if dpkg-query -W -f='${Status}\n' "$factory" 2>&1 | grep "install ok installed" >/dev/null 2>&1; then + echo "$factory has been installed." + else + apt-get install --yes "$factory" || true + fi + fi + if dpkg-query -W -f='${Status}\n' "$pkg" 2>&1 | grep "install ok installed" >/dev/null 2>&1; then + echo "$pkg has been installed." + else + if [ -n "$UBUNTU_DRIVERS_BLACKLIST" ] && echo "$UBUNTU_DRIVERS_BLACKLIST" | grep "$pkg" >/dev/null 2>&1; then + echo "Won't install '$pkg' listed in UBUNTU_DRIVERS_BLACKLIST" + else + apt-get install --yes "$pkg" + fi + fi +done +rm /etc/apt/apt.conf.d/99disable_authentication +IFHALT "Done with ubuntu-drivers autoinstall" From 4c06bc33f340f743827ebbd9922e9a7055625682 Mon Sep 17 00:00:00 2001 From: chinyakao Date: Wed, 21 Jul 2021 08:56:34 +0800 Subject: [PATCH 14/27] test new commit with offened --- new_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/new_test.sh b/new_test.sh index ff815862..34da1059 100644 --- a/new_test.sh +++ b/new_test.sh @@ -19,7 +19,7 @@ fi # Use the i2c device's subsystem ID as the BIOS ID. BIOSID=$(cut -c 3-6 < "$(dirname "$(find /sys -name modalias -exec echo {} \; -exec cat {} \; | grep bc0Csc05 -B 1 | head -n 1)")/subsystem_device") for pkg in $(ubuntu-drivers list | awk -F'[ ,]' '{print $1}'); do - if apt-cache show "$pkg" | grep ^Modaliases | grep -i "sv00001028sd0000$BIOSID" >/dev/null 2>&1; then + if apt-cache show $pkg | grep ^Modaliases | grep -i "sv00001028sd0000$BIOSID" >/dev/null 2>&1; then factory="${pkg/oem-somerville/oem-somerville-factory}" if dpkg-query -W -f='${Status}\n' "$factory" 2>&1 | grep "install ok installed" >/dev/null 2>&1; then echo "$factory has been installed." From bf601291b92b0410d3f781be969569256464b121 Mon Sep 17 00:00:00 2001 From: chinyakao Date: Wed, 21 Jul 2021 09:00:38 +0800 Subject: [PATCH 15/27] test new commit with offense --- new_test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/new_test.sh b/new_test.sh index 34da1059..85d5ae68 100644 --- a/new_test.sh +++ b/new_test.sh @@ -19,12 +19,12 @@ fi # Use the i2c device's subsystem ID as the BIOS ID. BIOSID=$(cut -c 3-6 < "$(dirname "$(find /sys -name modalias -exec echo {} \; -exec cat {} \; | grep bc0Csc05 -B 1 | head -n 1)")/subsystem_device") for pkg in $(ubuntu-drivers list | awk -F'[ ,]' '{print $1}'); do - if apt-cache show $pkg | grep ^Modaliases | grep -i "sv00001028sd0000$BIOSID" >/dev/null 2>&1; then + if apt-cache show "$pkg" | grep ^Modaliases | grep -i "sv00001028sd0000$BIOSID" >/dev/null 2>&1; then factory="${pkg/oem-somerville/oem-somerville-factory}" if dpkg-query -W -f='${Status}\n' "$factory" 2>&1 | grep "install ok installed" >/dev/null 2>&1; then echo "$factory has been installed." else - apt-get install --yes "$factory" || true + apt-get install --yes $factory || true fi fi if dpkg-query -W -f='${Status}\n' "$pkg" 2>&1 | grep "install ok installed" >/dev/null 2>&1; then From b33cdaa33faf899db3992fb7cbb997c2abb0a27c Mon Sep 17 00:00:00 2001 From: chinyakao Date: Wed, 21 Jul 2021 10:52:06 +0800 Subject: [PATCH 16/27] test with pre-commit & shellcheck --- new_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/new_test.sh b/new_test.sh index 85d5ae68..ff815862 100644 --- a/new_test.sh +++ b/new_test.sh @@ -24,7 +24,7 @@ for pkg in $(ubuntu-drivers list | awk -F'[ ,]' '{print $1}'); do if dpkg-query -W -f='${Status}\n' "$factory" 2>&1 | grep "install ok installed" >/dev/null 2>&1; then echo "$factory has been installed." else - apt-get install --yes $factory || true + apt-get install --yes "$factory" || true fi fi if dpkg-query -W -f='${Status}\n' "$pkg" 2>&1 | grep "install ok installed" >/dev/null 2>&1; then From 77e00dc98624f30fa1ae65780fbdfbdd5c3c0d74 Mon Sep 17 00:00:00 2001 From: chinyakao Date: Mon, 26 Jul 2021 09:49:28 +0800 Subject: [PATCH 17/27] contributor setup --- .gitignore | 1 + .pre-commit-config.yaml | 40 +++++++++++++++-- CONTRIBUTING.md | 51 ++++++++++++++++++++++ contrib/dependencies.xml | 11 +++++ contrib/generate_dependencies.py | 74 ++++++++++++++++++++++++++++++++ contrib/setup | 38 ++++++++++++++++ 6 files changed, 211 insertions(+), 4 deletions(-) create mode 100644 CONTRIBUTING.md create mode 100644 contrib/dependencies.xml create mode 100755 contrib/generate_dependencies.py create mode 100755 contrib/setup diff --git a/.gitignore b/.gitignore index d475a73f..c82411d7 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ debian/files debian/tmp/ secure_boot/MokSBStateSet.efi .vscode +/venv diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e82887d0..6e61e421 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,38 @@ repos: -- repo: https://github.com/shellcheck-py/shellcheck-py - rev: v0.7.2.1 +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.0.1 hooks: - - id: shellcheck - args: [--exclude, SC1091] \ No newline at end of file + - id: no-commit-to-branch + args: [--branch, master, --pattern, 1_.*_X] + - id: check-added-large-files + - id: check-byte-order-marker + - id: check-executables-have-shebangs + - id: forbid-new-submodules + - id: check-yaml + - id: check-json + - id: check-symlinks + - id: check-xml + - id: end-of-file-fixer + types_or: [c, shell, python] + - id: trailing-whitespace + types_or: [c, shell, python, xml] + - id: check-docstring-first + - id: check-merge-conflict + - id: mixed-line-ending + args: [--fix=lf] +- repo: https://github.com/ambv/black + rev: 21.6b0 + hooks: + - id: black +- repo: local + hooks: + - id: shellcheck + name: check shellscript style + language: system + entry: shellcheck --severity=error -e SC2068 + types: [shell] +- repo: https://github.com/igorshubovych/markdownlint-cli + rev: v0.27.1 + hooks: + - id: markdownlint + args: ['--fix', '--ignore', '.github'] \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..0bf70351 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,51 @@ +# Contributor Guidelines + +## Getting started + +To set up your local environment, from the top level of the checkout run + +`./contrib/setup` + +This will create pre-commit hooks to fixup many code style issues +before your code is submitted. + +On some Linux distributions this will install all build dependencies +needed to compile fwupd as well. + +## Coding Style + +The coding style to respect in this project is very similar to most +GLib projects. In particular, the following rules are largely adapted +from the PackageKit Coding Style. + +- 8-space tabs for indentation + +- Prefer lines of less than <= 100 columns + +- No spaces between function name and braces (both calls and macro declarations) + +- If function signature/call fits in a single line, +do not break it into multiple lines + +- Prefer descriptive names over abbreviations (unless well-known) +and shortening of names. e.g `device` not `dev` + +- Single statements inside if/else should not be enclosed by '{}' + +- Use comments to explain why something is being done, but also avoid +over-documenting the obvious. Here is an example of useless comment: + +// Fetch the document fetch_the_document(); + +- Comments should not start with a capital letter or end with a full stop +and should be C-style, not C++-style, e.g. `/* this */` not `// this` + +- Failing methods should return FALSE with a suitable `GError` set + +- Trailing whitespace is forbidden + +- Pointers should be checked for NULL explicitly, e.g. `foo != NULL` not `!foo` + +`./contrib/reformat-code.py` can be used in order to get automated formatting. +Calling the script without arguments formats the current patch while passing +filenames will do whole-file formatting on the specified files. diff --git a/contrib/dependencies.xml b/contrib/dependencies.xml new file mode 100644 index 00000000..a2da7d5d --- /dev/null +++ b/contrib/dependencies.xml @@ -0,0 +1,11 @@ + + + + + + + + ShellCheck + + + \ No newline at end of file diff --git a/contrib/generate_dependencies.py b/contrib/generate_dependencies.py new file mode 100755 index 00000000..bc41cc98 --- /dev/null +++ b/contrib/generate_dependencies.py @@ -0,0 +1,74 @@ +#!/usr/bin/python3 +# +# Copyright (C) 2017 Dell, Inc. +# Copyright (C) 2020 Intel, Inc. +# +# SPDX-License-Identifier: LGPL-2.1+ +# +import os +import sys +import argparse +import xml.etree.ElementTree as etree + + +def parse_dependencies(OS, SUBOS, requested_type): + deps = [] + dep = "" + directory = os.path.dirname(sys.argv[0]) + tree = etree.parse(os.path.join(directory, "dependencies.xml")) + root = tree.getroot() + for child in root: + if "type" not in child.attrib or "id" not in child.attrib: + continue + for distro in child: + if "id" not in distro.attrib: + continue + if distro.attrib["id"] != OS: + continue + packages = distro.findall("package") + for package in packages: + if SUBOS: + if "variant" not in package.attrib: + continue + if package.attrib["variant"] != SUBOS: + continue + if package.text: + dep = package.text + else: + dep = child.attrib["id"] + if child.attrib["type"] == requested_type and dep: + deps.append(dep) + return deps + + +if __name__ == "__main__": + + try: + import distro + + target = distro.linux_distribution()[0] + except ModuleNotFoundError: + target = None + + parser = argparse.ArgumentParser() + parser.add_argument( + "-o", + "--os", + default=target, + choices=["fedora", "centos", "flatpak", "debian", "ubuntu", "arch"], + help="dependencies for OS", + ) + args = parser.parse_args() + + target = os.getenv("OS", args.os) + if target is None: + print("Missing OS environment variable") + sys.exit(1) + + _os = target.lower() + _sub_os = "" + split = target.split("-") + if len(split) >= 2: + _os, _sub_os = split[:2] + dependencies = parse_dependencies(_os, _sub_os, "build") + print(*dependencies, sep="\n") diff --git a/contrib/setup b/contrib/setup new file mode 100755 index 00000000..2037ae7e --- /dev/null +++ b/contrib/setup @@ -0,0 +1,38 @@ +#!/bin/bash -e +# Setup the repository. + +cd "$(dirname "$0")/.." + +# Add default vscode settings if not existing +# SETTINGS_FILE=./.vscode/settings.json +# SETTINGS_TEMPLATE_FILE=./contrib/vscode/settings.json +# if [ ! -f "$SETTINGS_FILE" ]; then +# mkdir ./.vscode +# echo "Copy $SETTINGS_TEMPLATE_FILE to $SETTINGS_FILE." +# cp "$SETTINGS_TEMPLATE_FILE" "$SETTINGS_FILE" +# fi + +#if interactive install build deps +if [ -n "$PS1" ] || [[ $- == *i* ]] || [ -f /dev/.cros_milestone ]; then + read -p "Install build dependencies? (y/n) " question; + if [ "$question" = "y" ]; then + DEPS=$(./contrib/generate_dependencies.py) + OS=$(python3 -c "import distro; print(distro.linux_distribution()[0].split()[0].lower())") + if [ "$OS" = "debian" ] || [ "$OS" = "ubuntu" ]; then + if ! python3 -c "import venv"; then + DEPS="python3-venv" + fi + sudo apt install $DEPS + elif [ "$OS" = "fedora" ]; then + sudo dnf install $DEPS + elif [ "$OS" = "arch" ]; then + pacman -Syu --noconfirm --needed $DEPS + fi + fi +fi + +python3 -m venv venv +source venv/bin/activate + +python3 -m pip install pre-commit +pre-commit install From e5238099ffe72853748a3a789d3bc5ed56711cb2 Mon Sep 17 00:00:00 2001 From: chinyakao Date: Mon, 26 Jul 2021 10:19:44 +0800 Subject: [PATCH 18/27] contributor setup --- .github/workflows/main_test.yml | 16 +++++++++++++ contrib/setup | 2 +- new_test.sh | 41 --------------------------------- tests/pyflakes.exclude | 1 + 4 files changed, 18 insertions(+), 42 deletions(-) delete mode 100644 new_test.sh diff --git a/.github/workflows/main_test.yml b/.github/workflows/main_test.yml index a5c520bd..4f41a933 100644 --- a/.github/workflows/main_test.yml +++ b/.github/workflows/main_test.yml @@ -18,6 +18,22 @@ jobs: run: DEBIAN_FRONTEND=noninteractive sudo apt-get install -yq --no-install-recommends build-essential debhelper dh-python dpkg-dev python3 python3-distutils-extra po-debconf pyflakes3 lsb-release gnu-efi - name: Build package run: dpkg-buildpackage --no-sign + pre-commit: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Refresh dependencies + run: sudo apt update + - name: Install dependencies + run: sudo apt install shellcheck -y + - name: Run pre-commit hooks + run: | + ./contrib/setup + source venv/bin/activate + sed -i "/no-commit-to-branch/,+1d" .pre-commit-config.yaml + pre-commit run --all-files shellcheck: name: Shellcheck runs-on: ubuntu-20.04 diff --git a/contrib/setup b/contrib/setup index 2037ae7e..9a16fefb 100755 --- a/contrib/setup +++ b/contrib/setup @@ -14,7 +14,7 @@ cd "$(dirname "$0")/.." #if interactive install build deps if [ -n "$PS1" ] || [[ $- == *i* ]] || [ -f /dev/.cros_milestone ]; then - read -p "Install build dependencies? (y/n) " question; + read -r -p "Install build dependencies? (y/n) " question; if [ "$question" = "y" ]; then DEPS=$(./contrib/generate_dependencies.py) OS=$(python3 -c "import distro; print(distro.linux_distribution()[0].split()[0].lower())") diff --git a/new_test.sh b/new_test.sh deleted file mode 100644 index ff815862..00000000 --- a/new_test.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash - -. /usr/share/dell/scripts/fifuncs "" - -export DEBIAN_FRONTEND=noninteractive - -IFHALT "Run ubuntu-drivers autoinstall" -echo 'APT::Get::AllowUnauthenticated "true";' > /etc/apt/apt.conf.d/99disable_authentication -# while IFS= read -r -d '' blacklist; do -# UBUNTU_DRIVERS_BLACKLIST="$UBUNTU_DRIVERS_BLACKLIST $(cat "$blacklist")" -# done < <(find /cdrom/scripts/chroot-scripts/blacklist /isodevice/scripts/chroot-scripts/blacklist -type f -print0 2>/dev/null) -# shellcheck disable=SC2044 -for blacklist in $(find /cdrom/scripts/chroot-scripts/blacklist /isodevice/scripts/chroot-scripts/blacklist -type f 2>/dev/null); do - UBUNTU_DRIVERS_BLACKLIST="$UBUNTU_DRIVERS_BLACKLIST $(cat "$blacklist")" -done -if [ -n "$UBUNTU_DRIVERS_BLACKLIST" ]; then - echo "UBUNTU_DRIVERS_BLACKLIST: $UBUNTU_DRIVERS_BLACKLIST" -fi -# Use the i2c device's subsystem ID as the BIOS ID. -BIOSID=$(cut -c 3-6 < "$(dirname "$(find /sys -name modalias -exec echo {} \; -exec cat {} \; | grep bc0Csc05 -B 1 | head -n 1)")/subsystem_device") -for pkg in $(ubuntu-drivers list | awk -F'[ ,]' '{print $1}'); do - if apt-cache show "$pkg" | grep ^Modaliases | grep -i "sv00001028sd0000$BIOSID" >/dev/null 2>&1; then - factory="${pkg/oem-somerville/oem-somerville-factory}" - if dpkg-query -W -f='${Status}\n' "$factory" 2>&1 | grep "install ok installed" >/dev/null 2>&1; then - echo "$factory has been installed." - else - apt-get install --yes "$factory" || true - fi - fi - if dpkg-query -W -f='${Status}\n' "$pkg" 2>&1 | grep "install ok installed" >/dev/null 2>&1; then - echo "$pkg has been installed." - else - if [ -n "$UBUNTU_DRIVERS_BLACKLIST" ] && echo "$UBUNTU_DRIVERS_BLACKLIST" | grep "$pkg" >/dev/null 2>&1; then - echo "Won't install '$pkg' listed in UBUNTU_DRIVERS_BLACKLIST" - else - apt-get install --yes "$pkg" - fi - fi -done -rm /etc/apt/apt.conf.d/99disable_authentication -IFHALT "Done with ubuntu-drivers autoinstall" diff --git a/tests/pyflakes.exclude b/tests/pyflakes.exclude index 62b1433c..ae030d66 100644 --- a/tests/pyflakes.exclude +++ b/tests/pyflakes.exclude @@ -24,3 +24,4 @@ ubiquity/dell-default-ui.py:*: redefinition of unused 'install_misc' from line * #ignore error ubiquity/dell-default-ui.py:*: local variable 'e' is assigned to but never used +contrib/generate_dependencies.py:23: import 'distro' from line 47 shadowed by loop variable From ec97f3dc4cd6184ec664c66660ea7326d8a8e8c2 Mon Sep 17 00:00:00 2001 From: chinyakao Date: Mon, 26 Jul 2021 10:46:53 +0800 Subject: [PATCH 19/27] Markdown file syntax --- README.md | 46 ++++++++-------- installation_flow.md | 106 ++++++++++++++++++++++++------------- modifying_factory_image.md | 28 ++++++---- 3 files changed, 112 insertions(+), 68 deletions(-) diff --git a/README.md b/README.md index bf7d00c3..7d9b5e85 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -Dell Recovery Media Creator ----- +# Dell Recovery Media Creator + [![Build Status](https://travis-ci.org/dell/dell-recovery.png)](https://travis-ci.org/dell/dell-recovery) The Dell Recovery media creation tool supports two different usage modes, @@ -8,39 +8,43 @@ create an image from an existing recovery partition with no customizations. In builder mode, the tool allows modifying the source of the base image, the source of the framework, as well as injection of additional content. -# Tool Modes +## Tool Modes + +### End User Mode -End User Mode ---- When a customer receives a Dell machine that has been factory shipped with Linux, there will be an icon available in GNOME shell to launch this tool. They will be prompted for what type of media they would like to create. -Out of box experience mode ---- +### Out of box experience mode + If a DVD burner or USB port is found on the machine, customers will be offered to create media at the end of the out of box experience. -Media builder mode ---- -In builder mode, the user will be offered a variety of options that allow them to create ISOs based upon +### Media builder mode + +In builder mode, the user will be offered a variety of options that allow them +to create ISOs based upon different snapshots of release upon standard Ubuntu media. -The latest information on how to use builder mode will be documented within the integrated help dialog. +The latest information on how to use builder mode will be documented within the +integrated help dialog. -# Flow +## Flow -Due to the nature of including a recovery partition, the installation flow varies from the standard Ubuntu +Due to the nature of including a recovery partition, the installation flow +varies from the standard Ubuntu installation. It is further documented [here](installation_flow.md). -Ubiquity ---- -Dell recovery is built with an integrated Ubiquity plugin. It is branched with each Ubuntu LTS release and -has code that will tightly integrate with Ubiquity for factory installation. Documentation for all of the -features in Ubiquity mode and how to create packages to support it are stored outside of the dell-recovery -tree. +### Ubiquity + +Dell recovery is built with an integrated Ubiquity plugin. It is branched with +each Ubuntu LTS release and has code that will tightly integrate with Ubiquity +for factory installation. Documentation for all of the features in Ubiquity +mode and how to create packages to support it are stored outside of the +dell-recovery tree. + +### Modifying a factory image -Modifying a factory image ---- Information about how to modify a factory image are available [here](modifying_factory_image.md). diff --git a/installation_flow.md b/installation_flow.md index aed27c98..8237ead7 100644 --- a/installation_flow.md +++ b/installation_flow.md @@ -1,60 +1,94 @@ -Although the installer for Dell recovery media is the same as standard Ubuntu (*ubiquity*), the installation flow varies. +# Installation Flow -# Standard Ubuntu installation -A standard Ubuntu installation from a USB key only has one installation *phase*. The user is prompted for installation options such as disk, timezone, keyboard and username and installation runs in the background. +Although the installer for Dell recovery media is the same as standard Ubuntu +(*ubiquity*), the installation flow varies. -When the install is complete, upon rebooting the machine they are brought to a Ubuntu login screen and can use the computer. +## Standard Ubuntu installation -# *Standard* OEM installation -A standard OEM Ubuntu installation will be preseeded to operate in an automated fashion. Any questions that are not answered in the preseeding process will be prompted by the GUI. After installation is finished, the system will either be shut down or rebooted into **OEM-Config mode**. +A standard Ubuntu installation from a USB key only has one installation *phase*. + The user is prompted for installation options such as disk, timezone, keyboard + and username and installation runs in the background. -In **OEM-Config mode** the user will be prompted for questions that might not be the same as those preseeded. For example, Keyboard layout, Timezone or Language. +When the install is complete, upon rebooting the machine they are brought to a +Ubuntu login screen and can use the computer. + +## *Standard* OEM installation + +A standard OEM Ubuntu installation will be preseeded to operate in an automated +fashion. Any questions that are not answered in the preseeding process will be +prompted by the GUI. After installation is finished, the system will either be +shut down or rebooted into **OEM-Config mode**. + +In **OEM-Config mode** the user will be prompted for questions that might not be + the same as those preseeded. For example, Keyboard layout, Timezone or + Language. After completing OEM-Config, the user is brought to an Ubuntu login screen. -# Dell OEM installation +## Dell OEM installation + The Dell OEM installation is split across ***three** distinct phases*. -It is split this way to be able to support an archicture with a factory recovery partition on the hard disk. -This factory recovery partition is used both for Dell manufacturing as well as for customer based recovery. +It is split this way to be able to support an archicture with a factory recovery + partition on the hard disk. +This factory recovery partition is used both for Dell manufacturing as well as +for customer based recovery. + +### Phase 1: Prepare partitions and content + +The first phase prepares the disk and loads the recovery partition content onto +it. This can be approached from 3 different methods. -## Phase 1: Prepare partitions and content -The first phase prepares the disk and loads the recovery partition content onto it. This can be approached from 3 different methods. +#### Dell factory -### Dell factory +1. In the Dell factory we integrate with existing manufacturing tools, and these + tools create initial partition layout (ESP and Recovery partition) and load the + content onto the disk. -1. In the Dell factory we integrate with existing manufacturing tools, and these tools create initial partition layout (ESP and Recovery partition) and load the content onto the disk. +2. Other manufacturing tools also configure next boot (`BootOrder`/`BootNext` + variables) +3. Other manufacturing tools control reboot cycle. +4. On the next boot we’ll boot directly into phase 2. -2. Other manufacturing tools also configure next boot (`BootOrder`/`BootNext` variables) -3. Other manufacturing tools control reboot cycle. -4. On the next boot we’ll boot directly into phase 2. +#### Customer USB recovery -### Customer USB recovery +1. If customer boots up USB recovery disk, it will come to a prompt selecting +which disk to use to install to. +2. Customer presses next, and disk is wiped, content copied to ESP and recovery + partition +3. Boot variables set for next boot +4. System automatically reboots into phase 2. -1. If customer boots up USB recovery disk, it will come to a prompt selecting which disk to use to install to. -2. Customer presses next, and disk is wiped, content copied to ESP and recovery partition -3. Boot variables set for next boot -4. System automatically reboots into phase 2. +#### Customer HDD recovery -### Customer HDD recovery +1. GUI tool is offered in OS that will change grub next boot option to a recove +ry option we left to boot recovery partition. +2. Customer can also interrupt GRUB silent menu to select this option. +3. Customer agrees to wipe content. +4. System continues to phase 2. -1. GUI tool is offered in OS that will change grub next boot option to a recovery option we left to boot recovery partition. -2. Customer can also interrupt GRUB silent menu to select this option. -3. Customer agrees to wipe content. -4. System continues to phase 2. +### Phase 2: Install Ubuntu +This part of the installation is fully automated. The OS is booted from the rec +overy partition and the Ubiquity installer will launch. -## Phase 2: Install Ubuntu -This part of the installation is fully automated. The OS is booted from the recovery partition and the Ubiquity installer will launch. +Ubiquity will create additional partitions to install into, and all files will +be copied in. Any applicable drivers and updated packages distributed in +`/debs` of the recovery partition will be installed by Ubiquity and +dell-recovery plugins. -Ubiquity will create additional partitions to install into, and all files will be copied in. Any applicable drivers and updated packages distributed in `/debs` of the recovery partition will be installed by Ubiquity and dell-recovery plugins. +After Ubiquity finishes, a set of post-install scripts provided by Dell in the +`/scripts` directory of the recovery partition will run to complete the install. -After Ubiquity finishes, a set of post-install scripts provided by Dell in the `/scripts` directory of the recovery partition will run to complete the install. +When this phase is run during manufacturing, the system will return to Dell +manufacturing process. -When this phase is run during manufacturing, the system will return to Dell manufacturing process. +### Phase 3: Out of box experience -## Phase 3: Out of box experience -In a Dell manufactured machine, this is the first phase that a customer will actually see. +In a Dell manufactured machine, this is the first phase that a customer will +actually see. -As with standard OEM installation, the customer will select the Language, Timezone, Keyboard Layout, a username and a password. +As with standard OEM installation, the customer will select the Language, +Timezone, Keyboard Layout, a username and a password. -However specific to the Dell OEM install an additional page will prompt to create USB recovery media to use in the event of a failure. +However specific to the Dell OEM install an additional page will prompt to +create USB recovery media to use in the event of a failure. diff --git a/modifying_factory_image.md b/modifying_factory_image.md index 1fd19b00..aa9a1a29 100644 --- a/modifying_factory_image.md +++ b/modifying_factory_image.md @@ -1,18 +1,24 @@ -Modifying Factory images ----- -Factory images (.ISO) can be modified to include any additional Debian packages or to run extra scripts after the image installation is complete. +# Modifying Factory images -Development purposes --- +Factory images (.ISO) can be modified to include any additional Debian packages +or to run extra scripts after the image installation is complete. -For development purposes, additional `.deb` packages can be placed onto a USB stick with a factory image already written to it if the USB stick is formatted as FAT32. +## Development purposes -1. Create the directories `debs/main` on the USB stick if they don't already exist. -2. Copy all .deb packages and their dependencies into the `debs/main` directory on the USB disk. +For development purposes, additional `.deb` packages can be placed onto a USB +stick with a factory image already written to it if the USB stick is formatted +as FAT32. -Production purposes --- -To write these packages into a new ISO image, the **Dell Recovery** tool needs to be executed in *builder* mode. In *builder* mode it can take an existing factory ISO image and modify it. +1. Create the directories `debs/main` on the USB stick if they don't already +exist. +2. Copy all .deb packages and their dependencies into the `debs/main` directory + on the USB disk. + +## Production purposes + +To write these packages into a new ISO image, the **Dell Recovery** tool needs +to be executed in *builder* mode. In *builder* mode it can take an existing +factory ISO image and modify it. From an Ubuntu machine with `dell-recovery` installed, execute: From 8634880287c3238e021288509bdc219af7d50ebb Mon Sep 17 00:00:00 2001 From: chinyakao Date: Mon, 26 Jul 2021 13:40:01 +0800 Subject: [PATCH 20/27] keep shellchcek delete other checking --- .github/workflows/main_test.yml | 10 ----- .pre-commit-config.yaml | 30 ------------- contrib/dependencies.xml | 11 ----- contrib/generate_dependencies.py | 74 -------------------------------- contrib/setup | 32 ++++---------- tests/pyflakes.exclude | 1 - 6 files changed, 9 insertions(+), 149 deletions(-) delete mode 100644 contrib/dependencies.xml delete mode 100755 contrib/generate_dependencies.py diff --git a/.github/workflows/main_test.yml b/.github/workflows/main_test.yml index 4f41a933..f2ad5bbc 100644 --- a/.github/workflows/main_test.yml +++ b/.github/workflows/main_test.yml @@ -34,13 +34,3 @@ jobs: source venv/bin/activate sed -i "/no-commit-to-branch/,+1d" .pre-commit-config.yaml pre-commit run --all-files - shellcheck: - name: Shellcheck - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - name: Run ShellCheck - uses: ludeeus/action-shellcheck@master - env: - SHELLCHECK_OPTS: -e SC1091 - diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6e61e421..3c9e1d6d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,29 +1,4 @@ repos: -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 - hooks: - - id: no-commit-to-branch - args: [--branch, master, --pattern, 1_.*_X] - - id: check-added-large-files - - id: check-byte-order-marker - - id: check-executables-have-shebangs - - id: forbid-new-submodules - - id: check-yaml - - id: check-json - - id: check-symlinks - - id: check-xml - - id: end-of-file-fixer - types_or: [c, shell, python] - - id: trailing-whitespace - types_or: [c, shell, python, xml] - - id: check-docstring-first - - id: check-merge-conflict - - id: mixed-line-ending - args: [--fix=lf] -- repo: https://github.com/ambv/black - rev: 21.6b0 - hooks: - - id: black - repo: local hooks: - id: shellcheck @@ -31,8 +6,3 @@ repos: language: system entry: shellcheck --severity=error -e SC2068 types: [shell] -- repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.27.1 - hooks: - - id: markdownlint - args: ['--fix', '--ignore', '.github'] \ No newline at end of file diff --git a/contrib/dependencies.xml b/contrib/dependencies.xml deleted file mode 100644 index a2da7d5d..00000000 --- a/contrib/dependencies.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - ShellCheck - - - \ No newline at end of file diff --git a/contrib/generate_dependencies.py b/contrib/generate_dependencies.py deleted file mode 100755 index bc41cc98..00000000 --- a/contrib/generate_dependencies.py +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/python3 -# -# Copyright (C) 2017 Dell, Inc. -# Copyright (C) 2020 Intel, Inc. -# -# SPDX-License-Identifier: LGPL-2.1+ -# -import os -import sys -import argparse -import xml.etree.ElementTree as etree - - -def parse_dependencies(OS, SUBOS, requested_type): - deps = [] - dep = "" - directory = os.path.dirname(sys.argv[0]) - tree = etree.parse(os.path.join(directory, "dependencies.xml")) - root = tree.getroot() - for child in root: - if "type" not in child.attrib or "id" not in child.attrib: - continue - for distro in child: - if "id" not in distro.attrib: - continue - if distro.attrib["id"] != OS: - continue - packages = distro.findall("package") - for package in packages: - if SUBOS: - if "variant" not in package.attrib: - continue - if package.attrib["variant"] != SUBOS: - continue - if package.text: - dep = package.text - else: - dep = child.attrib["id"] - if child.attrib["type"] == requested_type and dep: - deps.append(dep) - return deps - - -if __name__ == "__main__": - - try: - import distro - - target = distro.linux_distribution()[0] - except ModuleNotFoundError: - target = None - - parser = argparse.ArgumentParser() - parser.add_argument( - "-o", - "--os", - default=target, - choices=["fedora", "centos", "flatpak", "debian", "ubuntu", "arch"], - help="dependencies for OS", - ) - args = parser.parse_args() - - target = os.getenv("OS", args.os) - if target is None: - print("Missing OS environment variable") - sys.exit(1) - - _os = target.lower() - _sub_os = "" - split = target.split("-") - if len(split) >= 2: - _os, _sub_os = split[:2] - dependencies = parse_dependencies(_os, _sub_os, "build") - print(*dependencies, sep="\n") diff --git a/contrib/setup b/contrib/setup index 9a16fefb..6645ff4a 100755 --- a/contrib/setup +++ b/contrib/setup @@ -3,31 +3,17 @@ cd "$(dirname "$0")/.." -# Add default vscode settings if not existing -# SETTINGS_FILE=./.vscode/settings.json -# SETTINGS_TEMPLATE_FILE=./contrib/vscode/settings.json -# if [ ! -f "$SETTINGS_FILE" ]; then -# mkdir ./.vscode -# echo "Copy $SETTINGS_TEMPLATE_FILE to $SETTINGS_FILE." -# cp "$SETTINGS_TEMPLATE_FILE" "$SETTINGS_FILE" -# fi - #if interactive install build deps -if [ -n "$PS1" ] || [[ $- == *i* ]] || [ -f /dev/.cros_milestone ]; then - read -r -p "Install build dependencies? (y/n) " question; - if [ "$question" = "y" ]; then - DEPS=$(./contrib/generate_dependencies.py) - OS=$(python3 -c "import distro; print(distro.linux_distribution()[0].split()[0].lower())") - if [ "$OS" = "debian" ] || [ "$OS" = "ubuntu" ]; then - if ! python3 -c "import venv"; then - DEPS="python3-venv" - fi - sudo apt install $DEPS - elif [ "$OS" = "fedora" ]; then - sudo dnf install $DEPS - elif [ "$OS" = "arch" ]; then - pacman -Syu --noconfirm --needed $DEPS +read -r -p "Install build dependencies? (y/n) " question; +if [ "$question" = "y" ]; then + DEPS=shellcheck + echo $DEPS + OS=$(python3 -c "import distro; print(distro.linux_distribution()[0].split()[0].lower())") + if [ "$OS" = "ubuntu" ]; then + if ! python3 -c "import venv"; then + DEPS="python3-venv" fi + sudo apt install $DEPS fi fi diff --git a/tests/pyflakes.exclude b/tests/pyflakes.exclude index ae030d66..62b1433c 100644 --- a/tests/pyflakes.exclude +++ b/tests/pyflakes.exclude @@ -24,4 +24,3 @@ ubiquity/dell-default-ui.py:*: redefinition of unused 'install_misc' from line * #ignore error ubiquity/dell-default-ui.py:*: local variable 'e' is assigned to but never used -contrib/generate_dependencies.py:23: import 'distro' from line 47 shadowed by loop variable From 7cec7105f8fb96a2cf4accd66a3380b558d9cb4d Mon Sep 17 00:00:00 2001 From: chinyakao Date: Mon, 26 Jul 2021 13:58:18 +0800 Subject: [PATCH 21/27] test new file --- temp_test.sh | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 temp_test.sh diff --git a/temp_test.sh b/temp_test.sh new file mode 100644 index 00000000..653eabc2 --- /dev/null +++ b/temp_test.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +TEMP="hello world test1!" +echo $TEMP From cb14917a70b159578b1a03520f29455498787152 Mon Sep 17 00:00:00 2001 From: chinyakao Date: Mon, 26 Jul 2021 14:16:44 +0800 Subject: [PATCH 22/27] fix pre commit --- .pre-commit-config.yaml | 9 ++++++++- temp_test.sh | 4 ---- 2 files changed, 8 insertions(+), 5 deletions(-) delete mode 100644 temp_test.sh diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3c9e1d6d..b156c5c1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,8 +1,15 @@ repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files - repo: local hooks: - id: shellcheck name: check shellscript style language: system - entry: shellcheck --severity=error -e SC2068 + entry: shellcheck -e SC1091 types: [shell] diff --git a/temp_test.sh b/temp_test.sh deleted file mode 100644 index 653eabc2..00000000 --- a/temp_test.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -TEMP="hello world test1!" -echo $TEMP From 15a2c92ab0fa4ee01a73f5759de5a0f032d0c02f Mon Sep 17 00:00:00 2001 From: chinyakao Date: Mon, 26 Jul 2021 14:57:36 +0800 Subject: [PATCH 23/27] fix github action's pre-commit --- .pre-commit-config.yaml | 7 ------- contrib/setup | 7 +++---- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b156c5c1..08b899ab 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,11 +1,4 @@ repos: -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.2.0 - hooks: - - id: trailing-whitespace - - id: end-of-file-fixer - - id: check-yaml - - id: check-added-large-files - repo: local hooks: - id: shellcheck diff --git a/contrib/setup b/contrib/setup index 6645ff4a..b489c8cc 100755 --- a/contrib/setup +++ b/contrib/setup @@ -4,10 +4,9 @@ cd "$(dirname "$0")/.." #if interactive install build deps -read -r -p "Install build dependencies? (y/n) " question; -if [ "$question" = "y" ]; then +# read -r -p "Install build dependencies? (y/n) " question; +# if [ "$question" = "y" ]; then DEPS=shellcheck - echo $DEPS OS=$(python3 -c "import distro; print(distro.linux_distribution()[0].split()[0].lower())") if [ "$OS" = "ubuntu" ]; then if ! python3 -c "import venv"; then @@ -15,7 +14,7 @@ if [ "$question" = "y" ]; then fi sudo apt install $DEPS fi -fi +# fi python3 -m venv venv source venv/bin/activate From 1a3d6fce49105bebea4e233d6e8271e8ff115aec Mon Sep 17 00:00:00 2001 From: chinyakao Date: Mon, 26 Jul 2021 18:24:50 +0800 Subject: [PATCH 24/27] local enviroment setting --- .gitignore | 1 - CONTRIBUTING.md | 38 --------------- contrib/setup | 21 +++----- po/dell-recovery.pot | 112 +++++++++++++++++++++---------------------- 4 files changed, 62 insertions(+), 110 deletions(-) diff --git a/.gitignore b/.gitignore index c82411d7..d475a73f 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,3 @@ debian/files debian/tmp/ secure_boot/MokSBStateSet.efi .vscode -/venv diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0bf70351..6d775c6a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,41 +11,3 @@ before your code is submitted. On some Linux distributions this will install all build dependencies needed to compile fwupd as well. - -## Coding Style - -The coding style to respect in this project is very similar to most -GLib projects. In particular, the following rules are largely adapted -from the PackageKit Coding Style. - -- 8-space tabs for indentation - -- Prefer lines of less than <= 100 columns - -- No spaces between function name and braces (both calls and macro declarations) - -- If function signature/call fits in a single line, -do not break it into multiple lines - -- Prefer descriptive names over abbreviations (unless well-known) -and shortening of names. e.g `device` not `dev` - -- Single statements inside if/else should not be enclosed by '{}' - -- Use comments to explain why something is being done, but also avoid -over-documenting the obvious. Here is an example of useless comment: - -// Fetch the document fetch_the_document(); - -- Comments should not start with a capital letter or end with a full stop -and should be C-style, not C++-style, e.g. `/* this */` not `// this` - -- Failing methods should return FALSE with a suitable `GError` set - -- Trailing whitespace is forbidden - -- Pointers should be checked for NULL explicitly, e.g. `foo != NULL` not `!foo` - -`./contrib/reformat-code.py` can be used in order to get automated formatting. -Calling the script without arguments formats the current patch while passing -filenames will do whole-file formatting on the specified files. diff --git a/contrib/setup b/contrib/setup index b489c8cc..f3bc3199 100755 --- a/contrib/setup +++ b/contrib/setup @@ -3,21 +3,14 @@ cd "$(dirname "$0")/.." -#if interactive install build deps -# read -r -p "Install build dependencies? (y/n) " question; -# if [ "$question" = "y" ]; then - DEPS=shellcheck - OS=$(python3 -c "import distro; print(distro.linux_distribution()[0].split()[0].lower())") - if [ "$OS" = "ubuntu" ]; then - if ! python3 -c "import venv"; then - DEPS="python3-venv" - fi - sudo apt install $DEPS +DEPS=shellcheck +OS=$(python3 -c "import distro; print(distro.linux_distribution()[0].split()[0].lower())") +if [ "$OS" = "ubuntu" ]; then + if ! python3 -c "import venv"; then + DEPS="python3-venv" fi -# fi - -python3 -m venv venv -source venv/bin/activate + sudo apt install $DEPS +fi python3 -m pip install pre-commit pre-commit install diff --git a/po/dell-recovery.pot b/po/dell-recovery.pot index fc137211..3a304850 100644 --- a/po/dell-recovery.pot +++ b/po/dell-recovery.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-07-12 11:40+0800\n" +"POT-Creation-Date: 2016-09-06 14:23-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,24 +17,24 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: ../Dell/recovery_gtk.py:108 +#: ../Dell/recovery_gtk.py:104 msgid "Cannot connect to dbus" msgstr "" -#: ../Dell/recovery_gtk.py:110 +#: ../Dell/recovery_gtk.py:106 msgid "Permission Denied" msgstr "" -#: ../Dell/recovery_gtk.py:117 +#: ../Dell/recovery_gtk.py:113 msgid "Exception" msgstr "" -#: ../Dell/recovery_gtk.py:173 ../gtk/dell-recovery-media.desktop.in.h:1 +#: ../Dell/recovery_gtk.py:158 ../gtk/dell-recovery-media.desktop.in.h:1 #: ../gtk/tool_selector.ui.h:2 msgid "Dell Recovery" msgstr "" -#: ../Dell/recovery_gtk.py:174 +#: ../Dell/recovery_gtk.py:159 msgid "Copyright 2008-2012 Dell Inc." msgstr "" @@ -50,51 +50,51 @@ msgstr "" msgid "Building Base image" msgstr "" -#: ../Dell/recovery_basic_gtk.py:181 +#: ../Dell/recovery_basic_gtk.py:179 msgid "Opening Burner" msgstr "" -#: ../Dell/recovery_basic_gtk.py:206 +#: ../Dell/recovery_basic_gtk.py:204 msgid "Recovery Media Creation Process Complete" msgstr "" -#: ../Dell/recovery_basic_gtk.py:207 +#: ../Dell/recovery_basic_gtk.py:205 msgid "" "If you would like to archive another copy, the generated image has been " "stored under the filename:\n" msgstr "" -#: ../Dell/recovery_basic_gtk.py:221 +#: ../Dell/recovery_basic_gtk.py:219 msgid "Unable to proceed" msgstr "" -#: ../Dell/recovery_basic_gtk.py:222 +#: ../Dell/recovery_basic_gtk.py:220 msgid "" "System does not appear to contain Dell factory installed partition layout." msgstr "" -#: ../Dell/recovery_basic_gtk.py:334 +#: ../Dell/recovery_basic_gtk.py:331 msgid "Image File" msgstr "" -#: ../Dell/recovery_basic_gtk.py:336 +#: ../Dell/recovery_basic_gtk.py:333 msgid "Media Type: " msgstr "" -#: ../Dell/recovery_basic_gtk.py:339 ../Dell/recovery_basic_gtk.py:342 +#: ../Dell/recovery_basic_gtk.py:336 ../Dell/recovery_basic_gtk.py:339 msgid "Recovery Partition: " msgstr "" -#: ../Dell/recovery_basic_gtk.py:343 +#: ../Dell/recovery_basic_gtk.py:340 msgid "Included" msgstr "" #. wizard.resize(400,400) -#: ../Dell/recovery_advanced_gtk.py:63 +#: ../Dell/recovery_advanced_gtk.py:69 msgid " (BTO Image Builder Mode)" msgstr "" -#: ../Dell/recovery_advanced_gtk.py:65 +#: ../Dell/recovery_advanced_gtk.py:71 msgid "" "This will integrate a Dell OEM FID framework & driver package set into a " "customized OS media image. You will have the option to create an USB key or " @@ -102,84 +102,84 @@ msgid "" msgstr "" #. insert builder pages in reverse order -#: ../Dell/recovery_advanced_gtk.py:84 +#: ../Dell/recovery_advanced_gtk.py:90 msgid "Application Packages" msgstr "" -#: ../Dell/recovery_advanced_gtk.py:85 +#: ../Dell/recovery_advanced_gtk.py:91 msgid "Driver Packages" msgstr "" -#: ../Dell/recovery_advanced_gtk.py:86 +#: ../Dell/recovery_advanced_gtk.py:92 msgid "FID Content" msgstr "" -#: ../Dell/recovery_advanced_gtk.py:87 +#: ../Dell/recovery_advanced_gtk.py:93 msgid "Base OS Image" msgstr "" -#: ../Dell/recovery_advanced_gtk.py:161 +#: ../Dell/recovery_advanced_gtk.py:167 msgid "Builder Summary" msgstr "" -#: ../Dell/recovery_advanced_gtk.py:162 +#: ../Dell/recovery_advanced_gtk.py:168 msgid "Base Image Distributor" msgstr "" -#: ../Dell/recovery_advanced_gtk.py:164 +#: ../Dell/recovery_advanced_gtk.py:170 msgid "Base Image Release" msgstr "" -#: ../Dell/recovery_advanced_gtk.py:167 +#: ../Dell/recovery_advanced_gtk.py:173 msgid "BTO Base Image" msgstr "" -#: ../Dell/recovery_advanced_gtk.py:170 +#: ../Dell/recovery_advanced_gtk.py:176 msgid "Base Image" msgstr "" -#: ../Dell/recovery_advanced_gtk.py:173 +#: ../Dell/recovery_advanced_gtk.py:179 msgid "Application" msgstr "" -#: ../Dell/recovery_advanced_gtk.py:174 +#: ../Dell/recovery_advanced_gtk.py:180 msgid "Driver" msgstr "" -#: ../Dell/recovery_advanced_gtk.py:180 +#: ../Dell/recovery_advanced_gtk.py:186 msgid "Packages" msgstr "" -#: ../Dell/recovery_advanced_gtk.py:186 +#: ../Dell/recovery_advanced_gtk.py:192 msgid "Inject Dell Recovery Package" msgstr "" #. update gui -#: ../Dell/recovery_advanced_gtk.py:196 +#: ../Dell/recovery_advanced_gtk.py:202 msgid "Assembling Image Components" msgstr "" -#: ../Dell/recovery_advanced_gtk.py:431 +#: ../Dell/recovery_advanced_gtk.py:442 msgid "All SRVs must be filled to proceed." msgstr "" -#: ../Dell/recovery_backend.py:368 +#: ../Dell/recovery_backend.py:346 msgid "Processing FISH packages" msgstr "" -#: ../Dell/recovery_backend.py:492 +#: ../Dell/recovery_backend.py:469 msgid "Adding in base image" msgstr "" -#: ../Dell/recovery_backend.py:947 +#: ../Dell/recovery_backend.py:1034 msgid "Preparing nested image" msgstr "" -#: ../Dell/recovery_backend.py:1051 +#: ../Dell/recovery_backend.py:1105 msgid "Regenerating UUID / Rebuilding initramfs" msgstr "" -#: ../Dell/recovery_backend.py:1177 +#: ../Dell/recovery_backend.py:1206 msgid "Building ISO" msgstr "" @@ -231,6 +231,10 @@ msgstr "" msgid "System policy prohibits changing network without user consent" msgstr "" +#: ../gtk/dell-driver-installer.desktop.in.h:1 +msgid "Dell Driver Installer" +msgstr "" + #: ../gtk/recovery_media_creator.ui.h:1 msgid "Cancel Recovery Media Creator" msgstr "" @@ -338,35 +342,39 @@ msgid "Build dell-recovery package from this system" msgstr "" #: ../gtk/builder.ui.h:16 +msgid "Install dpkg-repack" +msgstr "" + +#: ../gtk/builder.ui.h:17 msgid "" "Any add-on drivers or applications that need to be integrated into the image " "can be added here." msgstr "" -#: ../gtk/builder.ui.h:17 +#: ../gtk/builder.ui.h:18 msgid "" "The BTO FID framework is the first thing injected into a base vanilla " "image. If you are generating from an existing BTO compatible image, you may " "use the built-in framework." msgstr "" -#: ../gtk/builder.ui.h:18 +#: ../gtk/builder.ui.h:19 msgid "FID framework built into BTO image" msgstr "" -#: ../gtk/builder.ui.h:19 +#: ../gtk/builder.ui.h:20 msgid "FID Framework enclosed in debian package" msgstr "" -#: ../gtk/builder.ui.h:20 +#: ../gtk/builder.ui.h:21 msgid "Selected Overlay Details:" msgstr "" -#: ../gtk/builder.ui.h:21 +#: ../gtk/builder.ui.h:22 msgid "SRV Entry" msgstr "" -#: ../gtk/builder.ui.h:22 +#: ../gtk/builder.ui.h:23 msgid "Please enter the SRV to use:" msgstr "" @@ -388,30 +396,20 @@ msgid "" msgstr "" #: ../gtk/tool_selector.ui.h:6 -msgid "" -"This will restore the system with Dell Hybrid Client to the factory shipped " -"state using the recovery partition stored on the hard drive." -msgstr "" - -#: ../gtk/tool_selector.ui.h:7 msgid "Build OS Media" msgstr "" -#: ../gtk/tool_selector.ui.h:8 +#: ../gtk/tool_selector.ui.h:7 msgid "Restore System" msgstr "" -#: ../gtk/tool_selector.ui.h:9 -msgid "Restore Dell Hybrid Client" -msgstr "" - -#: ../gtk/tool_selector.ui.h:10 +#: ../gtk/tool_selector.ui.h:8 msgid "" "This will install a Dell driver package that you downloaded from the " "Internet." msgstr "" -#: ../gtk/tool_selector.ui.h:11 +#: ../gtk/tool_selector.ui.h:9 msgid "Install Drivers" msgstr "" @@ -464,4 +462,4 @@ msgstr "" #: ../ubiquity/stepRecoveryMedia.ui.h:11 msgid "ERROR: This media is only valid on Dell systems." -msgstr "" +msgstr "" \ No newline at end of file From 2d54ed6b439302212d3831cd53621bfdb35ea02a Mon Sep 17 00:00:00 2001 From: chinyakao Date: Tue, 27 Jul 2021 09:14:18 +0800 Subject: [PATCH 25/27] fix venv --- .gitignore | 1 + contrib/setup | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/.gitignore b/.gitignore index d475a73f..c82411d7 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ debian/files debian/tmp/ secure_boot/MokSBStateSet.efi .vscode +/venv diff --git a/contrib/setup b/contrib/setup index f3bc3199..38775843 100755 --- a/contrib/setup +++ b/contrib/setup @@ -12,5 +12,11 @@ if [ "$OS" = "ubuntu" ]; then sudo apt install $DEPS fi +python3 -m venv venv +source venv/bin/activate + python3 -m pip install pre-commit pre-commit install + +# remove the folder `venv` to let dkpg work +rm -r venv/ \ No newline at end of file From 8432ce9f0965f338776afc2b2821209218e30b42 Mon Sep 17 00:00:00 2001 From: chinyakao Date: Tue, 27 Jul 2021 09:19:16 +0800 Subject: [PATCH 26/27] fix venv --- contrib/setup | 3 --- 1 file changed, 3 deletions(-) diff --git a/contrib/setup b/contrib/setup index 38775843..d4ba8f8b 100755 --- a/contrib/setup +++ b/contrib/setup @@ -17,6 +17,3 @@ source venv/bin/activate python3 -m pip install pre-commit pre-commit install - -# remove the folder `venv` to let dkpg work -rm -r venv/ \ No newline at end of file From 3c50d2b5284abed0fdea4d5d6693f42a22c7e2ba Mon Sep 17 00:00:00 2001 From: chinyakao Date: Fri, 27 Aug 2021 10:13:12 +0800 Subject: [PATCH 27/27] first review & move to main yml --- .github/workflows/main.yml | 17 +++++++++- .github/workflows/main_test.yml | 36 --------------------- grub/99_dell_recovery | 4 +-- late/chroot_scripts/02-grub.sh | 3 +- late/chroot_scripts/03-ubuntu-drivers.sh | 7 ++-- late/chroot_scripts/05-enable-oem-config.sh | 3 +- late/chroot_scripts/95-set_UTC_TZ.sh | 10 +++--- late/scripts/CLEANUP-SCRIPT | 1 - late/scripts/FAIL-SCRIPT | 3 +- late/scripts/SUCCESS-SCRIPT | 3 +- late/scripts/fetch_logs.sh | 17 +++------- po/dell-recovery.pot | 2 +- 12 files changed, 38 insertions(+), 68 deletions(-) delete mode 100644 .github/workflows/main_test.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cd6bf4cd..1b1c1dc4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,4 +18,19 @@ jobs: run: DEBIAN_FRONTEND=noninteractive sudo apt-get install -yq --no-install-recommends build-essential debhelper dh-python dpkg-dev python3 python3-distutils-extra po-debconf pyflakes3 lsb-release gnu-efi - name: Build package run: dpkg-buildpackage --no-sign - + pre-commit: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Refresh dependencies + run: sudo apt update + - name: Install dependencies + run: sudo apt install shellcheck -y + - name: Run pre-commit hooks + run: | + ./contrib/setup + source venv/bin/activate + sed -i "/no-commit-to-branch/,+1d" .pre-commit-config.yaml + pre-commit run --all-files diff --git a/.github/workflows/main_test.yml b/.github/workflows/main_test.yml deleted file mode 100644 index f2ad5bbc..00000000 --- a/.github/workflows/main_test.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Continuous Integration -on: - push: - branches: - pull_request: - branches: - -jobs: - build: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Refresh dependencies - run: sudo apt update - - name: Install dependencies - run: DEBIAN_FRONTEND=noninteractive sudo apt-get install -yq --no-install-recommends build-essential debhelper dh-python dpkg-dev python3 python3-distutils-extra po-debconf pyflakes3 lsb-release gnu-efi - - name: Build package - run: dpkg-buildpackage --no-sign - pre-commit: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Refresh dependencies - run: sudo apt update - - name: Install dependencies - run: sudo apt install shellcheck -y - - name: Run pre-commit hooks - run: | - ./contrib/setup - source venv/bin/activate - sed -i "/no-commit-to-branch/,+1d" .pre-commit-config.yaml - pre-commit run --all-files diff --git a/grub/99_dell_recovery b/grub/99_dell_recovery index 5d869412..4547e2c1 100755 --- a/grub/99_dell_recovery +++ b/grub/99_dell_recovery @@ -2,7 +2,7 @@ source /usr/lib/grub/grub-mkconfig_lib -cat << EOF +cat << 'EOF' menuentry "#RECOVERY_TEXT#" { search --no-floppy --hint '(hd0,#PARTITION#)' --set --fs-uuid #UUID# set uuid_options="uuid=#UUID#" @@ -31,7 +31,7 @@ menuentry "#RECOVERY_TEXT#" { fi kernel=/casper/vmlinuz - if [ ! -f $(kernel) ]; then + if [ ! -f $kernel ]; then kernel=/casper/vmlinuz.efi fi linux \$kernel dell-recovery/recovery_type=#REC_TYPE# \$uuid_options \$options diff --git a/late/chroot_scripts/02-grub.sh b/late/chroot_scripts/02-grub.sh index b20178a5..e7ccaaeb 100755 --- a/late/chroot_scripts/02-grub.sh +++ b/late/chroot_scripts/02-grub.sh @@ -23,7 +23,8 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. -str="" . /usr/share/dell/scripts/fifuncs +# shellcheck disable=SC2240 +. /usr/share/dell/scripts/fifuncs "" IFHALT "Rerun GRUB update" /usr/sbin/update-grub diff --git a/late/chroot_scripts/03-ubuntu-drivers.sh b/late/chroot_scripts/03-ubuntu-drivers.sh index ff815862..eda3047b 100755 --- a/late/chroot_scripts/03-ubuntu-drivers.sh +++ b/late/chroot_scripts/03-ubuntu-drivers.sh @@ -6,11 +6,8 @@ export DEBIAN_FRONTEND=noninteractive IFHALT "Run ubuntu-drivers autoinstall" echo 'APT::Get::AllowUnauthenticated "true";' > /etc/apt/apt.conf.d/99disable_authentication -# while IFS= read -r -d '' blacklist; do -# UBUNTU_DRIVERS_BLACKLIST="$UBUNTU_DRIVERS_BLACKLIST $(cat "$blacklist")" -# done < <(find /cdrom/scripts/chroot-scripts/blacklist /isodevice/scripts/chroot-scripts/blacklist -type f -print0 2>/dev/null) -# shellcheck disable=SC2044 -for blacklist in $(find /cdrom/scripts/chroot-scripts/blacklist /isodevice/scripts/chroot-scripts/blacklist -type f 2>/dev/null); do +LIST=$(find /cdrom/scripts/chroot-scripts/blacklist /isodevice/scripts/chroot-scripts/blacklist -type f 2>/dev/null) +for blacklist in $LIST; do UBUNTU_DRIVERS_BLACKLIST="$UBUNTU_DRIVERS_BLACKLIST $(cat "$blacklist")" done if [ -n "$UBUNTU_DRIVERS_BLACKLIST" ]; then diff --git a/late/chroot_scripts/05-enable-oem-config.sh b/late/chroot_scripts/05-enable-oem-config.sh index 3024b3ff..58531afb 100755 --- a/late/chroot_scripts/05-enable-oem-config.sh +++ b/late/chroot_scripts/05-enable-oem-config.sh @@ -23,7 +23,8 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. -str="" . /usr/share/dell/scripts/fifuncs +# shellcheck disable=SC2240 +. /usr/share/dell/scripts/fifuncs "" IFHALT "Enable oem-config" oem-config-prepare --quiet diff --git a/late/chroot_scripts/95-set_UTC_TZ.sh b/late/chroot_scripts/95-set_UTC_TZ.sh index 75e952be..03712952 100755 --- a/late/chroot_scripts/95-set_UTC_TZ.sh +++ b/late/chroot_scripts/95-set_UTC_TZ.sh @@ -33,14 +33,12 @@ # the time offset for ICC tz_offset.py was adjusted # from 5:30 to 5 # ==== Do we need to change this??? -mkfifo mypipe -/proc/cmdline > mypipe & -while IFS= read -r arg; do - if echo "$arg" | grep "MFGSITE=" >/dev/null 2>&1; then +ARGLIST=$(cat /proc/cmdline) +for arg in $ARGLIST; do + if echo "$arg" | grep "MFGSITE=" > /dev/null 2>&1; then SITE=$(echo "$arg" | cut -d'=' -f2) fi -done < mypipe -rm mypipe +done if [ -n "$SITE" ]; then cat > /etc/init.d/run-tz-fix </dev/null if mount | grep -q "/mnt" 2>/dev/null;then umount /mnt fi diff --git a/late/scripts/FAIL-SCRIPT b/late/scripts/FAIL-SCRIPT index 023db3a5..4e4380f7 100755 --- a/late/scripts/FAIL-SCRIPT +++ b/late/scripts/FAIL-SCRIPT @@ -27,7 +27,8 @@ # BE AWARE THAT THIS SCRIPT IS CALLED FROM OUTSIDE THE CHROOT. # The OS is mounted under $TARGET -target="target" . /usr/share/dell/scripts/fifuncs +# shellcheck disable=SC2240 +. /usr/share/dell/scripts/fifuncs "target" set -x set -e diff --git a/late/scripts/SUCCESS-SCRIPT b/late/scripts/SUCCESS-SCRIPT index 70e7bf38..aedd50b3 100755 --- a/late/scripts/SUCCESS-SCRIPT +++ b/late/scripts/SUCCESS-SCRIPT @@ -27,7 +27,8 @@ # BE AWARE THAT THIS SCRIPT IS CALLED FROM OUTSIDE THE CHROOT. # The OS is mounted under $TARGET -target="target" . /usr/share/dell/scripts/fifuncs +# shellcheck disable=SC2240 +. /usr/share/dell/scripts/fifuncs "target" set -x set -e diff --git a/late/scripts/fetch_logs.sh b/late/scripts/fetch_logs.sh index 8ac01205..6f5a40aa 100755 --- a/late/scripts/fetch_logs.sh +++ b/late/scripts/fetch_logs.sh @@ -17,28 +17,26 @@ dump_MFG() { ESP="" BD="" - # BDD="" + BDD="" # check to see if it's already mounted, if not mount it - # readlink /dev/disk/by-label/OS | grep "sd" if readlink /dev/disk/by-label/OS | grep -q "sd"; then BD=$(readlink /dev/disk/by-label/OS | cut -c7-9) drive="/dev/${BD}1" - # BDD="/dev/${BD}" + BDD="/dev/${BD}" echo "Find boot disk ${drive}" else - # readlink /dev/disk/by-label/OS | grep "mmc" if readlink /dev/disk/by-label/OS | grep -q "mmc"; then BD=$(readlink /dev/disk/by-label/OS | cut -c7-13) drive="/dev/${BD}p1" - # BDD="/dev/${BD}" + BDD="/dev/${BD}" log "Find boot disk ${drive}" echo "Find boot disk ${drive}" else - # readlink /dev/disk/by-label/OS | grep "nvme" if readlink /dev/disk/by-label/OS | grep -q "nvme"; then BD=$(readlink /dev/disk/by-label/OS | cut -c7-13) drive="/dev/${BD}p1" - # BDD="/dev/${BD}" + # shellcheck disable=SC2034 + BDD="/dev/${BD}" echo "Find boot disk ${drive}" else echo "Fail to find boot disk !!!" @@ -46,7 +44,6 @@ dump_MFG() fi fi fi - # mount | grep -iqs "$drive" if ! mount | grep -iqs "$drive"; then echo "Mounting EFI System Partition" if [ ! -d /mnt/efi ]; then @@ -67,7 +64,6 @@ dump_MFG() echo "Missing MFGMEDIA folder from EFI System Partition" else # copy the file - # cp -rf "${ESP}"/"${MFGMEDIA}" ./ if ! cp -rf "${ESP}"/"${MFGMEDIA}" ./; then echo "Failed to copy MFGMEDIA" return 255 @@ -79,7 +75,6 @@ dump_MFG() } #find the usb key mount point -# usb_part=$(mount | grep "/cdrom" | cut -d ' ' -f 1) if ! mount | grep "/cdrom" | cut -d ' ' -f 1; then echo "Can't find the USB key!!" exit 1 @@ -103,7 +98,6 @@ if [ -z "$linux_part" ];then exit 1 fi #mount the partition -# mount | grep "/mnt" 2>/dev/null if ! mount | grep "/mnt" 2>/dev/null;then mount "$linux_part" /mnt fi @@ -120,7 +114,6 @@ if [ -d /mnt/var/log ];then touch dmesg.log 2>&1 chattr +a dmesg.log dmesg >> dmesg.log - # tar -zcf "/cdrom/OSLogs/ubuntu.log.tar.gz" /mnt/var/log/ dmesg.log $mfglog 2>/dev/null if tar -zcf "/cdrom/OSLogs/ubuntu.log.tar.gz" /mnt/var/log/ dmesg.log "$mfglog" 2>/dev/null;then echo "Finish copying the OS installation logs!" fi diff --git a/po/dell-recovery.pot b/po/dell-recovery.pot index 3a304850..b91abf08 100644 --- a/po/dell-recovery.pot +++ b/po/dell-recovery.pot @@ -462,4 +462,4 @@ msgstr "" #: ../ubiquity/stepRecoveryMedia.ui.h:11 msgid "ERROR: This media is only valid on Dell systems." -msgstr "" \ No newline at end of file +msgstr ""