mirror of
https://github.com/webinstall/webi-installers.git
synced 2026-02-14 17:49:53 +00:00
feat: add runzip for unzipping rar files
This commit is contained in:
33
runzip/README.md
Normal file
33
runzip/README.md
Normal file
@@ -0,0 +1,33 @@
|
||||
---
|
||||
title: runzip
|
||||
homepage: https://github.com/therootcompany/runzip
|
||||
tagline: |
|
||||
runzip: a cross-platform unrar alternative... for unzipping .rar files
|
||||
---
|
||||
|
||||
To update or switch versions, run `webi runzip@stable`.
|
||||
|
||||
### Files
|
||||
|
||||
These are the files / directories that are created and/or modified with this
|
||||
install:
|
||||
|
||||
```text
|
||||
~/.config/envman/PATH.env
|
||||
~/.local/bin/runzip
|
||||
```
|
||||
|
||||
## Cheat Sheet
|
||||
|
||||
> `runzip` is like `unrar`, but written in Go for security and wide
|
||||
> compatibility.
|
||||
|
||||
```sh
|
||||
# runzip <archive.rar> [./dst/]
|
||||
runzip ./backup.rar .
|
||||
```
|
||||
|
||||
```text
|
||||
extracting to temporary path 'backup.tmp/'...
|
||||
extracted to 'backup/'
|
||||
```
|
||||
55
runzip/install.ps1
Normal file
55
runzip/install.ps1
Normal file
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env pwsh
|
||||
|
||||
##################
|
||||
# Install runzip #
|
||||
##################
|
||||
|
||||
# Every package should define these variables
|
||||
$pkg_cmd_name = "runzip"
|
||||
|
||||
$pkg_dst_cmd = "$Env:USERPROFILE\.local\bin\runzip.exe"
|
||||
$pkg_dst = "$pkg_dst_cmd"
|
||||
|
||||
$pkg_src_cmd = "$Env:USERPROFILE\.local\opt\runzip-v$Env:WEBI_VERSION\bin\runzip.exe"
|
||||
$pkg_src_bin = "$Env:USERPROFILE\.local\opt\runzip-v$Env:WEBI_VERSION\bin"
|
||||
$pkg_src_dir = "$Env:USERPROFILE\.local\opt\runzip-v$Env:WEBI_VERSION"
|
||||
$pkg_src = "$pkg_src_cmd"
|
||||
|
||||
New-Item "$Env:USERPROFILE\Downloads\webi" -ItemType Directory -Force | Out-Null
|
||||
$pkg_download = "$Env:USERPROFILE\Downloads\webi\$Env:WEBI_PKG_FILE"
|
||||
|
||||
# Fetch archive
|
||||
IF (!(Test-Path -Path "$Env:USERPROFILE\Downloads\webi\$Env:WEBI_PKG_FILE")) {
|
||||
Write-Output "Downloading runzip from $Env:WEBI_PKG_URL to $pkg_download"
|
||||
& curl.exe -A "$Env:WEBI_UA" -fsSL "$Env:WEBI_PKG_URL" -o "$pkg_download.part"
|
||||
& Move-Item "$pkg_download.part" "$pkg_download"
|
||||
}
|
||||
|
||||
IF (!(Test-Path -Path "$pkg_src_cmd")) {
|
||||
Write-Output "Installing runzip"
|
||||
|
||||
# TODO: create package-specific temp directory
|
||||
# Enter tmp
|
||||
Push-Location .local\tmp
|
||||
|
||||
# Remove any leftover tmp cruft
|
||||
Remove-Item -Path ".\runzip-v*" -Recurse -ErrorAction Ignore
|
||||
Remove-Item -Path ".\runzip.exe" -Recurse -ErrorAction Ignore
|
||||
|
||||
# Unpack archive file into this temporary directory
|
||||
# Windows BSD-tar handles zip. Imagine that.
|
||||
Write-Output "Unpacking $pkg_download"
|
||||
& tar xf "$pkg_download"
|
||||
|
||||
# Settle unpacked archive into place
|
||||
Write-Output "Install Location: $pkg_src_cmd"
|
||||
New-Item "$pkg_src_bin" -ItemType Directory -Force | Out-Null
|
||||
Move-Item -Path ".\runzip.exe" -Destination "$pkg_src_bin"
|
||||
|
||||
# Exit tmp
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
Write-Output "Copying into '$pkg_dst_cmd' from '$pkg_src_cmd'"
|
||||
Remove-Item -Path "$pkg_dst_cmd" -Recurse -ErrorAction Ignore | Out-Null
|
||||
Copy-Item -Path "$pkg_src" -Destination "$pkg_dst" -Recurse
|
||||
46
runzip/install.sh
Normal file
46
runzip/install.sh
Normal file
@@ -0,0 +1,46 @@
|
||||
#!/bin/sh
|
||||
# shellcheck disable=SC2034
|
||||
|
||||
__init_runzip() {
|
||||
set -e
|
||||
set -u
|
||||
|
||||
####################
|
||||
# Install runzip #
|
||||
####################
|
||||
|
||||
# Every package should define these 6 variables
|
||||
pkg_cmd_name="runzip"
|
||||
|
||||
pkg_dst_cmd="${HOME}/.local/bin/runzip"
|
||||
pkg_dst="${pkg_dst_cmd}"
|
||||
|
||||
pkg_src_cmd="${HOME}/.local/opt/runzip-v${WEBI_VERSION}/bin/runzip"
|
||||
pkg_src_dir="${HOME}/.local/opt/runzip-v${WEBI_VERSION}"
|
||||
pkg_src="${pkg_src_cmd}"
|
||||
|
||||
pkg_install() {
|
||||
# $HOME/.local/opt/runzip-v1.0.0/bin
|
||||
mkdir -p "$(dirname "${pkg_src_cmd}")"
|
||||
|
||||
# mv ./runzip* "$HOME/.local/opt/runzip-v1.0.0/bin/runzip"
|
||||
mv ./"${pkg_cmd_name}"* "${pkg_src_cmd}"
|
||||
|
||||
# chmod a+x "$HOME/.local/opt/runzip-v1.0.0/bin/runzip"
|
||||
chmod a+x "${pkg_src_cmd}"
|
||||
}
|
||||
|
||||
pkg_get_current_version() {
|
||||
# 'runzip version' has output in this format:
|
||||
# runzip v1.0.0 (1234567) 2024-09-13T12:25:00Z
|
||||
# This trims it down to just the version number:
|
||||
# 1.0.0
|
||||
runzip --version 2> /dev/null |
|
||||
head -n 1 |
|
||||
cut -d' ' -f2 |
|
||||
sed 's:^v::'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
__init_runzip
|
||||
23
runzip/releases.js
Normal file
23
runzip/releases.js
Normal file
@@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
let Releases = module.exports;
|
||||
|
||||
let GitHub = require('../_common/github.js');
|
||||
let owner = 'therootcompany';
|
||||
let repo = 'runzip';
|
||||
|
||||
Releases.latest = async function () {
|
||||
let all = await GitHub.getAllPackages(null, owner, repo);
|
||||
return all;
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
(async function () {
|
||||
let normalize = require('../_webi/normalize.js');
|
||||
let all = await Releases.latest();
|
||||
all = normalize(all);
|
||||
// just select the first 5 for demonstration
|
||||
all.releases = all.releases.slice(0, 5);
|
||||
console.info(JSON.stringify(all, null, 2));
|
||||
})();
|
||||
}
|
||||
Reference in New Issue
Block a user