My Universal Manjaro Update Helper

Hi Everyone.


TLDR; I made an update helper script for performing updates, and generating a precompiled forum post if there were errors. Give it a go. Link and installation instructions below.


After spending quite some time on here, on the forum, I started noticing a pattern when updates happen. Usually after the update, when support is being asked, the people trying to help always have to request the same information. Hence me thinking that it can be scripted, seeing as it’s so repetitive. Also, if the information requested is present before the first person replies, it should cut the support time considerably, since then there is no need for back-and-forth for basic things.

Couple that with a desire to learn bash, and viola! I saw an opportunity to contribute, both to my favorite Linux distribution as well as myself.

So, I present My Universal Manjaro Update Helper.
(Or, mumuh if you will.)

It’s simple really. The steps it perform are:

  1. Makes a backup snapshot of your current system.
    By default it uses Timeshift to perform the backup, but it does have the ability to specify a different command.
  2. Checks for and prompts to install any updates from the official repositories.
    The updates are, as of yet, only a wrapper to pamac. I prefer to use pamac instead of pacman because it takes care of a lot more things automatically than pacman.
  3. Using pamac once again, it rebuilds updates any AUR packages.
    Once again, I use pamac for the reason mentioned above. And also because pacman itself cannot work with, build, rebuild or upgrade packages from the AUR. Therefore, an AUR helper is necessary. Enter pamac.
  4. When done, it checks for and provides the option to merge any .pacnew files.
  5. If any errors occurred, it copies a generated forum post to the clipboard with xsel, which contains a whole bunch of information, which can be used to start a forum post.

To install it:

  1. First step is to clone the repository:
mkdir /tmp/mumuh && cd /tmp/mumuh && git clone https://github.com/Mirdarthos/manjaro-update-helper.git

This will clone it and cause all subsequent actions to be performed in /tmp. which is temporary and will be deleted on shutdown. But don’t worry, the installation will be permanent. Adjust this as you see fit if you wish.

  1. Then change to the directory it just created:
cd manjaro-update-helper/
  1. Then install the package:
makepkg --syncdeps --install

Or, you can download the script wherever you want to:

wget https://raw.githubusercontent.com/Mirdarthos/manjaro-update-helper/master/src/usr/bin/mumuh

Then set it as executeable:

chmod u+x mumuh

And execute it directly:

./mumuh

Simply delete the file if you want to remove it:

rm mumuh

To uninstall it:

While I’ve searched high and low for doing this with makepkg, I was unable to figure it out. It’s quite simple really, so doing it manually iss quite easy, just run:

sudo rm --force /usr/bin/mumuh

To run it:

mumuh --help

Example:

$ mumuh --help

######################################################################
################### Manjaro update helper script.#####################
######################################################################
# This script is just a wrapper for pamac, with the exception that   #
# if there were any errors, it allows you to copy them, neatly       #
# formatted for use as. or with a forum post, along with all the     #
# details required for requesting assistance.                        #
# It also allows you to set the required suddoers permissions in     #
# '/etc/sudoers.d'                                                   #
#                                                                    #
# Usage:                                                             #
#     * --addsudoers, or -a                                          #
#       Will add a file called /etc/sudoers.d/manjaro-update-helper  #
#       with entries to enable running this script as the current    #
#       user without a password.                                     #
#       CARE MUST BE TAKED WITH THE /etc/sudoers FILE, AS DOING IT   #
#       INNCORRECTLY CAN LEAD TO BEING LOCKED OUT OF THE SYSTEM.     #
#       PLEASE BE VERY CAREFUL.                                      #
#     * --skipbackup, or -s                                          #
#       This will cause the update process to skip the backup step   #
#       for the update.                                              #
#     * --custombackupcommand, or -c                                 #
#     * This argument allows for specifying a custom backup command, #
#       for if you want to use something other than the default      #
#       timeshift one, or even is you use something other than       #
#       timeshift.                                                   #
#       NOTE:                                                        #
#       If --skipbackup, or -s is specified, then specifying this    #
#       will have no effect.                                         #
#     * If no arguments are passed, the script performs its main     #
#       functionality.                                               #
######################################################################

Link:

I’m absolutely sure there are things, a lot of things, that can be done differently, or even better. Feel free to pass suggestions along

Please note:

There are many places in the script that can use shorthand. For example, this:

pamac --version 1> /dev/null 2> /dev/null

instead of this:

pamac --version 2&1> /dev/null
There are 3 reasons for that:
  1. Legibility and clarity.
    @Fabby has mentioned once that the first is easier to read and understand than the second, and I find it true, especially as a newcomer to bash. So I’m sticking with it. At least for now.
  2. I’m attempting to learn bash, and the longer, more clear commands is easier for me to learn, understand and then use.
  3. Someone else might take a look at the code, possibly out of curiosity, possibly having to jump in and maintain it or even to contribute. Which ever it is, it’s not just me I have to think of here. So I try to be as clear as possible, and not learn, get used to and rely on magic.

Edit:

Based on this, by @dmt:

To uninstall:

It must be uninstalled witth a package mager, apparently, so uninstall it with:

pamac remove my-universal-manjaro-update-helper

But then the /usr/bin/mumuh file still remains, so remove it with:

sudo rm --force /usr/bin/mumuh

I suspect I’ll have to create a .install file for this with that removal inside. Unless I’m somehow mistaking it. Or doing something wrong, which is also quite the possibility.

6 Likes

Seems to be very interesting and handy to have. Can you also showcase how such a generated forum post would look like?

I just tried, and realized the output of the terminal windows is very excessive. Too much. For example:

[...]
                                                                                
981.2 MB/1.9 GB About 3 minutes remaining
                                                                                
982.0 MB/1.9 GB About 3 minutes remaining
                                                                                
982.7 MB/1.9 GB About 3 minutes remaining
                                                                                
983.2 MB/1.9 GB About 3 minutes remaining
                                                                                
983.5 MB/1.9 GB About 3 minutes remaining
                                                                                
983.7 MB/1.9 GB About 3 minutes remaining
                                                                                
984.2 MB/1.9 GB About 3 minutes remaining
                                                                                
985.1 MB/1.9 GB About 3 minutes remaining
                                                                                
985.5 MB/1.9 GB About 3 minutes remaining
                                                                                
986.1 MB/1.9 GB About 3 minutes remaining
                                                                                
986.4 MB/1.9 GB About 3 minutes remaining
                                                                                
986.8 MB/1.9 GB About 3 minutes remaining
                                                                                
987.2 MB/1.9 GB About 3 minutes remaining
                                                                                
987.9 MB/1.9 GB About 3 minutes remaining
                                                                                
988.3 MB/1.9 GB About 3 minutes remaining
                                                                                
988.7 MB/1.9 GB About 3 minutes remaining
                                                                                
989.0 MB/1.9 GB About 3 minutes remaining
                                                                                
989.9 MB/1.9 GB About 3 minutes remaining
                                                                                
990.3 MB/1.9 GB About 3 minutes remaining
                                                                                
990.6 MB/1.9 GB About 3 minutes remaining
                                                                                
990.9 MB/1.9 GB About 3 minutes remaining
                                                                                
991.7 MB/1.9 GB About 3 minutes remaining
                                                                                
992.1 MB/1.9 GB About 3 minutes remaining
                                                                                
992.5 MB/1.9 GB About 3 minutes remaining
                                                                                
992.9 MB/1.9 GB About 3 minutes remaining
                                                                                
993.5 MB/1.9 GB About 3 minutes remaining
                                                                                
994.0 MB/1.9 GB About 3 minutes remaining
                                                                                
994.6 MB/1.9 GB About 3 minutes remaining
                                                                                
994.9 MB/1.9 GB About 3 minutes remaining
                                                                                
995.5 MB/1.9 GB About 3 minutes remaining
                                                                               
[...]

It’s absolutely filled with that. I wanted it to be what you see when updating from the terminal.

Edit:

I am unable to figure out why this happens. Or rather, how to stop it from happening and so what I want it to do. I’m sure it can be done, though. I’d appreciate some guidance on how, if possible.

Edit #2:

Implemented a possible fix, based on this post. Unable to test it, though.

I’m going to play with this (clean manjaro gnome vm) and give feedback, great goals!

:green_heart:

The install has this command:
sudo makepkg --syncdeps --install
Terminal feedback:
==> ERROR: Running makepkg as root is not allowed as it can cause permanent, catastrophic damage to your system.
Running it without sudo ask for password (more then once) when needed and installs the dependencies & mumu runs.

2 Likes

Thank you. Fixed the instructions.

2 Likes

Since I am currently unable to provide an example forum post, here is the code that builds it:

# Compose a forum message.
if [[ $COPYOFFICIALCHOICE =~ [Yy] ]] || [[ $COPYAURCHOICE =~ [Yy] ]];
then
    MESSAGE='I encountered errors during the lat update,  which I performed on  **`'${RUNDATE}'`**. Please find my information below:

'

fi

# If chosen, add official update output.
if [[ $COPYOFFICIALCHOICE =~ [Yy] ]];
then
    MESSAGE+="##### \`pamac upgrade --force-refresh --enable-downgrade\`:

[details=View more]
~~~
$(cat "$SYSUPDLOGFILE")
~~~
[/details]

"
fi

# If chosen, add AUR packages' output.
if [[ $COPYAURCHOICE =~ [Yy] ]];
then
    MESSAGE+="##### \`pamac upgrade --enable-downgrade --aur --devel\`:
	
[details=View more]
~~~
$(cat "$AURUPDLOGFILE")
~~~
[/details]

"
fi
	
# Add system information gathered above, if any of the outputs are copied.
if [[ $COPYOFFICIALCHOICE =~ [Yy] ]] || [[ $COPYAURCHOICE =~ [Yy] ]];
then
    MESSAGE+="##### My **\`inxi --admin --verbosity=7 --filter --no-host --width\`**:

~~~
$SYSTEMINFO
~~~

***
	
# PLEASE REMOVE THIS TEXT AND ADD YOUR OWN DESCRIPTION HERE, BELOW THE LINE!
	
"
fi

This provides, roughly something like this (hopefully):


I encountered errors during the lat update, which I performed on '2023.02.14'. Please find my information below:

pamac upgrade --force-refresh --enable-downgrade:
View more
some terminal stuff
pamac upgrade --enable-downgrade --aur --devel:
View more
more terminal stuff
My inxi --admin --verbosity=7 --filter --no-host --width:
output of inxi on the, you guessed it, on the terminal

PLEASE REMOVE THIS TEXT AND ADD YOUR OWN DESCRIPTION HERE, BELOW THE LINE!

1 Like

I’ve run the script on gnome and xfce in a QEMU vm and do not seem to be able to get the script to fill the clipboard. Gnome defaults to wayland and starting a x session did not solve this. xfce is x only. I suspect this has something to do with the management of the clipboard between hosts. Will try with KDE next.

1 Like

Well, I use xsel for this, xclip was giving me headaches, so it might be related…

I suspect the cause is the tool I use.

Because makepkg is for making packages, -si is just a convenience. You should use a package manager.

1 Like

Because makepkg -si used pacman -U to install the package. The whole point of making a package is so that we can use the package manager to manage it.

If you just delete the file then the package is still installed but in a non-functional state.

AFAIK any files installed within the PKGBUILD should be uninstalled along with the package. Perhaps the package lost ownership of the file.

I just tested your PKGBUILD using makepkg -si then sudo pacman -R and it works as expected. :+1:

EDIT: Improved the wording slightly.

1 Like

Thank you so much I hope I installed it correctly :v:

1 Like

Original post: My Universal Manjaro Update Helper

I’ve released an update for the Update helper:

It should be better and more robust now. At least in theory.

See Changelog here for details.

In short:

  • I’ve added a check and double confirmation if an unsynchronised mirror was found.
  • Added functionality of cleaning orphans if update was successful.
  • Changed from kdialog to libnotify.
  • Implemented PAMAC_CLI_AUTH=1 for pamac.
  • Added pacman-mirrors debug info.

And likely more.

Find the updated PKGBUILD here:

# Maintainer: Mirdarthos mirdarthos[at]duck[dot]com
# shellcheck disable=all

pkgname=my-universal-manjaro-update-helper
pkgver=3.1.1
pkgrel=1
pkgdesc="A helper for updating Manjaro Linux."
arch=('any')
url="https://github.com/Mirdarthos/manjaro-update-helper"
license=('Apache')
depends=('sudo' 'xclip' 'ncurses' 'pamac-cli' 'pacman' 'inxi' 'meld' 'pacman-mirrors' 'libnotify')
optdepends=('timeshift: For creating backups with prior to updating if custom command not specified.')
source=("$pkgname-$pkgver.tar.gz::$url/archive/refs/tags/V$pkgver.tar.gz")
sha256sums=('f7c36b407d312348159cc5b11378f16090a259eead8c1ecb37a9cd9866a0df5e')

package() {
    cd manjaro-update-helper-$pkgver
    install -Dm755 src/usr/bin/mumuh -t "$pkgdir/usr/bin/"
}


Once again, thanks @Yochanan for the help in correcting the PKGBUILD.

Any suggestions welcome!

3 Likes

This is a nice improvement, no more pop up.

The messages I see now on the system I test this on (VM gnome unstable) start with <br /> I’m not sure if this is something to investigate, the one notification that does not do this is the .pacnew files succesfully ... notification.

Thank you.

On my system it worked flawlessly, but I removed it now. As you may or may not know, the <br /> is just HTML for a line break. So that was luckily only a layout thing, but I’ve removed it now.

Very cool, I always enjoy when people adventure in to the code realm.

I was a PHP, Javascript and HTML developer.

Then I got in a massive car accident.

Now I do what I can. Sometimes something with programming.

Edit:

Oh! And some CSS too.