You are not logged in.

#1 2022-07-21 15:29:06

JaydenDev
Member
Registered: 2022-07-11
Posts: 122

[Solved] how to add aur update function to saurh

the git sources are here

So yeah, installing an AUR package is as easy as cloning the aur repo and running makepkg. But how do I handle updates? How can I verify and detect the release of a package, and compare it to the latest release?

It's in bash.

Last edited by JaydenDev (2022-08-09 19:03:25)


System Specs:
Intel Core i5-2400 Nvidia GTX 1050ti Logitech G402 Hyperion Fury (Mouse) BestBuy Essentials USB Keyboard
Software Specifications:
Desktop Environment: KDE Plasma Window Manager: KWin Operating System: Arch Linux (btw)

Offline

#2 2022-07-21 15:42:23

JaydenDev
Member
Registered: 2022-07-11
Posts: 122

Re: [Solved] how to add aur update function to saurh

I could probably get a list of AUR packages installed by the user, clone them, and check the PKGBUILD for modifications. But wouldn't that be wasteful?


System Specs:
Intel Core i5-2400 Nvidia GTX 1050ti Logitech G402 Hyperion Fury (Mouse) BestBuy Essentials USB Keyboard
Software Specifications:
Desktop Environment: KDE Plasma Window Manager: KWin Operating System: Arch Linux (btw)

Offline

#3 2022-07-21 15:43:11

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 16,718

Re: [Solved] how to add aur update function to saurh

git pull? Make yourself familiar with git basics: https://git-scm.com/doc

Last edited by V1del (2022-07-21 15:43:52)

Offline

#4 2022-07-21 15:47:19

JaydenDev
Member
Registered: 2022-07-11
Posts: 122

Re: [Solved] how to add aur update function to saurh

V1del wrote:

git pull? Make yourself familiar with git basics: https://git-scm.com/doc

i use git on a daily basis, this just didn't come up when I thought of a method. Whoops, didn't think of that. I'll try just having git display diffs. is the ~/.cache directory permanent?


System Specs:
Intel Core i5-2400 Nvidia GTX 1050ti Logitech G402 Hyperion Fury (Mouse) BestBuy Essentials USB Keyboard
Software Specifications:
Desktop Environment: KDE Plasma Window Manager: KWin Operating System: Arch Linux (btw)

Offline

#5 2022-07-21 15:48:50

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 16,718

Re: [Solved] how to add aur update function to saurh

By definition you shouldn't rely on it, in practice for what you intend to do it will be sufficiently permanent.

Offline

#6 2022-07-21 15:50:42

JaydenDev
Member
Registered: 2022-07-11
Posts: 122

Re: [Solved] how to add aur update function to saurh

V1del wrote:

By definition you shouldn't rely on it, in practice for what you intend to do it will be sufficiently permanent.

So, to save a list of installed packages. I can have ~/.cache/saurh/installed. Then when the package is removed, it be removed from that list. Then when the user wants to update, it checks for new commits in the directories of the installed packages, if there are updates it then installs them. I assume this would work, though is there something im missing?


System Specs:
Intel Core i5-2400 Nvidia GTX 1050ti Logitech G402 Hyperion Fury (Mouse) BestBuy Essentials USB Keyboard
Software Specifications:
Desktop Environment: KDE Plasma Window Manager: KWin Operating System: Arch Linux (btw)

Offline

#7 2022-07-21 15:57:15

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 27,053
Website

Re: [Solved] how to add aur update function to saurh

Following your conventions already in place:

if [[ $1 == 'update' ]]
	find /home/$USER/.cache/saurh/ -mindepth 1 -maxdepth 1 -type d | while read pkg; do
		cd $pkg
		git pull # or maybe `git fetch` see https://bbs.archlinux.org/viewtopic.php?pid=2047011#p2047011
		makepkg -si
	done
fi

