Commit graph

80 commits

Author SHA1 Message Date
Joe Groocock 52bf777e67
Print errors on stderr
This makes a start on fixing https://github.com/Jguer/yay/issues/715
It is by no means a complete solution, but instead a start
2018-11-20 22:27:30 +00:00
Jguer 2ed7df4f5a
Unexport consts. Make default a literal
Signed-off-by: Jguer <me@jguer.space>
2018-10-22 21:00:16 +01:00
morganamilo e78070ebbe
Support color = auto
This is done using the test command as the stdlib lacks any way to
do this without using syscalls directly
2018-09-27 16:52:22 +01:00
morganamilo 7f064db676
Fix build when go module is enabled 2018-09-15 18:47:46 +01:00
morganamilo b2f636d93b
Use go-pacmanconf for config parsing
This moves the config parsing from out of alpm and into the
go-pacmanconf libary plus some boilerplate code to get it into our alpm
config.

This makes sense as many config options such as UseColor and CleanMethod
have nothing to do with alpm and only relate to pacman.

pacman-conf is used instead of direct config parsing. This tool resolves
defaults and includes for us, so we don't need to handle it.

It is now safe to drop all the config parsing from go-alpm.
2018-09-10 23:07:34 +01:00
morganamilo 0e695468b8
Expand env before making builddir 2018-09-04 23:07:26 +01:00
morganamilo 8c1658df0b
Expand environment variables in config 2018-08-31 21:20:40 +01:00
morganamilo 2f545c7fdc
Correctly set config.AURURL after parsing flags
And also honour aururl during -Pc
2018-08-19 05:53:32 +01:00
morganamilo 0454e8918b
Add --aururl 2018-08-19 05:10:24 +01:00
morganamilo 339a014614
Go back to using os.Getenv
Most programs seem to take an empty string as being the same as unset.
Even if they are technically different. This makes it easier to unset
variables via `VARIABLE= yay --foo`.
2018-08-12 05:09:56 +01:00
morganamilo febccaef3a
Reorder main
Split functions out into smaller, more simple chunks. Ensure the correct
order of things.

Before, initConfig() would also create config.BuildDirbefore
the command line flags have been applied, so yay would
try to mkdir what was in the config, ignoring the flag.
2018-08-12 05:09:53 +01:00
morganamilo 2fac9c036f
Refactor main.go to use one liner if err checks 2018-08-12 03:53:42 +01:00
morganamilo 1739a88be2
Refactor main function
Move cleanup and error checking to their own functions.
2018-08-12 03:53:42 +01:00
Anna b848514b4b
Merge pull request #585 from Morganamilo/usage
Support Usage in pacman.conf
2018-08-02 13:51:13 +01:00
morganamilo 42a74c41c5
Show alpm warnings 2018-07-31 22:00:41 +01:00
morganamilo 5ce740068e
Always pass PacmanConf to pacman
Normaly we only pass --config to pacman if the user specifies it on the
command line. Otherwise we let pacman use it's default config location.

If the user has changed pacmanconf in Yay's config file then this could
cause a miss match between the config we use to init alpm and the config
pacman is using.
2018-07-28 19:54:41 +01:00
morganamilo 3bdb534321
Separate Pacman upgrade and AUR Upgrade by default
Currently When performing a system upgrade, Yay will first refresh the
database then perform the repo and AUR upgrade. This allows Yay to add
some features such as better batch interaction, showing potential
dependency problems before the upgrade starts and combined menus
showing AUR and repo upgrades together.

There has been discussion that this approach is a bad idea. The main issue
people have is that the separation of the database refresh and the upgrade
could lead to a partial upgrade if Yay fails between the two stages.

Personally I do not like this argument, there are valid reasons to Yay
to fail between these points. For example there may be dependency or
conflict issues during the AUR upgrade. Yay can detect these before any
installing actually starts and exit, just like how pacman will when
there are dependency problems.

If Yay does fail between these points, for the previously mentioned
reasons or even a crash then a simple refresh will not cause a
partial upgrade by itself. It is then the user's responsibility
to either resolve these issues or instead perform an upgrade using
pacman directly.

My opinions aside, The discussions on the Arch wiki has reached
a decision, this method is not recommended. So to follow the decided
best practises this behaviour has been disabled by default.

This behaviour can be toggled using the --[no]combinedupgrade flag

It should be noted that Yay's upgrade menu will not show repo packages
unless --combinedupgrade is used.
2018-06-30 03:40:19 +01:00
Alan Jenkins c3a94edd20 Fix failing tests
There were several calls to fmt.Errorf in setPaths where the returned error was not
being used. This was indicated by ```make test``` as shown here:

```
make test
gofmt -l *.go
go vet
./main.go:16: result of fmt.Errorf call not used
./main.go:21: result of fmt.Errorf call not used
./main.go:25: result of fmt.Errorf call not used
./main.go:30: result of fmt.Errorf call not used
./main.go:35: result of fmt.Errorf call not used
./main.go:39: result of fmt.Errorf call not used
make: *** [Makefile:43: test] Error 2
```

With these changes the tests now all pass with no errors.
2018-06-09 15:40:30 +01:00
morganamilo 7fdb5c2007
Make sure enviroment paths are not empty 2018-06-05 14:17:07 +01:00
morganamilo e5d7cce49c
Fix file paths 2018-06-05 14:14:49 +01:00
morganamilo 3aea877ab9
Tweek config and cache dir initialization
Check if enviroment variables are set instead if they are empty strings.
Don't care if the dir exists just take the path at face value.
Error if $HOME and the respective $XDG.. variables are not set.
2018-06-04 23:31:50 +01:00
morganamilo c399996cab
Fix typos 2018-05-12 17:16:48 +01:00
Jguer ba4ef4f51c Use more filepath.Join, standardize separators 2018-04-28 12:15:18 +01:00
Jguer 58772c871b Fixes #373
Signed-off-by: Jguer <me@jguer.space>
2018-04-28 11:53:10 +01:00
Jguer 84569ef6d9 Fix completions from using wrong path. Regression introduced in filepath join
Signed-off-by: Jguer <me@jguer.space>
2018-04-21 16:43:12 +01:00
morganamilo 86bfacd253
Remove unneeded vars and fix missing err check 2018-04-17 17:57:02 +01:00
morganamilo 110a905a0c
Use filepath.Join() for adding paths together 2018-04-17 01:32:31 +01:00
morganamilo 7768fab978
Supress pacman error printing
add22f5957 added error checks to all the
passToPacman commands. This makes `yay -Q nonexistantpackage` return
non 0 as it should. Annoyingly it also made yay print `exit status = n`
which is the error string from passToPacman calls. This error doesn't
add much and is quite annoying, expecially when calling pacman commands
like `-Q` or `-Si` where yay should be kind of 'hidden' and print just
like pacman does.

Now set the error string to "" for pacman commands and don't print an
error if it == "" (avoids empty line printed).

Also behave more like pacman when using `yay -Qu`.
2018-03-23 19:56:28 +00:00
morganamilo 7fd2a74bd2
Lint 2018-03-22 16:39:27 +00:00
morganamilo 7655bd9c62
Add main.go 2018-03-22 16:38:21 +00:00