| 1 | # begin arch-check-hook |
| 2 | |
| 3 | # The line "# begin arch-check-hook" is used to check if the hook |
| 4 | # has been installed. |
| 5 | |
| 6 | # $1 - file to check |
| 7 | # $2 - architecture to check file against |
| 8 | check_file_archscip-shell shell debian-crossgrader 0.0.3+nmu5 check_file_arch(). () { |
| 9 | local arch_match arch_match_output |
| 10 | arch_match_output=$(python3scip-shell system . . python3. -c "import sys; from debian_crossgrader.utils.elf import e_machine; val=e_machine('${1}'); sys.exit(0 if val is None else val != e_machine('/usr/bin/dpkg'))") |
| 11 | arch_match=${?} |
| 12 | |
| 13 | # do not print trailing newline to prevent unnecessary prepending |
| 14 | printfscip-shell system . . printf. '%s' "${arch_match_output}" | sedscip-shell system . . sed. 's/^/crossgrader initramfs hook: /' |
| 15 | |
| 16 | if [scip-shell system . . `[`. ${arch_match} -ne 0 ]; then |
| 17 | echoscip-shell system . . echo. "crossgrader initramfs hook: (WARNING) initramfs binary ${1} might not be in the correct architecture." |
| 18 | echoscip-shell system . . echo. 'crossgrader initramfs hook: Ensure that it can be executed or crossgrade the package containing it, then update the initramfs again.' |
| 19 | echoscip-shell system . . echo. "crossgrader initramfs hook: output of \`file ${1}\`:" |
| 20 | filescip-shell system . . file. "${1}" |
| 21 | fi |
| 22 | } |
| 23 | |
| 24 | check_file_archscip-shell shell debian-crossgrader 0.0.3+nmu5 check_file_arch(). "${1}" |
| 25 | # end arch-check-hook |