99% of the time if a user wants to pas an argument twice they would do
`-cc` or `--clean --clean`. Still doing `-c --clean` is still a valid
thing to do. This commits allows getArg() to this properly.
Previosuly when reading from stdin we did not redirect back to the real
stdin afterwards so it was imposible to interact with y/n questions.
Now redirect back to "/dev/tty" just like pacman does.
With this The user should never have to manually edit the yay config
file. All options can be set directly through yay using
`yay --<option> <value> --save`
Reformatted comments to have a space between // and the start of the
comment.
Added capital letters and punctuation.
Fixed most grammar and spelling mistakes.
Fixed date to yyyy/mm/dd.
Comments have been added to a couple of functions here and there
where I feel warrent some explanation. Hopefully this makes it a little
easier for people to contribute.
I commented on a couple of functions but my main focus is:
DepTree
DepCatagories
StringSet
Arguments
These are parts that have been mostly written by me and might seem
confusing without taking a while to study the code. Especially the first
two mentioned. They're a little complex, I'm not sure if they need to be
This is just how I came up with them. Hopefully helping other people
understand them will let them come up with improvments I did not see.
I'm not the best at explaining things but I did try my best here.
Options such as --devel are now striped from the parser before handling
the command but the option is still processed so that config.devel would
be true.
Also changed `changedConfig` to a global in config.go
I have replaced the old install and dependancy algorithms with a new
design that attemps to be more pacaur like. Mostly in minimizing user
input. Ask every thing first then do everything with no need for more
user input.
It is not yet fully complete but is finished enough so that it works,
should not fail in most cases and provides a base for more contributors
to help address the existing problems.
The new install chain is as follows:
Source info about the provided targets
Fetch a list of all dependancies needed to install targets
I put alot of effort into fetching the dependancy tree
while making the least amount of aur requests as
possible. I'm actually very happy with how it turned out
and yay wil now resolve dependancies noticably faster
than pacaur when there are many aur dependancies.
Install repo targets by passing to pacman
Print dependancy tree and ask to confirm
Ask to clean build if directory already exists
Download all pkgbuilds
Ask to edit all pkgbuilds
Ask to continue with the install
Download the sources for each packagebuild
Build and install every package
using -s to get repo deps and -i to install
Ask to remove make dependancies
There are still a lot of things that need to be done for a fully working
system. Here are the problems I found with this system, either new or
existing:
Formating
I am not so good at formatting myself, I thought best to
leave it until last so I could get feedback on how it
should look and help implementing it.
Dependancy tree
The dependancy tree is usually correct although I have
noticed times where it doesnt detect all the
dependancies that it should. I have only noticed this
when there are circular dependancies so i think this
might be the cause. It's not a big deal currently
because makepkg -i installed repo deps for us which
handles the repo deps for us and will get the correct
ones. So yay might not list all the dependancies. but
they will get installed so I consider this a visual bug.
I have yet to see any circular dependancies in the AUR
so I can not say what will happend but I#m guessing that
it will break.
Versioned packages/dependencies
Targets and dependancies with version constriants such
as 'linux>=4.1' will not be checked on the aur side of
things but will be checked on the repo side.
Ignorepkg/Ignoregroup
Currently I do not handle this in any way but it
shouldn't be too hard to implement.
Conflict checking
This is not currently implemented either
Split Paclages
Split packages are not Handles properly. If we only
specify one package so install from a split package
makepkg -i ends up installing them all anyway. If we
specify more than one (n) package it will actually build the
package base n times and reinstall every split package
n times.
Makepkg
To get things working I decided to keep using the
makepkg -i method. I plan to eventually replace this
with a pacman -U based method. This should allow passing
args such as --dbpath and --config to aur packages
aswell as help solve some problems such as the split
packages.
Clean build
I plan to improve the clean build choice to be a little
more smart and instead of check if the directory exists,
check if the package is already build and if so skip the
build all together.
This allows us to use command line options such as '--root' and '-b' when
performing operations that use out alom handle.
Sadly this does not apply to passToMakepkg which will ignore options
such as '--root' and because we pass '-i' to makepkg it installs for us
using the default options.
Currently I have not planned a solution for this but one which I thought
of but not looked into is. Always call makepkg without arguments (except
from '--noconfirm' and others which might still be needed) and manage
the dependancies and post install outselves.
Another option might be to use makepkg's $PACMAN enviroment variable and
redirect the pacman calls to yay. Although I am unsure about both
stratergys they are just my current thoughts.
Also while editing the flow of cmd.go, I managed to refactor away all
os.Exit calls apart from the very last so it should be more clear as to
where the program exits.
Allows globals to be tracked more easily so that thay can be seperated
from normal arguments and passed easily while not passing other
arguments.
Also fixed some missing checks and bugs.
This reimplemens all operations yay previously supported:
'-S' 'Syu' 'Si' ect.
Currently the argument objects are not fully implemented with the code.
Theres alot of funky conversion from
argument object -> pkg, flags -> argument object
This is to just get back to the functionally we had before (almost).
I have not looked into it yet but alot of the time pacman flags get
passed to makepkg. this cases an error for most commands now because the
new system Passes all flags:
`yay -Syu` -> flags = '-S' '-y' '-u'
while the old system would have done:
`yay -Syu` -> op = '-Suy', flags = ''
So extra flags are no longer passed at all currently.
This means:
'yay -S aic94xx-firmware --noconfirm -b /tmp/pacutilesu2q6hw/tmp-pacman -d'
will no longer error and 'aic94xx-firmware' will be installed but the
database path change will not apply and the dep checking will not be
skipped.
passToPacman now takes and argParser as a paramater. And is implemented
for the simple cases in cmd.go. Although passToPacman is now left non
working in places which still try to usr the old call format and will
need to be reimplemented.
Some of the yay specific operations such as:
'-Qstats' '-Cd'
Break the standard pacamn has set.
Most yay specific specific options have been moved into their own
operator:
'-Y' '--yay'
'-Qstats' -> '-Y --stats'
'--Cd' -> '-Y --cleandeps'
'--gendb' -> '-Y --gendb'
Although:
'-G'
has been kepts and and alias has been added for is:
'--getpkgbuild'
This shouldnt feel too different for most people given that yay will
default to:
'-Y'
when no operator has been specified. So calls like:
'yay --gendb'
will still work as they did.
Internally handleConfig has been partially refactored. Now all that
remians in setters for config. All flags that did anything beond setting
config have been moved to handleYay(). This means less nasty
os.Exit()'s and nicer flow control.
The usage has also been updated. The options changes have been added but
the layout has also been tweaked a bit.
Lastly on the things not done:
Man page has not been updated
Shell completion has not been updated
This will be done in further commits as the usage is not guaranteed
to stay the same between now the completion of the argument system.
Currently the foundation for a new fuller argument parsing has been implemented in
parser.go. Most of the parsing is now done through the argParser object
instead of seperate arrays for options and packages. The rest of the
code still expects the old system so I have left most of the operations
unimplemented for now until I redo it with the new system. Currently
only '-S' and number menu have any functionality for testing purposes.
This new system parses arguments fully instead of just looking for
predefined strings such as:
'-Sqi' '-Siq'.
This allows:
'-Syu', '-S -y -u', '--sync -y -u'
to all be parsed as the same.
This system tries to be as similar to pacman as possible, eventually
aming to fully wrap pacman, allowing yay to be used instead of pacman in
all instances.
The current implementation is not as strict as pacman when checking
arguments. If you pass
--someinvalidflag to yay then yay will simply ignore it. The flag should
still be passed to pacman which should then cause an error.
Although operations '-S' '-R' '-U' ect. are checked to make sure you can not
try to use two operations at once.
conflicting flags such as:
'--quiet' and '--info'
will not raise an error and which options gains precedence is depend on
the implementation.
Another minor issue which is worth noting is. Due to the way double
arguments are parsed:
'-dd' '-cc' '--deps --deps'
if you pass the long version and the short version:
'-d --deps'
yay will not realize its a double argument. Meanwhile pacman will
reconise it when yay calls pacman.
Currently there are a few things that need to be done before this new
system can be fuly released:
Reimplement all operations to use to new parsing system so that
the new system is at least as functional as the old one
Strip yay specific flags before passing them to pacman
Move parts of config into the argument system and only use
config for options that are meant to be saved to disk
Move yay specific operations into its own operator '-Y'
Update documentation to show the altered syntax