From: AJ ONeal Date: Sat, 19 Sep 2020 08:56:24 +0000 (+0000) Subject: add mholt/archiver X-Git-Url: https://git.josue.xyz/?a=commitdiff_plain;h=d4de3b49ef9bdf61c11a693855711d0fa05dcbe9;p=webi-installers%2F.git add mholt/archiver --- diff --git a/arc/README.md b/arc/README.md new file mode 100644 index 0000000..f7099bf --- /dev/null +++ b/arc/README.md @@ -0,0 +1,78 @@ +--- +title: Archiver (arc) +homepage: https://github.com/mholt/archiver +tagline: | + Arc is a cross-platform, multi-format archive utility. +--- + +## Updating `arc` + +`webi arc@stable` + +Use the `@beta` tag for pre-releases. + +## Cheat Sheet + +> Archiver (`arc`) is a powerful and flexible library meets an elegant CLI in +> this generic replacement for several platform-specific or format-specific +> archive utilities. + +Much like MacOS Finder and Windows Explorer, the default behavior of `arc` is to +create a top-level directory if one does not exist. + +### List + +```txt +# arc ls +arc ls example.zip +``` + +### Unarchive (whole) + +```txt +# arc unarchive +arc unarchive example.zip +``` + +### Extract (partial) + +```txt +# arc extract +arc extract example.zip example/foo ~/Downloads/foo +``` + +### Archive (recursive) + +```txt +# arc archive +arc archive example.zip ./README.md ./bin ./src +``` + +### Compress (single file) + +```txt +# arc compress +arc compress ./example.tar xz +``` + +### Decompress (single file) + +```txt +# arc decompress +arc decompress ./example.tar.xz +``` + +## Supported extensions + +| format | packaged | raw compressed | +| ------ | --------------- | -------------- | +| RAR | .rar | - | +| - | .tar | - | +| brotli | .tar.br, .tbr | .br | +| gzip | .tar.gz, .tgz | .gz | +| bzip2 | .tar.bz2, .tbz2 | .bz2 | +| xz | .tar.xz, .txz | .xz | +| lzma | .tar.lz4, .tlz4 | .lz4 | +| snappy | .tar.sz, .tsz | .lsz | +| zstd | .tar.zst | .zst | +| ZIP | .zip | - | diff --git a/arc/install.ps1 b/arc/install.ps1 new file mode 100644 index 0000000..9708032 --- /dev/null +++ b/arc/install.ps1 @@ -0,0 +1,55 @@ +#!/usr/bin/env pwsh + +#################### +# Install archiver # +#################### + +# Every package should define these variables +$pkg_cmd_name = "arc" + +$pkg_dst_cmd = "$Env:USERPROFILE\.local\bin\arc.exe" +$pkg_dst = "$pkg_dst_cmd" + +$pkg_src_cmd = "$Env:USERPROFILE\.local\opt\archiver-v$Env:WEBI_VERSION\bin\arc.exe" +$pkg_src_bin = "$Env:USERPROFILE\.local\opt\archiver-v$Env:WEBI_VERSION\bin" +$pkg_src_dir = "$Env:USERPROFILE\.local\opt\archiver-v$Env:WEBI_VERSION" +$pkg_src = "$pkg_src_cmd" + +$pkg_download = "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE" + +# Fetch archive +IF (!(Test-Path -Path "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE")) +{ + # TODO: arch detection + echo "Downloading archiver from $Env:WEBI_PKG_URL to $pkg_download" + & curl.exe -A "$Env:WEBI_UA" -fsSL "$Env:WEBI_PKG_URL" -o "$pkg_download.part" + & move "$pkg_download.part" "$pkg_download" +} + +IF (!(Test-Path -Path "$pkg_src_cmd")) +{ + echo "Installing archiver" + + # TODO: create package-specific temp directory + # Enter tmp + pushd .local\tmp + + # Remove any leftover tmp cruft + Remove-Item -Path ".\arc-*" -Recurse -ErrorAction Ignore + Remove-Item -Path ".\arc.exe" -Recurse -ErrorAction Ignore + + # Move single binary into root of temporary folder + & move "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE" "arc.exe" + + # Settle unpacked archive into place + echo "Install Location: $pkg_src_cmd" + New-Item "$pkg_src_bin" -ItemType Directory -Force + Move-Item -Path "arc.exe" -Destination "$pkg_src_bin" + + # Exit tmp + popd +} + +echo "Copying into '$pkg_dst_cmd' from '$pkg_src_cmd'" +Remove-Item -Path "$pkg_dst_cmd" -Recurse -ErrorAction Ignore +Copy-Item -Path "$pkg_src" -Destination "$pkg_dst" -Recurse diff --git a/arc/install.sh b/arc/install.sh new file mode 100644 index 0000000..81fb65f --- /dev/null +++ b/arc/install.sh @@ -0,0 +1,35 @@ +{ + set -e + set -u + + #################### + # Install archiver # + #################### + + # Every package should define these 6 variables + pkg_cmd_name="arc" + + pkg_dst_cmd="$HOME/.local/bin/arc" + pkg_dst="$pkg_dst_cmd" + + pkg_src_cmd="$HOME/.local/opt/archiver-v$WEBI_VERSION/bin/arc" + pkg_src_dir="$HOME/.local/opt/archiver-v$WEBI_VERSION" + pkg_src="$pkg_src_cmd" + + # pkg_install must be defined by every package + pkg_install() { + # ~/.local/opt/arc-v3.2.0/bin + mkdir -p "$(dirname $pkg_src_cmd)" + + # mv ./arc_* ~/.local/opt/arc-v3.2.0/bin/arc + mv ./arc_* "$pkg_src_cmd" + } + + # pkg_get_current_version is recommended, but (soon) not required + pkg_get_current_version() { + # 'arc version' has no version output + # TODO https://github.com/mholt/archiver/issues/196 + #echo $(arc version 2>/dev/null | head -n 1 | cut -d ' ' -f 2) + echo v0.0.0 + } +} diff --git a/arc/releases.js b/arc/releases.js new file mode 100644 index 0000000..6ff07da --- /dev/null +++ b/arc/releases.js @@ -0,0 +1,20 @@ +'use strict'; + +var github = require('../_common/github.js'); +var owner = 'mholt'; +var repo = 'archiver'; + +module.exports = function (request) { + return github(request, owner, repo).then(function (all) { + return all; + }); +}; + +if (module === require.main) { + module.exports(require('@root/request')).then(function (all) { + all = require('../_webi/normalize.js')(all); + // just select the first 5 for demonstration + all.releases = all.releases.slice(0, 5); + console.info(JSON.stringify(all, null, 2)); + }); +}