diff --git a/play.it-2/src/20_dependencies.sh b/play.it-2/src/20_dependencies.sh index a3c24201328a5f08a463f3da0ebb25e231e13221..de71413917f20d420fe8bee32183e2fd54cd9684 100644 --- a/play.it-2/src/20_dependencies.sh +++ b/play.it-2/src/20_dependencies.sh @@ -10,7 +10,7 @@ check_deps() { SCRIPT_DEPS="$SCRIPT_DEPS cabextract" ;; ('debian') - SCRIPT_DEPS="$SCRIPT_DEPS dpkg" + SCRIPT_DEPS="$SCRIPT_DEPS debian" ;; ('innosetup1.7'*) SCRIPT_DEPS="$SCRIPT_DEPS innoextract1.7" @@ -59,6 +59,9 @@ check_deps() { ('innoextract'*) check_deps_innoextract "$dep" ;; + ('debian') + check_deps_deb + ;; (*) if ! command -v "$dep" >/dev/null 2>&1; then check_deps_error_not_found "$dep" @@ -139,3 +142,45 @@ check_deps_error_not_found() { return 1 } +# check presence of a software to handle .deb archives +# USAGE: check_deps_deb +# CALLS: check_deps_error_not_found +# CALLED BY: check_deps +check_deps_deb() { + if command -v dpkg-deb >/dev/null 2>&1; then + extract_deb() { dpkg-deb --extract "$1" "$2"; } + elif command -v bsdtar >/dev/null 2>&1; then + extract_deb() { bsdtar --extract --to-stdout --file "$1" 'data*' | bsdtar --directory "$2" --extract --file /dev/stdin; } + elif command -v unar >/dev/null 2>&1; then + extract_deb() { + [ -d "$PLAYIT_WORKDIR/extraction" ] || mkdir "$PLAYIT_WORKDIR/extraction" + unar -output-directory "$PLAYIT_WORKDIR/extraction" -force-overwrite -no-directory "$1" 'data*' 1>/dev/null + unar -output-directory "$2" -force-overwrite -no-directory "$PLAYIT_WORKDIR/extraction"/data* 1>/dev/null + rm --recursive --force "$PLAYIT_WORKDIR/extraction" + } + elif command -v tar >/dev/null 2>&1; then + if command -v 7z >/dev/null 2>&1; then + extract_deb() { 7z x -i'!data*' -so "$1" | tar --directory "$2" --extract; } + elif command -v 7zr >/dev/null 2>&1; then + extract_deb() { 7zr x -so "$1" | tar --directory "$2" --extract; } + elif command -v ar >/dev/null 2>&1; then + extract_deb() { + [ -d "$PLAYIT_WORKDIR/extraction" ] || mkdir "$PLAYIT_WORKDIR/extraction" + local archive_absolute_path + archive_absolute_path="$(realpath --canonicalize-existing "$1")" + ( + cd "$PLAYIT_WORKDIR/extraction" + ar x "$archive_absolute_path" "$(ar t "$archive_absolute_path" | grep ^data)" + + ) + tar --directory "$2" --extract --file "$PLAYIT_WORKDIR/extraction"/data* + rm --recursive --force "$PLAYIT_WORKDIR/extraction" + } + else + check_deps_error_not_found 'dpkg-deb/bsdtar/unar/p7zip/ar' + fi + else + check_deps_error_not_found 'dpkg-deb/bsdtar/unar/tar' + fi +} + diff --git a/play.it-2/src/30_archive-extraction.sh b/play.it-2/src/30_archive-extraction.sh index deaf4b67401ddc30a191cfef81118ea4f7b29c8c..114439010cd697484be19daf6139bec88f5e42be 100644 --- a/play.it-2/src/30_archive-extraction.sh +++ b/play.it-2/src/30_archive-extraction.sh @@ -26,7 +26,7 @@ extract_data_from() { cabextract -L -d "$destination" -q "$file" ;; ('debian') - dpkg-deb --extract "$file" "$destination" + extract_deb "$file" "$destination" ;; ('innosetup'*) archive_extraction_innosetup "$archive_type" "$file" "$destination"