Skip to content

Commit

Permalink
merge setup-util-{unzip,tar} and add support for xz
Browse files Browse the repository at this point in the history
  • Loading branch information
balupton committed Aug 24, 2023
1 parent cf062e2 commit 036fad3
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 74 deletions.
23 changes: 21 additions & 2 deletions commands/get-installer
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ function get_installer() (
aliases['fmt']='setup-util-coreutils'
aliases['fold']='setup-util-coreutils'
aliases['funzip']='setup-util-unzip'
aliases['funzip']='setup-util-unziptar'
aliases['fusermount']='setup-util-fuse'
aliases['fusermount3']='setup-util-fuse'
aliases['gem']='setup-ruby'
Expand All @@ -80,12 +81,12 @@ function get_installer() (
aliases['greadlink']='setup-util-coreutils'
aliases['groups']='setup-util-coreutils'
aliases['gxps']='setup-util-ghostscript'
aliases['http']='setup-util-httpie'
aliases['https']='setup-util-httpie'
aliases['hdparam']='setup-util-devices'
aliases['hdparm']='setup-util-devices'
aliases['head']='setup-util-coreutils'
aliases['hostid']='setup-util-coreutils'
aliases['http']='setup-util-httpie'
aliases['https']='setup-util-httpie'
aliases['id']='setup-util-coreutils'
aliases['ifconfig']='setup-util-netstat'
aliases['ifdata']='setup-util-moreutils'
Expand All @@ -109,6 +110,7 @@ function get_installer() (
aliases['ls']='setup-util-coreutils'
aliases['lshw']='setup-util-devices'
aliases['luajit']='setup-util-neovim'
aliases['lzmainfo']='setup-util-unziptar'
aliases['make']='setup-util-devel'
aliases['md5sum.textutils']='setup-util-coreutils'
aliases['md5sum']='setup-util-coreutils'
Expand Down Expand Up @@ -171,6 +173,7 @@ function get_installer() (
aliases['resilio-sync']='setup-util-resilio'
aliases['rm']='setup-util-coreutils'
aliases['rmdir']='setup-util-coreutils'
aliases['rmt-tar']='setup-util-unziptar'
aliases['route']='setup-util-netstat'
aliases['rpi-eeprom']='setup-linux-raspi'
aliases['ruby']='setup-ruby'
Expand Down Expand Up @@ -216,6 +219,8 @@ function get_installer() (
aliases['sync']='setup-util-coreutils'
aliases['tac']='setup-util-coreutils'
aliases['tail']='setup-util-coreutils'
aliases['tar']='setup-util-unziptar'
aliases['tarcat']='setup-util-unziptar'
aliases['tee']='setup-util-coreutils'
aliases['test']='setup-util-coreutils'
aliases['testparm']='setup-util-samba'
Expand All @@ -232,7 +237,10 @@ function get_installer() (
aliases['unexpand']='setup-util-coreutils'
aliases['uniq']='setup-util-coreutils'
aliases['unlink']='setup-util-coreutils'
aliases['unxz']='setup-util-unziptar'
aliases['unzip']='setup-util-unziptar'
aliases['unzipsfx']='setup-util-unzip'
aliases['unzipsfx']='setup-util-unziptar'
aliases['users']='setup-util-coreutils'
aliases['vdir']='setup-util-coreutils'
aliases['vidir']='setup-util-moreutils'
Expand All @@ -242,9 +250,20 @@ function get_installer() (
aliases['wc']='setup-util-coreutils'
aliases['who']='setup-util-coreutils'
aliases['whoami']='setup-util-coreutils'
aliases['xz']='setup-util-unziptar'
aliases['xzcat']='setup-util-unziptar'
aliases['xzcmp']='setup-util-unziptar'
aliases['xzdiff']='setup-util-unziptar'
aliases['xzegrep']='setup-util-unziptar'
aliases['xzfgrep']='setup-util-unziptar'
aliases['xzgrep']='setup-util-unziptar'
aliases['xzless']='setup-util-unziptar'
aliases['xzmore']='setup-util-unziptar'
aliases['yes']='setup-util-coreutils'
aliases['zipgrep']='setup-util-unzip'
aliases['zipgrep']='setup-util-unziptar'
aliases['zipinfo']='setup-util-unzip'
aliases['zipinfo']='setup-util-unziptar'
aliases['zrun']='setup-util-moreutils'

# testing
Expand Down
35 changes: 0 additions & 35 deletions commands/setup-util-tar

This file was deleted.

35 changes: 0 additions & 35 deletions commands/setup-util-unzip

This file was deleted.

86 changes: 86 additions & 0 deletions commands/setup-util-unziptar
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/usr/bin/env bash

# https://repology.org/project/tar/versions
# https://packages.debian.org/sid/amd64/tar/filelist
# /bin/tar
# /usr/sbin/rmt-tar
# /usr/sbin/tarcat

# https://repology.org/project/xz-utils/versions
# https://packages.debian.org/sid/amd64/xz-utils/filelist
# /usr/bin/lzmainfo
# /usr/bin/unxz
# /usr/bin/xz
# /usr/bin/xzcat
# /usr/bin/xzcmp
# /usr/bin/xzdiff
# /usr/bin/xzegrep
# /usr/bin/xzfgrep
# /usr/bin/xzgrep
# /usr/bin/xzless
# /usr/bin/xzmore

# https://packages.debian.org/sid/amd64/unzip/filelist
# /usr/bin/funzip
# /usr/bin/unzip
# /usr/bin/unzipsfx
# /usr/bin/zipgrep
# /usr/bin/zipinfo

function setup_util_unziptar() (
source "$DOROTHY/sources/bash.bash"
local options

# tar
if test "$*" != '--quiet' || command-missing tar; then
options=(
--cli='tar'
"$@"
APK='tar'
APT='tar'
AUR='tar'
NIX='gnutar'
RPM='tar'
ZYPPER='tar'
)
setup-util "${options[@]}"
fi

# xz
if test "$*" != '--quiet' || command-missing xz; then
options=(
--cli='xz'
"$@"
APK='xz'
APT='xz-utils'
AUR='xz'
GENTOO='app-arch/xz-utils'
MAGEIA='xz'
NIX='xz'
RPM='xz'
VOID='xz'
ZYPPER='xz'
)
setup-util "${options[@]}"
fi

# unzip
if test "$*" != '--quiet' || command-missing unzip; then
options=(
--cli='unzip'
"$@"
APK='unzip'
APT='unzip'
AUR='unzip'
BREW='unzip'
RPM='unzip'
ZYPPER='unzip'
)
setup-util "${options[@]}"
fi
)

# fire if invoked standalone
if test "$0" = "${BASH_SOURCE[0]}"; then
setup_util_unziptar "$@"
fi
4 changes: 2 additions & 2 deletions commands/unziptar
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ function unziptar() (
cp -Rfv "$@"
}
elif test "$format" = 'zip'; then
setup-util-unzip --quiet
setup-util-unziptar --quiet
unzip -u "$archive"
elif test "$format" = 'tar'; then
setup-util-tar --quiet
setup-util-unziptar --quiet
tar -xvf "$archive"
# don't use -z flag, as that enforces gzip (tar.xy) which is not valid for (.tar.xz)
# without -z, auto-detection is used
Expand Down

0 comments on commit 036fad3

Please sign in to comment.