You could start your script with `mkdir -p ...` on the cache dir rather than checking.  This could also likely benefit from a case block for the arguments rather than all the if/thens.

On the use of ~/.cache, that is intended to be content the user can delete on a whim with no actual harm (other than slowing down future program use as content needs to be recreated).  ~/.cache should not be used for anything that can't be fully recreated from other data sources.  Use ~/.local/share/saurh/.

Why maintain a separate list of installed packages?  Pacman can give you this, as can a list of directories under your saurh directory (every installation creates a directory there and a removal could just delete the relevant directory).

Last edited by Trilby (2022-07-21 16:01:42)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#8 2022-07-21 16:02:03

JaydenDev
Member
Registered: 2022-07-11
Posts: 122

Re: [Solved] how to add aur update function to saurh

Trilby wrote:

Following your conventions already in place:

if [[ $1 == 'update' ]]
	find /home/$USER/.cache/saurh/ -mindepth -maxdepth 1 -type d | while read pkg; do
		cd $pkg
		git pull # or maybe `git fetch` see https://bbs.archlinux.org/viewtopic.php?pid=2047011#p2047011
		makepkg -si
	done
fi

You could start your script with `mkdir -p ...` on the cache dir rather than checking.  This could also likely benefit from a case block for the arguments rather than all the if/thens.

On the use of ~/.cache, that is intended to be content the user can delete on a whim with no actual harm (other than slowing down future program use as content needs to be recreated).  ~/.cache should not be used for anything that can't be fully recreated from other data sources.  Use ~/.local/share/saurh/.

Why maintain a separate list of installed packages?  Pacman can give you this, as can a list of directories under your saurh directory (every installation creates a directory there).

Alright, thanks for the information! I will get to implementing the feature.


System Specs:
Intel Core i5-2400 Nvidia GTX 1050ti Logitech G402 Hyperion Fury (Mouse) BestBuy Essentials USB Keyboard
Software Specifications:
Desktop Environment: KDE Plasma Window Manager: KWin Operating System: Arch Linux (btw)

Offline

#9 2022-07-21 16:25:46

seth
Member
Registered: 2012-09-03
Posts: 30,850

Re: [Solved] how to add aur update function to saurh

You could also

old_head_ts=$(git show --format=%at HEAD | head -1)
git pull # or git fetch; git merge
new_head_ts=$(git show --format=%at HEAD | head -1)

and compare the timestamps to avodf idempotent builds - might require some extra stuff to detect that this is a *-git package and git pull and compare the timestamps on the sources rather than the package git.

Offline

#10 2022-07-21 17:30:35

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 27,053
Website

Re: [Solved] how to add aur update function to saurh

Why do all the checking?  Makepkg checks for itself, if there is nothing new to build, it will bail out gracefully.

This is logically the same as avoiding needless checks for a directories existence before creating it when `mkdir -p` will do precisely this on it's own.

Don't add complex steps to check for conditions that don't really matter as you can take the same action in either branch of the condition with little to no overhead (and perhaps less overhead than there is in running the conditional check in the first place).


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#11 2022-07-21 17:43:29

seth
Member
Registered: 2012-09-03
Posts: 30,850

Re: [Solved] how to add aur update function to saurh

