initial commit
This commit is contained in:
commit
459dd0f32e
1 changed files with 64 additions and 0 deletions
64
apt-satisfy
Executable file
64
apt-satisfy
Executable file
|
@ -0,0 +1,64 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
depends=$@
|
||||||
|
|
||||||
|
edspfile=$(mktemp)
|
||||||
|
solution=$(mktemp)
|
||||||
|
|
||||||
|
trap "rm -r \"$edspfile\" \"$solution\"" EXIT
|
||||||
|
|
||||||
|
# simulate installation of a random package - we choose apt because that has to exist
|
||||||
|
#
|
||||||
|
# we expect the dump solver to fail with exit 100
|
||||||
|
APT_EDSP_DUMP_FILENAME="$edspfile" apt-get --simulate install --solver dump apt >/dev/null 2>&1 && [ $? -eq 100 ]
|
||||||
|
|
||||||
|
request=$(grep-dctrl -F Request '' -s Request -n "$edspfile")
|
||||||
|
architecture=$(grep-dctrl -F Request '' -s Architecture -n "$edspfile")
|
||||||
|
architectures=$(grep-dctrl -F Request '' -s Architectures -n "$edspfile")
|
||||||
|
|
||||||
|
# generate the APT-ID of the dummy package from the largest id plus one
|
||||||
|
newid=$(grep-dctrl -F Package '' -s APT-ID -n "$edspfile" | sort -n | tail -1)
|
||||||
|
newid=$((newid+1))
|
||||||
|
|
||||||
|
# Replace the EDSP header and add a dummy package at the top
|
||||||
|
#
|
||||||
|
# We pass some custom options to /usr/lib/apt/solvers/apt because while it
|
||||||
|
# still needs access to the system's apt config, the presence of some settings
|
||||||
|
# will let it error out.
|
||||||
|
{
|
||||||
|
cat << END
|
||||||
|
Request: $request
|
||||||
|
Architecture: $architecture
|
||||||
|
Architectures: $architectures
|
||||||
|
Install: apt-satisfy-dummy:$architecture
|
||||||
|
|
||||||
|
Package: apt-satisfy-dummy
|
||||||
|
Architecture: $architecture
|
||||||
|
Version: 1
|
||||||
|
APT-ID: $newid
|
||||||
|
Depends: $depends
|
||||||
|
APT-Pin: 990
|
||||||
|
|
||||||
|
END
|
||||||
|
grep-dctrl -F Package '' "$edspfile";
|
||||||
|
} | /usr/lib/apt/solvers/apt -o APT::Default-Release="" > "$solution"
|
||||||
|
|
||||||
|
# FIXME: instead of using grep and cat we want to use grep-dctrl but
|
||||||
|
# unfortunately the EDSP that /usr/lib/apt/solvers/apt outputs is not valid
|
||||||
|
# deb822
|
||||||
|
if grep Error: "$solution"; then
|
||||||
|
cat "$solution"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
selector=$(grep-dctrl -F Install '' -n -s Install "$solution" | paste -s -d"|")
|
||||||
|
|
||||||
|
install=$(grep-dctrl --eregex -F APT-ID "^($selector)$" -n -s Package,Architecture,Version "$edspfile" \
|
||||||
|
| paste -sd ":= " )
|
||||||
|
echo apt install $install
|
||||||
|
|
||||||
|
auto=$(grep-dctrl --eregex -F APT-ID "^($selector)$" -n -s Package,Architecture "$edspfile" \
|
||||||
|
| paste -sd ": " )
|
||||||
|
echo apt-mark auto $auto
|
Loading…
Reference in a new issue