mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-03-03 15:38:22 +00:00
This is a recently introduced Linux Kernel feature that gives people like Debian package mantainers the power to arbitrarily redefine how executables are interpreted by the kernel. If your system gets tuned this way and you're not able to disable it, then you need to restore default behavior for the APE MZqFpD prefix as follows: sudo sh -c "echo ':APE:M::MZqFpD::/bin/sh:' >/proc/sys/fs/binfmt_misc/register" This prefix will cover all .com executables built with this tooling. Please don't run the above command unless you're certain you need it. See #2 for additional context.
82 lines
1.8 KiB
Bash
Executable file
82 lines
1.8 KiB
Bash
Executable file
#!/bin/sh
|
|
#-*-mode:sh;indent-tabs-mode:nil;tab-width:2;coding:utf-8-*-┐
|
|
#───vi: set net ft=sh ts=2 sts=2 fenc=utf-8 :vi─────────────┘
|
|
#
|
|
# OVERVIEW
|
|
#
|
|
# GNU Archiver Veneer
|
|
#
|
|
# DESCRIPTION
|
|
#
|
|
# This script wraps normal archive commands that're transparently
|
|
# passed-through. It adds value too, by addressing difficulties
|
|
# that would normally cause a developer to need `make clean`.
|
|
#
|
|
# EXAMPLE
|
|
#
|
|
# build/archive ar rcsD library.a foo.o ...
|
|
|
|
if [ ! -d o/third_party/gcc ]; then
|
|
third_party/gcc/unbundle.sh
|
|
fi
|
|
|
|
export LC_ALL=C
|
|
RM=${RM:-$(command -v rm) -f} || exit
|
|
MKDIR=${MKDIR:-$(command -v mkdir) -p} || exit
|
|
|
|
AR=$1
|
|
ARFLAGS=$2
|
|
OUT=$3
|
|
shift 3
|
|
|
|
# remove directory arguments (having .a targets depend on dirs is what
|
|
# lets them be invalidated by deleted files)
|
|
FIRST=1
|
|
for x; do
|
|
if [ $FIRST -eq 1 ]; then
|
|
set --
|
|
FIRST=0
|
|
fi
|
|
if [ -d "$x" ]; then
|
|
if [ -f "$OUT" ] && [ "$x" -nt "$OUT" ]; then
|
|
$RM "$OUT"
|
|
fi
|
|
continue
|
|
fi
|
|
if [ "$x" != "${x%.o}" ]; then
|
|
set -- "$@" "$x"
|
|
fi
|
|
done
|
|
|
|
set -- "$AR" "$ARFLAGS" "$OUT" "$@"
|
|
printf %s\\n "$*" >"$OUT.cmd"
|
|
|
|
OUTDIR="${OUT%/*}"
|
|
if [ "$OUTDIR" != "$OUT" ] && [ ! -d "$OUTDIR" ]; then
|
|
$MKDIR "$OUTDIR" || exit 2
|
|
fi
|
|
|
|
printf "$LOGFMT" "${ACTION:-ARCHIVE.a}" "$OUT" >&2
|
|
# if [ "$SILENT" = "0" ]; then
|
|
# # some of these windows nt archives are quite huge
|
|
# COLUMNS=${COLUMNS:-80}
|
|
# COLUMNS=$((COLUMNS - 4))
|
|
# printf "%s\n" "$*" |
|
|
# /usr/bin/fold -s -w $COLUMNS |
|
|
# sed -e '1bb' -e 's/^/ /' -e ':b' -e '$b' -e 's/$/ \\/' >&2
|
|
# else
|
|
# printf "$LOGFMT" "${ACTION:-ARCHIVE.a}" "$OUT" >&2
|
|
# fi
|
|
|
|
REASON=failed
|
|
trap REASON=interrupted INT
|
|
|
|
"$@" >/dev/null && exit
|
|
|
|
if [ "$TERM" = "dumb" ]; then
|
|
f='%s %s\r\n\r\n'
|
|
else
|
|
f='\033[91m%s\033[39m \033[94m%s\033[39m\r\n\r\n'
|
|
fi
|
|
printf "$f" "archive $REASON:" "$*" >&2
|
|
exit 1
|