That implies to keep the old packages around after installing them.
You could check the PKGBUILD against the installed package instead, though (what might be nasty for dynamic pkgver's)

Offline

#12 2022-07-21 17:58:56

JaydenDev
Member
Registered: 2022-07-11
Posts: 122

Re: [Solved] how to add aur update function to saurh

Trilby wrote:

Why do all the checking?  Makepkg checks for itself, if there is nothing new to build, it will bail out gracefully.

This is logically the same as avoiding needless checks for a directories existence before creating it when `mkdir -p` will do precisely this on it's own.

Don't add complex steps to check for conditions that don't really matter as you can take the same action in either branch of the condition with little to no overhead (and perhaps less overhead than there is in running the conditional check in the first place).

The thing is, I want it to check for updates for all installed AUR packages, ask the user if they want to update, if they choose to update thats that. It's 'simple aur helper', each process is designed to be minimal, practical, fast, and safe.


System Specs:
Intel Core i5-2400 Nvidia GTX 1050ti Logitech G402 Hyperion Fury (Mouse) BestBuy Essentials USB Keyboard
Software Specifications:
Desktop Environment: KDE Plasma Window Manager: KWin Operating System: Arch Linux (btw)

Offline

#13 2022-07-21 18:14:55

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 27,053
Website

Re: [Solved] how to add aur update function to saurh

You want to prompt for every package asking if the user wants that package updated?  Or you just want to prompt the user before all the updates are run?

Having redundant data and excess checking is at odds with being minimal, fast, and safe as it will generally result in the opposite on all three counts.

Last edited by Trilby (2022-07-21 18:16:45)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#14 2022-07-29 19:14:28

JaydenDev
Member
Registered: 2022-07-11
Posts: 122

Re: [Solved] how to add aur update function to saurh

So, when packages conflict. How do I handle this? My current setup is basically, to tell the user to drop into the package build directory and try makepkg themselves and to manually resolve conflicts. I believe that this will be easier and far less dangerous than automating it. Telling the user to look into the issue, do research, and learn and fix the conflict seems like the best solution. But will also make this more of an intermediate aur helper.

Last edited by JaydenDev (2022-07-29 19:27:28)


System Specs:
Intel Core i5-2400 Nvidia GTX 1050ti Logitech G402 Hyperion Fury (Mouse) BestBuy Essentials USB Keyboard
Software Specifications:
Desktop Environment: KDE Plasma Window Manager: KWin Operating System: Arch Linux (btw)

Offline

#15 2022-07-29 20:22:34

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 27,053
Website

Re: [Solved] how to add aur update function to saurh

This is the first time you mentioned anything about package conflicts.  But in any case, prompting the user before doing anything with each package does absolutely nothing to avoid or deal with conflicts (which should be extremely rare).  Conflicts will also happen only at the installation stage - all packages can be built in one go regardless of conflicts, then pacman started for the installation, and if there are conflicts pacman will give a suitable error message that the user can deal with.

Note that "manually running makepkg themselves" will also do absolutely nothing to resolve conflicts.

It doesn't make any sense to say that all these steps and checks exist to cope with an error condition which is 1) quite rare, and 2) not at all addressed by any of the steps or checks.

Last edited by Trilby (2022-07-29 20:24:16)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#16 2022-07-29 20:35:51

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,135
Website

Re: [Solved] how to add aur update function to saurh

JaydenDev wrote:

But will also make this more of an intermediate aur helper.

Given the questions in this thread, and your other posts, I hope that this is not intended to be an AUR helper for other users, but an exercise for your own learning


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Online

#17 2022-08-08 21:00:50

JaydenDev
Member
Registered: 2022-07-11
Posts: 122

Re: [Solved] how to add aur update function to saurh

assuming this upgrade functionality is all working and at least half decent, I'll push my commits. And have some more code review and testing before a major release. There are downsides to my current method, they are as follows:

If you upgrade with say, yay. Saurh will upgrade from the version last installed using Saurh, leading to double upgrades. Though, using some pacman tricks I can easily overcome this issue. But it seems most people don't like if/else ladders, i'll decide before release.

that's it.. surprisingly. It works for the most part, other than double upgrades.

Update: the upgrade function, doesn't work...with literal zero errors. I'll work on it more i guess.

Here's the saurh output:

$PROMPT ./saurh update
remote: Enumerating objects: 7, done.
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 3), reused 1 (delta 0), pack-reused 0
Unpacking objects: 100% (4/4), 738 bytes | 738.00 KiB/s, done.
From https://aur.archlinux.org/visual-studio-code-bin
   bd48d22..7b4319e  master     -> origin/master
