mirror of
https://github.com/eRgo35/ah.git
synced 2026-02-04 21:26:11 +01:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
2cf51b7595
|
|||
|
b41ba34e7f
|
|||
|
358b81dec5
|
|||
|
b4f118b4ad
|
|||
|
a06ecee67f
|
|||
|
462116743e
|
|||
|
0d0cd4380c
|
|||
|
7268726e82
|
|||
|
441a2a2367
|
281
.github/workflows/release.yml
vendored
Normal file
281
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,281 @@
|
|||||||
|
# Copyright 2022-2024, axodotdev
|
||||||
|
# SPDX-License-Identifier: MIT or Apache-2.0
|
||||||
|
#
|
||||||
|
# CI that:
|
||||||
|
#
|
||||||
|
# * checks for a Git Tag that looks like a release
|
||||||
|
# * builds artifacts with cargo-dist (archives, installers, hashes)
|
||||||
|
# * uploads those artifacts to temporary workflow zip
|
||||||
|
# * on success, uploads the artifacts to a GitHub Release
|
||||||
|
#
|
||||||
|
# Note that the GitHub Release will be created with a generated
|
||||||
|
# title/body based on your changelogs.
|
||||||
|
|
||||||
|
name: Release
|
||||||
|
permissions:
|
||||||
|
"contents": "write"
|
||||||
|
|
||||||
|
# This task will run whenever you push a git tag that looks like a version
|
||||||
|
# like "1.0.0", "v0.1.0-prerelease.1", "my-app/0.1.0", "releases/v1.0.0", etc.
|
||||||
|
# Various formats will be parsed into a VERSION and an optional PACKAGE_NAME, where
|
||||||
|
# PACKAGE_NAME must be the name of a Cargo package in your workspace, and VERSION
|
||||||
|
# must be a Cargo-style SemVer Version (must have at least major.minor.patch).
|
||||||
|
#
|
||||||
|
# If PACKAGE_NAME is specified, then the announcement will be for that
|
||||||
|
# package (erroring out if it doesn't have the given version or isn't cargo-dist-able).
|
||||||
|
#
|
||||||
|
# If PACKAGE_NAME isn't specified, then the announcement will be for all
|
||||||
|
# (cargo-dist-able) packages in the workspace with that version (this mode is
|
||||||
|
# intended for workspaces with only one dist-able package, or with all dist-able
|
||||||
|
# packages versioned/released in lockstep).
|
||||||
|
#
|
||||||
|
# If you push multiple tags at once, separate instances of this workflow will
|
||||||
|
# spin up, creating an independent announcement for each one. However, GitHub
|
||||||
|
# will hard limit this to 3 tags per commit, as it will assume more tags is a
|
||||||
|
# mistake.
|
||||||
|
#
|
||||||
|
# If there's a prerelease-style suffix to the version, then the release(s)
|
||||||
|
# will be marked as a prerelease.
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- '**[0-9]+.[0-9]+.[0-9]+*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
# Run 'cargo dist plan' (or host) to determine what tasks we need to do
|
||||||
|
plan:
|
||||||
|
runs-on: "ubuntu-20.04"
|
||||||
|
outputs:
|
||||||
|
val: ${{ steps.plan.outputs.manifest }}
|
||||||
|
tag: ${{ !github.event.pull_request && github.ref_name || '' }}
|
||||||
|
tag-flag: ${{ !github.event.pull_request && format('--tag={0}', github.ref_name) || '' }}
|
||||||
|
publishing: ${{ !github.event.pull_request }}
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
- name: Install cargo-dist
|
||||||
|
# we specify bash to get pipefail; it guards against the `curl` command
|
||||||
|
# failing. otherwise `sh` won't catch that `curl` returned non-0
|
||||||
|
shell: bash
|
||||||
|
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.20.0/cargo-dist-installer.sh | sh"
|
||||||
|
- name: Cache cargo-dist
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: cargo-dist-cache
|
||||||
|
path: ~/.cargo/bin/cargo-dist
|
||||||
|
# sure would be cool if github gave us proper conditionals...
|
||||||
|
# so here's a doubly-nested ternary-via-truthiness to try to provide the best possible
|
||||||
|
# functionality based on whether this is a pull_request, and whether it's from a fork.
|
||||||
|
# (PRs run on the *source* but secrets are usually on the *target* -- that's *good*
|
||||||
|
# but also really annoying to build CI around when it needs secrets to work right.)
|
||||||
|
- id: plan
|
||||||
|
run: |
|
||||||
|
cargo dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json
|
||||||
|
echo "cargo dist ran successfully"
|
||||||
|
cat plan-dist-manifest.json
|
||||||
|
echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT"
|
||||||
|
- name: "Upload dist-manifest.json"
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: artifacts-plan-dist-manifest
|
||||||
|
path: plan-dist-manifest.json
|
||||||
|
|
||||||
|
# Build and packages all the platform-specific things
|
||||||
|
build-local-artifacts:
|
||||||
|
name: build-local-artifacts (${{ join(matrix.targets, ', ') }})
|
||||||
|
# Let the initial task tell us to not run (currently very blunt)
|
||||||
|
needs:
|
||||||
|
- plan
|
||||||
|
if: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix.include != null && (needs.plan.outputs.publishing == 'true' || fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload') }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
# Target platforms/runners are computed by cargo-dist in create-release.
|
||||||
|
# Each member of the matrix has the following arguments:
|
||||||
|
#
|
||||||
|
# - runner: the github runner
|
||||||
|
# - dist-args: cli flags to pass to cargo dist
|
||||||
|
# - install-dist: expression to run to install cargo-dist on the runner
|
||||||
|
#
|
||||||
|
# Typically there will be:
|
||||||
|
# - 1 "global" task that builds universal installers
|
||||||
|
# - N "local" tasks that build each platform's binaries and platform-specific installers
|
||||||
|
matrix: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }}
|
||||||
|
runs-on: ${{ matrix.runner }}
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
BUILD_MANIFEST_NAME: target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json
|
||||||
|
steps:
|
||||||
|
- name: enable windows longpaths
|
||||||
|
run: |
|
||||||
|
git config --global core.longpaths true
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
- name: Install cargo-dist
|
||||||
|
run: ${{ matrix.install_dist }}
|
||||||
|
# Get the dist-manifest
|
||||||
|
- name: Fetch local artifacts
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
pattern: artifacts-*
|
||||||
|
path: target/distrib/
|
||||||
|
merge-multiple: true
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
${{ matrix.packages_install }}
|
||||||
|
- name: Build artifacts
|
||||||
|
run: |
|
||||||
|
# Actually do builds and make zips and whatnot
|
||||||
|
cargo dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
|
||||||
|
echo "cargo dist ran successfully"
|
||||||
|
- id: cargo-dist
|
||||||
|
name: Post-build
|
||||||
|
# We force bash here just because github makes it really hard to get values up
|
||||||
|
# to "real" actions without writing to env-vars, and writing to env-vars has
|
||||||
|
# inconsistent syntax between shell and powershell.
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
# Parse out what we just built and upload it to scratch storage
|
||||||
|
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
|
||||||
|
jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT"
|
||||||
|
echo "EOF" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
|
||||||
|
- name: "Upload artifacts"
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: artifacts-build-local-${{ join(matrix.targets, '_') }}
|
||||||
|
path: |
|
||||||
|
${{ steps.cargo-dist.outputs.paths }}
|
||||||
|
${{ env.BUILD_MANIFEST_NAME }}
|
||||||
|
|
||||||
|
# Build and package all the platform-agnostic(ish) things
|
||||||
|
build-global-artifacts:
|
||||||
|
needs:
|
||||||
|
- plan
|
||||||
|
- build-local-artifacts
|
||||||
|
runs-on: "ubuntu-20.04"
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
BUILD_MANIFEST_NAME: target/distrib/global-dist-manifest.json
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
- name: Install cached cargo-dist
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: cargo-dist-cache
|
||||||
|
path: ~/.cargo/bin/
|
||||||
|
- run: chmod +x ~/.cargo/bin/cargo-dist
|
||||||
|
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
|
||||||
|
- name: Fetch local artifacts
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
pattern: artifacts-*
|
||||||
|
path: target/distrib/
|
||||||
|
merge-multiple: true
|
||||||
|
- id: cargo-dist
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
cargo dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
|
||||||
|
echo "cargo dist ran successfully"
|
||||||
|
|
||||||
|
# Parse out what we just built and upload it to scratch storage
|
||||||
|
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
|
||||||
|
jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT"
|
||||||
|
echo "EOF" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
|
||||||
|
- name: "Upload artifacts"
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: artifacts-build-global
|
||||||
|
path: |
|
||||||
|
${{ steps.cargo-dist.outputs.paths }}
|
||||||
|
${{ env.BUILD_MANIFEST_NAME }}
|
||||||
|
# Determines if we should publish/announce
|
||||||
|
host:
|
||||||
|
needs:
|
||||||
|
- plan
|
||||||
|
- build-local-artifacts
|
||||||
|
- build-global-artifacts
|
||||||
|
# Only run if we're "publishing", and only if local and global didn't fail (skipped is fine)
|
||||||
|
if: ${{ always() && needs.plan.outputs.publishing == 'true' && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') && (needs.build-local-artifacts.result == 'skipped' || needs.build-local-artifacts.result == 'success') }}
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
runs-on: "ubuntu-20.04"
|
||||||
|
outputs:
|
||||||
|
val: ${{ steps.host.outputs.manifest }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
- name: Install cached cargo-dist
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: cargo-dist-cache
|
||||||
|
path: ~/.cargo/bin/
|
||||||
|
- run: chmod +x ~/.cargo/bin/cargo-dist
|
||||||
|
# Fetch artifacts from scratch-storage
|
||||||
|
- name: Fetch artifacts
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
pattern: artifacts-*
|
||||||
|
path: target/distrib/
|
||||||
|
merge-multiple: true
|
||||||
|
- id: host
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
cargo dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
|
||||||
|
echo "artifacts uploaded and released successfully"
|
||||||
|
cat dist-manifest.json
|
||||||
|
echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
|
||||||
|
- name: "Upload dist-manifest.json"
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
# Overwrite the previous copy
|
||||||
|
name: artifacts-dist-manifest
|
||||||
|
path: dist-manifest.json
|
||||||
|
# Create a GitHub Release while uploading all files to it
|
||||||
|
- name: "Download GitHub Artifacts"
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
pattern: artifacts-*
|
||||||
|
path: artifacts
|
||||||
|
merge-multiple: true
|
||||||
|
- name: Cleanup
|
||||||
|
run: |
|
||||||
|
# Remove the granular manifests
|
||||||
|
rm -f artifacts/*-dist-manifest.json
|
||||||
|
- name: Create GitHub Release
|
||||||
|
env:
|
||||||
|
PRERELEASE_FLAG: "${{ fromJson(steps.host.outputs.manifest).announcement_is_prerelease && '--prerelease' || '' }}"
|
||||||
|
ANNOUNCEMENT_TITLE: "${{ fromJson(steps.host.outputs.manifest).announcement_title }}"
|
||||||
|
ANNOUNCEMENT_BODY: "${{ fromJson(steps.host.outputs.manifest).announcement_github_body }}"
|
||||||
|
RELEASE_COMMIT: "${{ github.sha }}"
|
||||||
|
run: |
|
||||||
|
# Write and read notes from a file to avoid quoting breaking things
|
||||||
|
echo "$ANNOUNCEMENT_BODY" > $RUNNER_TEMP/notes.txt
|
||||||
|
|
||||||
|
gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/*
|
||||||
|
|
||||||
|
announce:
|
||||||
|
needs:
|
||||||
|
- plan
|
||||||
|
- host
|
||||||
|
# use "always() && ..." to allow us to wait for all publish jobs while
|
||||||
|
# still allowing individual publish jobs to skip themselves (for prereleases).
|
||||||
|
# "host" however must run to completion, no skipping allowed!
|
||||||
|
if: ${{ always() && needs.host.result == 'success' }}
|
||||||
|
runs-on: "ubuntu-20.04"
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
4
Cargo.lock
generated
4
Cargo.lock
generated
@@ -3,8 +3,8 @@
|
|||||||
version = 3
|
version = 3
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ah"
|
name = "ah-pkg"
|
||||||
version = "0.2.0"
|
version = "0.3.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"colored",
|
"colored",
|
||||||
|
|||||||
30
Cargo.toml
30
Cargo.toml
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "ah"
|
name = "ah-pkg"
|
||||||
version = "0.2.0"
|
version = "0.3.1"
|
||||||
authors = ["Michał Czyż <mike@c2yz.com>"]
|
authors = ["Michał Czyż <mike@c2yz.com>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
@@ -8,10 +8,34 @@ description = "A declarative package manager for Arch Linux"
|
|||||||
homepage = "https://github.com/eRgo35/ah"
|
homepage = "https://github.com/eRgo35/ah"
|
||||||
repository = "https://github.com/eRgo35/ah"
|
repository = "https://github.com/eRgo35/ah"
|
||||||
documentation = "https://github.com/eRgo35/ah"
|
documentation = "https://github.com/eRgo35/ah"
|
||||||
license = "MIT"
|
|
||||||
keywords = ["archlinux", "declarative", "package", "aur", "paru"]
|
keywords = ["archlinux", "declarative", "package", "aur", "paru"]
|
||||||
|
license = "MIT"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
path = "src/main.rs"
|
||||||
|
name = "ah"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.5.10", features = ["derive"] }
|
clap = { version = "4.5.10", features = ["derive"] }
|
||||||
colored = "2.1.0"
|
colored = "2.1.0"
|
||||||
|
|
||||||
|
# The profile that 'cargo dist' will build with
|
||||||
|
[profile.dist]
|
||||||
|
inherits = "release"
|
||||||
|
lto = "thin"
|
||||||
|
|
||||||
|
# Config for 'cargo dist'
|
||||||
|
[workspace.metadata.dist]
|
||||||
|
# The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax)
|
||||||
|
cargo-dist-version = "0.20.0"
|
||||||
|
# CI backends to support
|
||||||
|
ci = "github"
|
||||||
|
# The installers to generate for each app
|
||||||
|
installers = ["shell"]
|
||||||
|
# Target platforms to build apps for (Rust target-triple syntax)
|
||||||
|
targets = ["x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl"]
|
||||||
|
# Path that installers should place binaries in
|
||||||
|
install-path = "CARGO_HOME"
|
||||||
|
# Whether to install an updater program
|
||||||
|
install-updater = false
|
||||||
|
|||||||
21
LICENSE.md
Normal file
21
LICENSE.md
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2024 Michał Czyż
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
25
PKGBUILD
25
PKGBUILD
@@ -1,18 +1,21 @@
|
|||||||
# Maintainer: Michał Czyż <mike@c2yz.com>
|
# Maintainer: Michał Czyż <mike@c2yz.com>
|
||||||
pkgname=ah
|
|
||||||
pkgver=0.2.0
|
pkgname=ah-pkg-bin
|
||||||
|
pkgver=0.3.1
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
makedepends=('rust' 'cargo')
|
|
||||||
arch=('i686' 'x86_64' 'armv6h' 'armv7h')
|
|
||||||
pkgdesc="A declarative package manager for Arch Linux"
|
pkgdesc="A declarative package manager for Arch Linux"
|
||||||
url="https://github.com/eRgo35/ah"
|
url="https://github.com/eRgo35/ah"
|
||||||
license=('MIT')
|
license=("MIT")
|
||||||
|
arch=("x86_64")
|
||||||
build() {
|
provides=("ah-pkg")
|
||||||
return 0
|
conflicts=("ah-pkg")
|
||||||
}
|
depends=("paru" "topgrade")
|
||||||
|
source=("https://github.com/eRgo35/ah/releases/download/v$pkgver/ah-pkg-x86_64-unknown-linux-gnu.tar.xz")
|
||||||
|
sha256sums=("6d1778f508d42a3396e466bf44bd650c2dabcd9552f1f776c1c93019f0c52a68")
|
||||||
|
|
||||||
package() {
|
package() {
|
||||||
cd $srcdir
|
cd "$srcdir/ah-pkg-x86_64-unknown-linux-gnu"
|
||||||
cargo install --root="$pkgdir" --git=https://github.com/eRgo35/ah
|
|
||||||
|
install -Dm755 ah -t "$pkgdir/usr/bin"
|
||||||
|
install -Dm644 LICENSE.md "$pkgdir/usr/share/licenses/$pkgname/LICENSE.md"
|
||||||
}
|
}
|
||||||
|
|||||||
31
README.md
31
README.md
@@ -4,12 +4,18 @@ A declarative package manager for Arch Linux
|
|||||||
|
|
||||||
## What is ah?
|
## What is ah?
|
||||||
|
|
||||||
Arch Helper is a declarative package management tool for Arch Linux. It leverages paru or other package managers for seamless integration.
|
Arch Helper is a declarative package management tool for Arch Linux. It leverages paru and topgrade for package management.
|
||||||
|
|
||||||
It is currently in early development phase so watch out for bugs!
|
It is currently in early development phase so watch out for potential bugs!
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
Check out the [releases](https://github.com/eRgo35/ah/releases) tab for the latest release!
|
||||||
|
|
||||||
|
## Building
|
||||||
|
|
||||||
|
If you want to build from source, you can do so by following the instructions below.
|
||||||
|
|
||||||
Install Rust :crab:
|
Install Rust :crab:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
@@ -23,19 +29,21 @@ $ rustup default stable
|
|||||||
```
|
```
|
||||||
|
|
||||||
Clone this repo
|
Clone this repo
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ git clone https://github.com/eRgo35/ah
|
$ git clone https://github.com/eRgo35/ah
|
||||||
```
|
```
|
||||||
|
|
||||||
Change directory
|
Change directory
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ cd ah
|
$ cd ah
|
||||||
```
|
```
|
||||||
|
|
||||||
Install package
|
Build with cargo
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ makepkg -si
|
$ cargo build --release
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
@@ -47,12 +55,13 @@ Arch Helper is a declarative package management tool for Arch Linux. It leverage
|
|||||||
Usage: ah [COMMAND]
|
Usage: ah [COMMAND]
|
||||||
|
|
||||||
Commands:
|
Commands:
|
||||||
install Install packages
|
install Install packages
|
||||||
upgrade Upgrade packages
|
upgrade Upgrade packages
|
||||||
sync Synchronize packages
|
sync Synchronize packages
|
||||||
remove Remove packages
|
remove Remove packages
|
||||||
find Find packages
|
find Find packages
|
||||||
help Print this message or the help of the given subcommand(s)
|
choose-install Find and install packages
|
||||||
|
help Print this message or the help of the given subcommand(s)
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-h, --help
|
-h, --help
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
use clap::{Args, Parser, Subcommand};
|
use clap::{Args, Parser, Subcommand};
|
||||||
|
|
||||||
|
const VERSION: Option<&str> = option_env!("CARGO_PKG_VERSION");
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(
|
#[command(
|
||||||
name = "ah",
|
name = "ah",
|
||||||
author = "Michał Czyż",
|
author = "Michał Czyż",
|
||||||
version = "0.1.0",
|
version = VERSION.unwrap_or("unknown"),
|
||||||
about = "A declarative package manager for Arch Linux",
|
about = "A declarative package manager for Arch Linux",
|
||||||
long_about = "Arch Helper is a declarative package management tool for Arch Linux. It leverages paru or other package managers for seamless integration."
|
long_about = "Arch Helper is a declarative package management tool for Arch Linux. It leverages paru or other package managers for seamless integration."
|
||||||
)]
|
)]
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ pub fn read_packages(path: PathBuf) -> Vec<String> {
|
|||||||
|
|
||||||
pub fn append_package(path: PathBuf, package: &str) {
|
pub fn append_package(path: PathBuf, package: &str) {
|
||||||
let mut file = OpenOptions::new()
|
let mut file = OpenOptions::new()
|
||||||
.write(true)
|
|
||||||
.append(true)
|
.append(true)
|
||||||
.open(path)
|
.open(path)
|
||||||
.expect("Failed to open file");
|
.expect("Failed to open file");
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ fn main() {
|
|||||||
Some(cli::Commands::Remove(PackageList { packages })) => packages::remove(packages),
|
Some(cli::Commands::Remove(PackageList { packages })) => packages::remove(packages),
|
||||||
Some(cli::Commands::Find(Query { query })) => packages::find(query),
|
Some(cli::Commands::Find(Query { query })) => packages::find(query),
|
||||||
Some(cli::Commands::ChooseInstall(Query { query })) => packages::choose_install(query),
|
Some(cli::Commands::ChooseInstall(Query { query })) => packages::choose_install(query),
|
||||||
None => packages::upgrade(true),
|
None => packages::full_upgrade(true),
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Err(err) = result {
|
if let Err(err) = result {
|
||||||
|
|||||||
32
src/packages/full_upgrade.rs
Normal file
32
src/packages/full_upgrade.rs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
use colored::Colorize;
|
||||||
|
use std::process::Command;
|
||||||
|
|
||||||
|
use crate::packages::{ask_confirmation, SYSTEM_UPDATER};
|
||||||
|
|
||||||
|
pub fn full_upgrade(noconfirm: bool) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
println!(
|
||||||
|
"{} {}",
|
||||||
|
"::".bold().green(),
|
||||||
|
"Initializing full system update...".bold()
|
||||||
|
);
|
||||||
|
|
||||||
|
if !ask_confirmation()? {
|
||||||
|
return Err("Operation aborted".into());
|
||||||
|
}
|
||||||
|
|
||||||
|
let noconfirm = if noconfirm { "-y" } else { "" };
|
||||||
|
|
||||||
|
let mut child = Command::new(SYSTEM_UPDATER)
|
||||||
|
.arg(noconfirm)
|
||||||
|
.spawn()
|
||||||
|
.expect("Failed to execute command");
|
||||||
|
|
||||||
|
let status = child.wait().expect("Failed to wait on child");
|
||||||
|
|
||||||
|
if !status.success() {
|
||||||
|
return Err("System upgrade failed".into());
|
||||||
|
}
|
||||||
|
|
||||||
|
println!("{} {}", "::".bold().green(), "System upgraded".bold());
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ use std::path::PathBuf;
|
|||||||
|
|
||||||
pub mod choose_install;
|
pub mod choose_install;
|
||||||
pub mod find;
|
pub mod find;
|
||||||
|
pub mod full_upgrade;
|
||||||
pub mod install;
|
pub mod install;
|
||||||
pub mod rebuild;
|
pub mod rebuild;
|
||||||
pub mod remove;
|
pub mod remove;
|
||||||
@@ -12,12 +13,14 @@ pub mod upgrade;
|
|||||||
|
|
||||||
pub use choose_install::choose_install;
|
pub use choose_install::choose_install;
|
||||||
pub use find::find;
|
pub use find::find;
|
||||||
|
pub use full_upgrade::full_upgrade;
|
||||||
pub use install::install;
|
pub use install::install;
|
||||||
pub use rebuild::rebuild;
|
pub use rebuild::rebuild;
|
||||||
pub use remove::remove;
|
pub use remove::remove;
|
||||||
pub use sync::sync;
|
pub use sync::sync;
|
||||||
pub use upgrade::upgrade;
|
pub use upgrade::upgrade;
|
||||||
|
|
||||||
|
const SYSTEM_UPDATER: &str = "topgrade";
|
||||||
const PACKAGE_MANAGER: &str = "paru";
|
const PACKAGE_MANAGER: &str = "paru";
|
||||||
|
|
||||||
fn get_package_path() -> PathBuf {
|
fn get_package_path() -> PathBuf {
|
||||||
@@ -27,11 +30,7 @@ fn get_package_path() -> PathBuf {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn ask_confirmation() -> Result<bool, io::Error> {
|
fn ask_confirmation() -> Result<bool, io::Error> {
|
||||||
print!(
|
print!("{} Do you want to continue? [Y/n] ", "::".bold().blue());
|
||||||
"{} {}",
|
|
||||||
"::".bold().blue(),
|
|
||||||
"Do you want to continue? [Y/n] "
|
|
||||||
);
|
|
||||||
io::stdout().flush()?;
|
io::stdout().flush()?;
|
||||||
|
|
||||||
let mut input = String::new();
|
let mut input = String::new();
|
||||||
|
|||||||
Reference in New Issue
Block a user