mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-26 03:47:35 +00:00
Numerous improvement to extract-deb-pkg, in no particular order: * Use bash * More strict error checking (set -u -o pipefail) * Print error message if target dir exists * Check number of arguments, provide usage info * Separate mirror to a variable for easier changing * Use mirrors.kernel.org * Use https and check cert with curl * Make curl silent * Use zgrep instead of gunzip | grep * Error out with a message in case more than 1 package was found * Do not create a target directory before we need it * Fix shellcheck warnings (way too many to mention) * ... * PROFIT!!!111 Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
37 lines
650 B
Bash
Executable File
37 lines
650 B
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
set -u
|
|
set -o pipefail
|
|
MIRROR="https://mirrors.kernel.org/ubuntu"
|
|
PKGS="$MIRROR/dists/xenial/universe/binary-amd64/Packages.gz"
|
|
|
|
if [ $# -ne 1 ]; then
|
|
echo "Usage: $0 package-name" 1>&2
|
|
exit 1
|
|
fi
|
|
|
|
if [ -d "$1" ]; then
|
|
echo "Directory $1 already exists -- exiting"
|
|
exit 0
|
|
fi
|
|
|
|
if ! pkg=$(curl -sSL "$PKGS" | zgrep "Filename.*$1" | awk '{ print $2 }'); then
|
|
echo "ERROR: no packages matching $1" 1>&2
|
|
exit 1
|
|
fi
|
|
|
|
if [ "$(wc -w <<< "$pkg")" -gt 1 ]; then
|
|
echo "$pkg" 1>&2
|
|
echo "ERROR: more than one match for $1" 1>&2
|
|
exit 1
|
|
fi
|
|
|
|
mkdir "$1"
|
|
cd "$1"
|
|
|
|
wget "$MIRROR/$pkg"
|
|
pkg=$(basename "$pkg")
|
|
ar vx "$pkg"
|
|
tar xJvf data.tar.xz
|