Updating bd48d22..7b4319e
Fast-forward
 .SRCINFO | 16 ++++++++--------
 PKGBUILD |  8 ++++----
 2 files changed, 12 insertions(+), 12 deletions(-)
==> Making package: visual-studio-code-bin 1.70.0-1 (Mon Aug  8 15:57:03 2022)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Found visual-studio-code.desktop
  -> Found visual-studio-code-url-handler.desktop
  -> Found visual-studio-code-workspace.xml
  -> Found visual-studio-code-bin.sh
  -> Downloading code_x64_1.70.0.tar.gz...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   134  100   134    0     0    358      0 --:--:-- --:--:-- --:--:--   358
100  114M  100  114M    0     0  1765k      0  0:01:06  0:01:06 --:--:-- 1698k
==> Validating source files with sha256sums...
    visual-studio-code.desktop ... Passed
    visual-studio-code-url-handler.desktop ... Passed
    visual-studio-code-workspace.xml ... Passed
    visual-studio-code-bin.sh ... Passed
==> Validating source_x86_64 files with sha256sums...
    code_x64_1.70.0.tar.gz ... Passed
==> Extracting sources...
  -> Extracting code_x64_1.70.0.tar.gz with bsdtar
==> Removing existing $pkgdir/ directory...
==> Entering fakeroot environment...
==> Starting package()...
==> Tidying install...
  -> Removing libtool files...
  -> Purging unwanted files...
  -> Removing static library files...
  -> Stripping unneeded symbols from binaries and libraries...
  -> Compressing man and info pages...
==> Checking for packaging issues...
==> Creating package "visual-studio-code-bin"...
  -> Generating .PKGINFO file...
  -> Generating .BUILDINFO file...
  -> Adding install file...
  -> Generating .MTREE file...
  -> Compressing package...
==> Leaving fakeroot environment.
==> Finished making: visual-studio-code-bin 1.70.0-1 (Mon Aug  8 15:58:29 2022)
==> Installing package visual-studio-code-bin with pacman -U...
loading packages...
warning: visual-studio-code-bin-1.70.0-1 is up to date -- reinstalling
resolving dependencies...
looking for conflicting packages...

Packages (1) visual-studio-code-bin-1.70.0-1

Total Installed Size:  293.11 MiB
Net Upgrade Size:        0.23 MiB

:: Proceed with installation? [Y/n] /home/jmwills/.local/share/saur
==> WARNING: Failed to install built package(s).
There was a problem when installing this package, drop into ~/.local/share/saurh/package-name and try to makepkg or fix issues yourself.

Last edited by JaydenDev (2022-08-08 21:01:58)


System Specs:
Intel Core i5-2400 Nvidia GTX 1050ti Logitech G402 Hyperion Fury (Mouse) BestBuy Essentials USB Keyboard
Software Specifications:
Desktop Environment: KDE Plasma Window Manager: KWin Operating System: Arch Linux (btw)

Offline

#18 2022-08-08 21:28:29

seth
Member
Registered: 2012-09-03
Posts: 30,850

Re: [Solved] how to add aur update function to saurh

Can you explain the behavior of

seq 1 5 | while read num; do read foo; echo $num $foo; done

?

Offline

#19 2022-08-09 00:15:23

JaydenDev
Member
Registered: 2022-07-11
Posts: 122

Re: [Solved] how to add aur update function to saurh

seth wrote:

Can you explain the behavior of

seq 1 5 | while read num; do read foo; echo $num $foo; done

?

Entire unsure what

seq 1 5

does but it gets piped to a while function that reads the number, then reads foo? I'd assume, then echoes the values of both. seq probably stands for sequences. Are you talking about code in saurh, or quizzing me?


System Specs:
Intel Core i5-2400 Nvidia GTX 1050ti Logitech G402 Hyperion Fury (Mouse) BestBuy Essentials USB Keyboard
Software Specifications:
Desktop Environment: KDE Plasma Window Manager: KWin Operating System: Arch Linux (btw)

