Skip to content

Instantly share code, notes, and snippets.

@bobpaul
Last active October 17, 2022 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bobpaul/2adbab97db15c6ecdc846897d995e5ca to your computer and use it in GitHub Desktop.
Save bobpaul/2adbab97db15c6ecdc846897d995e5ca to your computer and use it in GitHub Desktop.
grub.d config for pcmemtest aur package
#!/usr/bin/env bash
##############################################################
# This script generates a pcmemtest (fork of memtest86+) #
# entry on grub.cfg if pcmemtest is installed on the system. #
##############################################################
prefix="/usr"
exec_prefix="${prefix}"
datarootdir="/usr/share"
datadir="${datarootdir}"
. "${datadir}/grub/grub-mkconfig_lib"
PCMEMTEST_IMAGE="/boot/pcmemtest/memtest.bin"
CLASS="--class memtest86 --class gnu --class tool"
if [ -e "${PCMEMTEST_IMAGE}" ] && is_path_readable_by_grub "${PCMEMTEST_IMAGE}" ; then
## image exists, create menu entry
echo "Found pcmemtest image: ${PCMEMTEST_IMAGE}" >&2
_GRUB_MEMTEST_HINTS_STRING="$(${grub_probe} --target=hints_string ${PCMEMTEST_IMAGE})"
_GRUB_MEMTEST_FS_UUID="$(${grub_probe} --target=fs_uuid ${PCMEMTEST_IMAGE})"
_GRUB_MEMTEST_REL_PATH="$(make_system_path_relative_to_its_root ${PCMEMTEST_IMAGE})"
cat << EOF
if [ "\${grub_platform}" == "pc" ]; then
menuentry "Memory Tester (pcmemtest)" ${CLASS} {
search --fs-uuid --no-floppy --set=root ${_GRUB_MEMTEST_HINTS_STRING} ${_GRUB_MEMTEST_FS_UUID}
linux16 ${_GRUB_MEMTEST_REL_PATH} ${GRUB_CMDLINE_PCMEMTEST}
}
fi
EOF
fi
# Maintainer: Stephan Springer <buzo+arch@Lini.de>
pkgname=pcmemtest
pkgver=1.5
pkgrel=2
pkgdesc='Stand-alone memory tester for x86 and x86-64 architecture computers'
arch=('x86_64')
url=https://github.com/martinwhitaker/pcmemtest
license=('GPL2')
source=("$pkgname-$pkgver.tar.gz::$url/archive/refs/tags/v${pkgver}.tar.gz"
"61_pcmemtest")
sha256sums=('6c47972b94b6f5078341e5b8622ab3ce0e499515629480a2c8daf65e4547d65e'
'40ed61325bd25598960387c5e3eb41c06b59107041a5d91cc26d85d91e9c92c7'
)
build() {
cd "$pkgname-$pkgver"/build64
make
}
package() {
cd "$pkgname-$pkgver"/build64
install -Dm644 -t "$pkgdir"/boot/pcmemtest/ memtest.{bin,efi}
cd "$srcdir"
install -Dm755 -t "$pkgdir"/etc/grub.d/ 61_pcmemtest
}
diff --git a/.SRCINFO b/.SRCINFO
index e52036b..af7837a 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,11 +1,13 @@
pkgbase = pcmemtest
pkgdesc = Stand-alone memory tester for x86 and x86-64 architecture computers
pkgver = 1.5
- pkgrel = 1
+ pkgrel = 2
url = https://github.com/martinwhitaker/pcmemtest
arch = x86_64
license = GPL2
source = pcmemtest-1.5.tar.gz::https://github.com/martinwhitaker/pcmemtest/archive/refs/tags/v1.5.tar.gz
+ source = 61_pcmemtest
sha256sums = 6c47972b94b6f5078341e5b8622ab3ce0e499515629480a2c8daf65e4547d65e
+ sha256sums = 40ed61325bd25598960387c5e3eb41c06b59107041a5d91cc26d85d91e9c92c7
pkgname = pcmemtest
diff --git a/61_pcmemtest b/61_pcmemtest
new file mode 100755
index 0000000..25e3254
--- /dev/null
+++ b/61_pcmemtest
@@ -0,0 +1,32 @@
+#!/usr/bin/env bash
+##############################################################
+# This script generates a pcmemtest (fork of memtest86+) #
+# entry on grub.cfg if pcmemtest is installed on the system. #
+##############################################################
+
+prefix="/usr"
+exec_prefix="${prefix}"
+
+datarootdir="/usr/share"
+datadir="${datarootdir}"
+
+. "${datadir}/grub/grub-mkconfig_lib"
+
+PCMEMTEST_IMAGE="/boot/pcmemtest/memtest.bin"
+CLASS="--class memtest86 --class gnu --class tool"
+
+if [ -e "${PCMEMTEST_IMAGE}" ] && is_path_readable_by_grub "${PCMEMTEST_IMAGE}" ; then
+ ## image exists, create menu entry
+ echo "Found pcmemtest image: ${PCMEMTEST_IMAGE}" >&2
+ _GRUB_MEMTEST_HINTS_STRING="$(${grub_probe} --target=hints_string ${PCMEMTEST_IMAGE})"
+ _GRUB_MEMTEST_FS_UUID="$(${grub_probe} --target=fs_uuid ${PCMEMTEST_IMAGE})"
+ _GRUB_MEMTEST_REL_PATH="$(make_system_path_relative_to_its_root ${PCMEMTEST_IMAGE})"
+ cat << EOF
+if [ "\${grub_platform}" == "pc" ]; then
+ menuentry "Memory Tester (pcmemtest)" ${CLASS} {
+ search --fs-uuid --no-floppy --set=root ${_GRUB_MEMTEST_HINTS_STRING} ${_GRUB_MEMTEST_FS_UUID}
+ linux16 ${_GRUB_MEMTEST_REL_PATH} ${GRUB_CMDLINE_PCMEMTEST}
+ }
+fi
+EOF
+fi
diff --git a/PKGBUILD b/PKGBUILD
index 5d4ef66..25c19cb 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -2,14 +2,16 @@
pkgname=pcmemtest
pkgver=1.5
-pkgrel=1
+pkgrel=2
pkgdesc='Stand-alone memory tester for x86 and x86-64 architecture computers'
arch=('x86_64')
url=https://github.com/martinwhitaker/pcmemtest
license=('GPL2')
-source=("$pkgname-$pkgver.tar.gz::$url/archive/refs/tags/v${pkgver}.tar.gz")
-sha256sums=('6c47972b94b6f5078341e5b8622ab3ce0e499515629480a2c8daf65e4547d65e')
-
+source=("$pkgname-$pkgver.tar.gz::$url/archive/refs/tags/v${pkgver}.tar.gz"
+ "61_pcmemtest")
+sha256sums=('6c47972b94b6f5078341e5b8622ab3ce0e499515629480a2c8daf65e4547d65e'
+ '40ed61325bd25598960387c5e3eb41c06b59107041a5d91cc26d85d91e9c92c7'
+ )
build() {
cd "$pkgname-$pkgver"/build64
make
@@ -17,5 +19,7 @@ build() {
package() {
cd "$pkgname-$pkgver"/build64
- install -Dm644 -t "$pkgdir"/boot memtest.{bin,efi}
+ install -Dm644 -t "$pkgdir"/boot/pcmemtest/ memtest.{bin,efi}
+ cd "$srcdir"
+ install -Dm755 -t "$pkgdir"/etc/grub.d/ 61_pcmemtest
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment