You are not logged in.
Pages: 1
Hi all,
I want to search the sync DB for an exact package name. According to the wiki:
https://wiki.archlinux.org/index.php/Pa … _databases
pacman supports ERE (Extended Regular Expressions). But why when I enter:
$ sudo pacman -Ssq '^vim$'
the output includes "gvim", not only "vim"? As if the anchor "^" does not work. Why is that?
Last edited by karcher (2018-04-21 19:08:15)
Offline
If you know the exact name, why are you searching? Just use the name, e.g. for package information do `pacman -Si vim`, to install it `pacman -S vim`.
EDIT: Regexes do work, but I gather the search also includes 'provides' as gvim provide vim, you'll note that the result for '^vim$' is much shorter than 'vim$'
Last edited by Trilby (2018-04-21 12:31:40)
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
@Trilby: thanks for the quick response!
"If you know the exact name, why are you searching? Just use the name, e.g. for package information do `pacman -Si vim`, to install it `pacman -S vim`."
I want to use it within a script e.g. if a specific package in a list matches what exists in the sync DB. This is known to me.
"EDIT: Regexes do work, but I gather the search also includes 'provides' as gvim provide vim, you'll note that the result for '^vim$' is much shorter than 'vim$'"
It doesn't sound logical to me. When I have set the caret anchor I'm expecting to get only results starting with the character after that. Yes, the results are much more without the caret anchor.
So can I assume that there is not a way to get exactly one result?
EDIT:
Of course I could still use other commands to filter the results but I don't mean that.
Last edited by karcher (2018-04-21 15:50:28)
Offline
pacsift --exact --name vim
Offline
I want to use it within a script e.g. if a specific package in a list matches what exists in the sync DB. This is known to me.
I don't really understand this. If you know the exact package name, why are you searching for it? What are you really trying to do with that script?
So can I assume that there is not a way to get exactly one result?
Yes, there is - if there is only one package that matches. If there is more than one match, you'll get more than one result. Either vim or gvim would satisfy the requirement of 'vim'.
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
@apg:
Thanks for the hint! I've installed pacutils and with:
pacsift --sync --exact --name vim
I'm getting exactly one package.
@Trilby:
"I don't really understand this. If you know the exact package name, why are you searching for it? What are you really trying to do with that script?"
I have a list of packages that I normally install. Some of them are in the sync DB, some of them are in the AUR, some of them should be installed manually. I want to check if the package exists in the sync DB and then invoke pacman to install it etc. I had separated lists e.g. for pacman and AUR helper but I like it better when all packages are in one column.
"Yes, there is - if there is only one package that matches. If there is more than one match, you'll get more than one result. Either vim or gvim would satisfy the requirement of 'vim'."
But vim and gvim are different packages.
Offline
I have a list of packages that I normally install. Some of them are in the sync DB, some of them are in the AUR, some of them should be installed manually. I want to check if the package exists in the sync DB and then invoke pacman to install it etc.
But you still don't need to search. Why loop through the list and use two pacman operations for each entry when one will do. Instead of looping through the list and searching for each package then installing it if found, just attempt to install it, and on error append it to the aur list. Or even better, instead of looping through the list and even calling pacman once for each entry, call pacman only twice overall:
pacman -Slq | sort > /tmp/repo.pkg
sort /path/to/yourlist > /tmp/needed.pkg
pacman -S $(comm -12 /tmp/repo.pkg /tmp/needed.pkg)
comm -13 /tmp/repo.pkg /tmp/needed.pkg | while read nonrepo; do
# check aur for $nonrepo
done
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
Offline
My first version is simpler:
pacman -S $pkg
If it succeeds, $pkg is in the repos, and now there is no need for an additional step of installing it. If it fails, $pkg is not in the repos.
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
pacman -Sql | grep "^vim$"
Thanks! With grep works fine but that I was meaning before without any other commands.
But you still don't need to search. Why loop through the list and use two pacman operations for each entry when one will do. Instead of looping through the list and searching for each package then installing it if found, just attempt to install it, and on error append it to the aur list. Or even better, instead of looping through the list and even calling pacman once for each entry, call pacman only twice overall
It seemed to me cleaner. Thanks for the code. I think, I will use it.
My first version is simpler:
pacman -S $pkg
If it succeeds, $pkg is in the repos, and now there is no need for an additional step of installing it. If it fails, $pkg is not in the repos.
Right!
Offline
Pages: 1