Home | News | Download | Packages | Forum | Wiki | Github

Check for updates


(Christian Lund Hansen) #1

Hi! :slight_smile:

I wanted to have a script running in i3blocks which tells me how many new updates are available, but I can’t find any command with that functionality. I asked at the irc and was suggested to use “xbps-install -S && xbps-install un” to get a view of packages with new updates. However, I was hoping for something a little more like “checkupdates” as in Arch Linux. I’m pretty sure I can script something, but I just wanted to make sure :slight_smile:

Thanks.


#2

Hi @chansen

Take a look at:

man xbps-checkvers

After you have forked the void-packages, you can check for outdated packages in your repository.

For example on my system (I cloned void-packages on my partition /dev/sda5):

$ xbps-checkvers -D /media/sda5/void-packages
pkgname: gnome-builder repover: 3.26.4_2 srcpkgver: 3.28.0_3
pkgname: dht-node repover: 0.1.0_6 srcpkgver: 0.1.0_7
pkgname: varnish repover: 3.0.7_6 srcpkgver: 5.2.1_1
pkgname: ngspice repover: 27_1 srcpkgver: 27_2
pkgname: k3b repover: 2.0.3a_6 srcpkgver: 17.12.0_1
pkgname: hugo repover: 0.38_1 srcpkgver: 0.38.1_1
pkgname: notion repover: 3.2014052800_2 srcpkgver: 3.2017050501_2
pkgname: collectd repover: 5.6.2_3 srcpkgver: 5.6.2_4
pkgname: valabind repover: 0.10.0_2 srcpkgver: 1.4.0_1
pkgname: android-tools repover: 7.0.0r5_5 srcpkgver: 7.0.0_r5/_/}_6
pkgname: pdf2htmlEX repover: 0.14.6_12 srcpkgver: 0.14.6_13
[...]

And Using this flag: -i, --installed
you can check for outdated installed packages rather than in repositories.

$ xbps-checkvers -i -D /media/sda5/void-packages
pkgname: unrar repover: 5.6.1_1 srcpkgver: 5.6.2_1

As you can see, my package unrar is outdated!

$ sudo xbps-install -Su
[*] Updating `https://repo.voidlinux.eu/current/musl/x86_64-musl-repodata' ...
[*] Updating `https://repo.voidlinux.eu/current/musl/nonfree/x86_64-musl-repodata' ...

Name  Action    Version           New version            Download size
unrar update    5.6.1_1           5.6.2_1                124KB 

Size to download:              124KB
Size required on disk:         124KB
Free space on disk:           6639MB

Do you want to continue? [Y/n] y

:wink:

Have a nice day.


(Christian Lund Hansen) #3

Hi! Thank you for writing a really comprehensive answer :slight_smile: I had already looked at the xbps-checkvers, but as you also write in your answer I need to fork the whole repository. Is this the easiest and fastest way to check for updates? The links you supply also says "this is only neccesary if you want to make changes to the packages? :smiley:

However, I like your solution :slight_smile: It gives a lot of incentive to learn new stuff :slight_smile: Thanks.


#4

Just wanted to add that when you want to check for updates later on (after you initially cloned void-packages) you’ll have to sync your local void-packages repository with upstream. From within void-packages run git pull upstream master.

And if listing available updates is all you want to do it’s not necessary to create a github account and do a fork: you can just clone the repo and then later use git pull.


(Christian Lund Hansen) #5

It just seems like a very complicated way to ensure, that there are/are no new updates? The initial solution I was given from IRC seems way less complicated? What are the benifits of bringing github into this?


#6

I guess if you have a local copy of void-packages already it’s a convenient alternative. However, if checking for updates is your only reason to clone the git repository it’s probably a bit overkill. :wink:

Isn’t the command you’ve been given on IRC sufficient for your needs (perhaps with some seding and greping)? Never used Arch so I don’t know what “checkupdates” does.

Maybe we could help you with your script if we knew a bit more detailed what you’re after. :slight_smile:


(Leszek Cimała) #7

Hi, just added xb checkupd to github repo, returns number of waiting updates. But it is basically what you know already:
xbps-install -S && xbps-install -un | wc -l


(Christian Lund Hansen) #8

Okay, I’ll try to be more specific - thanks for helping me out :slight_smile:

What I need is a script which prints out the result of ernierastas command. Since bash is very new to me, this is what I have come up with - and it’s not working very well :slight_smile:

#!/bin/bash
updates="xbps-install -S && xbps-install -un | wc -l"
ready="$($updates | tail -n 1)"
echo -e "U:$ready" || exit 1

So… It might be pretty obvious, but I’m just trying to get the last thing the first command prints out. Since I have just updated, this should be “U:0” :slight_smile:

Atm it gives me

U: -V --version                Show XBPS version"

So obviously something is wrong in the syntax. If I try to run the script in a terminal it gives me:

 xbps-install: invalid option -- 'l'

So I guess it gives me the last line from the --help instead.

EDIT: The timer is set in i3blocks, and will be set to like 5 hours. Not really sure how many updates to expect in Void


(Masato the Empty) #9

Change updates to a function

updates() {
  xbps-install -S && xbps-install -un | wc -l
}
ready="$(updates | tail -n 1)"

Alternatively, leave updates as is and do this

ready="$(eval $updates | tail -n 1)"

However I read a lot about how eval is evil yadda yadda. Not entirely sure why (I’ve read of various pitfalls and unexpected things if you’re not careful, but honestly, I don’t remember them. I usually forget about it until I run across a situation where I just can’t get things to work any other way)

Either one of those seems to work as you intend.


(Leszek Cimała) #10

You can also:
xbps-install -S >/dev/null && xbps-install -un | wc -l
or if you really want to go one line:
echo -n "U:";xbps-install -S >/dev/null && xbps-install -un | wc -l


(Christian Lund Hansen) #11

Thanks you so much @ernierasta and @masato :smiley: This really helpful and it’s working as intended.


#12

I use this

#!/bin/sh
# xupavail - counts the number of packages available for update

SUDO=
if command -v sudo >/dev/null &&
   sudo -l | grep -q -e ' ALL$' -e xbps-install; then
	SUDO=sudo
elif [ "$(whoami)" != root ]; then
	SUDO='su root -c '\''"$@"'\'' -- -'
fi

$SUDO xbps-install -SMun "$@" | grep -v hold | wc -l

#13

I don’t know about IRC, but solutions were already there and there on this forum…
The Search function is really useful. :wink:


(Christian Lund Hansen) #14

I promise I will make sure to use the search function as much as possible :slight_smile: