You are not logged in.

#1 2024-04-02 19:35:16

jorgenwiki
Member
Registered: 2024-04-01
Posts: 8

update helper

I like Arch Linux for being up to date, small and very configurable as I like it. But most of the time I'm just a user. So I needed reminders for myself:

  • To run pacman -Syu to check for updates

  • To process the pacnew configuration files

  • To read important news.

I provided for myself a script that does these things. But it could be made more smart I think. What I roughly did:

  1. used the checkupdates script

  2. used the pacdiff script

  3. used part of a news script from: https://bbs.archlinux.org/viewtopic.php?id=146850

  4. used systemd to provide a timer (I have a small preference over crontab)

  5. I needed to make two scripts to get it working (update-check & arch-news)

  6. You need to have xfce4-terminal to get it working (no general terminal or so is called, not very flexible).


I would like to hear tips or maybe others might use my solution. I can imagine that something similar exists, but this was what I needed...

Below my detailed instructions:
-------------------------------------------------

1. Make the folowing adjustments:
execute pacman -S pacman-contrib to install checkupdates and pacdiff

2. create script /usr/bin/update-check with this contents (set permitions to rwx r.x r.x):

if [ $? -eq 0 ]; then
  xfce4-terminal -e "bash -c 
                \"
                  echo -e \\\"read$yellow Arch Linux news$white before upgrading\\\"
                  echo -e \\\"hit$yellow q$white to end\\\"
                  sleep 3;
                  clear;
                  arch-news | less -R

                  echo Type password if you like to install updates or abort:;
                  echo;
                  echo updates:;
                  checkupdates;
                  echo;
                  
                  echo pacman -Syu;
                  sudo pacman -Syu;
                  echo;

                  echo \\\"executing pacdiff (use vim commands with view/merge e.g. :qa or :wqa)\\\";
                  pacdiff -s;
                  echo;

                  echo closing terminal...;
                  sleep 3;
                \""
fi

3. create script /usr/bin/arch-news with this contents (set permitions to rwx r.x r.x):

#!/bin/bash

url="https://archlinux.org/feeds/news/";
rss_source="$(curl --silent $url | sed -e ':a;N;$!ba;s/\n/ /g')";

if [ ! -n "$rss_source" ]; then
	echo "The feed is empty";
	return 1;
fi

# THE RSS PARSER

# Formatting
f_title="\\\\e[01;31m"
f_descr="\\\\e[00;37m"
f_ref="\\\\e[01;36m"
f_bold="\\\\e[01;36m"
f_italic="\\\\e[41;37m"
f_underline="\\\\e[4;37m"
f_code="\\\\e[00m"
f_linklabel="\\\\e[01;31m"
f_linkurl="\\\\e[04m"
f_formatchrs="\\\\e[01;34m"

# The characters "£, §" are used as metacharacters. They should not be encountered in a feed...
echo -e "$(echo $rss_source | \
	sed -e 's/&/\&/g
	s/&lt;\|&#60;/</g
	s/&gt;\|&#62;/>/g
	s/<\/a>/£/g
	s/href\=\"/§/g
	s/<title>/\\n\\n\\n   :: '$f_title'/g; s/<\/title>/\\e[00m ::\\n/g
	s/<link>/ [ '$f_ref'/g; s/<\/link>/\\e[00m ]/g
	s/<description>/\\n\\n'$f_descr'/g; s/<\/description>/\\e[00m\\n\\n/g
	s/<p\( [^>]*\)\?>\|<br\s*\/\?>/\n/g
	s/<b\( [^>]*\)\?>\|<strong\( [^>]*\)\?>/'$f_bold'/g; s/<\/b>\|<\/strong>/'$f_descr'/g
	s/<i\( [^>]*\)\?>\|<em\( [^>]*\)\?>/'$f_italic'/g; s/<\/i>\|<\/em>/'$f_descr'/g
	s/<u\( [^>]*\)\?>/'$f_underline'/g; s/<\/u>/'$f_descr'/g
	s/<code\( [^>]*\)\?>/'$f_code'/g; s/<\/code>/'$f_descr'/g
	s/<a[^§]*§\([^\"]*\)\"[^>]*>\([^£]*\)[^£]*£/'$f_linklabel'\2'$f_descr' '$f_formatchrs'['$f_descr' '$f_linkurl'\1'$f_descr''$f_formatchrs' ]'$f_descr'/g
	s/<li\( [^>]*\)\?>/\n '$f_formatchrs'*'$f_descr' /g
	s/<!\[CDATA\[\|\]\]>//g
	s/\|>\s*<//g
	s/ *<[^>]\+> */ /g
	s/[<>£§]//g')\n\n";
# END OF THE RSS PARSER

4. create the file: ~/.config/systemd/user/update.service with this contents (permitions rw. r.. r..):

[Unit]
Description=Check for package updates and ask to install them

[Service]
ExecStart=/usr/bin/update-check

[Install]
WantedBy=default.target


5. create the file: ~/.config/systemd/user/update.timer with this contents (permitions rw. r.. r..):

[Unit]
Description=Run update every hour and 3 min after boot

[Timer]
OnBootSec=3min
OnUnitActiveSec=1hour

[Install]
WantedBy=timers.target

6. enable the timer
execute systemctl --user enable update.timer

Last edited by jorgenwiki (2024-04-04 12:49:22)

Offline

#2 2024-04-03 06:14:21

Awebb
Member
Registered: 2010-05-06
Posts: 6,621

Re: update helper

  1. Use code tags for code on the forums.

  2. Use /usr/local/bin (and the other appropriate folders) for anything not managed by pacman.

  3. check out pacdiff

  4. check out newsie

Offline

#3 2024-04-04 11:30:11

jorgenwiki
Member
Registered: 2024-04-01
Posts: 8

Re: update helper

@Awebb: Thanks for your comments. I learned a lot and it was a substantial simplification.
I did everything you suggested except using newsie. I prefer being able to keep reading all the latest news (I read about newsie but didn't try it yet, but it might be an improvement anyway).

Anyone who might like to use this and prefers newsie can install it replace arch-news with newsie and skip the third instruction.

Last edited by jorgenwiki (2024-04-04 11:32:17)

Offline

#4 2024-04-04 12:50:18

jorgenwiki
Member
Registered: 2024-04-01
Posts: 8

Re: update helper

just removed two errors (removed an old statment and added -s to pacdiff)

Offline

Board footer

Powered by FluxBB