diff options
author | Xorg | 2016-04-09 12:32:12 +0200 |
---|---|---|
committer | Xorg | 2016-04-09 12:34:40 +0200 |
commit | 27fa806c30717ec760d97c4eef4107f6a9ed04ba (patch) | |
tree | 18c9427362e3dd63e1321bae75cd8b8b91c35658 | |
parent | cddd2a3a82819fe16cbe943c175d229772e85aaf (diff) | |
download | aur-27fa806c30717ec760d97c4eef4107f6a9ed04ba.tar.gz |
Improve memtest86-efi script again
-rw-r--r-- | .SRCINFO | 12 | ||||
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | PKGBUILD | 30 | ||||
-rw-r--r-- | grub.conf | 6 | ||||
-rw-r--r-- | memtest86-efi | 95 | ||||
-rw-r--r-- | memtest86-efi.install | 6 | ||||
-rw-r--r-- | systemd-boot.conf | 2 |
7 files changed, 104 insertions, 49 deletions
@@ -1,9 +1,9 @@ # Generated by mksrcinfo v8 -# Fri Apr 8 06:35:19 UTC 2016 +# Sat Apr 9 10:32:20 UTC 2016 pkgbase = memtest86-efi pkgdesc = A free, thorough, stand alone memory test as an EFI application pkgver = 6.3.0 - pkgrel = 4 + pkgrel = 5 url = http://www.memtest86.com install = memtest86-efi.install arch = i686 @@ -13,13 +13,17 @@ pkgbase = memtest86-efi makedepends = libarchive optdepends = efibootmgr: to add a new EFI boot entry optdepends = grub: to add MemTest86 entry in GRUB2 menu - backup = etc/memtest86-efi.conf + backup = etc/memtest86-efi/memtest86-efi.conf source = memtest86-6.3.0.iso.tar.gz::http://www.memtest86.com/downloads/memtest86-iso.tar.gz source = memtest86-efi source = memtest86-efi.conf + source = grub.conf + source = systemd-boot.conf md5sums = 87c0fb1338183b5eaf11096d1d2f0475 - md5sums = db8f92f995967b608a36324efd2d62b6 + md5sums = d27e3182a80b1a8c41227939792f4394 md5sums = 6c096df3f55baf3e27c3bd605a418aa2 + md5sums = cebcc8b15b9dc6646977d9d3573b8a71 + md5sums = 496120c33c2af986933bf33456fa6cf3 pkgname = memtest86-efi diff --git a/.gitignore b/.gitignore index 2ee27f800b60..62786e6fec03 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ !memtest86-efi !memtest86-efi.conf !memtest86-efi.install +!grub.conf +!systemd-boot.conf @@ -3,7 +3,7 @@ _pkgbasename=memtest86 pkgname=$_pkgbasename-efi pkgver=6.3.0 -pkgrel=4 +pkgrel=5 pkgdesc="A free, thorough, stand alone memory test as an EFI application" arch=('i686' 'x86_64') url="http://www.memtest86.com" @@ -11,14 +11,18 @@ license=('GPL2' 'custom:PassMark') makedepends=('libarchive') optdepends=('efibootmgr: to add a new EFI boot entry' 'grub: to add MemTest86 entry in GRUB2 menu') -backup=(etc/$pkgname.conf) +backup=(etc/$pkgname/$pkgname.conf) install=$pkgname.install source=("$_pkgbasename-$pkgver.iso.tar.gz::http://www.memtest86.com/downloads/$_pkgbasename-iso.tar.gz" "memtest86-efi" - "memtest86-efi.conf") + "memtest86-efi.conf" + "grub.conf" + "systemd-boot.conf") md5sums=('87c0fb1338183b5eaf11096d1d2f0475' - 'db8f92f995967b608a36324efd2d62b6' - '6c096df3f55baf3e27c3bd605a418aa2') + 'd27e3182a80b1a8c41227939792f4394' + '6c096df3f55baf3e27c3bd605a418aa2' + 'cebcc8b15b9dc6646977d9d3573b8a71' + '496120c33c2af986933bf33456fa6cf3') prepare() { msg2 "Extract ISO..." @@ -27,13 +31,15 @@ prepare() { package() { msg2 "Move MemTest86 stuff in share directory..." - [[ "$CARCH" == "i686" ]] && install -Dvm755 "$srcdir/EFI/BOOT/BOOTIA32.EFI" "$pkgdir/usr/share/$pkgname/bootia32.efi" - [[ "$CARCH" == "x86_64" ]] && install -Dvm755 "$srcdir/EFI/BOOT/BOOTX64.EFI" "$pkgdir/usr/share/$pkgname/bootx64.efi" - install -vm644 "$srcdir/EFI/BOOT/MT86.PNG" "$pkgdir/usr/share/$pkgname/mt86.png" - install -vm644 "$srcdir/EFI/BOOT/UNIFONT.BIN" "$pkgdir/usr/share/$pkgname/unifont.bin" - install -Dvm644 "$srcdir/LICENSE.RTF" "$pkgdir/usr/share/licenses/$pkgname/LICENSE.rtf" + [[ "$CARCH" == "i686" ]] && install -Dvm755 "$srcdir/EFI/BOOT/BOOTIA32.EFI" "$pkgdir/usr/share/$pkgname/bootia32.efi" + [[ "$CARCH" == "x86_64" ]] && install -Dvm755 "$srcdir/EFI/BOOT/BOOTX64.EFI" "$pkgdir/usr/share/$pkgname/bootx64.efi" + install -Dvm644 "$srcdir/EFI/BOOT/MT86.PNG" "$pkgdir/usr/share/$pkgname/mt86.png" + install -Dvm644 "$srcdir/EFI/BOOT/UNIFONT.BIN" "$pkgdir/usr/share/$pkgname/unifont.bin" + install -Dvm644 "$srcdir/LICENSE.RTF" "$pkgdir/usr/share/licenses/$pkgname/LICENSE.rtf" msg2 "Install AUR provided script..." - install -Dvm755 "$srcdir/memtest86-efi" "$pkgdir/usr/bin/memtest86-efi" - install -Dvm644 "$srcdir/memtest86-efi.conf" "$pkgdir/etc/memtest86-efi.conf" + install -Dvm755 "$srcdir/memtest86-efi" "$pkgdir/usr/bin/memtest86-efi" + install -Dvm644 "$srcdir/memtest86-efi.conf" "$pkgdir/etc/memtest86-efi/memtest86-efi.conf" + install -Dvm644 "$srcdir/grub.conf" "$pkgdir/etc/memtest86-efi/grub.conf" + install -Dvm644 "$srcdir/systemd-boot.conf" "$pkgdir/etc/memtest86-efi/systemd-boot.conf" } diff --git a/grub.conf b/grub.conf new file mode 100644 index 000000000000..878012f2d083 --- /dev/null +++ b/grub.conf @@ -0,0 +1,6 @@ +if [ "x${grub_platform}" = xefi ]; then + menuentry "Memtest86" { + search --set=root --no-floppy --fs-uuid @UUID@ + chainloader /EFI/memtest86/memtest@ARCH@.efi + } +fi diff --git a/memtest86-efi b/memtest86-efi index 3155fc073679..6b4fa61858b6 100644 --- a/memtest86-efi +++ b/memtest86-efi @@ -5,14 +5,17 @@ CE="\033[31m" # Color red CB="\033[1m" # Color bold CR="\033[0m" # Color reset PRGNAME=$(basename $0) -CONFFILE="/etc/memtest86-efi.conf" -source "$CONFFILE" +CONFDIR="/etc/memtest86-efi" +CONFFILE="$CONFDIR/memtest86-efi.conf" +source "$CONFFILE" || exit 127 [[ "$(uname -m)" == "i686" ]] && ARCH="ia32" [[ "$(uname -m)" == "x86_64" ]] && ARCH="x64" warn() { echo -e "${CB}${CE}This script is unofficial, written by an AUR (Arch User Repository) user. Use it at YOUR OWN RISK.${CR}" +} +checkuid() { if [[ $EUID -ne 0 ]]; then echo -e "${CE}You must be root to run $PRGNAME. Aborted.${CR}" > /dev/stderr exit -1 @@ -32,22 +35,31 @@ install() { exit 1 fi + # Find ESP device number partition=$(fdisk -l | grep "EFI System" | awk '{print $1}' | tail -n1) - esp=$(mount | grep $partition | awk '{print $3}' | tail -n1) - [[ -n $esp ]] && mountpoint=" (mounted on ${CB}$esp${CR})" - - echo -en "Press Enter if ${CB}$partition${CR}$mountpoint is your ESP partition, " + echo -en "Press Enter if ${CB}$partition${CR} is your ESP partition, " echo -en "else enter device path manually (like ${CB}/dev/sdXY${CR}): " read choice [[ -n $choice ]] && partition=$choice + # Find ESP mount point esp=$(mount | grep $partition | awk '{print $3}' | tail -n1) - if [[ -z $esp ]]; then - echo -e "${CE}ESP $partition is not mounted, you need to mount it. Aborted.${CR}" > /dev/stderr - exit 2 + echo -en "Press Enter if ${CB}$esp${CR} is your mount point, " + echo -en "else enter mount point manually (like ${CB}/boot/efi${CR}): " + read choice + [[ -n $choice ]] && esp=$choice + + # Check if ESP is mounted + if ! mount | grep $partition | grep -q $esp; then + echo -e "ESP ${CB}$partition${CR} is not mounted, mounting..." + if ! mount "$partition" "$esp"; then + echo -e "${CE}Fail to mount $partition on $esp. Aborted.${CR}" > /dev/stderr + exit 2 + fi fi echo -e "The target is: ${CB}$partition${CR} (mounted on ${CB}$esp${CR}).\n" + # Get user choice echo "Select $PRGNAME action to perform:" echo -e "${CB}1${CR}: Copy shellx64.efi file on ESP's root (bit safe)" echo -e "${CB}2${CR}: Add a new EFI boot entry (more safe)" @@ -64,38 +76,39 @@ install() { 1) # Install MemTest86 in $esp/ echo -e "MemTest86 will be installed in ${CB}$esp/${CR}." [[ -f "$esp/shell$ARCH.efi" ]] && mv -v "$esp/shell$ARCH.efi" "$esp/shell$ARCH.efi.bak" # Backup if exist - cp -v "$MEMTEST86_PATH/"* "$esp/" # Move files in ESP root - mv -v "$esp/boot$ARCH.efi" "$esp/shell$ARCH.efi" # Rename .efi file + cp -v "$MEMTEST86_PATH/"* "$esp/" # Move files in ESP root + mv -v "$esp/boot$ARCH.efi" "$esp/shell$ARCH.efi" # Rename .efi file ;; 2) # Install MemTest86 in $esp/EFI/memtest86/ & add an EFI boot entry checkcommand efibootmgr + echo -e "MemTest86 will be installed in ${CB}$esp/EFI/memtest86/${CR}." mkdir -pv "$esp/EFI/memtest86" cp -v "$MEMTEST86_PATH/"* "$esp/EFI/memtest86/" # Move files in memtest ESP directory mv -v "$esp/EFI/memtest86/boot$ARCH.efi" "$esp/EFI/memtest86/memtest$ARCH.efi" # Rename .efi file + echo -e "\nAdd a new EFI boot entry..." efibootmgr -c -d ${partition:0:8} -p ${partition:8} -w -L "MemTest86" -l "\EFI\memtest86\memtest$ARCH.efi" # Manage efi entry ;; 3) # Install MemTest86 in $esp/EFI/memtest86/ & add a file for GRUB2 checkcommand grub-mkconfig - echo -e "MemTest86 will be installed in ${CB}$esp/EFI/memtest86/${CR}." if [[ ! -d "/etc/grub.d/" ]]; then echo -e "${CE}GRUB2 seems not installed on your system. Aborted.${CR}" > /dev/stderr exit 2 fi + + echo -e "MemTest86 will be installed in ${CB}$esp/EFI/memtest86/${CR}." mkdir -pv "$esp/EFI/memtest86" cp -v "$MEMTEST86_PATH/"* "$esp/EFI/memtest86/" # Move files in memtest ESP directory mv -v "$esp/EFI/memtest86/boot$ARCH.efi" "$esp/EFI/memtest86/memtest$ARCH.efi" # Rename .efi file + echo -e "\nAdd a new configuration file for GRUB..." - echo -e "if [ \"x\${grub_platform}\" = xefi ]; then\n" \ - "menuentry \"Memtest86\" {\n" \ - "\tsearch --set=root --no-floppy --fs-uuid $(blkid $partition -s UUID -o value)\n" \ - "\tchainloader /EFI/memtest86/memtest$ARCH.efi\n" \ - "}\n" \ - "fi" > "/etc/grub.d/86_memtest" - chmod +x "/etc/grub.d/86_memtest" + /bin/install -Dvm755 "$CONFDIR/grub.conf" "/etc/grub.d/86_memtest" + uuid=$(blkid $partition -s UUID -o value) + sed -i "s|@UUID@|$uuid|g" "/etc/grub.d/86_memtest" + sed -i "s|@ARCH@|$ARCH|g" "/etc/grub.d/86_memtest" grub-mkconfig -o "/boot/grub/grub.cfg" ;; @@ -104,9 +117,10 @@ install() { mkdir -pv "$esp/EFI/memtest86" "$esp/loader/entries" cp -v "$MEMTEST86_PATH/"* "$esp/EFI/memtest86/" # Move files in memtest ESP directory mv -v "$esp/EFI/memtest86/boot$ARCH.efi" "$esp/EFI/memtest86/memtest$ARCH.efi" # Rename .efi file + echo -e "\nAdd a new configuration file for systemd-boot..." - echo -e "title MemTest86" \ - "\nefi /EFI/memtest86/memtest$ARCH.efi" > "$esp/loader/entries/memtest86-efi.conf" + /bin/install -Dvm644 "$CONFDIR/systemd-boot.conf" "$esp/loader/entries/memtest86-efi.conf" + sed -i "s|@ARCH@|$ARCH|g" "$esp/loader/entries/memtest86-efi.conf" ;; *) # Do nothing and quit @@ -162,16 +176,21 @@ remove() { 2) # Remove files in $esp/EFI/memtest86/ & delete EFI boot entry checkcommand efibootmgr + echo -e "MemTest86 will be removed from ${CB}$esp/EFI/memtest86/${CR}." rm -rfv "$esp/EFI/memtest86/" + echo -e "\nRemove MemTest86 EFI boot entry..." - efibootmgr -b $(efibootmgr | grep MemTest86 | cut -c 5-8) -B + entry=$(efibootmgr | grep MemTest86 | cut -c 5-8) + [[ -n $entry ]] && efibootmgr -b $entry -B ;; 3) # Remove files in $esp/EFI/memtest86/ & delete file for GRUB2 checkcommand grub-mkconfig + echo -e "MemTest86 will be removed from ${CB}$esp/EFI/memtest86/${CR}." rm -rfv "$esp/EFI/memtest86/" + echo -e "\nRemove configuration file for GRUB..." rm -v "/etc/grub.d/86_memtest" grub-mkconfig -o "/boot/grub/grub.cfg" @@ -180,6 +199,7 @@ remove() { 4) # Remove files in $esp/EFI/memtest86/ & delete file for systemd-boot echo -e "MemTest86 will be removed from ${CB}$esp/EFI/memtest86/${CR}." rm -rfv "$esp/EFI/memtest86/" + echo -e "\nRemove configuration file for systemd-boot..." rm -v "$esp/loader/entries/memtest86-efi.conf" ;; @@ -194,6 +214,23 @@ remove() { echo -e "\nMemTest86 has been removed from ESP." } +status() { + echo -e "${CB}Default MemTest86 directories:${CR}" + echo -e "Configuration directory: $CONFDIR/" + echo -e "Data directory: $MEMTEST86_PATH/\n" + + if [[ $install == 0 ]]; then + echo -e "${CB}MemTest86 is not installed on your system.${CR}" + exit 1 + else + echo -e "${CB}MemTest86 is installed on your system with following parameters:${CR}" + echo -e "ESP device name: $partition" + echo -e "ESP mount point: $esp" + echo -e "Type of installation: $choice" + exit 0 + fi +} + help() { echo -e "Usage: $PRGNAME ACTION\n" echo -e "Available ACTION:" @@ -211,11 +248,11 @@ about() { } case "$1" in - -i|--install) warn; install; exit 0;; - -u|--update) warn; update; exit 0;; - -r|--remove) warn; remove; exit 0;; - -s|--status) exit $install;; - -h|--help) help; exit 0;; - -a|--about) about; exit 0;; - *) help; exit 1;; + -i|--install) warn; checkuid; install; exit 0;; + -u|--update) checkuid; update; exit 0;; + -r|--remove) checkuid; remove; exit 0;; + -s|--status) status;; + -h|--help) help; exit 0;; + -a|--about) warn; about; exit 0;; + *) help; exit 1;; esac diff --git a/memtest86-efi.install b/memtest86-efi.install index f40d1d681834..1ab672e9e084 100644 --- a/memtest86-efi.install +++ b/memtest86-efi.install @@ -3,11 +3,9 @@ post_install() { } post_upgrade() { - /usr/bin/memtest86-efi --status || /usr/bin/memtest86-efi --update - exit 0 + /usr/bin/memtest86-efi --status &> /dev/null && /usr/bin/memtest86-efi --update } pre_remove() { - /usr/bin/memtest86-efi --status || /usr/bin/memtest86-efi --remove - exit 0 + /usr/bin/memtest86-efi --status &> /dev/null && /usr/bin/memtest86-efi --remove } diff --git a/systemd-boot.conf b/systemd-boot.conf new file mode 100644 index 000000000000..593166be1f72 --- /dev/null +++ b/systemd-boot.conf @@ -0,0 +1,2 @@ +title MemTest86 +efi /EFI/memtest86/memtest@ARCH@.efi |