Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f41a026ca | ||
|
|
0ee4f46537 |
@@ -38,22 +38,109 @@ mkdir -p "${DOWNLOAD_CACHE_DIR}" "${CACHE_DIR}/bin" "${CACHE_DIR}/lib"
|
||||
|
||||
# ── download HPL source ────────────────────────────────────────────────────────
|
||||
HPL_TAR="${DOWNLOAD_CACHE_DIR}/hpl-${HPL_VERSION}.tar.gz"
|
||||
HPL_URL="https://www.netlib.org/benchmark/hpl/hpl-${HPL_VERSION}.tar.gz"
|
||||
DEFAULT_HPL_URLS="
|
||||
https://www.netlib.org/benchmark/hpl/hpl-${HPL_VERSION}.tar.gz
|
||||
https://fossies.org/linux/privat/hpl-${HPL_VERSION}.tar.gz
|
||||
"
|
||||
HPL_GIT_URL="${HPL_GIT_URL:-https://github.com/icl-utk-edu/hpl.git}"
|
||||
DEFAULT_HPL_GIT_REFS="v${HPL_VERSION} ${HPL_VERSION} main"
|
||||
HPL_SOURCE_MODE="tarball"
|
||||
|
||||
download_to_file() {
|
||||
url="$1"
|
||||
out="$2"
|
||||
|
||||
if command -v curl >/dev/null 2>&1; then
|
||||
curl -fL \
|
||||
--connect-timeout 15 \
|
||||
--max-time 180 \
|
||||
--retry 2 \
|
||||
--retry-delay 2 \
|
||||
--output "${out}" \
|
||||
"${url}"
|
||||
return $?
|
||||
fi
|
||||
|
||||
wget \
|
||||
--show-progress \
|
||||
--tries=2 \
|
||||
--timeout=30 \
|
||||
-O "${out}" \
|
||||
"${url}"
|
||||
}
|
||||
|
||||
download_hpl_tarball() {
|
||||
out="$1"
|
||||
tmp="${out}.part"
|
||||
urls="${HPL_URLS:-$DEFAULT_HPL_URLS}"
|
||||
|
||||
rm -f "${tmp}"
|
||||
for url in ${urls}; do
|
||||
[ -n "${url}" ] || continue
|
||||
echo "=== trying HPL source: ${url} ==="
|
||||
if download_to_file "${url}" "${tmp}"; then
|
||||
mv "${tmp}" "${out}"
|
||||
return 0
|
||||
fi
|
||||
rm -f "${tmp}"
|
||||
echo "=== failed: ${url} ==="
|
||||
done
|
||||
|
||||
echo "ERROR: failed to download HPL ${HPL_VERSION} from all configured URLs" >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
download_hpl_from_git_archive() {
|
||||
out="$1"
|
||||
refs="${HPL_GIT_REFS:-$DEFAULT_HPL_GIT_REFS}"
|
||||
tmp_root="$(mktemp -d)"
|
||||
repo_dir="${tmp_root}/repo"
|
||||
archive_dir="${tmp_root}/hpl-${HPL_VERSION}"
|
||||
archive_tmp="${out}.part"
|
||||
|
||||
for ref in ${refs}; do
|
||||
[ -n "${ref}" ] || continue
|
||||
echo "=== trying HPL git source: ${HPL_GIT_URL} ref ${ref} ==="
|
||||
rm -rf "${repo_dir}" "${archive_dir}" "${archive_tmp}"
|
||||
if git clone --depth 1 --branch "${ref}" "${HPL_GIT_URL}" "${repo_dir}"; then
|
||||
mv "${repo_dir}" "${archive_dir}"
|
||||
tar czf "${archive_tmp}" -C "${tmp_root}" "hpl-${HPL_VERSION}"
|
||||
mv "${archive_tmp}" "${out}"
|
||||
rm -rf "${tmp_root}"
|
||||
HPL_SOURCE_MODE="git"
|
||||
return 0
|
||||
fi
|
||||
echo "=== failed git ref: ${ref} ==="
|
||||
done
|
||||
|
||||
rm -rf "${tmp_root}" "${archive_tmp}"
|
||||
echo "ERROR: failed to obtain HPL ${HPL_VERSION} from all configured sources" >&2
|
||||
echo " looked for cache: ${out}" >&2
|
||||
echo " tarball mirrors: ${HPL_URLS:-$DEFAULT_HPL_URLS}" >&2
|
||||
echo " git fallback: ${HPL_GIT_URL} refs ${refs}" >&2
|
||||
echo " override mirrors with HPL_URLS=\"https://mirror1/...\"" >&2
|
||||
echo " override git refs with HPL_GIT_REFS=\"v${HPL_VERSION} ${HPL_VERSION} main\"" >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
if [ ! -f "${HPL_TAR}" ]; then
|
||||
echo "=== downloading HPL ${HPL_VERSION} ==="
|
||||
wget --show-progress -O "${HPL_TAR}" "${HPL_URL}"
|
||||
download_hpl_tarball "${HPL_TAR}" || download_hpl_from_git_archive "${HPL_TAR}"
|
||||
fi
|
||||
|
||||
actual_sha="$(sha256sum "${HPL_TAR}" | awk '{print $1}')"
|
||||
if [ "${actual_sha}" != "${HPL_SHA256}" ]; then
|
||||
echo "ERROR: sha256 mismatch for hpl-${HPL_VERSION}.tar.gz" >&2
|
||||
echo " expected: ${HPL_SHA256}" >&2
|
||||
echo " actual: ${actual_sha}" >&2
|
||||
rm -f "${HPL_TAR}"
|
||||
exit 1
|
||||
if [ "${HPL_SOURCE_MODE}" = "tarball" ]; then
|
||||
actual_sha="$(sha256sum "${HPL_TAR}" | awk '{print $1}')"
|
||||
if [ "${actual_sha}" != "${HPL_SHA256}" ]; then
|
||||
echo "ERROR: sha256 mismatch for hpl-${HPL_VERSION}.tar.gz" >&2
|
||||
echo " expected: ${HPL_SHA256}" >&2
|
||||
echo " actual: ${actual_sha}" >&2
|
||||
rm -f "${HPL_TAR}"
|
||||
exit 1
|
||||
fi
|
||||
echo "sha256 OK: hpl-${HPL_VERSION}.tar.gz"
|
||||
else
|
||||
echo "=== HPL source obtained from git fallback; skipping tarball sha256 check ==="
|
||||
fi
|
||||
echo "sha256 OK: hpl-${HPL_VERSION}.tar.gz"
|
||||
|
||||
# ── download OpenBLAS from Debian 12 apt repo ─────────────────────────────────
|
||||
REPO_BASE="https://deb.debian.org/debian/pool/main/o/openblas"
|
||||
|
||||
@@ -10,20 +10,15 @@ import os
|
||||
|
||||
W, H = 1920, 1080
|
||||
|
||||
GLYPHS = {
|
||||
'E': ["11111", "10000", "11110", "10000", "10000", "10000", "11111"],
|
||||
'A': ["01110", "10001", "10001", "11111", "10001", "10001", "10001"],
|
||||
'S': ["01111", "10000", "10000", "01110", "00001", "00001", "11110"],
|
||||
'Y': ["10001", "10001", "01010", "00100", "00100", "00100", "00100"],
|
||||
'B': ["11110", "10001", "10001", "11110", "10001", "10001", "11110"],
|
||||
'-': ["00000", "00000", "11111", "00000", "00000", "00000", "00000"],
|
||||
}
|
||||
|
||||
TITLE = "EASY-BEE"
|
||||
SUBTITLE = "Hardware Audit LiveCD"
|
||||
CELL = 30
|
||||
GLYPH_GAP = 18
|
||||
ROW_GAP = 6
|
||||
ASCII_ART = [
|
||||
" ███████╗ █████╗ ███████╗██╗ ██╗ ██████╗ ███████╗███████╗",
|
||||
" ██╔════╝██╔══██╗██╔════╝╚██╗ ██╔╝ ██╔══██╗██╔════╝██╔════╝",
|
||||
" █████╗ ███████║███████╗ ╚████╔╝ █████╗██████╔╝█████╗ █████╗",
|
||||
" ██╔══╝ ██╔══██║╚════██║ ╚██╔╝ ╚════╝██╔══██╗██╔══╝ ██╔══╝",
|
||||
" ███████╗██║ ██║███████║ ██║ ██████╔╝███████╗███████╗",
|
||||
" ╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═════╝ ╚══════╝╚══════╝",
|
||||
]
|
||||
SUBTITLE = " Hardware Audit LiveCD"
|
||||
|
||||
FG = (0xF6, 0xD0, 0x47)
|
||||
FG_DIM = (0xD4, 0xA9, 0x1C)
|
||||
@@ -31,6 +26,12 @@ SHADOW = (0x5E, 0x47, 0x05)
|
||||
SUB = (0x96, 0x7A, 0x17)
|
||||
BG = (0x05, 0x05, 0x05)
|
||||
|
||||
MONO_FONT_CANDIDATES = [
|
||||
'/usr/share/fonts/truetype/dejavu/DejaVuSansMono-Bold.ttf',
|
||||
'/usr/share/fonts/truetype/liberation2/LiberationMono-Bold.ttf',
|
||||
'/usr/share/fonts/truetype/liberation/LiberationMono-Bold.ttf',
|
||||
'/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf',
|
||||
]
|
||||
SUB_FONT_CANDIDATES = [
|
||||
'/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf',
|
||||
'/usr/share/fonts/truetype/liberation2/LiberationSans-Bold.ttf',
|
||||
@@ -39,43 +40,34 @@ SUB_FONT_CANDIDATES = [
|
||||
]
|
||||
|
||||
|
||||
def load_font(size):
|
||||
for path in SUB_FONT_CANDIDATES:
|
||||
def load_font(candidates, size):
|
||||
for path in candidates:
|
||||
if os.path.exists(path):
|
||||
return ImageFont.truetype(path, size)
|
||||
return ImageFont.load_default()
|
||||
|
||||
|
||||
def glyph_width(ch):
|
||||
return len(GLYPHS[ch][0])
|
||||
def mono_metrics(font):
|
||||
probe = Image.new('L', (W, H), 0)
|
||||
draw = ImageDraw.Draw(probe)
|
||||
char_w = int(round(draw.textlength("M", font=font)))
|
||||
bb = draw.textbbox((0, 0), "Mg", font=font)
|
||||
char_h = bb[3] - bb[1]
|
||||
return char_w, char_h
|
||||
|
||||
|
||||
def render_logo_mask():
|
||||
width_cells = 0
|
||||
for idx, ch in enumerate(TITLE):
|
||||
width_cells += glyph_width(ch)
|
||||
if idx != len(TITLE) - 1:
|
||||
width_cells += 1
|
||||
mask_w = width_cells * CELL + (len(TITLE) - 1) * GLYPH_GAP
|
||||
mask_h = 7 * CELL + 6 * ROW_GAP
|
||||
mask = Image.new('L', (mask_w, mask_h), 0)
|
||||
def render_ascii_mask(font, lines, char_w, char_h, line_gap):
|
||||
width = max(len(line) for line in lines) * char_w
|
||||
height = len(lines) * char_h + line_gap * (len(lines) - 1)
|
||||
mask = Image.new('L', (width, height), 0)
|
||||
draw = ImageDraw.Draw(mask)
|
||||
|
||||
cx = 0
|
||||
for idx, ch in enumerate(TITLE):
|
||||
glyph = GLYPHS[ch]
|
||||
for row_idx, row in enumerate(glyph):
|
||||
for col_idx, cell in enumerate(row):
|
||||
if cell != '1':
|
||||
continue
|
||||
x0 = cx + col_idx * CELL
|
||||
y0 = row_idx * (CELL + ROW_GAP)
|
||||
x1 = x0 + CELL - 4
|
||||
y1 = y0 + CELL - 4
|
||||
draw.rounded_rectangle((x0, y0, x1, y1), radius=4, fill=255)
|
||||
cx += glyph_width(ch) * CELL
|
||||
if idx != len(TITLE) - 1:
|
||||
cx += CELL + GLYPH_GAP
|
||||
for row, line in enumerate(lines):
|
||||
y = row * (char_h + line_gap)
|
||||
for col, ch in enumerate(line):
|
||||
if ch == ' ':
|
||||
continue
|
||||
x = col * char_w
|
||||
draw.text((x, y), ch, font=font, fill=255)
|
||||
return mask
|
||||
|
||||
|
||||
@@ -90,20 +82,22 @@ glow_draw.ellipse((520, 340, 1400, 760), fill=(255, 190, 40, 36))
|
||||
glow = glow.filter(ImageFilter.GaussianBlur(60))
|
||||
img = Image.alpha_composite(img.convert('RGBA'), glow)
|
||||
|
||||
logo_mask = render_logo_mask()
|
||||
font_logo = load_font(MONO_FONT_CANDIDATES, 64)
|
||||
char_w, char_h = mono_metrics(font_logo)
|
||||
logo_mask = render_ascii_mask(font_logo, ASCII_ART, char_w, char_h, 8)
|
||||
logo_w, logo_h = logo_mask.size
|
||||
logo_x = (W - logo_w) // 2
|
||||
logo_y = 290
|
||||
logo_y = 270
|
||||
|
||||
shadow_mask = logo_mask.filter(ImageFilter.GaussianBlur(2))
|
||||
img.paste(SHADOW, (logo_x + 16, logo_y + 14), shadow_mask)
|
||||
img.paste(FG_DIM, (logo_x + 8, logo_y + 7), logo_mask)
|
||||
img.paste(FG, (logo_x, logo_y), logo_mask)
|
||||
|
||||
font_sub = load_font(30)
|
||||
font_sub = load_font(SUB_FONT_CANDIDATES, 30)
|
||||
sub_bb = draw.textbbox((0, 0), SUBTITLE, font=font_sub)
|
||||
sub_x = (W - (sub_bb[2] - sub_bb[0])) // 2
|
||||
sub_y = logo_y + logo_h + 54
|
||||
sub_y = logo_y + logo_h + 48
|
||||
draw = ImageDraw.Draw(img)
|
||||
draw.text((sub_x + 2, sub_y + 2), SUBTITLE, font=font_sub, fill=(35, 28, 6))
|
||||
draw.text((sub_x, sub_y), SUBTITLE, font=font_sub, fill=SUB)
|
||||
|
||||
Reference in New Issue
Block a user