Compare commits

..

No commits in common. 'fdd9ecb3a5b5a3536fb0a27afd37e3d3a88e324b' and '1dffd70db2b4e5b46d6cadddcaa46a8de2be2e1b' have entirely different histories.

  1. 16
      cmd/declpac/main.go
  2. 18
      pkg/fetch/alpm/alpm.go
  3. 10
      pkg/fetch/aur/aur.go
  4. 16
      pkg/fetch/fetch.go
  5. 10
      pkg/log/log.go
  6. 41
      pkg/pacman/pacman.go
  7. 31
      pkg/pacman/read/read.go
  8. 28
      pkg/pacman/sync/sync.go

16
cmd/declpac/main.go

@ -20,7 +20,6 @@ type Config struct {
StateFiles []string
NoConfirm bool
DryRun bool
Verbose bool
}
func main() {
@ -41,15 +40,8 @@ func main() {
Usage: "Simulate the sync without making changes",
Destination: &cfg.DryRun,
},
&cli.BoolFlag{
Name: "verbose",
Aliases: []string{"v"},
Usage: "Enable verbose output",
Destination: &cfg.Verbose,
},
},
Action: func(ctx context.Context, cmd *cli.Command) error {
log.Verbose = cfg.Verbose
return run(cfg)
},
}
@ -61,14 +53,14 @@ func main() {
func run(cfg *Config) error {
start := time.Now()
log.Debug("run: starting...")
fmt.Fprintf(os.Stderr, "[debug] run: starting...\n")
packages, err := input.ReadPackages(cfg.StateFiles)
if err != nil {
fmt.Fprintf(os.Stderr, "error: %v\n", err)
return err
}
log.Debug("run: packages read (%.2fs)", time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] run: packages read (%.2fs)\n", time.Since(start).Seconds())
merged := merge.Merge(packages)
@ -79,7 +71,7 @@ func run(cfg *Config) error {
return err
}
fmt.Println(output.Format(result))
log.Debug("run: dry-run done (%.2fs)", time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] run: dry-run done (%.2fs)\n", time.Since(start).Seconds())
return nil
}
@ -96,6 +88,6 @@ func run(cfg *Config) error {
}
fmt.Println(output.Format(result))
log.Debug("run: sync done (%.2fs)", time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] run: sync done (%.2fs)\n", time.Since(start).Seconds())
return nil
}

18
pkg/fetch/alpm/alpm.go

