2023-11-11 21:28:58
This commit is contained in:
parent
bf42c530ff
commit
b0ae0a6632
200
.github/workflows/mirror.yml
vendored
Normal file
200
.github/workflows/mirror.yml
vendored
Normal file
|
@ -0,0 +1,200 @@
|
|||
name: 'Mirror'
|
||||
|
||||
on:
|
||||
- push
|
||||
|
||||
env:
|
||||
OWNER: '${{ github.repository_owner }}'
|
||||
USER_AGENT: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0'
|
||||
|
||||
jobs:
|
||||
|
||||
# ------------------------------------------------------------------------------------------------------------------ #
|
||||
# GitLab.
|
||||
# ------------------------------------------------------------------------------------------------------------------ #
|
||||
|
||||
mirror_gitlab:
|
||||
runs-on: ubuntu-latest
|
||||
name: 'GitLab'
|
||||
env:
|
||||
DOMAIN: 'https://gitlab.com'
|
||||
VERSION: 'v4'
|
||||
NSID: '69852292'
|
||||
steps:
|
||||
- name: 'Get repository name'
|
||||
shell: bash
|
||||
run: |
|
||||
echo "REPO_NAME=$( echo '${{ github.repository }}' | awk -F '/' '{ print $2 }' )" >> $GITHUB_ENV
|
||||
- name: 'Create repository'
|
||||
shell: bash
|
||||
run: |
|
||||
http="$( curl -s -o '/dev/null' -I -w '%{http_code}' -A '${{ env.USER_AGENT }}' '${{ env.DOMAIN }}/${{ env.OWNER }}/${{ env.REPO_NAME }}' )"
|
||||
if [[ "${http}" -ne 200 ]]; then
|
||||
curl -X POST \
|
||||
-H 'Authorization: Bearer ${{ secrets.BOT_MIRROR_TOKEN_GITLAB }}' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-A '${{ env.USER_AGENT }}' \
|
||||
'${{ env.DOMAIN }}/api/${{ env.VERSION }}/projects/' \
|
||||
-d '{"name":"${{ env.REPO_NAME }}","path":"${{ env.REPO_NAME }}","namespace_id":"${{ env.NSID }}","visibility":"public"}'
|
||||
fi
|
||||
- name: 'Mirror repository'
|
||||
uses: ghastore/github-mirror@main
|
||||
with:
|
||||
src_repo: '${{ github.server_url }}/${{ github.repository }}.git'
|
||||
src_user: '${{ secrets.BOT_MIRROR_NAME }}'
|
||||
src_token: '${{ secrets.BOT_MIRROR_TOKEN_GITHUB }}'
|
||||
dst_repo: '${{ env.DOMAIN }}/${{ env.OWNER }}/${{ env.REPO_NAME }}.git'
|
||||
dst_user: '${{ secrets.BOT_MIRROR_NAME }}'
|
||||
dst_token: '${{ secrets.BOT_MIRROR_TOKEN_GITLAB }}'
|
||||
|
||||
# ------------------------------------------------------------------------------------------------------------------ #
|
||||
# Codeberg.
|
||||
# ------------------------------------------------------------------------------------------------------------------ #
|
||||
|
||||
mirror_codeberg:
|
||||
runs-on: ubuntu-latest
|
||||
name: 'Codeberg'
|
||||
env:
|
||||
DOMAIN: 'https://codeberg.org'
|
||||
VERSION: 'v1'
|
||||
steps:
|
||||
- name: 'Get repository name'
|
||||
shell: bash
|
||||
run: |
|
||||
echo "REPO_NAME=$( echo '${{ github.repository }}' | awk -F '/' '{ print $2 }' )" >> $GITHUB_ENV
|
||||
- name: 'Create repository'
|
||||
shell: bash
|
||||
run: |
|
||||
http="$( curl -s -o '/dev/null' -I -w '%{http_code}' -A '${{ env.USER_AGENT }}' '${{ env.DOMAIN }}/${{ env.OWNER }}/${{ env.REPO_NAME }}' )"
|
||||
if [[ "${http}" -ne 200 ]]; then
|
||||
curl -X POST \
|
||||
-H 'Authorization: token ${{ secrets.BOT_MIRROR_TOKEN_CODEBERG }}' \
|
||||
-H 'Accept: application/json' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-A '${{ env.USER_AGENT }}' \
|
||||
'${{ env.DOMAIN }}/api/${{ env.VERSION }}/orgs/${{ env.OWNER }}/repos' \
|
||||
-d '{"name":"${{ env.REPO_NAME }}"}'
|
||||
fi
|
||||
- name: 'Mirror repository'
|
||||
uses: ghastore/github-mirror@main
|
||||
with:
|
||||
src_repo: '${{ github.server_url }}/${{ github.repository }}.git'
|
||||
src_user: '${{ secrets.BOT_MIRROR_NAME }}'
|
||||
src_token: '${{ secrets.BOT_MIRROR_TOKEN_GITHUB }}'
|
||||
dst_repo: '${{ env.DOMAIN }}/${{ env.OWNER }}/${{ env.REPO_NAME }}.git'
|
||||
dst_user: '${{ secrets.BOT_MIRROR_NAME }}'
|
||||
dst_token: '${{ secrets.BOT_MIRROR_TOKEN_CODEBERG }}'
|
||||
|
||||
# ------------------------------------------------------------------------------------------------------------------ #
|
||||
# MosHub.
|
||||
# ------------------------------------------------------------------------------------------------------------------ #
|
||||
|
||||
mirror_moshub:
|
||||
runs-on: ubuntu-latest
|
||||
name: 'MosHub'
|
||||
env:
|
||||
DOMAIN: 'https://hub.mos.ru'
|
||||
VERSION: 'v4'
|
||||
NSID: '38795'
|
||||
steps:
|
||||
- name: 'Get repository name'
|
||||
shell: bash
|
||||
run: |
|
||||
echo "REPO_NAME=$( echo '${{ github.repository }}' | awk -F '/' '{ print $2 }' )" >> $GITHUB_ENV
|
||||
- name: 'Create repository'
|
||||
shell: bash
|
||||
run: |
|
||||
http="$( curl -s -o '/dev/null' -I -w '%{http_code}' -A '${{ env.USER_AGENT }}' '${{ env.DOMAIN }}/${{ env.OWNER }}/${{ env.REPO_NAME }}' )"
|
||||
if [[ "${http}" -ne 200 ]]; then
|
||||
curl -X POST \
|
||||
-H 'Authorization: Bearer ${{ secrets.BOT_MIRROR_TOKEN_MOSHUB }}' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-A '${{ env.USER_AGENT }}' \
|
||||
'${{ env.DOMAIN }}/api/${{ env.VERSION }}/projects/' \
|
||||
-d '{"name":"${{ env.REPO_NAME }}","path":"${{ env.REPO_NAME }}","namespace_id":"${{ env.NSID }}","visibility":"public"}'
|
||||
fi
|
||||
- name: 'Mirror repository'
|
||||
uses: ghastore/github-mirror@main
|
||||
with:
|
||||
src_repo: '${{ github.server_url }}/${{ github.repository }}.git'
|
||||
src_user: '${{ secrets.BOT_MIRROR_NAME }}'
|
||||
src_token: '${{ secrets.BOT_MIRROR_TOKEN_GITHUB }}'
|
||||
dst_repo: '${{ env.DOMAIN }}/${{ env.OWNER }}/${{ env.REPO_NAME }}.git'
|
||||
dst_user: '${{ secrets.BOT_MIRROR_NAME }}'
|
||||
dst_token: '${{ secrets.BOT_MIRROR_TOKEN_MOSHUB }}'
|
||||
|
||||
# ------------------------------------------------------------------------------------------------------------------ #
|
||||
# GIT.ORG.RU.
|
||||
# ------------------------------------------------------------------------------------------------------------------ #
|
||||
|
||||
mirror_gitorgru:
|
||||
runs-on: ubuntu-latest
|
||||
name: 'GIT.ORG.RU'
|
||||
env:
|
||||
DOMAIN: 'https://git.org.ru'
|
||||
VERSION: 'v1'
|
||||
steps:
|
||||
- name: 'Get repository name'
|
||||
shell: bash
|
||||
run: |
|
||||
echo "REPO_NAME=$( echo '${{ github.repository }}' | awk -F '/' '{ print $2 }' )" >> $GITHUB_ENV
|
||||
- name: 'Create repository'
|
||||
shell: bash
|
||||
run: |
|
||||
http="$( curl -s -o '/dev/null' -I -w '%{http_code}' -A '${{ env.USER_AGENT }}' '${{ env.DOMAIN }}/${{ env.OWNER }}/${{ env.REPO_NAME }}' )"
|
||||
if [[ "${http}" -ne 200 ]]; then
|
||||
curl -X POST \
|
||||
-H 'Authorization: token ${{ secrets.BOT_MIRROR_TOKEN_GITORGRU }}' \
|
||||
-H 'Accept: application/json' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-A '${{ env.USER_AGENT }}' \
|
||||
'${{ env.DOMAIN }}/api/${{ env.VERSION }}/orgs/${{ env.OWNER }}/repos' \
|
||||
-d '{"name":"${{ env.REPO_NAME }}"}'
|
||||
fi
|
||||
- name: 'Mirror repository'
|
||||
uses: ghastore/github-mirror@main
|
||||
with:
|
||||
src_repo: '${{ github.server_url }}/${{ github.repository }}.git'
|
||||
src_user: '${{ secrets.BOT_MIRROR_NAME }}'
|
||||
src_token: '${{ secrets.BOT_MIRROR_TOKEN_GITHUB }}'
|
||||
dst_repo: '${{ env.DOMAIN }}/${{ env.OWNER }}/${{ env.REPO_NAME }}.git'
|
||||
dst_user: '${{ secrets.BOT_MIRROR_NAME }}'
|
||||
dst_token: '${{ secrets.BOT_MIRROR_TOKEN_GITORGRU }}'
|
||||
|
||||
# ------------------------------------------------------------------------------------------------------------------ #
|
||||
# Disroot.
|
||||
# ------------------------------------------------------------------------------------------------------------------ #
|
||||
|
||||
mirror_disroot:
|
||||
runs-on: ubuntu-latest
|
||||
name: 'Disroot'
|
||||
env:
|
||||
DOMAIN: 'https://git.disroot.org'
|
||||
VERSION: 'v1'
|
||||
steps:
|
||||
- name: 'Get repository name'
|
||||
shell: bash
|
||||
run: |
|
||||
echo "REPO_NAME=$( echo '${{ github.repository }}' | awk -F '/' '{ print $2 }' )" >> $GITHUB_ENV
|
||||
- name: 'Create repository'
|
||||
shell: bash
|
||||
run: |
|
||||
http="$( curl -s -o '/dev/null' -I -w '%{http_code}' -A '${{ env.USER_AGENT }}' '${{ env.DOMAIN }}/${{ env.OWNER }}/${{ env.REPO_NAME }}' )"
|
||||
if [[ "${http}" -ne 200 ]]; then
|
||||
curl -X POST \
|
||||
-H 'Authorization: token ${{ secrets.BOT_MIRROR_TOKEN_DISROOT }}' \
|
||||
-H 'Accept: application/json' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-A '${{ env.USER_AGENT }}' \
|
||||
'${{ env.DOMAIN }}/api/${{ env.VERSION }}/orgs/${{ env.OWNER }}/repos' \
|
||||
-d '{"name":"${{ env.REPO_NAME }}"}'
|
||||
fi
|
||||
- name: 'Mirror repository'
|
||||
uses: ghastore/github-mirror@main
|
||||
with:
|
||||
src_repo: '${{ github.server_url }}/${{ github.repository }}.git'
|
||||
src_user: '${{ secrets.BOT_MIRROR_NAME }}'
|
||||
src_token: '${{ secrets.BOT_MIRROR_TOKEN_GITHUB }}'
|
||||
dst_repo: '${{ env.DOMAIN }}/${{ env.OWNER }}/${{ env.REPO_NAME }}.git'
|
||||
dst_user: '${{ secrets.BOT_MIRROR_NAME }}'
|
||||
dst_token: '${{ secrets.BOT_MIRROR_TOKEN_DISROOT }}'
|
0
CHANGELOG.md
Normal file
0
CHANGELOG.md
Normal file
14
CONTRIBUTING.md
Normal file
14
CONTRIBUTING.md
Normal file
|
@ -0,0 +1,14 @@
|
|||
# Contributing
|
||||
|
||||
- Feedback, wishes and suggestions can be sent by email.
|
||||
- Constructive criticism, bug descriptions and other reports are welcome.
|
||||
- Email: [mail@ihub.to](mailto:mail@ihub.to) / [mail@kitsune.solar](mailto:mail@kitsune.solar).
|
||||
|
||||
## Sources
|
||||
|
||||
- [**GitHub**](https://github.com/pkgstore)
|
||||
- [GitLab](https://gitlab.com/pkgstore) (MIRROR)
|
||||
- [Codeberg](https://codeberg.org/pkgstore) (MIRROR)
|
||||
- [Disroot](https://git.disroot.org/pkgstore) (MIRROR)
|
||||
- [MosHub](https://hub.mos.ru/pkgstore) (MIRROR)
|
||||
- [Git.Org.Ru](https://git.org.ru/pkgstore) (MIRROR)
|
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2023 Package Store
|
||||
Copyright (c) 2023 iHub TO <https://ihub.to>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
19
PkgStore.7z.psd1
Normal file
19
PkgStore.7z.psd1
Normal file
|
@ -0,0 +1,19 @@
|
|||
@{
|
||||
RootModule = 'PkgStore.7z.psm1'
|
||||
ModuleVersion = '0.1.0'
|
||||
GUID = '613eb0b0-1b1e-4f28-92c9-1c6e73e91a1a'
|
||||
Author = 'Kitsune Solar'
|
||||
CompanyName = 'iHub.TO'
|
||||
Copyright = '(c) 2023 Kitsune Solar. All rights reserved.'
|
||||
Description = 'Compress end expand 7z archive.'
|
||||
PowerShellVersion = '7.2'
|
||||
RequiredModules = @('PkgStore.Kernel')
|
||||
FunctionsToExport = @('Compress-7z', 'Expand-7z', 'Compress-ISO')
|
||||
PrivateData = @{
|
||||
PSData = @{
|
||||
Tags = @('pwsh', '7z', '7zip')
|
||||
LicenseUri = 'https://choosealicense.com/licenses/mit/'
|
||||
ProjectUri = 'https://github.com/pkgstore/pwsh-7z'
|
||||
}
|
||||
}
|
||||
}
|
105
PkgStore.7z.psm1
Normal file
105
PkgStore.7z.psm1
Normal file
|
@ -0,0 +1,105 @@
|
|||
<#PSScriptInfo
|
||||
.VERSION 0.1.0
|
||||
.GUID 613eb0b0-1b1e-4f28-92c9-1c6e73e91a1a
|
||||
.AUTHOR Kitsune Solar
|
||||
.AUTHOREMAIL mail@kitsune.solar
|
||||
.COMPANYNAME iHub.TO
|
||||
.COPYRIGHT 2023 Kitsune Solar. All rights reserved.
|
||||
.LICENSEURI https://choosealicense.com/licenses/mit/
|
||||
.PROJECTURI
|
||||
#>
|
||||
|
||||
$7Zip = @('7za.exe', '7za.dll', '7zxa.dll')
|
||||
|
||||
function Compress-7z() {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
|
||||
.DESCRIPTION
|
||||
#>
|
||||
|
||||
Param(
|
||||
[Alias('A')][string]$P_App = (
|
||||
(Get-ChildItem -LiteralPath "${PSScriptRoot}" -Filter "$($7z[0])" -Recurse -File) | Select-Object -First 1
|
||||
),
|
||||
[Parameter(Mandatory)][SupportsWildcards()][Alias('F')][string[]]$P_Files,
|
||||
[ValidateSet('7z', 'BZIP2', 'GZIP', 'TAR', 'WIM', 'XZ', 'ZIP')][Alias('T')][string]$P_Type = '7z',
|
||||
[ValidateRange(1,9)][Alias('L')][int]$P_Level = 5,
|
||||
[Alias('P')][string]$P_Password,
|
||||
[Alias('D')][switch]$P_Delete = $false
|
||||
)
|
||||
|
||||
Test-7Zip
|
||||
|
||||
(Get-ChildItem $Files) | ForEach-Object {
|
||||
$Params = @( "a", "-t${P_Type}", "-mx${P_Level}" )
|
||||
if (-not ([string]::IsNullOrEmpty($P_Password))) {$Params += @("-p${P_Password}")}
|
||||
if ($P_Delete) {$Params += @("-sdel")}
|
||||
$Params += @("$($_.FullName + '.' + $Type.ToLower())", "$($_.FullName)")
|
||||
|
||||
& "${P_App}" $Params
|
||||
}
|
||||
}
|
||||
|
||||
function Expand-7z() {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
|
||||
.DESCRIPTION
|
||||
#>
|
||||
|
||||
Param(
|
||||
[Parameter(Mandatory)][SupportsWildcards()][Alias('F')][string[]]$Files
|
||||
)
|
||||
|
||||
Test-7Zip
|
||||
|
||||
(Get-ChildItem $Files) | ForEach-Object {
|
||||
$Params = @('x', "$($_.FullName)")
|
||||
|
||||
& "${P_App}" $Params
|
||||
}
|
||||
}
|
||||
|
||||
function Compress-ISO() {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
|
||||
.DESCRIPTION
|
||||
#>
|
||||
|
||||
Param(
|
||||
[Parameter(Mandatory)][SupportsWildcards()][Alias('F')][string[]]$Files
|
||||
)
|
||||
|
||||
Test-7Zip
|
||||
|
||||
(Get-ChildItem $Files) | ForEach-Object {
|
||||
# Hash 'SHA1' pattern.
|
||||
$SHA1 = Get-FileHash "$($_.FullName)" -Algorithm 'SHA1'
|
||||
| Select-Object 'Hash', @{N = 'Path'; E = {$_.Path | Resolve-Path -Relative}}
|
||||
$SHA1 | Out-File "$($_.FullName + '.sha1')"
|
||||
|
||||
# Hash 'SHA256' pattern.
|
||||
$SHA256 = Get-FileHash "$($_.FullName)" -Algorithm 'SHA256'
|
||||
| Select-Object 'Hash', @{N = 'Path'; E = {$_.Path | Resolve-Path -Relative}}
|
||||
$SHA256 | Out-File "$($_.FullName + '.sha256')"
|
||||
|
||||
# Compressing a '*.ISO' file.
|
||||
Compress-7z -F "$($_.FullName)" -L 9
|
||||
}
|
||||
}
|
||||
|
||||
function Test-7Zip {
|
||||
# Getting '7za.exe' directory.
|
||||
$D_App = "$($P_App.DirectoryName)"
|
||||
|
||||
# Checking the location of files.
|
||||
$7Zip | ForEach-Object {
|
||||
if (-not (Test-Data -T 'F' -P "${D_App}\${_}")) {
|
||||
Write-Msg -T 'W' -A 'Stop' -M ("'$_' not found!${NL}${NL}" +
|
||||
"1. Download 7-Zip Extra from 'https://www.7-zip.org/download.html'.${NL}" +
|
||||
"2. Extract all the contents of the archive into a directory '${PSScriptRoot}'.")
|
||||
}
|
||||
}
|
||||
}
|
22
README.md
22
README.md
|
@ -1 +1,21 @@
|
|||
# pwsh-7z
|
||||
# PowerShell 7-ZIP Module
|
||||
|
||||
PowerShell module for working with 7-ZIP.
|
||||
|
||||
## Install
|
||||
|
||||
```powershell
|
||||
${MOD} = "7z"; ${PFX} = "PkgStore"; ${DIR} = "$( (${env:PSModulePath} -split ';')[0] )"; Invoke-WebRequest "https://github.com/pkgstore/pwsh-${MOD}/archive/refs/heads/main.zip" -OutFile "${DIR}\${MOD}.zip"; Expand-Archive -Path "${DIR}\${MOD}.zip" -DestinationPath "${DIR}"; if ( Test-Path -Path "${DIR}\${PFX}.${MOD}" ) { Remove-Item -Path "${DIR}\${PFX}.${MOD}" -Recurse -Force }; Rename-Item -Path "${DIR}\pwsh-${MOD}-main" -NewName "${DIR}\${PFX}.${MOD}"; Remove-Item -Path "${DIR}\${MOD}.zip";
|
||||
```
|
||||
|
||||
## Syntax
|
||||
|
||||
For syntax information, enter module info command and get help command.
|
||||
|
||||
```powershell
|
||||
Get-Command -Module 'PkgStore.7z'
|
||||
```
|
||||
|
||||
```powershell
|
||||
Get-Help '<COMMAND-NAME>'
|
||||
```
|
||||
|
|
Loading…
Reference in a new issue