add mholt/archiver

This commit is contained in:
AJ ONeal
2020-09-23 02:20:54 +00:00
parent b60b4619ba
commit d4de3b49ef
4 changed files with 188 additions and 0 deletions
+78
View File
@@ -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 <archive file>
arc ls example.zip
```
### Unarchive (whole)
```txt
# arc unarchive <archive file>
arc unarchive example.zip
```
### Extract (partial)
```txt
# arc extract <archive file> <archived path> <extracted path>
arc extract example.zip example/foo ~/Downloads/foo
```
### Archive (recursive)
```txt
# arc archive <archive file> <files or folders ...>
arc archive example.zip ./README.md ./bin ./src
```
### Compress (single file)
```txt
# arc compress <single file> <format>
arc compress ./example.tar xz
```
### Decompress (single file)
```txt
# arc decompress <archive file>
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 | - |
+55
View File
@@ -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
+35
View File
@@ -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
}
}
+20
View File
@@ -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));
});
}