@ -2,10 +2,10 @@ package alpm
import (
"fmt"
"os"
"time"
"github.com/Jguer/dyalpm"
"github.com/Riyyi/declpac/pkg/log"
)
var (
@ -21,7 +21,7 @@ type Handle struct {
func New() (*Handle, error) {
start := time.Now()
log.Debug("alpm.New: starting...")
fmt.Fprintf(os.Stderr, "[debug] alpm.New: starting...\n")
handle, err := dyalpm.Initialize(Root, PacmanState)
if err != nil {
@ -48,7 +48,7 @@ func New() (*Handle, error) {
}
}
log.Debug("alpm.New: done (%.2fs)", time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] alpm.New: done (%.2fs)\n", time.Since(start).Seconds())
return &Handle{
handle: handle,
localDB: localDB,
@ -64,7 +64,7 @@ func (h *Handle) Release() error {
}
func registerSyncDBs(handle dyalpm.Handle) ([]dyalpm.Database, error) {
log.Debug("registerSyncDBs: starting...")
fmt.Fprintf(os.Stderr, "[debug] registerSyncDBs: starting...\n")
repos := []string{"core", "extra", "multilib"}
var dbs []dyalpm.Database
@ -86,13 +86,13 @@ func registerSyncDBs(handle dyalpm.Handle) ([]dyalpm.Database, error) {
}
}
log.Debug("registerSyncDBs: done (%d dbs)", len(dbs))
fmt.Fprintf(os.Stderr, "[debug] registerSyncDBs: done (%d dbs)\n", len(dbs))
return dbs, nil
}
func (h *Handle) LocalPackages() (map[string]dyalpm.Package, error) {
start := time.Now()
log.Debug("LocalPackages: starting...")
fmt.Fprintf(os.Stderr, "[debug] LocalPackages: starting...\n")
localPkgs := make(map[string]dyalpm.Package)
@ -104,13 +104,13 @@ func (h *Handle) LocalPackages() (map[string]dyalpm.Package, error) {
return nil, fmt.Errorf("failed to iterate local package cache: %w", err)
}
log.Debug("LocalPackages: done (%.2fs)", time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] LocalPackages: done (%.2fs)\n", time.Since(start).Seconds())
return localPkgs, nil
}
func (h *Handle) SyncPackages(pkgNames []string) (map[string]dyalpm.Package, error) {
start := time.Now()
log.Debug("SyncPackages: starting...")
fmt.Fprintf(os.Stderr, "[debug] SyncPackages: starting...\n")
syncPkgs := make(map[string]dyalpm.Package)
pkgSet := make(map[string]bool)
@ -132,6 +132,6 @@ func (h *Handle) SyncPackages(pkgNames []string) (map[string]dyalpm.Package, err
}
}
log.Debug("SyncPackages: done (%.2fs)", time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] SyncPackages: done (%.2fs)\n", time.Since(start).Seconds())
return syncPkgs, nil
}

10
pkg/fetch/aur/aur.go

@ -2,12 +2,12 @@ package aur
import (
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
"os"
"time"
"github.com/Riyyi/declpac/pkg/log"
)
var AURInfoURL = "https://aur.archlinux.org/rpc?v=5&type=info"
@ -35,7 +35,7 @@ func New() *Client {
func (c *Client) Fetch(packages []string) (map[string]Package, error) {
start := time.Now()
log.Debug("aur.Fetch: starting...")
fmt.Fprintf(os.Stderr, "[debug] aur.Fetch: starting...\n")
result := make(map[string]Package)
@ -51,7 +51,7 @@ func (c *Client) Fetch(packages []string) (map[string]Package, error) {
}
if len(uncached) == 0 {
log.Debug("aur.Fetch: done (cached) (%.2fs)", time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] aur.Fetch: done (cached) (%.2fs)\n", time.Since(start).Seconds())
for _, pkg := range packages {
result[pkg] = c.cache[pkg]
}
@ -84,7 +84,7 @@ func (c *Client) Fetch(packages []string) (map[string]Package, error) {
result[r.Name] = r
}
log.Debug("aur.Fetch: done (%.2fs)", time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] aur.Fetch: done (%.2fs)\n", time.Since(start).Seconds())
return result, nil
}

16
pkg/fetch/fetch.go

@ -2,11 +2,11 @@ package fetch
import (
"fmt"
"os"
"time"
"github.com/Riyyi/declpac/pkg/fetch/alpm"
"github.com/Riyyi/declpac/pkg/fetch/aur"
"github.com/Riyyi/declpac/pkg/log"
)
type PackageInfo struct {
@ -24,7 +24,7 @@ type Fetcher struct {
func New() (*Fetcher, error) {
start := time.Now()
log.Debug("fetch.Fetcher New: starting...")
fmt.Fprintf(os.Stderr, "[debug] fetch.Fetcher New: starting...\n")
alpmHandle, err := alpm.New()
if err != nil {
@ -33,7 +33,7 @@ func New() (*Fetcher, error) {
aurClient := aur.New()
log.Debug("fetch.Fetcher New: done (%.2fs)", time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] fetch.Fetcher New: done (%.2fs)\n", time.Since(start).Seconds())
return &Fetcher{
alpmHandle: alpmHandle,
aurClient: aurClient,
@ -62,7 +62,7 @@ func (f *Fetcher) BuildLocalPkgMap() (map[string]interface{}, error) {
func (f *Fetcher) Resolve(packages []string) (map[string]*PackageInfo, error) {
start := time.Now()
log.Debug("fetch.Resolve: starting...")
fmt.Fprintf(os.Stderr, "[debug] fetch.Resolve: starting...\n")
result := make(map[string]*PackageInfo)
for _, pkg := range packages {
@ -73,7 +73,7 @@ func (f *Fetcher) Resolve(packages []string) (map[string]*PackageInfo, error) {
if err != nil {
return nil, err
}
log.Debug("fetch.Resolve: sync db check done (%.2fs)", time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] fetch.Resolve: sync db check done (%.2fs)\n", time.Since(start).Seconds())
for pkg := range syncPkgs {
result[pkg].Exists = true
@ -84,7 +84,7 @@ func (f *Fetcher) Resolve(packages []string) (map[string]*PackageInfo, error) {
if err != nil {
return nil, err
}
log.Debug("fetch.Resolve: local pkgs built (%.2fs)", time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] fetch.Resolve: local pkgs built (%.2fs)\n", time.Since(start).Seconds())
for pkg := range localPkgs {
if info, ok := result[pkg]; ok {
@ -101,7 +101,7 @@ func (f *Fetcher) Resolve(packages []string) (map[string]*PackageInfo, error) {
if len(notInSync) > 0 {
if _, err := f.aurClient.Fetch(notInSync); err != nil {
log.Debug("fetch.Resolve: aur fetch error: %v", err)
fmt.Fprintf(os.Stderr, "[debug] fetch.Resolve: aur fetch error: %v\n", err)
}
for _, pkg := range packages {
@ -127,6 +127,6 @@ func (f *Fetcher) Resolve(packages []string) (map[string]*PackageInfo, error) {
}
}
log.Debug("fetch.Resolve: done (%.2fs)", time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] fetch.Resolve: done (%.2fs)\n", time.Since(start).Seconds())
return result, nil
}

10
pkg/log/log.go

@ -11,16 +11,6 @@ import (
// -----------------------------------------
var logFile *os.File
var Verbose bool
// -----------------------------------------
func Debug(format string, args ...interface{}) {
if !Verbose {
return
}
fmt.Fprintf(os.Stderr, "[debug] "+format+"\n", args...)
}
// -----------------------------------------

41
pkg/pacman/pacman.go

@ -15,7 +15,7 @@ import (
func Sync(packages []string) (*output.Result, error) {
start := time.Now()
log.Debug("Sync: starting...")
fmt.Fprintf(os.Stderr, "[debug] Sync: starting...\n")
list, err := read.List()
if err != nil {
@ -32,35 +32,36 @@ func Sync(packages []string) (*output.Result, error) {
return nil, err
}
}
log.Debug("Sync: database fresh (%.2fs)", time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] Sync: database fresh (%.2fs)\n", time.Since(start).Seconds())
f, err := fetch.New()
if err != nil {
return nil, err
}
defer f.Close()
log.Debug("Sync: initialized fetcher (%.2fs)", time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] Sync: initialized fetcher (%.2fs)\n", time.Since(start).Seconds())
log.Debug("Sync: categorizing packages...")
fmt.Fprintf(os.Stderr, "[debug] Sync: categorizing packages...\n")
pacmanPkgs, aurPkgs, err := categorizePackages(f, packages)
if err != nil {
return nil, err
}
log.Debug("Sync: packages categorized (%.2fs)", time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] Sync: packages categorized (%.2fs)\n", time.Since(start).Seconds())
if len(pacmanPkgs) > 0 {
log.Debug("Sync: syncing %d pacman packages...", len(pacmanPkgs))
fmt.Fprintf(os.Stderr, "[debug] Sync: syncing %d pacman packages...\n", len(pacmanPkgs))
if err := sync.SyncPackages(pacmanPkgs, log.GetLogWriter()); err != nil {
return nil, err
}
log.Debug("Sync: pacman packages synced (%.2fs)", time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] Sync: pacman packages synced (%.2fs)\n", time.Since(start).Seconds())
}
for _, pkg := range aurPkgs {
if slices.Contains(list, pkg) {
fmt.Fprintf(os.Stderr, "[debug] Sync: AUR package %s already installed, skipping...\n", pkg)
continue
}
log.Debug("Sync: installing AUR package %s...", pkg)
fmt.Fprintf(os.Stderr, "[debug] Sync: installing AUR package %s...\n", pkg)
aurInfo, ok := f.GetAURPackage(pkg)
if !ok {
return nil, fmt.Errorf("AUR package not found in cache: %s", pkg)
@ -68,18 +69,18 @@ func Sync(packages []string) (*output.Result, error) {
if err := sync.InstallAUR(pkg, aurInfo.PackageBase, log.GetLogWriter()); err != nil {
return nil, err
}
log.Debug("Sync: AUR package %s installed (%.2fs)", pkg, time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] Sync: AUR package %s installed (%.2fs)\n", pkg, time.Since(start).Seconds())
}
log.Debug("Sync: marking all as deps...")
fmt.Fprintf(os.Stderr, "[debug] Sync: marking all as deps...\n")
markAllAsDeps()
log.Debug("Sync: all marked as deps (%.2fs)", time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] Sync: all marked as deps (%.2fs)\n", time.Since(start).Seconds())
log.Debug("Sync: marking state packages as explicit...")
fmt.Fprintf(os.Stderr, "[debug] Sync: marking state packages as explicit...\n")
if err := sync.MarkAs(packages, "explicit", log.GetLogWriter()); err != nil {
fmt.Fprintf(os.Stderr, "warning: could not mark state packages as explicit: %v\n", err)
}
log.Debug("Sync: state packages marked as explicit (%.2fs)", time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] Sync: state packages marked as explicit (%.2fs)\n", time.Since(start).Seconds())
removed, err := cleanupOrphans()
if err != nil {
@ -94,7 +95,7 @@ func Sync(packages []string) (*output.Result, error) {
installedCount := max(after-before, 0)
log.Debug("Sync: done (%.2fs)", time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] Sync: done (%.2fs)\n", time.Since(start).Seconds())
return &output.Result{
Installed: installedCount,
Removed: removed,
@ -103,7 +104,7 @@ func Sync(packages []string) (*output.Result, error) {
func categorizePackages(f *fetch.Fetcher, packages []string) (pacmanPkgs, aurPkgs []string, err error) {
start := time.Now()
log.Debug("categorizePackages: starting...")
fmt.Fprintf(os.Stderr, "[debug] categorizePackages: starting...\n")
resolved, err := f.Resolve(packages)
if err != nil {
@ -123,13 +124,13 @@ func categorizePackages(f *fetch.Fetcher, packages []string) (pacmanPkgs, aurPkg
}
}
log.Debug("categorizePackages: done (%.2fs)", time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] categorizePackages: done (%.2fs)\n", time.Since(start).Seconds())
return pacmanPkgs, aurPkgs, nil
}
func markAllAsDeps() error {
start := time.Now()
log.Debug("markAllAsDeps: starting...")
fmt.Fprintf(os.Stderr, "[debug] markAllAsDeps: starting...\n")
packages, err := read.List()
if err != nil || len(packages) == 0 {
@ -141,13 +142,13 @@ func markAllAsDeps() error {
return err
}
log.Debug("markAllAsDeps: done (%.2fs)", time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] markAllAsDeps: done (%.2fs)\n", time.Since(start).Seconds())
return nil
}
func cleanupOrphans() (int, error) {
start := time.Now()
log.Debug("cleanupOrphans: starting...")
fmt.Fprintf(os.Stderr, "[debug] cleanupOrphans: starting...\n")
orphans, err := read.ListOrphans()
if err != nil {
@ -161,6 +162,6 @@ func cleanupOrphans() (int, error) {
return 0, err
}
log.Debug("cleanupOrphans: done (%.2fs)", time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] cleanupOrphans: done (%.2fs)\n", time.Since(start).Seconds())
return removed, nil
}

31
pkg/pacman/read/read.go

@ -1,8 +1,6 @@
package read
import (
"bytes"
"errors"
"fmt"
"os"
"os/exec"
@ -10,7 +8,6 @@ import (
"time"
"github.com/Riyyi/declpac/pkg/fetch"
"github.com/Riyyi/declpac/pkg/log"
"github.com/Riyyi/declpac/pkg/output"
)
@ -18,7 +15,7 @@ var LockFile = "/var/lib/pacman/db.lock"
func List() ([]string, error) {
start := time.Now()
log.Debug("List: starting...")
fmt.Fprintf(os.Stderr, "[debug] List: starting...\n")
cmd := exec.Command("pacman", "-Qq")
output, err := cmd.Output()
@ -31,25 +28,17 @@ func List() ([]string, error) {
list = nil
}
log.Debug("List: done (%.2fs)", time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] List: done (%.2fs)\n", time.Since(start).Seconds())
return list, nil
}
func ListOrphans() ([]string, error) {
start := time.Now()
log.Debug("ListOrphans: starting...")
fmt.Fprintf(os.Stderr, "[debug] ListOrphans: starting...\n")
cmd := exec.Command("pacman", "-Qdtq")
var stderr bytes.Buffer
cmd.Stderr = &stderr
output, err := cmd.Output()
if err != nil {
// pacman -Qdtq exits 1 when there are no orphans, this isnt an error
var exitErr *exec.ExitError
if errors.As(err, &exitErr) && exitErr.ExitCode() == 1 && stderr.Len() == 0 {
return nil, nil
}
return nil, err
}
@ -58,7 +47,7 @@ func ListOrphans() ([]string, error) {
orphans = orphans[1:]
}
log.Debug("ListOrphans: done (%.2fs)", time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] ListOrphans: done (%.2fs)\n", time.Since(start).Seconds())
return orphans, nil
}
@ -74,20 +63,20 @@ func DBFreshness() (bool, error) {
func DryRun(packages []string) (*output.Result, error) {
start := time.Now()
log.Debug("DryRun: starting...")
fmt.Fprintf(os.Stderr, "[debug] DryRun: starting...\n")
f, err := fetch.New()
if err != nil {
return nil, err
}
defer f.Close()
log.Debug("DryRun: initialized fetcher (%.2fs)", time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] DryRun: initialized fetcher (%.2fs)\n", time.Since(start).Seconds())
resolved, err := f.Resolve(packages)
if err != nil {
return nil, err
}
log.Debug("DryRun: packages resolved (%.2fs)", time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] DryRun: packages resolved (%.2fs)\n", time.Since(start).Seconds())
var toInstall []string
var aurPkgs []string
@ -102,13 +91,13 @@ func DryRun(packages []string) (*output.Result, error) {
toInstall = append(toInstall, pkg)
}
}
log.Debug("DryRun: packages categorized (%.2fs)", time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] DryRun: packages categorized (%.2fs)\n", time.Since(start).Seconds())
orphans, err := ListOrphans()
if err != nil {
return nil, err
}
log.Debug("DryRun: orphans listed (%.2fs)", time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] DryRun: orphans listed (%.2fs)\n", time.Since(start).Seconds())
pkgSet := make(map[string]bool)
for _, p := range packages {
@ -121,7 +110,7 @@ func DryRun(packages []string) (*output.Result, error) {
}
}
log.Debug("DryRun: done (%.2fs)", time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] DryRun: done (%.2fs)\n", time.Since(start).Seconds())
return &output.Result{
Installed: len(toInstall) + len(aurPkgs),
Removed: len(toRemove),

28
pkg/pacman/sync/sync.go

@ -7,8 +7,6 @@ import (
"os/exec"
"strings"
"time"
"github.com/Riyyi/declpac/pkg/log"
)
type Result struct {
@ -18,7 +16,7 @@ type Result struct {
func SyncPackages(packages []string, logWriter io.Writer) error {
start := time.Now()
log.Debug("SyncPackages: starting...")
fmt.Fprintf(os.Stderr, "[debug] SyncPackages: starting...\n")
if logWriter == nil {
logWriter = os.Stderr
@ -35,13 +33,13 @@ func SyncPackages(packages []string, logWriter io.Writer) error {
return fmt.Errorf("pacman sync failed: %w", err)
}
log.Debug("SyncPackages: done (%.2fs)", time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] SyncPackages: done (%.2fs)\n", time.Since(start).Seconds())
return nil
}
func RefreshDB(logWriter io.Writer) error {
start := time.Now()
log.Debug("RefreshDB: starting...")
fmt.Fprintf(os.Stderr, "[debug] RefreshDB: starting...\n")
if logWriter == nil {
logWriter = os.Stderr
@ -55,7 +53,7 @@ func RefreshDB(logWriter io.Writer) error {
return fmt.Errorf("failed to refresh pacman database: %w", err)
}
log.Debug("RefreshDB: done (%.2fs)", time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] RefreshDB: done (%.2fs)\n", time.Since(start).Seconds())
return nil
}
@ -65,7 +63,7 @@ func MarkAs(packages []string, flag string, logWriter io.Writer) error {
}
start := time.Now()
flagName := map[string]string{"deps": "asdeps", "explicit": "asexplicit"}[flag]
log.Debug("MarkAs(%s): starting...", flag)
fmt.Fprintf(os.Stderr, "[debug] MarkAs(%s): starting...\n", flag)
if logWriter == nil {
logWriter = os.Stderr
@ -82,20 +80,20 @@ func MarkAs(packages []string, flag string, logWriter io.Writer) error {
return fmt.Errorf("mark as %s failed: %w", flag, err)
}
log.Debug("MarkAs(%s): done (%.2fs)", flag, time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] MarkAs(%s): done (%.2fs)\n", flag, time.Since(start).Seconds())
return nil
}
func RemoveOrphans(orphans []string, logWriter io.Writer) (int, error) {
start := time.Now()
log.Debug("RemoveOrphans: starting...")
fmt.Fprintf(os.Stderr, "[debug] RemoveOrphans: starting...\n")
if logWriter == nil {
logWriter = os.Stderr
}
if len(orphans) == 0 {
log.Debug("RemoveOrphans: done (no orphans) (%.2fs)", time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] RemoveOrphans: done (no orphans) (%.2fs)\n", time.Since(start).Seconds())
return 0, nil
}
@ -114,13 +112,13 @@ func RemoveOrphans(orphans []string, logWriter io.Writer) (int, error) {
count := len(orphans)
log.Debug("RemoveOrphans: done (%d) (%.2fs)", count, time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] RemoveOrphans: done (%d) (%.2fs)\n", count, time.Since(start).Seconds())
return count, nil
}
func InstallAUR(pkgName string, packageBase string, logWriter io.Writer) error {
start := time.Now()
log.Debug("InstallAUR: starting...")
fmt.Fprintf(os.Stderr, "[debug] InstallAUR: starting...\n")
if logWriter == nil {
logWriter = os.Stderr
@ -152,7 +150,7 @@ func InstallAUR(pkgName string, packageBase string, logWriter io.Writer) error {
if err := cloneCmd.Run(); err != nil {
return fmt.Errorf("failed to clone AUR repo: %w", err)
}
log.Debug("InstallAUR: cloned (%.2fs)", time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] InstallAUR: cloned (%.2fs)\n", time.Since(start).Seconds())
makepkgCmdStr := "su - " + sudoUser + " -c 'cd " + tmpDir + " && makepkg -s --noconfirm'"
fmt.Fprintf(logWriter, "[cmd] %s\n", makepkgCmdStr)
@ -162,7 +160,7 @@ func InstallAUR(pkgName string, packageBase string, logWriter io.Writer) error {
if err := makepkgCmd.Run(); err != nil {
return fmt.Errorf("makepkg failed to build AUR package: %w", err)
}
log.Debug("InstallAUR: built (%.2fs)", time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] InstallAUR: built (%.2fs)\n", time.Since(start).Seconds())
pkgFile, err := findPKGFile(tmpDir)
if err != nil {
@ -177,7 +175,7 @@ func InstallAUR(pkgName string, packageBase string, logWriter io.Writer) error {
if err := installCmd.Run(); err != nil {
return fmt.Errorf("failed to install package: %w", err)
}
log.Debug("InstallAUR: done (%.2fs)", time.Since(start).Seconds())
fmt.Fprintf(os.Stderr, "[debug] InstallAUR: done (%.2fs)\n", time.Since(start).Seconds())
return nil
}

Loading…
Cancel
Save