wow
This commit is contained in:
parent
9f864c63de
commit
41c0069730
8 changed files with 474 additions and 89 deletions
39
modules/mizukios/features/packages/docker2libc.nix
Normal file
39
modules/mizukios/features/packages/docker2libc.nix
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
{ pkgs }:
|
||||
pkgs.writeShellApplication {
|
||||
name = "nr";
|
||||
|
||||
runtimeInputs = with pkgs; [
|
||||
nix-output-monitor
|
||||
openssh
|
||||
coreutils
|
||||
nix
|
||||
attic-client
|
||||
];
|
||||
|
||||
text = ''
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
image="${1:-tmp-elf-extract}"
|
||||
|
||||
docker build -t "$image" .
|
||||
|
||||
cid="$(docker create "$image" /bin/true)"
|
||||
cleanup() {
|
||||
docker rm -f "$cid" >/dev/null 2>&1 || true
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
libc_path="$(docker run --rm --entrypoint /bin/sh "$image" -c 'for p in /lib/x86_64-linux-gnu/libc.so.6 /usr/lib/x86_64-linux-gnu/libc.so.6 /lib64/libc.so.6 /lib/libc.so.6; do if [ -e "$p" ]; then echo "$p"; exit 0; fi; done; exit 1')"
|
||||
ld_path="$(docker run --rm --entrypoint /bin/sh "$image" -c 'for p in /lib64/ld-linux-x86-64.so.2 /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 /lib/ld-linux-x86-64.so.2; do if [ -e "$p" ]; then echo "$p"; exit 0; fi; done; find /lib /usr/lib /lib64 -type f \( -name "ld-linux*.so*" -o -name "ld-*.so*" \) 2>/dev/null | head -n 1')"
|
||||
|
||||
[ -n "$libc_path" ] || { echo "libc.so.6 not found" >&2; exit 1; }
|
||||
[ -n "$ld_path" ] || { echo "ld-linux not found" >&2; exit 1; }
|
||||
|
||||
docker cp -L "${cid}:${libc_path}" ./libc.so.6
|
||||
docker cp -L "${cid}:${ld_path}" ./ld-linux-x86-64.so.2
|
||||
|
||||
file libc.so.6 ld-linux-x86-64.so.2
|
||||
ls -lh libc.so.6 ld-linux-x86-64.so.2
|
||||
'';
|
||||
}
|
||||
Loading…
Reference in a new issue