Compare commits

..
8 Commits
Author SHA1 Message Date
AI BotandRiyyi 1159be59d0 Add safety check before package pruning
Verifies all state packages are installed locally before running
markAllAsDeps and orphan cleanup.
2026-05-04 23:28:58 +02:00
Riyyi 0fc0684801 Improve tarball selection when installing AUR packages 2026-05-04 22:47:07 +02:00
AI BotandRiyyi bcddfd13e7 Also install repo dependencies when installing AUR packages 2026-05-04 21:13:25 +02:00
Riyyi 4472bbc2e9 Add grill-me skill 2026-05-04 20:25:43 +02:00
Riyyi b371c74e9a Make tool request elevated privileges on-demand 2026-05-03 23:04:34 +02:00
Riyyi 76b83437ac Add safety check before rm -rf call 2026-05-03 22:17:51 +02:00
AI BotandRiyyi b04869f0e1 Move log to user owned directory 2026-05-03 21:29:49 +02:00
AI BotandRiyyi 7c4b0eda8b Apply coding conventions 2026-05-03 18:01:00 +02:00
18 changed files with 253 additions and 2790 deletions
-376
View File
@@ -1,376 +0,0 @@
{
"name": ".opencode",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"dependencies": {
"@opencode-ai/plugin": "1.14.17"
}
},
"node_modules/@msgpackr-extract/msgpackr-extract-darwin-arm64": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-darwin-arm64/-/msgpackr-extract-darwin-arm64-3.0.3.tgz",
"integrity": "sha512-QZHtlVgbAdy2zAqNA9Gu1UpIuI8Xvsd1v8ic6B2pZmeFnFcMWiPLfWXh7TVw4eGEZ/C9TH281KwhVoeQUKbyjw==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"darwin"
]
},
"node_modules/@msgpackr-extract/msgpackr-extract-darwin-x64": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-darwin-x64/-/msgpackr-extract-darwin-x64-3.0.3.tgz",
"integrity": "sha512-mdzd3AVzYKuUmiWOQ8GNhl64/IoFGol569zNRdkLReh6LRLHOXxU4U8eq0JwaD8iFHdVGqSy4IjFL4reoWCDFw==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"darwin"
]
},
"node_modules/@msgpackr-extract/msgpackr-extract-linux-arm": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-linux-arm/-/msgpackr-extract-linux-arm-3.0.3.tgz",
"integrity": "sha512-fg0uy/dG/nZEXfYilKoRe7yALaNmHoYeIoJuJ7KJ+YyU2bvY8vPv27f7UKhGRpY6euFYqEVhxCFZgAUNQBM3nw==",
"cpu": [
"arm"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@msgpackr-extract/msgpackr-extract-linux-arm64": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-linux-arm64/-/msgpackr-extract-linux-arm64-3.0.3.tgz",
"integrity": "sha512-YxQL+ax0XqBJDZiKimS2XQaf+2wDGVa1enVRGzEvLLVFeqa5kx2bWbtcSXgsxjQB7nRqqIGFIcLteF/sHeVtQg==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@msgpackr-extract/msgpackr-extract-linux-x64": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-linux-x64/-/msgpackr-extract-linux-x64-3.0.3.tgz",
"integrity": "sha512-cvwNfbP07pKUfq1uH+S6KJ7dT9K8WOE4ZiAcsrSes+UY55E/0jLYc+vq+DO7jlmqRb5zAggExKm0H7O/CBaesg==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
]
},
"node_modules/@msgpackr-extract/msgpackr-extract-win32-x64": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-win32-x64/-/msgpackr-extract-win32-x64-3.0.3.tgz",
"integrity": "sha512-x0fWaQtYp4E6sktbsdAqnehxDgEc/VwM7uLsRCYWaiGu0ykYdZPiS8zCWdnjHwyiumousxfBm4SO31eXqwEZhQ==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"win32"
]
},
"node_modules/@opencode-ai/plugin": {
"version": "1.14.17",
"resolved": "https://registry.npmjs.org/@opencode-ai/plugin/-/plugin-1.14.17.tgz",
"integrity": "sha512-duZbNClMsIR1rmYGsrkA92BuGKkH2TsXk1TpPNBASVukVXSSz2jLdhe1UkSeNVXiDg/aGT52yVgitga3rV8qWw==",
"license": "MIT",
"dependencies": {
"@opencode-ai/sdk": "1.14.17",
"effect": "4.0.0-beta.48",
"zod": "4.1.8"
},
"peerDependencies": {
"@opentui/core": ">=0.1.100",
"@opentui/solid": ">=0.1.100"
},
"peerDependenciesMeta": {
"@opentui/core": {
"optional": true
},
"@opentui/solid": {
"optional": true
}
}
},
"node_modules/@opencode-ai/sdk": {
"version": "1.14.17",
"resolved": "https://registry.npmjs.org/@opencode-ai/sdk/-/sdk-1.14.17.tgz",
"integrity": "sha512-Q42C4VsczrPc+8hB76OO18KZ3A3l4cRHy31Vn8if7W/02qHAA1JoQXbbZD9/9fBqHHyYXC6h9dd4H4TaBi53Zw==",
"license": "MIT",
"dependencies": {
"cross-spawn": "7.0.6"
}
},
"node_modules/@standard-schema/spec": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.1.0.tgz",
"integrity": "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==",
"license": "MIT"
},
"node_modules/cross-spawn": {
"version": "7.0.6",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
"integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
"license": "MIT",
"dependencies": {
"path-key": "^3.1.0",
"shebang-command": "^2.0.0",
"which": "^2.0.1"
},
"engines": {
"node": ">= 8"
}
},
"node_modules/detect-libc": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz",
"integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==",
"license": "Apache-2.0",
"optional": true,
"engines": {
"node": ">=8"
}
},
"node_modules/effect": {
"version": "4.0.0-beta.48",
"resolved": "https://registry.npmjs.org/effect/-/effect-4.0.0-beta.48.tgz",
"integrity": "sha512-MMAM/ZabuNdNmgXiin+BAanQXK7qM8mlt7nfXDoJ/Gn9V8i89JlCq+2N0AiWmqFLXjGLA0u3FjiOjSOYQk5uMw==",
"license": "MIT",
"dependencies": {
"@standard-schema/spec": "^1.1.0",
"fast-check": "^4.6.0",
"find-my-way-ts": "^0.1.6",
"ini": "^6.0.0",
"kubernetes-types": "^1.30.0",
"msgpackr": "^1.11.9",
"multipasta": "^0.2.7",
"toml": "^4.1.1",
"uuid": "^13.0.0",
"yaml": "^2.8.3"
}
},
"node_modules/fast-check": {
"version": "4.7.0",
"resolved": "https://registry.npmjs.org/fast-check/-/fast-check-4.7.0.tgz",
"integrity": "sha512-NsZRtqvSSoCP0HbNjUD+r1JH8zqZalyp6gLY9e7OYs7NK9b6AHOs2baBFeBG7bVNsuoukh89x2Yg3rPsul8ziQ==",
"funding": [
{
"type": "individual",
"url": "https://github.com/sponsors/dubzzz"
},
{
"type": "opencollective",
"url": "https://opencollective.com/fast-check"
}
],
"license": "MIT",
"dependencies": {
"pure-rand": "^8.0.0"
},
"engines": {
"node": ">=12.17.0"
}
},
"node_modules/find-my-way-ts": {
"version": "0.1.6",
"resolved": "https://registry.npmjs.org/find-my-way-ts/-/find-my-way-ts-0.1.6.tgz",
"integrity": "sha512-a85L9ZoXtNAey3Y6Z+eBWW658kO/MwR7zIafkIUPUMf3isZG0NCs2pjW2wtjxAKuJPxMAsHUIP4ZPGv0o5gyTA==",
"license": "MIT"
},
"node_modules/ini": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/ini/-/ini-6.0.0.tgz",
"integrity": "sha512-IBTdIkzZNOpqm7q3dRqJvMaldXjDHWkEDfrwGEQTs5eaQMWV+djAhR+wahyNNMAa+qpbDUhBMVt4ZKNwpPm7xQ==",
"license": "ISC",
"engines": {
"node": "^20.17.0 || >=22.9.0"
}
},
"node_modules/isexe": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
"integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",
"license": "ISC"
},
"node_modules/kubernetes-types": {
"version": "1.30.0",
"resolved": "https://registry.npmjs.org/kubernetes-types/-/kubernetes-types-1.30.0.tgz",
"integrity": "sha512-Dew1okvhM/SQcIa2rcgujNndZwU8VnSapDgdxlYoB84ZlpAD43U6KLAFqYo17ykSFGHNPrg0qry0bP+GJd9v7Q==",
"license": "Apache-2.0"
},
"node_modules/msgpackr": {
"version": "1.11.10",
"resolved": "https://registry.npmjs.org/msgpackr/-/msgpackr-1.11.10.tgz",
"integrity": "sha512-iCZNq+HszvF+fC3anCm4nBmWEnbeIAfpDs6IStAEKhQ2YSgkjzVG2FF9XJqwwQh5bH3N9OUTUt4QwVN6MLMLtA==",
"license": "MIT",
"optionalDependencies": {
"msgpackr-extract": "^3.0.2"
}
},
"node_modules/msgpackr-extract": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/msgpackr-extract/-/msgpackr-extract-3.0.3.tgz",
"integrity": "sha512-P0efT1C9jIdVRefqjzOQ9Xml57zpOXnIuS+csaB4MdZbTdmGDLo8XhzBG1N7aO11gKDDkJvBLULeFTo46wwreA==",
"hasInstallScript": true,
"license": "MIT",
"optional": true,
"dependencies": {
"node-gyp-build-optional-packages": "5.2.2"
},
"bin": {
"download-msgpackr-prebuilds": "bin/download-prebuilds.js"
},
"optionalDependencies": {
"@msgpackr-extract/msgpackr-extract-darwin-arm64": "3.0.3",
"@msgpackr-extract/msgpackr-extract-darwin-x64": "3.0.3",
"@msgpackr-extract/msgpackr-extract-linux-arm": "3.0.3",
"@msgpackr-extract/msgpackr-extract-linux-arm64": "3.0.3",
"@msgpackr-extract/msgpackr-extract-linux-x64": "3.0.3",
"@msgpackr-extract/msgpackr-extract-win32-x64": "3.0.3"
}
},
"node_modules/multipasta": {
"version": "0.2.7",
"resolved": "https://registry.npmjs.org/multipasta/-/multipasta-0.2.7.tgz",
"integrity": "sha512-KPA58d68KgGil15oDqXjkUBEBYc00XvbPj5/X+dyzeo/lWm9Nc25pQRlf1D+gv4OpK7NM0J1odrbu9JNNGvynA==",
"license": "MIT"
},
"node_modules/node-gyp-build-optional-packages": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/node-gyp-build-optional-packages/-/node-gyp-build-optional-packages-5.2.2.tgz",
"integrity": "sha512-s+w+rBWnpTMwSFbaE0UXsRlg7hU4FjekKU4eyAih5T8nJuNZT1nNsskXpxmeqSK9UzkBl6UgRlnKc8hz8IEqOw==",
"license": "MIT",
"optional": true,
"dependencies": {
"detect-libc": "^2.0.1"
},
"bin": {
"node-gyp-build-optional-packages": "bin.js",
"node-gyp-build-optional-packages-optional": "optional.js",
"node-gyp-build-optional-packages-test": "build-test.js"
}
},
"node_modules/path-key": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
"integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/pure-rand": {
"version": "8.4.0",
"resolved": "https://registry.npmjs.org/pure-rand/-/pure-rand-8.4.0.tgz",
"integrity": "sha512-IoM8YF/jY0hiugFo/wOWqfmarlE6J0wc6fDK1PhftMk7MGhVZl88sZimmqBBFomLOCSmcCCpsfj7wXASCpvK9A==",
"funding": [
{
"type": "individual",
"url": "https://github.com/sponsors/dubzzz"
},
{
"type": "opencollective",
"url": "https://opencollective.com/fast-check"
}
],
"license": "MIT"
},
"node_modules/shebang-command": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
"integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
"license": "MIT",
"dependencies": {
"shebang-regex": "^3.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/shebang-regex": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",
"integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/toml": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/toml/-/toml-4.1.1.tgz",
"integrity": "sha512-EBJnVBr3dTXdA89WVFoAIPUqkBjxPMwRqsfuo1r240tKFHXv3zgca4+NJib/h6TyvGF7vOawz0jGuryJCdNHrw==",
"license": "MIT",
"engines": {
"node": ">=20"
}
},
"node_modules/uuid": {
"version": "13.0.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-13.0.0.tgz",
"integrity": "sha512-XQegIaBTVUjSHliKqcnFqYypAd4S+WCYt5NIeRs6w/UAry7z8Y9j5ZwRRL4kzq9U3sD6v+85er9FvkEaBpji2w==",
"funding": [
"https://github.com/sponsors/broofa",
"https://github.com/sponsors/ctavan"
],
"license": "MIT",
"bin": {
"uuid": "dist-node/bin/uuid"
}
},
"node_modules/which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"license": "ISC",
"dependencies": {
"isexe": "^2.0.0"
},
"bin": {
"node-which": "bin/node-which"
},
"engines": {
"node": ">= 8"
}
},
"node_modules/yaml": {
"version": "2.8.3",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.3.tgz",
"integrity": "sha512-AvbaCLOO2Otw/lW5bmh9d/WEdcDFdQp2Z2ZUH3pX9U2ihyUY0nvLv7J6TrWowklRGPYbB/IuIMfYgxaCPg5Bpg==",
"license": "ISC",
"bin": {
"yaml": "bin.mjs"
},
"engines": {
"node": ">= 14.6"
},
"funding": {
"url": "https://github.com/sponsors/eemeli"
}
},
"node_modules/zod": {
"version": "4.1.8",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/colinhacks"
}
}
}
}
+10
View File
@@ -0,0 +1,10 @@
---
name: grill-me
description: Interview the user relentlessly about a plan or design until reaching shared understanding, resolving each branch of the decision tree. Use when user wants to stress-test a plan, get grilled on their design, or mentions "grill me".
---
Interview me relentlessly about every aspect of this plan until we reach a shared understanding. Walk down each branch of the design tree, resolving dependencies between decisions one-by-one. For each question, provide your recommended answer.
Ask the questions one at a time.
If a question can be answered by exploring the codebase, explore the codebase instead.
-56
View File
@@ -1,56 +0,0 @@
# Checking if a Package is Provided by Another Package
## Using FindDBSatisfier
The `FindDBSatisfier` method in the handle finds a package that satisfies a given dependency string across sync databases. It automatically resolves `Provides` relationships.
### Basic Usage
```go
// Given a package name "foo", find which package provides it
h := dyalpm.NewHandle(...)
dbs := h.SyncDBS()
// This finds ANY package that satisfies "foo" - including via Provides
provider := h.FindDBSatisfier(dbs, "foo")
if provider != nil {
// The package "foo" is provided by provider.Name()
}
```
### How It Works
When you search for a package "foo", ALPM will find packages that:
1. Are named "foo"
2. Have `Provides: foo` in their metadata
### Full Example
```go
h, err := dyalpm.NewHandle(rootDir, cacheDir, dyalpm.ArchLinux)
if err != nil {
// handle error
}
syncDBs, err := h.SyncDBS()
if err != nil {
// handle error
}
// Search for "foo" package (may be provided by another package)
targetName := "foo"
provider := h.FindDBSatisfier(syncDBs, targetName)
if provider != nil {
fmt.Printf("%s is provided by: %s\n", targetName, provider.Name())
fmt.Printf("Version: %s\n", provider.Version())
} else {
fmt.Printf("No package found providing: %s\n", targetName)
}
```
## Related Functions
- `FindSatisfier(pkgs []Package, depstring)` - Same concept but for an in-memory package list
- `PackageIterator.FindSatisfier(depstring)` - Works on iterator results from `db.Search()`
- `pkg.Provides() []Depend` - Get what a package provides (see `package.go:144`)
+7 -13
View File
@@ -27,22 +27,22 @@ sudo mv declpac /usr/local/bin/
- pacman - pacman
- makepkg (for AUR support) - makepkg (for AUR support)
- git (for AUR support) - git (for AUR support)
- Root privileges - sudo/doas (root privileges)
## Usage ## Usage
```bash ```bash
# Single state file # Single state file
sudo declpac --state packages.txt declpac --state packages.txt
# Multiple state files # Multiple state files
sudo declpac --state base.txt --state apps.txt declpac --state base.txt --state apps.txt
# From stdin # From stdin
cat packages.txt | sudo declpac cat packages.txt | declpac
# Preview changes without applying # Preview changes without applying
sudo declpac --dry-run --state packages.txt declpac --dry-run --state packages.txt
``` ```
### State File Format ### State File Format
@@ -89,17 +89,11 @@ If the pacman database is older than 24 hours, it is automatically refreshed.
### Logging ### Logging
Operations are logged to `/var/log/declpac.log`. Operation are logged to `$XDG_STATE_HOME/declpac.log`
(or `~/.local/state/declpac.log` on fallback)
## Troubleshooting ## Troubleshooting
### Permission denied
Use sudo:
```bash
sudo declpac --state packages.txt
```
### Package not found ### Package not found
Check if the package exists: Check if the package exists:
-1
View File
@@ -1 +0,0 @@
hexchat
-1
View File
@@ -1 +0,0 @@
noctalia-shell
+3
View File
@@ -8,6 +8,7 @@ import (
"github.com/urfave/cli/v3" "github.com/urfave/cli/v3"
"github.com/Riyyi/declpac/pkg/auth"
"github.com/Riyyi/declpac/pkg/input" "github.com/Riyyi/declpac/pkg/input"
"github.com/Riyyi/declpac/pkg/log" "github.com/Riyyi/declpac/pkg/log"
"github.com/Riyyi/declpac/pkg/output" "github.com/Riyyi/declpac/pkg/output"
@@ -97,6 +98,8 @@ func run(cfg *Config) error {
return nil return nil
} }
auth.Start()
if err := log.OpenLog(); err != nil { if err := log.OpenLog(); err != nil {
fmt.Fprintf(os.Stderr, "error: %v\n", err) fmt.Fprintf(os.Stderr, "error: %v\n", err)
return err return err
-1659
View File
File diff suppressed because it is too large Load Diff
-254
View File
@@ -1,254 +0,0 @@
[debug] run: starting...
[debug] run: packages read (0.00s)
[debug] CheckDBFreshness: starting...
[debug] Sync: starting...
[debug] getInstalledCount: starting...
[debug] getInstalledCount: done (0.01s)
[debug] CheckDBFreshness: starting...
[debug] Sync: database fresh (0.01s)
[debug] Fetcher New: starting...
[debug] registerSyncDBs: starting...
[debug] registerSyncDBs: done (3 dbs)
[debug] Fetcher New: done (0.13s)
[debug] Sync: initialized fetcher (0.13s)
[debug] Sync: categorizing packages...
[debug] categorizePackages: starting...
[debug] Resolve: starting...
[debug] buildLocalPkgMap: starting...
[debug] buildLocalPkgMap: done (0.00s)
[debug] Resolve: local pkgs built (0.00s)
[debug] checkSyncDBs: starting...
[debug] checkSyncDBs: done (0.00s)
[debug] ensureAURCache: starting...
[debug] fetchAURInfo: starting...
[debug] fetchAURInfo: done (0.20s)
[debug] ensureAURCache: done (0.20s)
[debug] Resolve: done (0.21s)
[debug] categorizePackages: done (0.21s)
[debug] Sync: packages categorized (0.34s)
[debug] Sync: syncing 183 pacman packages...
[debug] SyncPackages: starting...
error: pacman sync failed: warning: texlab-5.25.1-1 is up to date -- skipping
warning: wpa_supplicant-2:2.11-5 is up to date -- skipping
warning: kcachegrind-25.12.3-1 is up to date -- skipping
warning: kdenlive-25.12.3-1 is up to date -- skipping
warning: aspell-en-2026.02.25-1 is up to date -- skipping
warning: dialog-1:1.3_20260107-1 is up to date -- skipping
warning: duf-0.9.1-1 is up to date -- skipping
warning: ffmpegthumbnailer-2.3.0-1 is up to date -- skipping
warning: python-certifi-2026.02.25-1 is up to date -- skipping
warning: base-3-3 is up to date -- skipping
warning: hunspell-1.7.2-3 is up to date -- skipping
warning: hunspell-nl-2.20.19-5 is up to date -- skipping
warning: ttf-dejavu-nerd-3.4.0-2 is up to date -- skipping
warning: vim-spell-en-20220628-2 is up to date -- skipping
warning: hunspell-en_us-2026.02.25-1 is up to date -- skipping
warning: pacman-contrib-1.13.1-1 is up to date -- skipping
warning: unzip-6.0-23 is up to date -- skipping
warning: base-devel-1-2 is up to date -- skipping
warning: sysfsutils-2.1.1-2 is up to date -- skipping
warning: imv-5.0.1-1 is up to date -- skipping
warning: otf-font-awesome-7.2.0-1 is up to date -- skipping
warning: python-zstandard-0.25.0-2 is up to date -- skipping
warning: socat-1.8.1.1-1 is up to date -- skipping
warning: wget-1.25.0-3 is up to date -- skipping
warning: zsh-completions-0.36.0-1 is up to date -- skipping
warning: python-adblock-0.6.0-5 is up to date -- skipping
warning: gammastep-2.0.11-2 is up to date -- skipping
warning: nwg-look-1.0.6-1 is up to date -- skipping
warning: man-pages-6.17-1 is up to date -- skipping
warning: inetutils-2.7-2 is up to date -- skipping
warning: kolourpaint-25.12.3-1 is up to date -- skipping
warning: thunar-volman-4.20.0-2 is up to date -- skipping
warning: valgrind-3.25.1-4 is up to date -- skipping
warning: dnsmasq-2.92-1 is up to date -- skipping
warning: evtest-1.36-1 is up to date -- skipping
warning: rtmpdump-1:2.6-1 is up to date -- skipping
warning: man-db-2.13.1-1 is up to date -- skipping
warning: ncdu-2.9.2-1 is up to date -- skipping
warning: jq-1.8.1-1 is up to date -- skipping
warning: qt5ct-1.9-1 is up to date -- skipping
warning: linux-firmware-20260309-1 is up to date -- skipping
warning: mpv-1:0.41.0-3 is up to date -- skipping
warning: waybar-0.15.0-2 is up to date -- skipping
warning: capitaine-cursors-4-3 is up to date -- skipping
warning: exfat-utils-1.4.0-4 is up to date -- skipping
warning: qt5-tools-5.15.18+kde+r3-2 is up to date -- skipping
warning: ydotool-1.0.4-2 is up to date -- skipping
warning: isync-1.5.1-2 is up to date -- skipping
warning: namcap-3.6.0-3 is up to date -- skipping
warning: qt5-serialport-5.15.18-1 is up to date -- skipping
warning: kvantum-qt5-1.1.6-1 is up to date -- skipping
warning: 7zip-26.00-1 is up to date -- skipping
warning: aspell-nl-0.50.2-8 is up to date -- skipping
warning: python-beautifulsoup4-4.14.3-2 is up to date -- skipping
warning: gnome-themes-extra-1:3.28-1 is up to date -- skipping
warning: mesa-demos-9.0.0-7 is up to date -- skipping
warning: mysql-workbench-8.0.46-1 is up to date -- skipping
warning: vim-spell-nl-20220628-2 is up to date -- skipping
warning: xf86-input-wacom-1.2.4-1 is up to date -- skipping
warning: kvantum-1.1.6-1 is up to date -- skipping
warning: efibootmgr-18-3 is up to date -- skipping
warning: ntfs-3g-2022.10.3-2 is up to date -- skipping
warning: tokei-14.0.0-1 is up to date -- skipping
warning: python-pycurl-7.45.7-3 is up to date -- skipping
warning: rofi-2.0.0-1 is up to date -- skipping
warning: r-4.5.3-1 is up to date -- skipping
warning: smartmontools-7.5-1 is up to date -- skipping
warning: acpi-1.8-2 is up to date -- skipping
warning: reflector-2023-5 is up to date -- skipping
warning: tlp-1.9.1-1 is up to date -- skipping
warning: rtkit-0.14-1 is up to date -- skipping
warning: lib32-glibc-2.43+r5+g856c426a7534-1 is up to date -- skipping
warning: mariadb-12.2.2-2 is up to date -- skipping
warning: brightnessctl-0.5.1-3 is up to date -- skipping
warning: usbutils-019-1 is up to date -- skipping
warning: amd-ucode-20260309-1 is up to date -- skipping
warning: lib32-openal-1.25.1-1 is up to date -- skipping
warning: pavucontrol-1:6.2-1 is up to date -- skipping
warning: python-pyusb-1.3.1-2 is up to date -- skipping
warning: aria2-1.37.0-2 is up to date -- skipping
warning: git-2.53.0-1 is up to date -- skipping
warning: python-matplotlib-3.10.8-5 is up to date -- skipping
warning: iw-6.17-1 is up to date -- skipping
warning: ark-25.12.3-1 is up to date -- skipping
warning: grim-1.5.0-2 is up to date -- skipping
warning: python-watchdog-6.0.0-2 is up to date -- skipping
warning: nlohmann-json-3.12.0-2 is up to date -- skipping
warning: netctl-1.29-2 is up to date -- skipping
warning: rsync-3.4.1-2 is up to date -- skipping
warning: sqlitebrowser-3.13.1-3 is up to date -- skipping
warning: tumbler-4.20.1-1 is up to date -- skipping
warning: python-opengl-3.1.10-3 is up to date -- skipping
warning: sshfs-3.7.5-1 is up to date -- skipping
resolving dependencies...
looking for conflicting packages...
error: failed to prepare transaction (could not satisfy dependencies)
:: installing hyprutils (0.12.0-1) breaks dependency 'libhyprutils.so=10-64' required by aquamarine
:: installing libvpx (1.16.0-3) breaks dependency 'libvpx.so=11-64' required by ffmpeg
:: installing gst-plugins-base-libs (1.28.2-1) breaks dependency 'gst-plugins-base-libs=1.28.1-1' required by gst-plugins-bad-libs
:: installing gstreamer (1.28.2-1) breaks dependency 'gstreamer=1.28.1-1' required by gst-plugins-bad-libs
:: installing gst-plugins-base-libs (1.28.2-1) breaks dependency 'gst-plugins-base-libs=1.28.1-1' required by gst-plugins-base
:: installing gstreamer (1.28.2-1) breaks dependency 'gstreamer=1.28.1-1' required by gst-plugins-base
:: installing hyprutils (0.12.0-1) breaks dependency 'libhyprutils.so=10-64' required by hyprgraphics
:: installing hyprutils (0.12.0-1) breaks dependency 'libhyprutils.so=10-64' required by hyprland-guiutils
:: installing hyprutils (0.12.0-1) breaks dependency 'libhyprutils.so=10-64' required by hyprlang
:: installing hyprutils (0.12.0-1) breaks dependency 'libhyprutils.so=10-64' required by hyprtoolkit
:: installing hyprutils (0.12.0-1) breaks dependency 'libhyprutils.so=10-64' required by hyprwire
:: installing libpipewire (1:1.6.3-1) breaks dependency 'libpipewire=1:1.6.1-1' required by pipewire-jack
:: installing pipewire-audio (1:1.6.3-1) breaks dependency 'pipewire-audio=1:1.6.1-1' required by pipewire-jack
:: installing pipewire (1:1.6.3-1) breaks dependency 'pipewire=1:1.6.1-1' required by pipewire-jack
:: installing poppler (26.04.0-1) breaks dependency 'poppler=26.02.0' required by poppler-qt6
error: pacman sync failed: warning: texlab-5.25.1-1 is up to date -- skipping
warning: wpa_supplicant-2:2.11-5 is up to date -- skipping
warning: kcachegrind-25.12.3-1 is up to date -- skipping
warning: kdenlive-25.12.3-1 is up to date -- skipping
warning: aspell-en-2026.02.25-1 is up to date -- skipping
warning: dialog-1:1.3_20260107-1 is up to date -- skipping
warning: duf-0.9.1-1 is up to date -- skipping
warning: ffmpegthumbnailer-2.3.0-1 is up to date -- skipping
warning: python-certifi-2026.02.25-1 is up to date -- skipping
warning: base-3-3 is up to date -- skipping
warning: hunspell-1.7.2-3 is up to date -- skipping
warning: hunspell-nl-2.20.19-5 is up to date -- skipping
warning: ttf-dejavu-nerd-3.4.0-2 is up to date -- skipping
warning: vim-spell-en-20220628-2 is up to date -- skipping
warning: hunspell-en_us-2026.02.25-1 is up to date -- skipping
warning: pacman-contrib-1.13.1-1 is up to date -- skipping
warning: unzip-6.0-23 is up to date -- skipping
warning: base-devel-1-2 is up to date -- skipping
warning: sysfsutils-2.1.1-2 is up to date -- skipping
warning: imv-5.0.1-1 is up to date -- skipping
warning: otf-font-awesome-7.2.0-1 is up to date -- skipping
warning: python-zstandard-0.25.0-2 is up to date -- skipping
warning: socat-1.8.1.1-1 is up to date -- skipping
warning: wget-1.25.0-3 is up to date -- skipping
warning: zsh-completions-0.36.0-1 is up to date -- skipping
warning: python-adblock-0.6.0-5 is up to date -- skipping
warning: gammastep-2.0.11-2 is up to date -- skipping
warning: nwg-look-1.0.6-1 is up to date -- skipping
warning: man-pages-6.17-1 is up to date -- skipping
warning: inetutils-2.7-2 is up to date -- skipping
warning: kolourpaint-25.12.3-1 is up to date -- skipping
warning: thunar-volman-4.20.0-2 is up to date -- skipping
warning: valgrind-3.25.1-4 is up to date -- skipping
warning: dnsmasq-2.92-1 is up to date -- skipping
warning: evtest-1.36-1 is up to date -- skipping
warning: rtmpdump-1:2.6-1 is up to date -- skipping
warning: man-db-2.13.1-1 is up to date -- skipping
warning: ncdu-2.9.2-1 is up to date -- skipping
warning: jq-1.8.1-1 is up to date -- skipping
warning: qt5ct-1.9-1 is up to date -- skipping
warning: linux-firmware-20260309-1 is up to date -- skipping
warning: mpv-1:0.41.0-3 is up to date -- skipping
warning: waybar-0.15.0-2 is up to date -- skipping
warning: capitaine-cursors-4-3 is up to date -- skipping
warning: exfat-utils-1.4.0-4 is up to date -- skipping
warning: qt5-tools-5.15.18+kde+r3-2 is up to date -- skipping
warning: ydotool-1.0.4-2 is up to date -- skipping
warning: isync-1.5.1-2 is up to date -- skipping
warning: namcap-3.6.0-3 is up to date -- skipping
warning: qt5-serialport-5.15.18-1 is up to date -- skipping
warning: kvantum-qt5-1.1.6-1 is up to date -- skipping
warning: 7zip-26.00-1 is up to date -- skipping
warning: aspell-nl-0.50.2-8 is up to date -- skipping
warning: python-beautifulsoup4-4.14.3-2 is up to date -- skipping
warning: gnome-themes-extra-1:3.28-1 is up to date -- skipping
warning: mesa-demos-9.0.0-7 is up to date -- skipping
warning: mysql-workbench-8.0.46-1 is up to date -- skipping
warning: vim-spell-nl-20220628-2 is up to date -- skipping
warning: xf86-input-wacom-1.2.4-1 is up to date -- skipping
warning: kvantum-1.1.6-1 is up to date -- skipping
warning: efibootmgr-18-3 is up to date -- skipping
warning: ntfs-3g-2022.10.3-2 is up to date -- skipping
warning: tokei-14.0.0-1 is up to date -- skipping
warning: python-pycurl-7.45.7-3 is up to date -- skipping
warning: rofi-2.0.0-1 is up to date -- skipping
warning: r-4.5.3-1 is up to date -- skipping
warning: smartmontools-7.5-1 is up to date -- skipping
warning: acpi-1.8-2 is up to date -- skipping
warning: reflector-2023-5 is up to date -- skipping
warning: tlp-1.9.1-1 is up to date -- skipping
warning: rtkit-0.14-1 is up to date -- skipping
warning: lib32-glibc-2.43+r5+g856c426a7534-1 is up to date -- skipping
warning: mariadb-12.2.2-2 is up to date -- skipping
warning: brightnessctl-0.5.1-3 is up to date -- skipping
warning: usbutils-019-1 is up to date -- skipping
warning: amd-ucode-20260309-1 is up to date -- skipping
warning: lib32-openal-1.25.1-1 is up to date -- skipping
warning: pavucontrol-1:6.2-1 is up to date -- skipping
warning: python-pyusb-1.3.1-2 is up to date -- skipping
warning: aria2-1.37.0-2 is up to date -- skipping
warning: git-2.53.0-1 is up to date -- skipping
warning: python-matplotlib-3.10.8-5 is up to date -- skipping
warning: iw-6.17-1 is up to date -- skipping
warning: ark-25.12.3-1 is up to date -- skipping
warning: grim-1.5.0-2 is up to date -- skipping
warning: python-watchdog-6.0.0-2 is up to date -- skipping
warning: nlohmann-json-3.12.0-2 is up to date -- skipping
warning: netctl-1.29-2 is up to date -- skipping
warning: rsync-3.4.1-2 is up to date -- skipping
warning: sqlitebrowser-3.13.1-3 is up to date -- skipping
warning: tumbler-4.20.1-1 is up to date -- skipping
warning: python-opengl-3.1.10-3 is up to date -- skipping
warning: sshfs-3.7.5-1 is up to date -- skipping
resolving dependencies...
looking for conflicting packages...
error: failed to prepare transaction (could not satisfy dependencies)
:: installing hyprutils (0.12.0-1) breaks dependency 'libhyprutils.so=10-64' required by aquamarine
:: installing libvpx (1.16.0-3) breaks dependency 'libvpx.so=11-64' required by ffmpeg
:: installing gst-plugins-base-libs (1.28.2-1) breaks dependency 'gst-plugins-base-libs=1.28.1-1' required by gst-plugins-bad-libs
:: installing gstreamer (1.28.2-1) breaks dependency 'gstreamer=1.28.1-1' required by gst-plugins-bad-libs
:: installing gst-plugins-base-libs (1.28.2-1) breaks dependency 'gst-plugins-base-libs=1.28.1-1' required by gst-plugins-base
:: installing gstreamer (1.28.2-1) breaks dependency 'gstreamer=1.28.1-1' required by gst-plugins-base
:: installing hyprutils (0.12.0-1) breaks dependency 'libhyprutils.so=10-64' required by hyprgraphics
:: installing hyprutils (0.12.0-1) breaks dependency 'libhyprutils.so=10-64' required by hyprland-guiutils
:: installing hyprutils (0.12.0-1) breaks dependency 'libhyprutils.so=10-64' required by hyprlang
:: installing hyprutils (0.12.0-1) breaks dependency 'libhyprutils.so=10-64' required by hyprtoolkit
:: installing hyprutils (0.12.0-1) breaks dependency 'libhyprutils.so=10-64' required by hyprwire
:: installing libpipewire (1:1.6.3-1) breaks dependency 'libpipewire=1:1.6.1-1' required by pipewire-jack
:: installing pipewire-audio (1:1.6.3-1) breaks dependency 'pipewire-audio=1:1.6.1-1' required by pipewire-jack
:: installing pipewire (1:1.6.3-1) breaks dependency 'pipewire=1:1.6.1-1' required by pipewire-jack
:: installing poppler (26.04.0-1) breaks dependency 'poppler=26.02.0' required by poppler-qt6
-236
View File
@@ -1,236 +0,0 @@
7zip
acpi
adobe-source-han-sans-jp-fonts
adw-gtk-theme
amd-ucode
android-studio
arc-icon-theme
archlinux-keyring
aria2
ark
aspell-en
aspell-nl
base
base-devel
bc
blender
brightnessctl
bun-bin
capitaine-cursors
cbindgen
checkbashisms
chromium
clang
cmake
dbeaver
declpac-git
dhcpcd
dialog
dnsmasq
dos2unix
downgrade
duf
dunst
dxvk-bin
easyeda-pro-bin
efibootmgr
emacs-wayland
evtest
exfat-utils
fastfetch
ffmpegthumbnailer
firefox
freecad
gamescope
gammastep
gdb
gedit
ghostty
git
gnome-calculator
gnome-keyring
gnome-themes-extra
gopls
gparted
grim
gst-plugins-good
gucharmap
gvfs
gvfs-gphoto2
gvfs-mtp
gvim
hexchat
htop
hunspell
hunspell-en_us
hunspell-nl
hypridle
hyprland
hyprlock
hyprpaper
hyprpolkitagent
icu76
imagemagick
imake
imv
inetutils
inkscape
ipfs-desktop-bin
isync
iw
jdownloader2
jq
kcachegrind
kdenlive
keepmenu-git
kolourpaint
krita
kvantum
kvantum-qt5
lib32-glibc
lib32-mesa
lib32-openal
lib32-vkd3d-proton-git
lib32-vulkan-radeon
libvirt
linux
linux-firmware
linux-headers
linux-lts
linux-lts-headers
llvm
man-db
man-pages
manafiles-git
mariadb
mesa-demos
mkvtoolnix-cli
moka-icon-theme-git
mokutil
mpv
mu
mysql-workbench
namcap
nasm
ncdu
neovim
netctl
niri-no-decorations
nix
nixfmt
nlohmann-json
nodejs-intelephense
npm
ns-usbloader
ntfs-3g
nwg-look
ollama-rocm
ollama-vulkan
opencode
openssh
otf-font-awesome
pacman-contrib
pamixer
pavucontrol
pdfjs
picard
pipewire-alsa
pipewire-pulse
platformio-core
playwright
poppler-glib
python-adblock
python-beautifulsoup4
python-certifi
python-filelock
python-flask
python-google-api-python-client
python-google-auth-oauthlib
python-matplotlib
python-opengl
python-pycurl
python-pyqt5
python-pyusb
python-watchdog
python-zstandard
qbittorrent
qt5-declarative
qt5-serialport
qt5-tools
qt5-wayland
qt5ct
qt6ct
r
reflector
rofi
rsync
rtkit
rtmpdump
rust
signal-desktop
slurp
smartmontools
socat
sqlitebrowser
sshfs
steam
streamlink
sunshine-bin
syncthing
sysfsutils
texlab
texlive-bibtexextra
texlive-fontsextra
texlive-formatsextra
texlive-games
texlive-humanities
texlive-latexextra
texlive-mathscience
texlive-music
texlive-pictures
texlive-pstricks
texlive-publishers
thunar
thunar-volman
thunderbird
tibia
tlp
tokei
tree
trizen
ttf-dejavu
ttf-dejavu-nerd
ttf-joypixels
tumbler
tumbler-extra-thumbnailers
unrar
unzip
usbutils
valgrind
ventoy-bin
vim-spell-en
vim-spell-nl
virt-manager
vkd3d-proton-bin
vulkan-radeon
waybar
wget
wine-staging
winetricks
wl-clipboard
wpa_supplicant
x86_energy_perf_policy
xdg-desktop-portal-hyprland
xf86-input-wacom
xfsprogs
xorg-server-xvfb
yasm
ydotool
yt-dlp
yt-dlp-drop-in
zathura
zathura-pdf-mupdf
zip
zsh
zsh-completions
zsh-syntax-highlighting
+104
View File
@@ -0,0 +1,104 @@
package auth
import (
"fmt"
"os/exec"
"regexp"
"strconv"
"time"
"github.com/Riyyi/declpac/pkg/log"
)
var tool string
var timeout time.Duration = 5 * time.Minute
var refreshCommand []string = []string{"-n", "true"}
// -----------------------------------------
// public
func Command(name string, args ...string) *exec.Cmd {
if tool == "" {
return log.Command(name, args...)
}
args = append([]string{name}, args...)
return log.Command(tool, args...)
}
func Run() {
exec.Command(tool, refreshCommand...).Run()
}
func Start() error {
err := detect()
if err != nil {
return err
}
// Automatically refresh privilege elevation to prevent user prompts
go func() {
for {
Run()
time.Sleep(timeout)
}
}()
return nil
}
// -----------------------------------------
// private
func detect() error {
tool = getTool()
if tool == "" {
return fmt.Errorf("no privilege elevation tool detected in PATH")
}
parseTimeout()
// We have to be a little faster than the actual timeout
timeout -= 30 * time.Second
return nil
}
func execLookPath(name string) string {
path, err := exec.LookPath(name)
if err != nil {
return ""
}
return path
}
func getTool() string {
sudo := execLookPath("sudo")
doas := execLookPath("doas")
if sudo != "" {
return "sudo"
}
if doas != "" {
return "doas"
}
return ""
}
func parseTimeout() {
switch tool {
case "sudo":
out, err := exec.Command("sudo", "sudo", "-V").CombinedOutput()
if err != nil {
return
}
re := regexp.MustCompile(`Authentication timestamp timeout: (\d+)\..*`)
matches := re.FindStringSubmatch(string(out))
if len(matches) == 2 {
if minutes, err := strconv.Atoi(matches[1]); err == nil {
timeout = time.Duration(minutes) * time.Minute
}
}
case "doas":
exec.Command("doas", "true").Run()
}
}
+5 -13
View File
@@ -6,6 +6,8 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
"github.com/Riyyi/declpac/pkg/lib"
) )
var ErrEmptyList = errors.New("package list is empty") var ErrEmptyList = errors.New("package list is empty")
@@ -28,7 +30,7 @@ func ReadPackages(stateFiles []string) (map[string]bool, error) {
packages := make(map[string]bool) packages := make(map[string]bool)
for _, file := range stateFiles { for _, file := range stateFiles {
expanded := expandPath(file) expanded := lib.ExpandPath(file)
if err := readStateFile(expanded, packages); err != nil { if err := readStateFile(expanded, packages); err != nil {
return nil, err return nil, err
} }
@@ -51,27 +53,17 @@ func ReadPackages(stateFiles []string) (map[string]bool, error) {
// ----------------------------------------- // -----------------------------------------
// private // private
func expandPath(path string) string {
if strings.HasPrefix(path, "~/") {
home, err := os.UserHomeDir()
if err != nil {
return path
}
return filepath.Join(home, path[2:])
}
return path
}
func fileExists(path string) bool { func fileExists(path string) bool {
_, err := os.Stat(path) _, err := os.Stat(path)
return err == nil return err == nil
} }
func getImplicitStateFile() string { func getImplicitStateFile() string {
cfgDir, _ := os.UserConfigDir() cfgDir := os.Getenv("XDG_CONFIG_HOME")
if cfgDir == "" { if cfgDir == "" {
cfgDir = "~/.config" cfgDir = "~/.config"
} }
cfgDir = lib.ExpandPath(cfgDir)
return filepath.Join(cfgDir, "declpac") return filepath.Join(cfgDir, "declpac")
} }
+21
View File
@@ -0,0 +1,21 @@
package lib
import (
"os"
"path/filepath"
"strings"
)
// -----------------------------------------
// public
func ExpandPath(path string) string {
if strings.HasPrefix(path, "~/") {
home, err := os.UserHomeDir()
if err != nil {
return path
}
return filepath.Join(home, path[2:])
}
return path
}
+11 -2
View File
@@ -8,6 +8,8 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"time" "time"
"github.com/Riyyi/declpac/pkg/lib"
) )
var logFile *os.File var logFile *os.File
@@ -29,7 +31,7 @@ func Command(name string, args ...string) *exec.Cmd {
return exec.Command(name, args...) return exec.Command(name, args...)
} }
func Debug(format string, args ...interface{}) { func Debug(format string, args ...any) {
if !Verbose { if !Verbose {
return return
} }
@@ -41,11 +43,18 @@ func GetLogWriter() io.Writer {
} }
func OpenLog() error { func OpenLog() error {
logPath := filepath.Join("/var/log", "declpac.log") stateDir := os.Getenv("XDG_STATE_HOME")
if stateDir == "" {
stateDir = "~/.local/state"
}
stateDir = lib.ExpandPath(stateDir)
logPath := filepath.Join(stateDir, "declpac.log")
f, err := os.OpenFile(logPath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) f, err := os.OpenFile(logPath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil { if err != nil {
return err return err
} }
logFile = f logFile = f
writeTimestamp() writeTimestamp()
return nil return nil
+32
View File
@@ -84,6 +84,12 @@ func Sync(packages []string, noCheck bool, prune bool) (*output.Result, error) {
var removed int var removed int
if prune { if prune {
log.Debug("Sync: running prune sanity check...")
if err := pruneSanityCheck(packages); err != nil {
return nil, err
}
log.Debug("Sync: prune sanity check passed (%.2fs)", time.Since(start).Seconds())
log.Debug("Sync: marking all as deps...") log.Debug("Sync: marking all as deps...")
if err := markAllAsDeps(); err != nil { if err := markAllAsDeps(); err != nil {
return nil, err return nil, err
@@ -183,3 +189,29 @@ func markAllAsDeps() error {
log.Debug("markAllAsDeps: done (%.2fs)", time.Since(start).Seconds()) log.Debug("markAllAsDeps: done (%.2fs)", time.Since(start).Seconds())
return nil return nil
} }
// pruneSanityCheck checks if the installation of all state packages succeeded,
// before attempting to do package marking and orphan cleanup.
func pruneSanityCheck(statePackages []string) error {
start := time.Now()
log.Debug("pruneSanityCheck: starting...")
localPackages, err := read.List()
if err != nil {
return fmt.Errorf("failed to list local packages: %w", err)
}
var missing []string
for _, pkg := range statePackages {
if !slices.Contains(localPackages, pkg) {
missing = append(missing, pkg)
}
}
if len(missing) > 0 {
return fmt.Errorf("safety check: missing state packages: %v", missing)
}
log.Debug("pruneSanityCheck: done (%.2fs)", time.Since(start).Seconds())
return nil
}
+53 -36
View File
@@ -4,18 +4,16 @@ import (
"fmt" "fmt"
"io" "io"
"os" "os"
"os/user"
"strings" "strings"
"sync"
"time" "time"
"github.com/Riyyi/declpac/pkg/auth"
"github.com/Riyyi/declpac/pkg/fetch" "github.com/Riyyi/declpac/pkg/fetch"
"github.com/Riyyi/declpac/pkg/fetch/aur" "github.com/Riyyi/declpac/pkg/fetch/aur"
"github.com/Riyyi/declpac/pkg/log" "github.com/Riyyi/declpac/pkg/log"
) )
var sudoUser string
var sudoUserOnce sync.Once
type Result struct { type Result struct {
Installed int Installed int
Removed int Removed int
@@ -37,19 +35,18 @@ func InstallAUR(f *fetch.Fetcher, pkgName string, packageBase string, asDeps boo
return err return err
} }
sudoUser := getSudoUser() tmpDir := getTempDirName() + "/" + pkgName
tmpDir := "/tmp/declpac/" + pkgName if err := createTempDir(tmpDir); err != nil {
if err := createTempDir(sudoUser, tmpDir); err != nil {
return err return err
} }
defer os.RemoveAll(tmpDir) defer os.RemoveAll(tmpDir)
if err := cloneRepo(sudoUser, packageBase, tmpDir, logWriter); err != nil { if err := cloneRepo(packageBase, tmpDir, logWriter); err != nil {
return err return err
} }
log.Debug("InstallAUR: cloned (%.2fs)", time.Since(start).Seconds()) log.Debug("InstallAUR: cloned (%.2fs)", time.Since(start).Seconds())
if err := buildPackage(sudoUser, tmpDir, asDeps, logWriter); err != nil { if err := buildPackage(tmpDir, asDeps, logWriter); err != nil {
return err return err
} }
log.Debug("InstallAUR: built (%.2fs)", time.Since(start).Seconds()) log.Debug("InstallAUR: built (%.2fs)", time.Since(start).Seconds())
@@ -80,7 +77,7 @@ func MarkAs(packages []string, flag string, logWriter io.Writer) error {
} }
args := append([]string{"-D", "--" + flagName}, packages...) args := append([]string{"-D", "--" + flagName}, packages...)
cmd := log.Command("pacman", args...) cmd := auth.Command("pacman", args...)
cmd.Stdout = logWriter cmd.Stdout = logWriter
cmd.Stderr = logWriter cmd.Stderr = logWriter
err := cmd.Run() err := cmd.Run()
@@ -100,7 +97,7 @@ func RefreshDB(logWriter io.Writer) error {
logWriter = os.Stderr logWriter = os.Stderr
} }
cmd := log.Command("pacman", "-Syy") cmd := auth.Command("pacman", "-Syy")
cmd.Stdout = logWriter cmd.Stdout = logWriter
cmd.Stderr = logWriter cmd.Stderr = logWriter
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {
@@ -127,7 +124,7 @@ func RemoveOrphans(orphans []string, logWriter io.Writer) (int, error) {
args := make([]string, 0, 3+len(orphans)) args := make([]string, 0, 3+len(orphans))
args = append(args, "pacman", "-Rns", "--noconfirm") args = append(args, "pacman", "-Rns", "--noconfirm")
args = append(args, orphans...) args = append(args, orphans...)
removeCmd := log.Command(args[0], args[1:]...) removeCmd := auth.Command(args[0], args[1:]...)
removeCmd.Stdout = logWriter removeCmd.Stdout = logWriter
removeCmd.Stderr = logWriter removeCmd.Stderr = logWriter
err := removeCmd.Run() err := removeCmd.Run()
@@ -150,7 +147,7 @@ func SyncPackages(packages []string, logWriter io.Writer) error {
} }
args := append([]string{"-S", "--needed", "--noconfirm"}, packages...) args := append([]string{"-S", "--needed", "--noconfirm"}, packages...)
cmd := log.Command("pacman", args...) cmd := auth.Command("pacman", args...)
cmd.Stdout = logWriter cmd.Stdout = logWriter
cmd.Stderr = logWriter cmd.Stderr = logWriter
err := cmd.Run() err := cmd.Run()
@@ -165,12 +162,12 @@ func SyncPackages(packages []string, logWriter io.Writer) error {
// ----------------------------------------- // -----------------------------------------
// private // private
func buildPackage(sudoUser string, tmpDir string, asDeps bool, logWriter io.Writer) error { func buildPackage(tmpDir string, asDeps bool, logWriter io.Writer) error {
makepkgArgs := []string{"makepkg", "-s", "--noconfirm"} makepkgArgs := []string{"-D", tmpDir, "-s", "--noconfirm"}
if asDeps { if asDeps {
makepkgArgs = append(makepkgArgs, "--asdeps") makepkgArgs = append(makepkgArgs, "--asdeps")
} }
makepkgCmd := log.Command("su", "-", sudoUser, "-c", "cd "+tmpDir+" && "+strings.Join(makepkgArgs, " ")) makepkgCmd := log.Command("makepkg", makepkgArgs...)
makepkgCmd.Stdout = logWriter makepkgCmd.Stdout = logWriter
makepkgCmd.Stderr = logWriter makepkgCmd.Stderr = logWriter
if err := makepkgCmd.Run(); err != nil { if err := makepkgCmd.Run(); err != nil {
@@ -179,9 +176,9 @@ func buildPackage(sudoUser string, tmpDir string, asDeps bool, logWriter io.Writ
return nil return nil
} }
func cloneRepo(sudoUser string, packageBase string, tmpDir string, logWriter io.Writer) error { func cloneRepo(packageBase string, tmpDir string, logWriter io.Writer) error {
cloneURL := "https://aur.archlinux.org/" + packageBase + ".git" cloneURL := "https://aur.archlinux.org/" + packageBase + ".git"
cloneCmd := log.Command("su", "-", sudoUser, "-c", "git clone "+cloneURL+" "+tmpDir) cloneCmd := log.Command("git", "clone", cloneURL, tmpDir)
cloneCmd.Stdout = logWriter cloneCmd.Stdout = logWriter
cloneCmd.Stderr = logWriter cloneCmd.Stderr = logWriter
if err := cloneCmd.Run(); err != nil { if err := cloneCmd.Run(); err != nil {
@@ -190,11 +187,21 @@ func cloneRepo(sudoUser string, packageBase string, tmpDir string, logWriter io.
return nil return nil
} }
func createTempDir(sudoUser string, tmpDir string) error { func createTempDir(tmpDir string) error {
mkdirCmd := log.Command("su", "-", sudoUser, "-c", "rm -rf "+tmpDir+" && mkdir -p "+tmpDir) if tmpDir == "" || tmpDir == "/" || !strings.HasPrefix(tmpDir, "/tmp") {
return fmt.Errorf("safety check: prevented malformed rm -rf call")
}
rmdirCmd := log.Command("rm", "-rf", tmpDir)
if err := rmdirCmd.Run(); err != nil {
return fmt.Errorf("failed to remove temp directory: %w", err)
}
mkdirCmd := log.Command("mkdir", "-p", tmpDir)
if err := mkdirCmd.Run(); err != nil { if err := mkdirCmd.Run(); err != nil {
return fmt.Errorf("failed to create temp directory: %w", err) return fmt.Errorf("failed to create temp directory: %w", err)
} }
return nil return nil
} }
@@ -208,6 +215,11 @@ func findPKGFile(pkgName string, dir string) (string, error) {
if !strings.HasSuffix(name, ".pkg.tar.zst") && !strings.HasSuffix(name, ".pkg.tar.gz") { if !strings.HasSuffix(name, ".pkg.tar.zst") && !strings.HasSuffix(name, ".pkg.tar.gz") {
continue continue
} }
// Skip packages that do not start with the exact package name, ex: sunshine-bin -> sunshine
if !strings.HasPrefix(name, pkgName) {
continue
}
// Skip packages that provide a debug package, ex: sunshine-bin -> sunshine-debug
if strings.HasPrefix(name, pkgName+"-debug") { if strings.HasPrefix(name, pkgName+"-debug") {
continue continue
} }
@@ -227,21 +239,17 @@ func getAURInfo(f *fetch.Fetcher, pkgName string, packageBase string) *aur.Packa
return &info return &info
} }
func getSudoUser() string { func getTempDirName() string {
sudoUserOnce.Do(func() { user, err := user.Current()
sudoUser = os.Getenv("SUDO_USER") if err != nil {
if sudoUser == "" { return "/tmp/declpac"
sudoUser = os.Getenv("USER")
if sudoUser == "" {
sudoUser = "root"
} }
}
}) return "/tmp/declpac-" + user.Username
return sudoUser
} }
func installBuiltPackage(pkgFile string, logWriter io.Writer) error { func installBuiltPackage(pkgFile string, logWriter io.Writer) error {
installCmd := log.Command("pacman", "-U", "--noconfirm", pkgFile) installCmd := auth.Command("pacman", "-U", "--noconfirm", pkgFile)
installCmd.Stdout = logWriter installCmd.Stdout = logWriter
installCmd.Stderr = logWriter installCmd.Stderr = logWriter
if err := installCmd.Run(); err != nil { if err := installCmd.Run(); err != nil {
@@ -265,17 +273,26 @@ func resolveAndInstallDeps(f *fetch.Fetcher, aurInfo *aur.Package, logWriter io.
return fmt.Errorf("failed to resolve dependencies: %w", err) return fmt.Errorf("failed to resolve dependencies: %w", err)
} }
var aurDeps []string var repoDeps, aurDeps []string
for _, dep := range depends { for _, dep := range depends {
info := resolved[dep] info := resolved[dep]
if info.Installed { if info.Installed {
continue continue
} }
if info.Exists { pkg := dep
continue if info.Provided != "" {
pkg = info.Provided
} }
if info.InAUR { if info.Exists {
aurDeps = append(aurDeps, dep) repoDeps = append(repoDeps, pkg)
} else if info.InAUR {
aurDeps = append(aurDeps, pkg)
}
}
if len(repoDeps) > 0 {
if err := SyncPackages(repoDeps, logWriter); err != nil {
return fmt.Errorf("failed to install repo dependencies: %w", err)
} }
} }
-142
View File
@@ -1,142 +0,0 @@
[debug] run: starting...
[debug] run: packages read (0.00s)
[debug] CheckDBFreshness: starting...
[debug] Sync: starting...
[debug] getInstalledCount: starting...
[debug] getInstalledCount: done (0.01s)
[debug] CheckDBFreshness: starting...
[debug] Sync: database fresh (0.01s)
[debug] Fetcher New: starting...
[debug] registerSyncDBs: starting...
[debug] registerSyncDBs: done (3 dbs)
[debug] Fetcher New: done (0.15s)
[debug] Sync: initialized fetcher (0.15s)
[debug] Sync: categorizing packages...
[debug] categorizePackages: starting...
[debug] Resolve: starting...
[debug] buildLocalPkgMap: starting...
[debug] buildLocalPkgMap: done (0.00s)
[debug] Resolve: local pkgs built (0.00s)
[debug] checkSyncDBs: starting...
[debug] checkSyncDBs: done (0.00s)
[debug] ensureAURCache: starting...
[debug] fetchAURInfo: starting...
[debug] fetchAURInfo: done (0.19s)
[debug] ensureAURCache: done (0.19s)
[debug] Resolve: done (0.20s)
[debug] categorizePackages: done (0.20s)
[debug] Sync: packages categorized (0.36s)
[debug] Sync: syncing 183 pacman packages...
[debug] SyncPackages: starting...
error: pacman sync failed: warning: imv-5.0.1-1 is up to date -- skipping
warning: jq-1.8.1-1 is up to date -- skipping
warning: ntfs-3g-2022.10.3-2 is up to date -- skipping
warning: python-pycurl-7.45.7-3 is up to date -- skipping
warning: usbutils-019-1 is up to date -- skipping
warning: smartmontools-7.5-1 is up to date -- skipping
warning: rsync-3.4.1-2 is up to date -- skipping
warning: linux-firmware-20260309-1 is up to date -- skipping
warning: wget-1.25.0-3 is up to date -- skipping
warning: kvantum-1.1.6-1 is up to date -- skipping
warning: mpv-1:0.41.0-3 is up to date -- skipping
warning: unzip-6.0-23 is up to date -- skipping
warning: ark-25.12.3-1 is up to date -- skipping
warning: brightnessctl-0.5.1-3 is up to date -- skipping
warning: gnome-themes-extra-1:3.28-1 is up to date -- skipping
warning: kolourpaint-25.12.3-1 is up to date -- skipping
warning: rtkit-0.14-1 is up to date -- skipping
warning: isync-1.5.1-2 is up to date -- skipping
warning: qt5-serialport-5.15.18-1 is up to date -- skipping
warning: tlp-1.9.1-1 is up to date -- skipping
warning: amd-ucode-20260309-1 is up to date -- skipping
warning: aria2-1.37.0-2 is up to date -- skipping
warning: lib32-glibc-2.43+r5+g856c426a7534-1 is up to date -- skipping
warning: r-4.5.3-1 is up to date -- skipping
warning: 7zip-26.00-1 is up to date -- skipping
warning: base-devel-1-2 is up to date -- skipping
warning: pacman-contrib-1.13.1-1 is up to date -- skipping
warning: ydotool-1.0.4-2 is up to date -- skipping
warning: sysfsutils-2.1.1-2 is up to date -- skipping
warning: tumbler-4.20.1-1 is up to date -- skipping
warning: efibootmgr-18-3 is up to date -- skipping
warning: exfat-utils-1.4.0-4 is up to date -- skipping
warning: mysql-workbench-8.0.46-1 is up to date -- skipping
warning: python-matplotlib-3.10.8-5 is up to date -- skipping
warning: rofi-2.0.0-1 is up to date -- skipping
warning: inetutils-2.7-2 is up to date -- skipping
warning: thunar-volman-4.20.0-2 is up to date -- skipping
warning: valgrind-3.25.1-4 is up to date -- skipping
warning: python-certifi-2026.02.25-1 is up to date -- skipping
warning: python-opengl-3.1.10-3 is up to date -- skipping
warning: qt5-tools-5.15.18+kde+r3-2 is up to date -- skipping
warning: nwg-look-1.0.6-1 is up to date -- skipping
warning: python-zstandard-0.25.0-2 is up to date -- skipping
warning: sshfs-3.7.5-1 is up to date -- skipping
warning: waybar-0.15.0-2 is up to date -- skipping
warning: base-3-3 is up to date -- skipping
warning: kdenlive-25.12.3-1 is up to date -- skipping
warning: pavucontrol-1:6.2-1 is up to date -- skipping
warning: python-adblock-0.6.0-5 is up to date -- skipping
warning: qt5ct-1.9-1 is up to date -- skipping
warning: wpa_supplicant-2:2.11-5 is up to date -- skipping
warning: aspell-en-2026.02.25-1 is up to date -- skipping
warning: aspell-nl-0.50.2-8 is up to date -- skipping
warning: lib32-openal-1.25.1-1 is up to date -- skipping
warning: ncdu-2.9.2-1 is up to date -- skipping
warning: otf-font-awesome-7.2.0-1 is up to date -- skipping
warning: hunspell-nl-2.20.19-5 is up to date -- skipping
warning: git-2.53.0-1 is up to date -- skipping
warning: nlohmann-json-3.12.0-2 is up to date -- skipping
warning: zsh-completions-0.36.0-1 is up to date -- skipping
warning: man-db-2.13.1-1 is up to date -- skipping
warning: grim-1.5.0-2 is up to date -- skipping
warning: dnsmasq-2.92-1 is up to date -- skipping
warning: kvantum-qt5-1.1.6-1 is up to date -- skipping
warning: iw-6.17-1 is up to date -- skipping
warning: man-pages-6.17-1 is up to date -- skipping
warning: namcap-3.6.0-3 is up to date -- skipping
warning: mesa-demos-9.0.0-7 is up to date -- skipping
warning: reflector-2023-5 is up to date -- skipping
warning: tokei-14.0.0-1 is up to date -- skipping
warning: gammastep-2.0.11-2 is up to date -- skipping
warning: dialog-1:1.3_20260107-1 is up to date -- skipping
warning: mariadb-12.2.2-2 is up to date -- skipping
warning: ttf-dejavu-nerd-3.4.0-2 is up to date -- skipping
warning: vim-spell-nl-20220628-2 is up to date -- skipping
warning: python-pyusb-1.3.1-2 is up to date -- skipping
warning: socat-1.8.1.1-1 is up to date -- skipping
warning: duf-0.9.1-1 is up to date -- skipping
warning: evtest-1.36-1 is up to date -- skipping
warning: rtmpdump-1:2.6-1 is up to date -- skipping
warning: hunspell-1.7.2-3 is up to date -- skipping
warning: kcachegrind-25.12.3-1 is up to date -- skipping
warning: python-watchdog-6.0.0-2 is up to date -- skipping
warning: texlab-5.25.1-1 is up to date -- skipping
warning: sqlitebrowser-3.13.1-3 is up to date -- skipping
warning: acpi-1.8-2 is up to date -- skipping
warning: netctl-1.29-2 is up to date -- skipping
warning: python-beautifulsoup4-4.14.3-2 is up to date -- skipping
warning: vim-spell-en-20220628-2 is up to date -- skipping
warning: xf86-input-wacom-1.2.4-1 is up to date -- skipping
warning: capitaine-cursors-4-3 is up to date -- skipping
warning: ffmpegthumbnailer-2.3.0-1 is up to date -- skipping
warning: hunspell-en_us-2026.02.25-1 is up to date -- skipping
resolving dependencies...
looking for conflicting packages...
error: failed to prepare transaction (could not satisfy dependencies)
:: installing hyprutils (0.12.0-1) breaks dependency 'libhyprutils.so=10-64' required by aquamarine
:: installing libvpx (1.16.0-3) breaks dependency 'libvpx.so=11-64' required by ffmpeg
:: installing gst-plugins-base-libs (1.28.2-1) breaks dependency 'gst-plugins-base-libs=1.28.1-1' required by gst-plugins-bad-libs
:: installing gstreamer (1.28.2-1) breaks dependency 'gstreamer=1.28.1-1' required by gst-plugins-bad-libs
:: installing gst-plugins-base-libs (1.28.2-1) breaks dependency 'gst-plugins-base-libs=1.28.1-1' required by gst-plugins-base
:: installing gstreamer (1.28.2-1) breaks dependency 'gstreamer=1.28.1-1' required by gst-plugins-base
:: installing hyprutils (0.12.0-1) breaks dependency 'libhyprutils.so=10-64' required by hyprgraphics
:: installing hyprutils (0.12.0-1) breaks dependency 'libhyprutils.so=10-64' required by hyprland-guiutils
:: installing hyprutils (0.12.0-1) breaks dependency 'libhyprutils.so=10-64' required by hyprlang
:: installing hyprutils (0.12.0-1) breaks dependency 'libhyprutils.so=10-64' required by hyprtoolkit
:: installing hyprutils (0.12.0-1) breaks dependency 'libhyprutils.so=10-64' required by hyprwire
:: installing libpipewire (1:1.6.3-1) breaks dependency 'libpipewire=1:1.6.1-1' required by pipewire-jack
:: installing pipewire-audio (1:1.6.3-1) breaks dependency 'pipewire-audio=1:1.6.1-1' required by pipewire-jack
:: installing pipewire (1:1.6.3-1) breaks dependency 'pipewire=1:1.6.1-1' required by pipewire-jack
:: installing poppler (26.04.0-1) breaks dependency 'poppler=26.02.0' required by poppler-qt6
+6
View File
@@ -5,6 +5,12 @@
"source": "JuliusBrussee/caveman", "source": "JuliusBrussee/caveman",
"sourceType": "github", "sourceType": "github",
"computedHash": "a818cdc41dcfaa50dd891c5cb5e5705968338de02e7e37949ca56e8c30ad4176" "computedHash": "a818cdc41dcfaa50dd891c5cb5e5705968338de02e7e37949ca56e8c30ad4176"
},
"grill-me": {
"source": "mattpocock/skills",
"sourceType": "github",
"skillPath": "skills/productivity/grill-me/SKILL.md",
"computedHash": "784f0dbb7403b0f00324bce9a112f715342777a0daee7bbb7385f9c6f0a170ea"
} }
} }
} }