Offline

#20 2022-08-09 06:34:46

seth
Member
Registered: 2012-09-03
Posts: 30,850

Re: [Solved] how to add aur update function to saurh

I didn't mean to interpret and guess the code, but to run it, observe the behavior and try explain what you see.
It is obviously reflective of the problem you're facing in your script - just maybe easier to understand.
Once you can explain your problem (and maybe can envision what would have to happen to avoid it), I'll tell you how to get around this, but we're not developing yasah on this board that then gets released to tbe public by somebody who doesn't actually understand how it works. There're far too many yasah's out there already.

Offline

#21 2022-08-09 16:30:05

JaydenDev
Member
Registered: 2022-07-11
Posts: 122

Re: [Solved] how to add aur update function to saurh

seth wrote:

I didn't mean to interpret and guess the code, but to run it, observe the behavior and try explain what you see.
It is obviously reflective of the problem you're facing in your script - just maybe easier to understand.
Once you can explain your problem (and maybe can envision what would have to happen to avoid it), I'll tell you how to get around this, but we're not developing yasah on this board that then gets released to tbe public by somebody who doesn't actually understand how it works. There're far too many yasah's out there already.

Entirely unsure what yasah is.


System Specs:
Intel Core i5-2400 Nvidia GTX 1050ti Logitech G402 Hyperion Fury (Mouse) BestBuy Essentials USB Keyboard
Software Specifications:
Desktop Environment: KDE Plasma Window Manager: KWin Operating System: Arch Linux (btw)

Offline

#22 2022-08-09 16:41:28

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,135
Website

Re: [Solved] how to add aur update function to saurh

Yet Another Stupid AUR Helper


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Online

#23 2022-08-09 16:57:26

seth
Member
Registered: 2012-09-03
Posts: 30,850

Re: [Solved] how to add aur update function to saurh

Yeah… let's just pretend I thought of "stupid" and no harsher terms at all.

Also it's vastly besides the point.
Do you understand what happens in that loop?

Offline

#24 2022-08-09 19:02:55

JaydenDev
Member
Registered: 2022-07-11
Posts: 122

Re: [Solved] how to add aur update function to saurh

There is no point of saurh's existance, literally. The only real world reasons:

1. I am bored, and have nothing but time
2. getting better at bash

I have found saurh to be one of the most difficult bash projects to make, its development is far worse than unorganized, its buggy, unstable, inconsistent, and code thats the equivalent of walls covered in sphagetti. And possibly a few security vulnerabilities dotted around. This project was a failure from the beginning, marking topic as solved.


System Specs:
Intel Core i5-2400 Nvidia GTX 1050ti Logitech G402 Hyperion Fury (Mouse) BestBuy Essentials USB Keyboard
Software Specifications:
Desktop Environment: KDE Plasma Window Manager: KWin Operating System: Arch Linux (btw)

Offline

#25 2022-08-09 19:42:38

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 27,053
Website

Re: [Solved] how to add aur update function to saurh

JaydenDev wrote:

1. I am bored, and have nothing but time
2. getting better at bash

Don't underestimate these as valid reasons to pursue a project.  Making your own AUR helper is a great way to learn about bash and about programming in general.  And seeking help here for such a project is more than welcome.  But there is a huge range between learning and growing as a programmer and making something that is worth encouraging others to use.  The fact that you've been told repeatedly, and sometimes abruptly, that your tool is not suitable to publish for other people's use does not mean you should quit working on it.

As I said in another thread of yours, you need to learn to walk before you run.  But that doesn't mean you should stop walking.

Most active members here are happy to help new programmers learn for various reasons including the fact that if we help you build your scripting skills with projects like your own AUR helper, then someday later you might be well equipped to solve other problems that could end up being useful to the broader community.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

Board footer

Powered by FluxBB