You are not logged in.

#1 2017-12-06 09:21:50

Cody Learner
Banned
Registered: 2017-12-06
Posts: 54
Website

aurt, yet another, but very minamilistic AUR assistant

UpdateMay 2, 2018

Made a Linux container image with aurt-setup ready to run on Arch. I'm using systemd-nspawn, but as far as I know, it should work with most Linux container management systems. I've used the Arch Docker image in nspawn...

https://github.com/Cody-Learner/Arch-Image


Update April 29, 2018

Aurt-setup script rollout available on Github: https://github.com/Cody-Learner/aurt.aurutils.based. This script automates the setup for aurutils use. I've tested this script in Linux containers only at this point.

Aurt-setup is a very much an initial, alpha stage script. Run as your own risk and be capable of fixing things on your own before considering testing this outside a VM, container, etc. I'm posting this news here rather than a new post, as stated below, I do not feel the aurt-setup script is ready for main stream testing at this point.

If you're feeling adventurous and meet the above criteria, feel free to give it a spin. I'd really appreciate constructive feedback and critique either here or in github issues. Especially if fairly specific and accompanied with suggestions on how I can make it better.


Update March 17, 2018

As explained below, a new version of aurt based on aurutils is in the works.
Scripts currently available on Github: https://github.com/Cody-Learner/aurt.aurutils.based
Will post a new topic on forum when it's further along and I feel it's ready for testing.


UPDATE ABOUT AURT: Dec 14, 2017

What exactly is aurt?
It’s a simple, thin, wrapper shell script around makepkg, pacman, git, and cower, for the purpose of convenience. It uses existing, well proven, powerful tools, a handful of important commands, along with “convenience adding fluff” commands. It combines what I would use and do if building and installing AUR packages manually, into a single script, with enough feedback to know whats going on while running. For my use case, aurt has replaced pacaur without the penalty of any added inconvenience.
Why another AUR helper?
    I saw writing this script as a perfect opportunity to learn more about Arch and shell scripting. After getting a functioning concept, I thought others may find it useful.

Who would want to use this?
    Likely no one, after all it’s written by an unknown, who is inexperienced at scripting.
    Those wanting and able to deal with their own custom AUR management solution.
    Those experienced enough to read the script as safe, using it as a starting point for customization.
    The above, opting for the simple, minimalist convenience aurt offers, using it as is.
    Those preferring cli pacman directly for official repo packages, while preferring a separate, mostly integrated solution for AUR package management.

Who would NOT want use this?
    Those having not mastered at all aspects of manual AUR management.
    Those wanting a well proven with track record, stable, hands off, turnkey AUR solution.
    Those having more than a dozen or so AUR packages.
    Those wanting automation of AUR stuff on the level that pacman provides for official repo packages.
    Those wanting a single solution for all package management.
    Those not wanting to handle AUR packages individually, one at a time.

What differentiates aurt?  Why a 175 line script for a small handful of 'important' commands?
    It's different in it’s presentation and offering as a script / template, and nothing more.
    '175 line script'? Because it makes things more convenient for me and I enjoy writing and using it.

Goals and future?
    It has already met my goals so I'll likely not expand on it. EDIT: I may occasionally post updates.
    Keep the script as simply as possible so myself and others can modify to suite.
    Don't implement any code I don't have my head around and understand what it is doing.
    Post it on the Arch forums as a first real contribution after many years (AIF days) as a user.
    Generate some community feedback via comments on thoughts, problems, solutions, customizations, etc.
    Transition into becoming a transparent, community driven and maintained "unofficial" AUR helper script.
    No plan on maintenance outside my personal use or offering it as an AUR package.



Dec 15, 2017 Update: Further refinements. Script comes in at about * 185 lines of code now. Enhanced a few features. The most worthy of mention is a change to the "stop" during install. Install function now does a cat PKGBUILD per default, followed with "stop -  select"  "proceed to PKGBUILD in $EDITOR"  -or- "not".

This allows the user to view the PKGBUILD, then requires input to proceed, for every AUR package install.

* Changed default "edit and view PKGBUILD" behaviour
* Changed option parsing
* Changed layout of header and help messages
* Added "option input" error handling ie:  pacaur -cx
                                                              ERROR ... ...

Jan 6, 2018 Update:

More changes, additions deletions and testing. Added a detailed dependency checking function that replaces the download AUR dependencies. I personally prefer having a comprehensive list of dependencies for viewing rather than a directory containing  AUR downloads for building that will have their own list of dependencies.

I've been continuously rotating various AUR packages in and out of my system for testing, keeping the count at around 60. My testing results indicate this version accurately handles anything I've installed from the AUR so far. Using git HEAD local vs remote to check update status and also have version number checking as a fall back. Added a force option for installing and or upgrading. Have also added an option to bypass the git HEAD test for package updates. Getting an accurate update status for packages turned into quite a challenge that I seem to have solved! More testing will be the ultimate test......

I've made the move to installing shellcheck rather than trying to use the online version. This version of aurt comes with some shellcheck warnings, many of which I believe to be rather inconsequential. Others, specifically pointing to quoting issues in the new new dependency check function are proving problematic. The currently script gives accurate results. Changes per shellcheck suggestions results in breakage.  I need more time to look into this and may need input from someone more familiar with shell scripting.

The script is still very much a work in progress. I'd encourage giving this version a test spin as it's finally doing everything as expected at this point. I could also put it up on github if requested to do so. Interested in all feedback, suggestions on improving things, different directions, methods, etc.



Jan 11, 2018 Update:

Mostly just little refinements for this one. It runs pretty well at this point. I currently have 80+ AUR packages. Everything has worked as intended so far.

In process of a -q --quiet option to stop all the aurt supplied user feedback for the next release.



Feb 1, 2018 Update:

I humbly admit, the more I figure out working on aurt, the more I realize how much more I have to learn to get my head around everything involved! Going back to re-read what Trilby and others have been explaining all along, is finally adding up. I had misconceptions on how some of this works, and will most likely continue going down this path as I continue to expand my knowledge on this stuff.

Quote source: https://wiki.archlinux.org/index.php/.SRCINFO

Warning: Changes to PKGBUILD metadata, such as pkgver() updates, do not automatically propagate to .SRCINFO. Pushing an edited PKGBUILD to the AUR without also updating its .SRCINFO will cause the AUR to serve stale metadata.

This update deals with the above situation + VCS and development packages by gathering version status from running "makepkg -so" and "makepkg --printsrcinfo", and parsing epoch, pkgver, pkgrel from the updated .SRCINFO generated. The cost of checking for updates using this method is time. It takes around 3 min to run aurt -Sy on my system currently with 81 AUR packages to check. Any unmet dependencies must also be installed to run these commands. I'd suggest leaving them installed for more streamlined, faster checks in the future. I've also thought about setting -Sy up so it runs in the background every so often, say once every 24 hours, at 3:00am, and have a configurable file to set it up. That way, the 3 min wait would be eliminated for the user when checking update status.


I'm contemplating an optional faster but incomplete package version check using the aurweb RPC interface to parse remote .SRCINFO. This method is as thorough as the standard I guess, and does not provide results for all the possible variety of AUR package set ups. Another possibility would be a return to using git HEAD local vs remote as the fast option. I currently need more info to proceed either way with this. It seems that some PKGBUILDS are basically static links unless I'm mistaken. I need to determine which method would provide the most thorough results.. EDIT On second thought, Trilby's explanation on what constitutes broken regarding this comes to mind. Removing this from a possible feature add. Use aurt -C = (cower -u :  Check foreign packages for updates in the AUR.)


Feature additions:

Two Commands Update All AUR Packages: aurt -Sy ; aurt -Su.   Separate commands are easily combined into single command.

Single Command Update System + AUR Packages: aurt -Syu   aurt -Syu runs sudo pacman -Syu ; aurt -Sy ; aurt -Su


I've done limited testing with this version of aurt. This may also be close to the last update for this version of the script before a possible rewrite if I decide to implement getopts.


I've been testing getopt and getopts. Placing getopts + additional scripting in a function located at the beginning of the script is where I left off with testing. Testing was to make a drop in replacement for the current manual parsing in aurt. At this point, the cost of implementing getopts would be much additional complexity without completely rewriting aurt. I see implementing the test results in current aurt as being very much counter productive with the goal of keeping the aurt script as simple as possible.

As I see it, one benefit of implementing getopts would be for users (none currently) to be able to improperly place operations, options, etc, on the command line, with aurt having the ability to attempt to decipher what is actually wanted. Another may be for others (none currently) to more easily read the script after a rewrite for getopts. As aurt is currently written, it would be quite counter productive for script readability. Bottom line to properly implement getopts, I'd first need to learn how to properly differentiate and implement operations and options in the script.

At this point, I'm holding off on getopts until I can more accurately assess getopts implementation and find more payoff.



Feb 11, 2018 Update:

Several changes worthy of mentioning in this update. This update is still using the "manual option parsing" version of aurt. I'm in the beginning process of working with arrays, and have quite a way to go to get my head around all the capabilities they bring to the table. With this, it has brought to my attention of how relying on white space in variable strings, although functional, is not a reliable method. Furthermore, this leads me to thinking about additional improvements to the aurt script!

1) Rewrote the "-D, dependency details" operation implementing arrays, eliminating several poorly implemented (but functional) methods in the previous version.

2) Revised the "-Sy, sync update status" operation to add git HEAD local vs remote as a secondary check. Some packages would not show an update available even though the git Head status had changed.

3) Added ability to handle multiple packages on the command line using the "-S install / update package" operation.

4) Created workaround for the following situation:

Running aurt -Sy checks all installed AUR packages for update availability using two methods.

For the first check, it gets the currently available package version from running 'makepkg -so' and then parsing version from 'makepkg --printsrcinfo'. Then it compares current to installed versions. If they don't match, it prints the package to /tmp/updates for an update.

The second check compares 'remote' to 'local' git HEAD hashes via: 'git ls-remote \https://aur.archlinux.org/"${package name}".git' -vs- 'git -C "${package build dir}" rev-parse HEAD'.

It's common to have packages listed for updates from either of the two checks. The majority of the time when followed with running aurt -Su, it results in seamless updates via git pull, building and installing the packages.

However, on two occasions so far, the git HEAD check has indicating an update is available. When aurt -Su runs a git pull, it results in the following error with no update occurring.


$ aurt -Su

Updates (1) vim-tern

:: Running update list from: Feb 11 2018 @ 12:32:23
:: Will build and install with makepkg -Csfci --noconfirm. 
:: Proceed with update? [Y/n] y
error: Your local changes to the following files would be overwritten by merge:
	PKGBUILD
Please commit your changes or stash them before you merge.
Aborting

Same results with manually git pulling those packages. Stashing the PKGBUILD results in different git errors, same results.

However, starting with a fresh git clone always builds and installs the update. So, until I figure out the git related issue and a solution, I've leveraged aurt "-Sf force install or update" to automatically backup the existing build directory, git clone, build and install the update in cases where the git pull error occurs.

In the above mentioned cases, you will get the  ":: Error with git pull. Running forcebuild option to git clone." message along with the normal force build information, then it will exit after that package is updated. If this happens, you should run aurt -Su again so it can complete the update process on the update file generated.

If running aurt -Su results in the message ":: Update status unknown, Run aurt -Sy to check for updates.", this indicates the update process has completed.



Feb 24, 2018 Update:

This will be the last update for this version of aurt. Among other minor changes, the most notable change in this version is fixing the -D dependency details issues which I introduced with the last update.

Now onto some great news. After getting what I considered very important approval before changing direction, I've decided to discontinue work on this version of aurt to focus in a new direction. Although this effort was without user feedback, it did somehow get the attention and feedback from some key community members. As such, I couldn't be more pleased as an Arch community member and "Linux mechanic", with the outcome, which ultimately led to the change in direction.

I'm going to re-base the aurt script on aurutils. I've mentioned the duplication of efforts I was making with aurt, and have thought about this for quite some time. My personal thoughts are Alad and the team behind aurutils bring AUR helpers to a whole new level to say the least. With the thorough planning, versatility, integration with pacman, modularity, etc. that aurutils brings to the table as an AUR helper, it unavoidably comes along with some additional complexity to set up and use.

I'd like to attempt to bridge the gap somewhere between thorough and robust with usability, with a wrapper script that taps into some of what aurutils has to offer, initially to fit my personal usage pattern, then possibly expand on that. I've learned so much from the efforts of working on aurt. The one that stands out the most right now is the importance of spending adequate time for planning, testing, using, etc, prior to rushing out a test script.

I'll offer a new aurt script when I feel it's far along enough to be ready for testing.




Feature list

$ aurt -h

  Usage: aurt <operation> [AUR package name]

  Operations:                       
 -S   = Install and or update package.
 -Sy  = Sync update status to current available versions, provide results.
 -Su  = Update all AUR packages based on sync results.
 -Syu = System Update and Update AUR packages.
 -Sf  = Force install and or update package.
 -R   = Remove package.
 -C   = Cower check packages for updates.
 -D   = Dependency details for package.
 -F   = List of files provided by package.
 -s   = Search for package.
 -p   = Display pacman.log.
 -h   = Aurt help, this page.

  Overview:
 -S   Checks if package is installed, builds, installs, else checks for updates and update in this order.
 -Sy  Check packages for updates based on version number results from makepkg -so, makepkg --printsrcinfo, (epoch, pkgver, pkgrel)
 -Su  Update all eligible AUR packages based on sync results.
 -Syu Check and update all official and AUR repo packages. Runs sudo pacman -Syu, aurt -Sy, aurt -Su
 -Sf  Force install or update backs up build directory to /path/[packagename].aurt-BU, re-builds and or re-installs package.
 -R   Performs pacman -Rns on package and deletes package build directory and log.
 -C   Displays list of all installed AUR packages and their update status via cower.
 -D   Displays details on package dependencies, installed or not via cower, pacman, pacinfo, and aurt.
 -F   Displays a list of all the files belonging to a package.
 -s   Displays list of search results for package and details if match is found via cower.
 -p   Displays pacman log file.
 -h   Displays this help page.


Running aurt -Sy (two updates available)

$ aurt -Sy

:: Creating AUR package check list ....
:: Checking for updates ....


:: Checking : aacgain-cvs  
:: Version  : 20130814-2 

:: Checking : astyle-svn  
:: Version  : r638-1 

:: Checking : aurget  
:: Version  : 4.7.2-1 

:: Checking : aurora  
:: Version  : 20160907.16_f78867f-1 

:: Checking : aurutils  
:: Version  : 1.5.3-8 

:: Checking : aurvote-git  
:: Version  : r27.fd413f1-2 

:: Checking : burgaur-git  
:: Version  : 2.2.5.gb282099-1 

:: Checking : cloc-svn  
:: Version  : 1.62-1 

:: Checking : cower  
:: Version  : 17-2 

:: Checking : downgrade  
:: Version  : 6.0.0-1 

:: Checking : fetchpkg  
:: Version  : 0.3-7 

:: Checking : gcc-gcj-ecj  
:: Version  : 4.9-4 

:: Checking : gedit2  
:: Version  : 2.30.4-7 

:: Checking : grive  
:: Version  : 0.5.0-9 

:: Checking : grub-legacy  
:: Version  : 0.97-25 

:: Checking : hgsubversion-hg  
:: Version  : 1550.67b28d657f62-1 

:: Checking : idutils  
:: Version  : 4.6-1 

:: Checking : libcurl-openssl-1.0  
:: Version  : 7.57.0-1 

:: Checking : menulibre  
:: Version  : 2.1.3-2 

:: Checking : mime-editor  
:: Version  : 0.6-6 

:: Checking : mimeo  
:: Version  : 2017.6.6-1 

:: Checking : modprobed-db  
:: Version  : 2.37-1 

:: Checking : neofetch  
:: Version  : 3.3.0-1 

:: Checking : pacnews-neovim  
:: Version  : 0.0.2-1 

:: Checking : pacvcs  
:: Version  : 1:1.0.0-1 

:: Checking : pacvim-git  
:: Version  : v1.1.1.r10.gb0934ca-1 

:: Checking : pdftk  
:: Version  : 2.02-18 

:: Checking : pkgbrowser  
:: Version  : 0.21-1 

:: Checking : pkgbuilder  
:: Version  : 4.2.14-1 

:: Checking : plymouth  
:: Version  : 0.9.3-3 

:: Checking : polkit-explorer  
:: Version  : 10.84983b1-1 

:: Checking : pvim  
:: Version  : v0.3.1-1 

:: Checking : python3-aur  
:: Version  : 2018-1 

:: Checking : python3-memoizedb  
:: Version  : 2017.3.30-1 

:: Checking : python3-xcgf  
:: Version  : 2017.3-1 

:: Checking : python3-xcpf  
:: Version  : 2017.12-1 

:: Checking : raur-git  
:: Version  : 49.89f019b-1 

:: Checking : ruby-neovim  
:: Version  : 0.6.1-1 

:: Checking : ruby-redcarpet  
:: Version  : 3.2.2-1 

:: Checking : surfraw-git ..................... UPDATE AVAILABLE
:: Installed: 2018.01.31.gfad3905-1 
:: Available: 2018.02.02.g8b7e1d1-1 

:: Checking : terminfo-neovim-tmux  
:: Version  : 1.0-1 

:: Checking : trizen  
:: Version  : 1:1.42-1 

:: Checking : tstat-svn  
:: Version  : 775-1 

:: Checking : ttf-ms-fonts  
:: Version  : 2.0-10 

:: Checking : typescript-vim-git  
:: Version  : 7843f89-1 

:: Checking : urxvt-vim-insert  
:: Version  : 14.07a4afb-1 

:: Checking : vim-ack  
:: Version  : 1.0.9-1 

:: Checking : vim-apprentice  
:: Version  : 1.9-1 

:: Checking : vim-assistant  
:: Version  : 1.5.8-1 

:: Checking : vim-bash-support  
:: Version  : 4.2.1-1 

:: Checking : vim-bitbake-git  
:: Version  : r67.e1c3218-1 

:: Checking : vim-brainfuck  
:: Version  : 1.0.3-1 

:: Checking : vim-buftabline-git  
:: Version  : r60.12f29d2-1 

:: Checking : vim-buftabs  
:: Version  : 0.18-2 

:: Checking : vim-codepad  
:: Version  : 1.4-1 

:: Checking : vim-coffeescript-git  
:: Version  : v003.21.gde6b632-1 

:: Checking : vim-command-t  
:: Version  : 4.0-1 

:: Checking : vim-comments  
:: Version  : 2.12-1 

:: Checking : vim-csv-git  
:: Version  : 20150115-1 

:: Checking : vim-dein-git  
:: Version  : 1.0.r23.g5bbff63-1 

:: Checking : vim-diffchar  
:: Version  : 7.40-1 

:: Checking : vim-easytags  
:: Version  : 3.11-1 

:: Checking : vim-endwise  
:: Version  : 1.2-3 

:: Checking : vim-fcitx  
:: Version  : 1.2.5-1 

:: Checking : vim-fluxkeys  
:: Version  : 20091101-5 

:: Checking : vim-json-git  
:: Version  : 1:r102.3727f08-1 

:: Checking : vim-markdown  
:: Version  : 2.0.0.r246.861e84f-1 

:: Checking : vim-misc-xolox  
:: Version  : 1.17.6-1 

:: Checking : vim-openscad  
:: Version  : r14.2ac407d-1 

:: Checking : vim-pep8  
:: Version  : 1.1-1 

:: Checking : vim-pkgbuild  
:: Version  : 0.1.20141125.ca8e436-1 

:: Checking : vim-rest  
:: Version  : 0.1-1 

:: Checking : vim-session  
:: Version  : 2.13.1-2 

:: Checking : vim-tern  
:: Version  : 94.3cffc28-1 

:: Checking : vim-vimproc-git  
:: Version  : ver.9.3.r6.2300224-1 

:: Checking : vim-vim-support  
:: Version  : 2.3-1 

:: Checking : virtualbox-ext-oracle  
:: Version  : 5.2.6-1 

:: Checking : vi-vim-symlink  
:: Version  : 1-2 

:: Checking : wrapaur  
:: Version  : 2.0.10-1 

:: Checking : you-get-git ..................... UPDATE AVAILABLE
:: Installed: 0.4.1011.20180125.1868-1 
:: Available: 0.4.1011.20180202.1869-1 


Running aurt -Su (following the aurt -Sy above)

$ aurt -Su

Updates (2) surfraw-git you-get-git

 :: Build and install update with makepkg + pacman --needed --noconfirm options. 
 :: Proceed with update? [Y/n] y
From https://aur.archlinux.org/surfraw-git
 * branch            HEAD       -> FETCH_HEAD
Already up to date.
==> Making package: surfraw-git 2018.02.02.g8b7e1d1-1 (Fri Feb  2 10:52:29 PST 2018)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Updating surfraw git repo...
Fetching origin
==> Validating source files with sha1sums...
    surfraw ... Skipped
==> Extracting sources...
  -> Creating working copy of surfraw git repo...
Reset branch 'makepkg'
==> Starting pkgver()...
==> Removing existing $pkgdir/ directory...
==> Starting build()...
autoreconf: Entering directory `.'
autoreconf: configure.in: not using Gettext
autoreconf: running: aclocal 
aclocal: warning: autoconf input should be named 'configure.ac', not 'configure.in'
autoreconf: configure.in: tracing
autoreconf: configure.in: not using Libtool
autoreconf: running: /usr/bin/autoconf
autoreconf: configure.in: not using Autoheader
autoreconf: running: automake --add-missing --copy --no-force
automake: warning: autoconf input should be named 'configure.ac', not 'configure.in'
automake: warning: autoconf input should be named 'configure.ac', not 'configure.in'
autoreconf: Leaving directory `.'
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
/home/cody/z-AUR-Aurt/surfraw-git/src/surfraw/missing: Unknown `--is-lightweight' option
Try `/home/cody/z-AUR-Aurt/surfraw-git/src/surfraw/missing --help' for more information
configure: WARNING: 'missing' script is too old or missing
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether to enable local OpenSearch support... no
checking whether to install sr alias... yes
checking for lynx... lynx
checking for iceweasel... no
checking for firefox... firefox
checking for gawk... (cached) gawk
checking for perl... /usr/bin/perl
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating surfraw.lsm
config.status: creating surfraw.spec
config.status: creating elvi/Makefile
config.status: creating test/Makefile
config.status: creating examples/Makefile
make  all-recursive
make[1]: Entering directory '/home/cody/z-AUR-Aurt/surfraw-git/src/surfraw'
Making all in elvi
make[2]: Entering directory '/home/cody/z-AUR-Aurt/surfraw-git/src/surfraw/elvi'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/cody/z-AUR-Aurt/surfraw-git/src/surfraw/elvi'
Making all in test
make[2]: Entering directory '/home/cody/z-AUR-Aurt/surfraw-git/src/surfraw/test'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/cody/z-AUR-Aurt/surfraw-git/src/surfraw/test'
Making all in examples
make[2]: Entering directory '/home/cody/z-AUR-Aurt/surfraw-git/src/surfraw/examples'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/cody/z-AUR-Aurt/surfraw-git/src/surfraw/examples'
make[2]: Entering directory '/home/cody/z-AUR-Aurt/surfraw-git/src/surfraw'
make[2]: Nothing to be done for 'all-am'.
make[2]: Leaving directory '/home/cody/z-AUR-Aurt/surfraw-git/src/surfraw'
make[1]: Leaving directory '/home/cody/z-AUR-Aurt/surfraw-git/src/surfraw'
==> Entering fakeroot environment...
==> Starting package()...
make  install-recursive
make[1]: Entering directory '/home/cody/z-AUR-Aurt/surfraw-git/src/surfraw'
Making install in elvi
make[2]: Entering directory '/home/cody/z-AUR-Aurt/surfraw-git/src/surfraw/elvi'
make[3]: Entering directory '/home/cody/z-AUR-Aurt/surfraw-git/src/surfraw/elvi'
make[3]: Nothing to be done for 'install-exec-am'.
 /usr/bin/mkdir -p '/home/cody/z-AUR-Aurt/surfraw-git/pkg/surfraw-git/usr/lib/surfraw'
 /usr/bin/install -c S W acronym ads alioth amazon archpkg archwiki arxiv ask aur austlii bing bbcnews bookfinder bugmenot bugzilla cia cisco cite cliki cnn comlaw commandlinefu ctan currency cve debbugs debcodesearch debcontents deblists deblogs debpackages debpkghome debpts debsec debvcsbrowse debwiki deja discogs '/home/cody/z-AUR-Aurt/surfraw-git/pkg/surfraw-git/usr/lib/surfraw'
 /usr/bin/install -c duckduckgo ebay etym excite f5 foldoc finkpkg freebsd freedb freshmeat fsfdir gcache genbugs genportage github gmane google gutenberg imdb ixquick jamendo javasun jquery l1sp lastfm leodict lsm macports mathworld mdn mininova musicbrainz mysqldoc netbsd nlab ntrs openbsd oraclesearch pgdoc pgpkeys '/home/cody/z-AUR-Aurt/surfraw-git/pkg/surfraw-git/usr/lib/surfraw'
 /usr/bin/install -c phpdoc pin piratebay priberam pubmed rae rfc scholar scpan searx slashdot slinuxdoc sourceforge springer stack stockquote thesaurus translate urban w3css w3html w3link w3rdf wayback webster wikipedia wiktionary woffle wolfram worldwidescience yahoo yandex youtube '/home/cody/z-AUR-Aurt/surfraw-git/pkg/surfraw-git/usr/lib/surfraw'
make[3]: Leaving directory '/home/cody/z-AUR-Aurt/surfraw-git/src/surfraw/elvi'
make[2]: Leaving directory '/home/cody/z-AUR-Aurt/surfraw-git/src/surfraw/elvi'
Making install in test
make[2]: Entering directory '/home/cody/z-AUR-Aurt/surfraw-git/src/surfraw/test'
make[3]: Entering directory '/home/cody/z-AUR-Aurt/surfraw-git/src/surfraw/test'
make[3]: Nothing to be done for 'install-exec-am'.
make[3]: Nothing to be done for 'install-data-am'.
make[3]: Leaving directory '/home/cody/z-AUR-Aurt/surfraw-git/src/surfraw/test'
make[2]: Leaving directory '/home/cody/z-AUR-Aurt/surfraw-git/src/surfraw/test'
Making install in examples
make[2]: Entering directory '/home/cody/z-AUR-Aurt/surfraw-git/src/surfraw/examples'
make[3]: Entering directory '/home/cody/z-AUR-Aurt/surfraw-git/src/surfraw/examples'
make[3]: Nothing to be done for 'install-exec-am'.
make[3]: Nothing to be done for 'install-data-am'.
make[3]: Leaving directory '/home/cody/z-AUR-Aurt/surfraw-git/src/surfraw/examples'
make[2]: Leaving directory '/home/cody/z-AUR-Aurt/surfraw-git/src/surfraw/examples'
make[2]: Entering directory '/home/cody/z-AUR-Aurt/surfraw-git/src/surfraw'
make[3]: Entering directory '/home/cody/z-AUR-Aurt/surfraw-git/src/surfraw'
 /usr/bin/mkdir -p '/home/cody/z-AUR-Aurt/surfraw-git/pkg/surfraw-git/usr/share/man/man1'
 /usr/bin/mkdir -p '/home/cody/z-AUR-Aurt/surfraw-git/pkg/surfraw-git/usr/bin'
 /usr/bin/install -c surfraw surfraw-update-path '/home/cody/z-AUR-Aurt/surfraw-git/pkg/surfraw-git/usr/bin'
 /usr/bin/install -c -m 644 surfraw-update-path.1 surfraw.1 elvi.1sr '/home/cody/z-AUR-Aurt/surfraw-git/pkg/surfraw-git/usr/share/man/man1'
make  install-data-hook
make[4]: Entering directory '/home/cody/z-AUR-Aurt/surfraw-git/src/surfraw'
chmod -x surfraw.conf elvi.1sr surfraw.1
mkdir -p /home/cody/z-AUR-Aurt/surfraw-git/pkg/surfraw-git/etc/xdg/surfraw
cp surfraw.conf /home/cody/z-AUR-Aurt/surfraw-git/pkg/surfraw-git/etc/xdg/surfraw/conf
cp ./surfraw.bookmarks /home/cody/z-AUR-Aurt/surfraw-git/pkg/surfraw-git/etc/xdg/surfraw/bookmarks
while read target link ;\
do \
	ln -sf $target  /home/cody/z-AUR-Aurt/surfraw-git/pkg/surfraw-git/$link ;\
done < links
ln -sf surfraw /home/cody/z-AUR-Aurt/surfraw-git/pkg/surfraw-git//usr/bin/sr
ln -sf surfraw.1.gz /home/cody/z-AUR-Aurt/surfraw-git/pkg/surfraw-git//usr/share/man/man1/sr.1.gz
make[4]: Leaving directory '/home/cody/z-AUR-Aurt/surfraw-git/src/surfraw'
make[3]: Leaving directory '/home/cody/z-AUR-Aurt/surfraw-git/src/surfraw'
make[2]: Leaving directory '/home/cody/z-AUR-Aurt/surfraw-git/src/surfraw'
make[1]: Leaving directory '/home/cody/z-AUR-Aurt/surfraw-git/src/surfraw'
==> 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 issue...
==> Creating package "surfraw-git"...
  -> Generating .PKGINFO file...
  -> Generating .BUILDINFO file...
  -> Adding install file...
  -> Generating .MTREE file...
  -> Compressing package...
==> Leaving fakeroot environment.
==> Finished making: surfraw-git 2018.02.02.g8b7e1d1-1 (Fri Feb  2 10:52:40 PST 2018)
==> Installing package surfraw-git with pacman -U...
[sudo] password for cody: 
loading packages...
resolving dependencies...
looking for conflicting packages...

Packages (1) surfraw-git-2018.02.02.g8b7e1d1-1

Total Installed Size:  0.33 MiB
Net Upgrade Size:      0.00 MiB

:: Proceed with installation? [Y/n] 
(1/1) checking keys in keyring                                                                [#######################################################] 100%
(1/1) checking package integrity                                                              [#######################################################] 100%
(1/1) loading package files                                                                   [#######################################################] 100%
(1/1) checking for file conflicts                                                             [#######################################################] 100%
(1/1) checking available disk space                                                           [#######################################################] 100%
:: Processing package changes...
(1/1) upgrading surfraw-git                                                                   [#######################################################] 100%
==> NOTE: Config files have moved since surfraw v2.2.5!
==> Global config is now located in /etc/xdg/surfraw/conf
==> Local config is now in /root/.config/surfraw/conf
:: Running post-transaction hooks...
(1/1) Arming ConditionNeedsUpdate...
From https://aur.archlinux.org/you-get-git
 * branch            HEAD       -> FETCH_HEAD
Already up to date.
==> Making package: you-get-git 0.4.1011.20180202.1869-1 (Fri Feb  2 10:52:50 PST 2018)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Updating you-get git repo...
Fetching origin
==> Validating source files with md5sums...
    you-get ... Skipped
==> Extracting sources...
  -> Creating working copy of you-get git repo...
Reset branch 'makepkg'
==> Starting pkgver()...
==> Removing existing $pkgdir/ directory...
==> Starting build()...
==> GIT checkout done or server timeout
==> Starting make...
==> 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 issue...
==> Creating package "you-get-git"...
  -> Generating .PKGINFO file...
  -> Generating .BUILDINFO file...
  -> Generating .MTREE file...
  -> Compressing package...
==> Leaving fakeroot environment.
==> Finished making: you-get-git 0.4.1011.20180202.1869-1 (Fri Feb  2 10:53:00 PST 2018)
==> Installing package you-get-git with pacman -U...
loading packages...
resolving dependencies...
looking for conflicting packages...

Packages (1) you-get-git-0.4.1011.20180202.1869-1

Total Installed Size:  1.34 MiB
Net Upgrade Size:      0.00 MiB

:: Proceed with installation? [Y/n] 
(1/1) checking keys in keyring                                                                [#######################################################] 100%
(1/1) checking package integrity                                                              [#######################################################] 100%
(1/1) loading package files                                                                   [#######################################################] 100%
(1/1) checking for file conflicts                                                             [#######################################################] 100%
(1/1) checking available disk space                                                           [#######################################################] 100%
:: Processing package changes...
(1/1) upgrading you-get-git                                                                   [#######################################################] 100%
:: Running post-transaction hooks...
(1/1) Arming ConditionNeedsUpdate...


Dependency Details Results

$ aurt -D monero-wallet-qt
----------------------------------------------------------------------------------------------------------------

 Package             : monero-wallet-qt
 Unmet AUR repo      : libmonero-wallet
 Unmet Official repo : qt5-graphicaleffects qt5-quickcontrols qt5-tools qt5-webengine
 Make Dependancies   : git cmake boost
 Dependencies        : Dependencies list too wide, printed below:

libmonero-wallet>=0.11.1.0
openssl
boost-libs>=1.45
libunwind
readline
qt5-base
qt5-declarative
qt5-graphicaleffects
qt5-location
qt5-quickcontrols
qt5-tools
qt5-webchannel
qt5-webengine
qt5-x11extras
qt5-xmlpatterns 
----------------------------------------------------------------------------------------------------------------
 Install all required AUR dependencies prior to installing monero-wallet-qt.
----------------------------------------------------------------------------------------------------------------




$ aurt -D cower
----------------------------------------------------------------------------------------------------------------

 Package             : cower
 Unmet AUR repo      : 
 Unmet Official repo : 
 Make Dependancies   : perl
 Dependancies        : curl pacman yajl
 
----------------------------------------------------------------------------------------------------------------
 Install all required AUR dependencies prior to installing cower.
----------------------------------------------------------------------------------------------------------------


Latest aurt script

#!/bin/bash
# aurt 2018-02-18   Depencencies: sudo base-devel git cower pacutils
# date:year-mo-day

basedir="${HOME}"/z-AUR-Aurt                             # "${basedir}"   =  base directory for build
builddir="${HOME}"/z-AUR-Aurt/"${2}"                     # "${builddir}"  =  build directory
pdate=$(date '+%Y-%m-%d')				 # "${pdate}"     =  todays date

   #==================================== MULTI PACKAGE INSTALL & UPDATE SUPPORT ===================================
for pkgs in "$2"
do			### Enabled multiple package installing and or updating.
			### 'Done' for this loop is ~ line 177, directly following  morepkgs function.

   #=============================================== INSTALL PACKAGE ===============================================
install () {

	builddir="${HOME}"/z-AUR-Aurt/"${2}"

	echo; echo ":: RUNNING INSTALL ON : ${2}"

if	[[ -z $2 ]]; then
	echo "Error: Positional parameter 2 (package) empty."
	exit
fi
	exec &> >(tee -i "${basedir}/${2}.log")
   #.................................................................................................

		### Check if package is installed, if yes bypass, if no proceed to next test
		### Check if AUR package is available, if yes git clone w/o building or installing 
		### 				       if no, print "package is unavailable" massage and exit aurt

	cd "${basedir}" || exit

if	[[ $(pacman -Q "${2}" 2>/dev/null | awk '{print $1}') != "${2}" ]]; then

	if	[[ -n $(git ls-remote https://aur.archlinux.org/"${2}".git) ]]; then
		git clone --progress https://aur.archlinux.org/"${2}".git
	   else
		echo; echo "Error: AUR git repo for ${2} is unavailable"; echo
		exit
	fi
fi
   #.................................................................................................

		### Check if package is installed, if yes bypass to check for updates, if no next test
		### Check if PKGBUILD is present, if yes run interactive function, build, install package and exit aurt 
		###                               if no, display "PKGBUILD unavailable" message, exit

	cd "${builddir}"  || exit

if	[[ $(pacman -Q "${2}" 2>/dev/null | awk '{print $1}') != "${2}" ]]; then

	if	[[ -s PKGBUILD ]]; then

		### Print info from aurt-help   
		### Run interactive function

		. aurt-help --pkgbuild
		stopYesNo
		makepkg -Csfci --noconfirm --needed ;  exitcode1=$?								#pos 1 exit code
		C1=$(pacman -Qm "${2}" | awk '{print $2}')
		C2="Current, just installed."		
		. aurt-help --updates "${2}"; echo

			if 	[[ -n $exitcode1 ]] && [[ $exitcode1 != 0 ]]; then 
				echo "makepkg (pos 1) exit code error $exitcode1"; echo; 
			fi
		morepkgs "${@}"
		exit
	    else
		echo; echo "Error: PKGBUILD unavailable, to restore, remove then reinstall package with aurt"; echo
		exit
	fi
fi
				echo ":: Already installed ---------------> bypassing"
	checkupdate "${@}"
}
   #=================================================== UPDATE PACKAGE ==================================================

checkupdate () {

	builddir="${HOME}"/z-AUR-Aurt/"${2}"
	
	echo ":: RUNNING UPDATE ON  : ${2}"

		### Check if builddir is present, if no print message & exit aurt

if	[[ ! -d ${builddir} ]]; then
	echo " Build directory is not present, remove and reinstall package."
	exit
fi
   #.................................................................................................

		### Check if .git dir is present, if yes, compare local to remote git HEAD
		### If different, git pull, build, install update, exit

	cd "${builddir}"  || exit

 	local=$(git -C "${builddir}" rev-parse HEAD)
	remote=$(git ls-remote https://aur.archlinux.org/"${2}".git HEAD|awk '{print $1}')

if	[[  -d  ${builddir}/.git ]] &&
	[[ $remote != "$local" ]]; then                                                                             ####| != |#### default present
	echo "git ud"

	git pull --progress https://aur.archlinux.org/"${2}".git  2> /dev/null

   	. aurt-help --pkgbuild
 	. aurt-help --updates "${2}"	### Print info from aurt-help
	stopYesNo			### Run interactive function

	makepkg -Csfci --noconfirm --needed ;  exitcode2=$?									#pos 2 exit code

	echo "updated on ${pdate}" >> "${builddir}"/Aurt-Update.log
	echo; echo ":: Update ran on ${2}"; echo
	
	if 	[[ -n $exitcode2 ]] && [[ $exitcode2 != 0 ]]; then 
		echo "makepkg (pos 2) exit code error $exitcode2"; echo
	fi

fi
   #.................................................................................................

		### Prepare for update test comparing version numbers (makepkg -so makepkg --printsrcinfo)
		### Get info and set variables

	makepkg -so &>/dev/null ;  exitcode3=$?											#pos 3 exit code
	
	C1=$(pacman -Qm "${2}" | awk '{print $2}')
	C2=$(makepkg --printsrcinfo | awk '/pkg[vr]/ {print $3}' | awk '{printf $0 "-"; getline; print $0}')

	epoch=$(makepkg --printsrcinfo | awk '/epoch/ {print $3}')

if	[[ -n $epoch ]]; then 
	C2="$epoch:${C2}" 
fi
		### If installed version not same as available, git pull, build, install update

if	[[ ${C1} != "${C2}" ]]; then
	echo "version ud"
	. aurt-help --pkgbuild
	. aurt-help --updates "${2}"	### Print info from aurt-help
	stopYesNo			### Run interactive function

	makepkg -Csfci --noconfirm --needed ;  exitcode4=$?									#pos 4 exit code

	echo "updated on ${pdate}" >> "${builddir}"/Aurt-Update.log
	echo; echo "Update ran on ${2}"; echo
   else
	echo "checked on ${pdate}" >> "${builddir}"/Aurt-Update.log
	echo
	. aurt-help --updates "${2}"



	echo ":: ${2} is up to date, Exiting. "; echo
fi
	if [[ -n $exitcode3 ]] && [[ $exitcode3 != 0 ]]; then echo "makepkg (pos 3) exit code error $exitcode3"; echo; fi
	if [[ -n $exitcode4 ]] && [[ $exitcode4 != 0 ]]; then echo "makepkg (pos 4) exit code error $exitcode4"; echo; fi

    morepkgs "${@}"

}
   #======================================== MULTI PACKAGE SUPPORT FUNCTION ========================================

morepkgs () {

	shift
if	[[ -n "$2" ]]; then
	install "${@}"
    else
	exit
fi

}

done       ### The 'do' for this loop is from ~ line 10. ###

   #============================================= FORCE BUILD INSTALL UPDATE ===========================================

forcebuild () {

if 	[[ -z ${2} ]]; then 
	echo "Error: No package"
	exit
fi

if	[[ -d ${builddir} ]]; then
	mv "${builddir}" "${builddir}"."${pdate}".bu
fi
	cd "${basedir}"  || exit
	git clone https://aur.archlinux.org/"${2}".git
	cd "${builddir}"  || exit

	. aurt-help --pkgbuild
	. aurt-help --updates "${2}"	### Print info from aurt-help
	stopYesNo

	makepkg -Csfci --noconfirm --needed 
	echo; echo " NOTE: If ${builddir} was present, it has been renamed to ${2}.aurt-BACKUP".
}
   #========================================= SYNC & CHECK FOR ALL AUR UPDATES =============================================

sync () {

	echo; echo ":: Creating AUR package check list ...."

if 	[[ -e /tmp/updates ]]; then
	rm /tmp/updates || echo "ERROR Removing /tmp/updates"
fi
		### Create a list of AUR packages to check for updates
		### Filter out any non official repo packages currently not in AUR repos

	alist=$(pacman -Qqm)
	blist=$(comm -23 <(echo "${alist}" | sort) <(curl -s https://aur.archlinux.org/packages.gz | gzip -cd | sort))
	clist=$(echo -e "${alist} \\n${blist}" | sort); echo "${clist}" > /tmp/list
	dlist=$(uniq -u /tmp/list)

	echo ":: Checking for updates ...."; echo

for P in $dlist
do
		### Prepare to check installed version -vs- available version
		### Available version obtained via 'makepkg -so' and parsing version from 'makepkg --printsrcinfo'

	builddir="${HOME}"/z-AUR-Aurt/"${P}"
	C1=$(pacman -Qm "${P}" | awk '{print $2}')
 
	echo ":: Checking : ${P}  "
	echo ":: Version  : ${C1} "
	cd "${builddir}" || exit

	makepkg -so --needed --noconfirm &>/dev/null

	C2=$(makepkg --printsrcinfo | awk '/pkg[vr]/ {print $3}' | awk '{printf $0 "-"; getline; print $0}')
	epoch=$(makepkg --printsrcinfo | awk '/epoch/ {print $3}')
if	[[ -n $epoch ]]; then
	C2="$epoch:$C2"
fi
		### Check if installed version different from available version
		### If different, add package to update list and message user.

if	[[ $C1 != "$C2" ]]; then
	echo ":: Available: ${C2} ..................... UPDATE AVAILABLE"
	echo "${P}" >> /tmp/updates
fi
		### Prepare for git HEAD local -vs- remote backup check

	C3=$(git ls-remote https://aur.archlinux.org/"${P}".git HEAD|awk '{print $1}')
	C4=$(git -C "${builddir}" rev-parse HEAD)

		### For pkgs only included as part of others & w/o git repo. (ie: aursec-tui is part of aursec)
		### Eliminate false positive update status.

if	[[ -z ${C3} ]]; then
	C3=$C4
fi
		### Check if local git HEAD different from remote as backup check
		### If different, add package to update list and message user.

if	[[ ${C3} != "${C4}" ]]; then

	echo ":: Checking : ${P} ..................... UPDATE AVAILABLE (git check)"
	echo ":: Local HEAD : ${C4}"
	echo ":: Remote HEAD: ${C3}"
	echo "${P}" >> /tmp/updates
fi
	echo
done
		### If no updates available, create file with message and current date.
		### Notify user with message.

if	[[ ! -e /tmp/updates ]]; then
	echo; echo ":: All AUR packages up to date." ; echo
	echo ":: No AUR updates available as of last sync on ${pdate}" >/tmp/noupdates
	exit
fi
	md5sum /tmp/updates >/tmp/md5sum 2>/dev/null
}
   #============================================== UPDATE ALL AUR PACKAGES ==============================================

update () {

if	[[ -e /tmp/noupdates ]] && [[ -e /tmp/updates  ]]; then
	rm /tmp/noupdates
fi

if	[[ -e /tmp/noupdates ]]; then
	echo; cat /tmp/noupdates; echo
	exit
fi

if	[[ ! -e /tmp/updates ]] && [[ ! -e /tmp/md5sum ]]; then
	echo; echo " Update status unknown, Run aurt -Sy "; echo
	exit
fi		### Integrity check updates file
		### If pass, prepare update list for makepkg

if	[[ $(cat /tmp/md5sum) = $(md5sum /tmp/updates) ]]; then

		### Remove any duplicate entries in updates file
		### Set filtered update list to variable
		### Count number of updates in list and set to variable

	awk '!seen[$0]++' /tmp/updates >/tmp/ud && mv /tmp/ud /tmp/updates
	udlist=$(cat /tmp/updates | fmt -1000)
	N=$(cat /tmp/updates | wc -l)

		### Message user, get authorization to proceed with update
	echo
	echo "AUR Packages ($N) $(cat /tmp/updates | fmt -1000)"
   else
	echo " Current AUR update data unavailable. 'Run aurt -Sy' before updating."
	exit	
fi
	echo
	date -r /tmp/updates | awk '{print ":: Running update list from: " $2, $3, $6, "@", $4}'
	echo                               ":: Will build and install with makepkg -Csfci --noconfirm. "
while true 
do 	read -r -p ":: Proceed with update? [Y/n] " yn
	case $yn in
		y|yes) break	 ;;
		n|no)  exit	 ;;
		 *) echo "y-n ?" ;;
	esac
done
		### Feed update list packages consecutively to makepkg for build and install
for P in $udlist
do
	builddir=${HOME}/z-AUR-Aurt/"${P}"

	if	[[  -d  ${builddir}/.git ]]; then
		cd "${builddir}"  || exit

		git pull 2>&1 |tee /tmp/null

	if	[[ -n $(cat /tmp/null | awk '/error/,/PKGBUILD/') ]]; then
		echo
		echo ":: Error with git pull. Running forcebuild option to git clone."; echo
		forcebuild echo "${P}"
		rm /tmp/null
		exit
	fi
		makepkg -Csfci --noconfirm
	   else
		echo " Error: ${builddir}/.git for $P is not present."
	fi
done
		### Delete update related files

	rm /tmp/updates
	rm /tmp/md5sum
	rm /tmp/noupdates 2>/dev/null
}
   #=================================================== INTERACTIVE ===================================================

stopYesNo () {

	echo                "   Edit PKGBUILD?                                            [yes]/[no] "
	echo                "   EXIT NOW: Do not install / update.                            [exit] "; echo
	echo                "                                            Please Select:  [y]/[n]/[e] "; echo
while	true; do read -r -p "   Note: exit editor upon completion to proceed with update.    " yne
	case $yne in
		y|yes) $EDITOR PKGBUILD; break	;;
		n|no) break			;;
		e|exit) exit			;;
		* ) echo "   y-n-e ?"		;;
	esac
done
}
   #===================================================== REMOVE ======================================================

remove () {

	if [[ -z ${2} ]]; then echo "Error: No package"; exit; fi
	exec &> >(tee -i "${basedir}/${2}.log")
	echo "   NEXT: Runing sudo pacman -Rns --noconfirm ${2}, and sudo rm -fr ${builddir}"; echo
while	true; do read -r -p "  Proceed? [Y/n] " yn
	case $yn in
		y|yes) break 		;;
		n|no) exit 		;;
		* ) echo "y-n ?"	;;
	esac
done
        rm -fr "${builddir}"
	rm "${basedir}"/"${2}".log
	sudo pacman -Rns --noconfirm "${2}"
	sudo -K
}
   #===================================================== SEARCH ======================================================

search () {
	cower -qs --by=name "${2}"
	number=$(cower -qs --by=name "${2}" | wc -l)
	echo; echo " Found: ${number} packages above with ${2} in name."; echo
	echo       " If there is an exact match, details shown below. " ; echo
	cower -i "${2}"
}
   #================================================ DEPENDENCY DETAILS ===============================================

dependencies () {
               # alldeps   =   all dependencies
    readarray -t alldeps <<< $(cower -i --format=%D%M --listdelim=' ' "${2}"|fmt -1)
	       # mdeps  =    make dependencies
    readarray -t mdeps <<< $(cower -i --format=%M --listdelim=' ' "${2}"|fmt -1)

	# exit if no results
if	[[ -z "${alldeps[@]}" ]] && [[ -z "${mdeps[@]}" ]]; then
	echo "No dependencies found for ${2}."
	exit
fi
                # muall  =   met + unmet all (filtered)
    readarray -t  muall <<< $(echo "${alldeps[@]}" | fmt -1 | awk -F'<|>|=' '{print $1}' | sort)

for pkg in "${muall[@]}"
do
	X=$(pacman -Qq "$pkg" 2>/dev/null)
      # mall  =  met all dependencies
	mall+=("$X")
done
	       # uall  =   unmet all dependencies
    readarray -t uall <<< $(comm -23 <(echo "${muall[@]}"|fmt -1|sort|awk '{$1=$1}1') <(echo "${mall[@]}"|fmt -1|sort|awk '{$1=$1}1'))
	       # uoff  =   unmet official repos
    readarray -t uoff <<< $(pacinfo --short $(echo "${uall[@]}") 2>/dev/null|awk -F'/' '/core|extra|community|multilib/ {print $2}'|awk '{print $1}')
	       # uaur  =   unmet aur repos
    readarray -t uaur <<< $(comm -23 <(echo "${uall[@]}"|fmt -1|sort|awk '{$1=$1}1') <(echo "${uoff[@]}"|fmt -1|sort|awk '{$1=$1}1'))
	       # deps  =   dependencies
    readarray -t deps <<< $(comm -23 <(echo "${alldeps[@]}"|fmt -1|sort|awk '{$1=$1}1') <(echo "${mdeps[@]}"|fmt -1|sort|awk '{$1=$1}1'))

	       # If list is too wide, display as column
if 	(( $(echo "${deps[@]}"|wc -c) > 120 )); then
	cdc="$(echo "${deps[@]}" | fmt -1)"
	pb="$(echo "Dependencies list too wide, printed below:")"
	else
	cdr="$(echo "${deps[@]}" | fmt -125)"
fi
	. aurt-help --depend "${2}"

}
   #================================================== SYU SYSTEM UPDATE ==============================================

runsyu () {

if 	[[ -e /tmp/updates ]]; then
	rm /tmp/updates || echo "ERROR Removing /tmp/updates"
fi
	echo; echo ":: Checking AUR packages for updates ...." ; 
	cower -u | awk '{print $2}'	>/tmp/updates

if	[[ -s /tmp/updates ]]; then
	N=$(cat /tmp/updates | wc -l)
	echo ":: AUR updates available: ($N) $(cat /tmp/updates|fmt -1000)"
	echo ":: Will install after system update."
	md5sum /tmp/updates >/tmp/md5sum 2>/dev/null
    else
	echo ":: All AUR packages up to date."
	rm /tmp/updates || echo "ERROR Removing /tmp/updates"
fi
	echo ":: Running: 'sudo pacman -Syu' "; echo
	sudo pacman -Syu
	echo

if	[[ -e /tmp/updates ]]; then
	update
fi
	sudo -K
}
   #=================================================== UPDATE REPORT ==================================================

updatereport () {
	echo
	cower -uv; echo
	echo " Number of AUR packages installed & checked: $(cower -uv |tee | wc -l)"; echo
	echo " Official repo updates if available listed below. Update system prior to installing or updating AUR packages. "; echo
	checkupdates; echo
}
   #=================================================== PARAM ERROR ======================================================

parametererror () {
	echo
	echo "  Input Error: Please try again or see    aurt --help"
}
   #=================================================== RUN FUNCTIONS =====================================================

if 	[[ -z "$*" ]]; then aurt-help --header "${@}"
fi
while	:; do
	case "${1}" in
	    -S|--install)	install			"${@}"			;;
	   -Sy|--sync)		sync						;;
	   -Su|--update)	update						;;
	  -Syu|--sysupdate)	runsyu						;;
	   -Sf|--force)		forcebuild		"${@}"			;;
	    -R|--remove)	remove			"${@}"			;;
	    -C|--checkupdates)	updatereport       				;;
	    -D|--dependencies)	dependencies		"${@}"			;;
	    -F|--files)		pacman -Ql		"${2}"			;;
	    -s|--search)	search			"${@}" 			;;
	    -p|--pacmanlog)	paclog						;;
     	    -h|--help)		aurt-help --help	"${@}"			;;
	   -?*)			parametererror;		aurt-help --header	;;
	     *)	break
	esac
    shift
done



Latest aurt-help script (provides information to user)

#!/bin/bash
# aurt-help 2018-02-11   Depencencies: aurt
# date:     year-mo-day

header () {

cat << Read-Header

 |=====================================================================================|
 |    Aurt, a tiny AUR helper script.         USAGE:  \$ aurt [operation] [package]     |
 |-------------------------------------------------------------------------------------|
 | -S   Install And Or Update       -C  Cower Check For Updates           NOTES:       |
 | -Sy  Sync & Check for Updates    -D  Package Dependency Details                     |
 | -Su  Update All AUR Packages     -F  Files Provided By Pkg                          |
 | -Syu System And AUR Update       -s  Search For Pkg            leafpad-aurt: lat    | 
 | -Sf  Force Install Or Update     -p  Pacman Log             thunar-base dir: tbd    |
 | -R   Remove Pkg And Bld Dir      -h  Help                  Orphans:  R \$(p -Qtdq)   |
 |=====================================================================================| 

Read-Header
}
 
help () {

cat << Read-Help

  Usage: aurt <operation> [AUR package name]

  Operations:                       
 -S   = Install and or update package.
 -Sy  = Sync update status to current available versions, provide results.
 -Su  = Update all AUR packages based on sync results.
 -Syu = System Update and Update AUR packages.
 -Sf  = Force install and or update package.
 -R   = Remove package.
 -C   = Cower check packages for updates.
 -D   = Dependency details for package.
 -F   = List of files provided by package.
 -s   = Search for package.
 -p   = Display pacman.log.
 -h   = Aurt help, this page.

  Overview:
 -S   Checks if package is installed, builds, installs, else checks for updates and update in this order.
 -Sy  Check packages for updates based on version number results from makepkg -so, makepkg --printsrcinfo, (epoch, pkgver, pkgrel)
 -Su  Update all eligible AUR packages based on sync results.
 -Syu Check and update all official and AUR repo packages. Runs sudo pacman -Syu, aurt -Sy, aurt -Su
 -Sf  Force install or update backs up build directory to /path/[packagename].aurt-BU, re-builds and or re-installs package.
 -R   Performs pacman -Rns on package and deletes package build directory and log.
 -C   Displays list of all installed AUR packages and their update status via cower.
 -D   Displays details on package dependencies, installed or not via cower, pacman, pacinfo, and aurt.
 -F   Displays a list of all the files belonging to a package.
 -s   Displays list of search results for package and details if match is found via cower.
 -p   Displays pacman log file.
 -h   Displays this help page.

Read-Help

}

updates () {

cat << Read-updates
------------------------------------------------------------------------
                           Information:

  Todays date:             : ${pdate}
  Package                  : ${2}
  Base Directory           : ${basedir}
  Build directory          : ${builddir}
  Installed version        : ${C1}
  Latest available version : ${C2}
------------------------------------------------------------------------

Read-updates
}

pkgbuild () {

catpkgbuild=$(cat PKGBUILD) 	# "${pkgbuild}"  =  used in aurt-help, pkgbuild function

cat << Read-pkgbuild

=========================================================================
                             START PKGBUILD
=========================================================================

${catpkgbuild}

=========================================================================
                           ^ PKGBUILD ABOVE ^
=========================================================================

Read-pkgbuild
}

depend () {

cat << Read-deps
----------------------------------------------------------------------------------------------------------------

 Package             : ${2}
 Unmet AUR repo      : ${uaur[@]}
 Unmet Official repo : ${uoff[@]}
 Make Dependancies   : ${mdeps[@]}
 Dependencies        : ${cdr}${pb}

${cdc} 
----------------------------------------------------------------------------------------------------------------
 Install all required AUR dependencies prior to installing ${2}.
----------------------------------------------------------------------------------------------------------------

Read-deps
}

while :; do
		case "${1}" in
	--header)	header			;;
	--help)		help			;;
	--updates)	updates		"${@}"	;;
	--pkgbuild)	pkgbuild		;;
	--depend)	depend		"${@}"	;;
	        *)	break
	esac
	shift
done

Last edited by Cody Learner (2018-05-02 23:36:57)


Self designated Linux and Bash mechanic.....
I fix and build stuff hands on. I'm not opposed to creating a mess in obtaining a goal.

Offline

#2 2017-12-06 09:49:17

Slithery
Forum Moderator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 2,864

Re: aurt, yet another, but very minamilistic AUR assistant

Some of your variables need quoting, run it through shellcheck.net to see what I mean.


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#3 2017-12-06 09:52:31

Alad
Wiki Admin/IRC Op/TU
From: The Land of The Bloat
Registered: 2014-05-04
Posts: 1,858
Website

Re: aurt, yet another, but very minamilistic AUR assistant

I'm having some trouble reading what's going on here - Try to avoid things like putting blocks on a single line to test if the output matches some string.

Otherwise it seems you've written 110 lines to basically run three commands - git clone, git pull and makepkg -si. Not sure why you're running git clone after running git pull either.


Mods are just community members who have the occasionally necessary option to move threads around and edit posts. -- Trilby
Honest Alad's Package Emporium—Now with added bugs! (Closed until further notice)

Offline

#4 2017-12-06 10:44:08

Seventh
Member
Registered: 2016-08-05
Posts: 47

Re: aurt, yet another, but very minamilistic AUR assistant

Whats the difference in what Trillby posted here? https://bbs.archlinux.org/viewtopic.php … 2#p1752342

Offline

#5 2017-12-06 21:03:49

Cody Learner
Banned
Registered: 2017-12-06
Posts: 54
Website

Re: aurt, yet another, but very minamilistic AUR assistant

slithery wrote:

Some of your variables need quoting, run it through shellcheck.net to see what I mean.

Thanks slithery, ran it through shellcheck and fixed everything i think.

Alad wrote:

I'm having some trouble reading what's going on here - Try to avoid things like putting blocks on a single line to test if the output matches some string.

Otherwise it seems you've written 110 lines to basically run three commands - git clone, git pull and makepkg -si. Not sure why you're running git clone after running git pull either.

Thanks Alad. I guess readability would be pretty subjective depending on skills, etc. It seems easy to me - or could likely be said of whoever wrote a script... I'd like to try learn whats more "standard" so everyone including myself sees it as easy to read. I get lost reading most scripts unless I really dissect and work on one, but I'm very inexperienced. Shorter seems easier though. Do people tend to all have distinctive styles of writing shell, or is it pretty standardized?

You mean like the one below? Would you put the "Already up to date." into another variable or? I'm sure there are cleaner ways to check for updates, but this one just popped into thought while working on it. Are there any others that stand out as needing attention? Oh and in case it's not obvious and if I screwed up on my methods, I try avoid git for the most part. It hurts my brain for some reason.

if [[ $(cd "${builddir}" ; git pull 2> /dev/null) = "Already up to date." ]] ; then

This script started out a copy and paste of Trilby's 3 lines. I just kept testing, adding, wanting more, etc. I like feedback in the shell on whats going on during running someones script. I tend to focus on that too much, and end up with something that is 3 - 4 times longer than necessary just to satisfy my ocd with it. I do find it entertaining to try write shell for some odd reason though. Prolly cause it's not remotely related to what I do for work, which petty much discourages using your brain to think.

Running git pull to check for updates, then delete the directory to start clean with clone.

@ Seventh, did you see the attribute to Tribly in the script? Trilby got my thought process going with his example so I ran with it and considered his input worthy of mention. I could have stopped at probably 10 lines, but like I said, I enjoy it and just got carried away.

I've used pacaur for some time. I have looked at the script and was honestly completely lost. For the limited features of pacaur I use (pacaur -S) I think the 20 or so lines of code actually doing something in my script could replace that functionality to suite my preferred requirements. The rest just make it more enjoyable to use for me...lol. Pacman and makepkg and now git are pretty much 99% of my solution. I just glued it together with the remaining 1% to my liking.

Enjoying the feedback. I'll post the updates below. I added a yes no during removal regarding deletion of files. I'm also getting some minor unwanted issues I'm unsure of on how to solve. For the help and show log options, the positional variables are unset. This leads to a .log file being produced on the base directory. The log is of whatever is on my screen. I could I do a if else to disable logging for those options, but hopefully learn of something simpler.


#!/bin/bash
# By Cody Learner
# aurt's a tiny AUR script to complement pacman + pkgbrowser use.
# aurt's designed to handle AUR packages one at a time. 
#
# Attribute Trilby @ arch forums for the meat* of this script. 
# https://bbs.archlinux.org/viewtopic.php?pid=1752342#p1752342
# *Providing the idea & sample commands, inspiring me.
#------------------------------------------------------------------
#		bash  "positional parameters"
#------------------------------------------------------------------
#		$0 would contain "a_program_name"
#		$1 would contain "word1"
#		$2 would contain "word2"
#		$3 would contain "word3"
#------------------------------------------------------------------
#  Define:     [COMMAND]   -[OPTIONS]     [PACKAGE]     [Not Used]
#------------------------------------------------------------------
#  Example:  |    aurt    |     -I     |  pkgbrowser  |     NR    |
#------------------------------------------------------------------
#  Position: |    $0	  |     $1     |     $2       |	    $3    |
#------------------------------------------------------------------
# echo "$@" ($@ in bouble quotes) expands all parameters
# Function commands follwed by "$@" passes positional parameters to functions.

#============================= START SCRIPT ================================

echo -----------------------------------------------------------------------
echo " aurt, a tiny AUR assistant.   UEAGE: aurt [option] [package]        "
echo " [-I] install [-R] remove [-h] help [-l] pacman log [no combinations] "
echo -----------------------------------------------------------------------
echo

#----------------------------
#   SET VARIABLES & LOGGING
#----------------------------
# parameter $1 = -[OPTIONS] Entered when calling aurt 
# parameter $2 =  [PACKAGE] Entered when calling aurt

basedir=${HOME}/z-AUR-Auto/aurt-built
builddir=${HOME}/z-AUR-Auto/aurt-built/${2}

touch "${basedir}"/"${2}".log 
exec &> >(tee -i "${basedir}/${2}.log")

#------------------------
# Some messages to echo 
#-----------------------

      if   [[ ${1} = -I ]] ; then
	echo "    Installing $2"

      elif [[ ${1} = -R ]] ; then
	echo "    Removing $2 with pacman -Rns and rm -r ${builddir} and ${2}.log"
      fi
echo

#------------------------
# Begin INSTALL function
#------------------------
install() {

	echo "    '${builddir}' variable set to: ${builddir}"
echo
     if [ -e  "${builddir}" ] ; then
	echo "    Build directory is already present, check if update available via git pull." ; echo
	else
	mkdir "${builddir}"
      fi

      if [[ $(cd "${builddir}" ; git pull 2> /dev/null) = "Already up to date." ]] ; then
	echo "    Git pull indicates ${2} is up to date. Nothing to do. Exiting aurt" - exit code $? ; echo ; exit
echo
	else
	cd "${basedir}" || exit
	echo "    Git pull indicates update available for ${2}, cd to ${basedir}, preparing for git clone."
echo
	rm -fr "${builddir}" 
	git clone https://aur.archlinux.org/"${2}".git
      fi
echo
	cd "${builddir}" || exit
	echo "    cd back into ${builddir} to run makepkg -si "
echo
	makepkg -si --needed
echo
}

#-----------------------
# Begin REMOVE function
#-----------------------
remove() {
echo ----------------------------------------------------
	echo " PACMAN:"
echo
	sudo pacman -Rns "${2}"
echo ----------------------------------------------------
echo
echo ----------------------------------------------------
echo " ls -al ${basedir}"
echo
	ls -al "${basedir}"
echo ----------------------------------------------------
echo
echo "  Deleting files mentioned above." 
	yes-no
echo
	sudo rm -r "${builddir}"
	sudo rm "${basedir}/${2}".log
echo
echo ----------------------------------------------------
echo " ls -al ${basedir}"
echo
	ls -al "${basedir}"
echo ----------------------------------------------------
echo
	echo "   Remove function completed. - exit code $? "
echo
}

#-----------------------
# Begin YES-NO function
#-----------------------
yes-no () {
while true; do 
 read -r -p "  Proceed? " yn
    case $yn in
        [Yy]* ) break;;
        [Nn]* ) exit;;
        * ) echo "yes or no.";;
    esac
done
}

#--------------------
#   RUN FUNCTIONS
#--------------------

      if [[ "$1" == "-I" ]]; then
    	install "$@"                    #  RUN INSTALL #

	elif [[ "$1" == "-R" ]]; then
	remove "$@"                     #  RUN REMOVE  #

	elif [[ "$1" == "-h" ]]; then
	aurt-help                       #   RUN HELP   #

	elif [[ "$1" == "-l" ]]; then
	cat /var/log/pacman.log; echo	#  PACMAN LOG  #
      fi

echo "  aurt's done exit code $? 'zero is good!'"

Here's what I mean by feedback from the script.

$ aurt -I cower
-----------------------------------------------------------------------
 aurt, a tiny AUR assistant.   UEAGE: aurt [option] [package]        
 [-I] install [-R] remove [-h] help [-l] pacman log [no combinations] 
-----------------------------------------------------------------------

    Installing cower

    '/home/cody/z-AUR-Auto/aurt-built/cower' variable set to: /home/cody/z-AUR-Auto/aurt-built/cower

    Git pull indicates update available for cower, cd to /home/cody/z-AUR-Auto/aurt-built, preparing for git clone.

Cloning into 'cower'...

    cd back into /home/cody/z-AUR-Auto/aurt-built/cower to run makepkg -si 

==> Making package: cower 17-2 (Wed Dec  6 11:50:02 PST 2017)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Downloading cower-17.tar.gz...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 25661  100 25661    0     0  25661      0  0:00:01  0:00:01 --:--:-- 17233
  -> Downloading cower-17.tar.gz.sig...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   310  100   310    0     0    310      0  0:00:01  0:00:01 --:--:--   298
==> Validating source files with md5sums...
    cower-17.tar.gz ... Passed
    cower-17.tar.gz.sig ... Skipped
==> Verifying source file signatures with gpg...
    cower-17.tar.gz ... Passed
==> Extracting sources...
  -> Extracting cower-17.tar.gz with bsdtar
==> Starting build()...
cc -Wclobbered -Wempty-body -Wfloat-equal -Wignored-qualifiers -Wmissing-declarations -Wmissing-parameter-type -Wsign-compare -Wmissing-prototypes -Wold-style-declaration -Wtype-limits -Woverride-init -Wunused -Wstrict-prototypes -Wuninitialized -std=c99 -g -pthread -pedantic -Wall -Wextra -fstack-protector-strong -O2 -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -D_GNU_SOURCE -DCOWER_VERSION=\"17\" -D_FORTIFY_SOURCE=2  -c -o cower.o src/cower.c
cc -Wclobbered -Wempty-body -Wfloat-equal -Wignored-qualifiers -Wmissing-declarations -Wmissing-parameter-type -Wsign-compare -Wmissing-prototypes -Wold-style-declaration -Wtype-limits -Woverride-init -Wunused -Wstrict-prototypes -Wuninitialized -std=c99 -g -pthread -pedantic -Wall -Wextra -fstack-protector-strong -O2 -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -D_GNU_SOURCE -DCOWER_VERSION=\"17\" -D_FORTIFY_SOURCE=2  -c -o aur.o src/aur.c
cc -Wclobbered -Wempty-body -Wfloat-equal -Wignored-qualifiers -Wmissing-declarations -Wmissing-parameter-type -Wsign-compare -Wmissing-prototypes -Wold-style-declaration -Wtype-limits -Woverride-init -Wunused -Wstrict-prototypes -Wuninitialized -std=c99 -g -pthread -pedantic -Wall -Wextra -fstack-protector-strong -O2 -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -D_GNU_SOURCE -DCOWER_VERSION=\"17\" -D_FORTIFY_SOURCE=2  -c -o package.o src/package.c
pod2man --section=1 --center="Cower Manual" --name="COWER" --release="cower 17" README.pod cower.1
src/cower.c: In function ‘parse_options’:
src/cower.c:1194:23: warning: this statement may fall through [-Wimplicit-fallthrough=]
         cfg.sortorder = SORT_REVERSE;
         ~~~~~~~~~~~~~~^~~~~~~~~~~~~~
src/cower.c:1195:7: note: here
       case OP_SORT:
       ^~~~
cc -pthread  -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now  cower.o aur.o package.o  -lcurl -lalpm -lyajl -larchive -o cower
==> Entering fakeroot environment...
==> Starting package()...
install -D -m755 cower "/home/cody/z-AUR-Auto/aurt-built/cower/pkg/cower/usr/bin/cower"
install -D -m644 cower.1 "/home/cody/z-AUR-Auto/aurt-built/cower/pkg/cower/usr/share/man/man1/cower.1"
install -D -m644 extra/bash_completion "/home/cody/z-AUR-Auto/aurt-built/cower/pkg/cower/usr/share/bash-completion/completions/cower"
install -D -m644 extra/zsh_completion "/home/cody/z-AUR-Auto/aurt-built/cower/pkg/cower/usr/share/zsh/site-functions/_cower"
install -D -m644 config "/home/cody/z-AUR-Auto/aurt-built/cower/pkg/cower/usr/share/doc/cower/config"
==> 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 issue...
==> Creating package "cower"...
  -> Generating .PKGINFO file...
  -> Generating .BUILDINFO file...
  -> Generating .MTREE file...
  -> Compressing package...
==> Leaving fakeroot environment.
==> Finished making: cower 17-2 (Wed Dec  6 11:50:08 PST 2017)
==> Installing package cower with pacman -U...
[sudo] password for cody: 
warning: cower-17-2 is up to date -- skipping
loading packages...
 there is nothing to do

  aurt's done exit code 0 'zero is good!'



$ aurt -R cower
-----------------------------------------------------------------------
 aurt, a tiny AUR assistant.   UEAGE: aurt [option] [package]        
 [-I] install [-R] remove [-h] help [-l] pacman log [no combinations] 
-----------------------------------------------------------------------

    Removing cower with pacman -Rns and rm -r /home/cody/z-AUR-Auto/aurt-built/cower and cower.log

----------------------------------------------------
 PACMAN:

[sudo] password for cody: 
checking dependencies...
error: failed to prepare transaction (could not satisfy dependencies)
:: pacaur: removing cower breaks dependency 'cower'
----------------------------------------------------

----------------------------------------------------
 ls -al /home/cody/z-AUR-Auto/aurt-built

total 32
drwxr-xr-x 4 cody cody 4096 Dec  6 11:35 .
drwxr-xr-x 3 cody cody 4096 Dec  5 11:38 ..
drwxr-xr-x 5 cody cody 4096 Dec  6 11:35 cower
-rw-r--r-- 1 cody cody  459 Dec  6 11:37 cower.log
-rw-r--r-- 1 cody cody 1041 Dec  6 11:29 .log
drwxr-xr-x 5 cody cody 4096 Dec  6 01:58 pkgbrowser
-rw-r--r-- 1 cody cody 4755 Dec  6 01:58 pkgbrowser.log
----------------------------------------------------

  Deleting files mentioned above.
  Proceed? y


----------------------------------------------------
 ls -al /home/cody/z-AUR-Auto/aurt-built

total 24
drwxr-xr-x 3 cody cody 4096 Dec  6 11:37 .
drwxr-xr-x 3 cody cody 4096 Dec  5 11:38 ..
-rw-r--r-- 1 cody cody 1041 Dec  6 11:29 .log
drwxr-xr-x 5 cody cody 4096 Dec  6 01:58 pkgbrowser
-rw-r--r-- 1 cody cody 4755 Dec  6 01:58 pkgbrowser.log
----------------------------------------------------

   Remove function completed. - exit code 0 

  aurt's done exit code 0 'zero is good!'
$ aurt -h
-----------------------------------------------------------------------
 aurt, a tiny AUR assistant.   UEAGE: aurt [option] [package]        
 [-I] install [-R] remove [-h] help [-l] pacman log [no combinations] 
-----------------------------------------------------------------------


  ################## aurt: a tiny aur helper ##################


          #    Usage: aurt [option] [package name]    #

          #    Option: -I = Install AUR package       #

          #    Option: -R = Remove  AUR package       #

          #    Option: -h = This help message         #

  # -I checks 4 udates, builds if avail, installs in this order #
   # -R option = pacman -Rns + aurt removes package build dir #

              EXAMPLE:    $ aurt -I pkgbrowser


  ###############################################################

     __
    '. \
     '- \
      / /_         .---.
     / | \\,.\/--.//    )
     |  \//        )/  /
      \  ' ^ ^    /    )____.----..  6
       '.____.    .___/            \._)
          .\/.                      )
           '\                       /
           _/ \/    ).        )    (
          /#  .!    |        /\    /
          \  C// #  /'-----''/ #  /
       .   'C/ |    |    |   |    |mrf  ,
       \), .. .'OOO-'. ..'OOO'OOO-'. ..\(,

  aurt's done exit code 0 'zero is good!'

Last edited by Cody Learner (2017-12-06 21:28:08)


Self designated Linux and Bash mechanic.....
I fix and build stuff hands on. I'm not opposed to creating a mess in obtaining a goal.

Offline

#6 2017-12-06 22:21:29

Alad
Wiki Admin/IRC Op/TU
From: The Land of The Bloat
Registered: 2014-05-04
Posts: 1,858
Website

Re: aurt, yet another, but very minamilistic AUR assistant

Cody Learner wrote:
slithery wrote:

Some of your variables need quoting, run it through shellcheck.net to see what I mean.

Do people tend to all have distinctive styles of writing shell, or is it pretty standardized?

There's some technical aspects that verge on style, such as avoiding echo and using [[ instead of [ or test. Other constructs have definite drawbacks, such as parsing "ls" output and should be avoided. In doubt, check BashFAQ:

http://mywiki.wooledge.org/BashFAQ

You mean like the one below? Would you put the "Already up to date." into another variable or? I'm sure there are cleaner ways to check for updates, but this one just popped into thought while working on it. Are there any others that stand out as needing attention? Oh and in case it's not obvious and if I screwed up on my methods, I try avoid git for the most part. It hurts my brain for some reason.

Checking for git updates is unfortunately not a trivial matter since "git fetch" always returns 0 for some reason. You can however use git rev-parse, which doesn't depend on locale output (if you stick to checking the string "Already up to date", you should prefix the command with LC_MESSAGES=C). See the example below.

Running git pull to check for updates, then delete the directory to start clean with clone.

If you want to start fresh, you can just run "git reset --hard HEAD" with "git merge" since that doesn't involve the overhead of cloning a repository all over. For example:

https://github.com/AladW/aurutils/blob/ … ch#L10-L34

I've used pacaur for some time. I have looked at the script and was honestly completely lost.

I think anyone who looks at that script will inevitably be completely lost, regardless of experience level.

For the help and show log options, the positional variables are unset. This leads to a .log file being produced on the base directory. The log is of whatever is on my screen. I could I do a if else to disable logging for those options, but hopefully learn of something simpler.

I suggest looking into getopts.

http://wiki.bash-hackers.org/howto/getopts_tutorial

Last edited by Alad (2017-12-06 22:28:36)


Mods are just community members who have the occasionally necessary option to move threads around and edit posts. -- Trilby
Honest Alad's Package Emporium—Now with added bugs! (Closed until further notice)

Offline

#7 2017-12-06 23:40:51

eschwartz
Trusted User/Bug Wrangler
Registered: 2014-08-08
Posts: 2,372

Re: aurt, yet another, but very minamilistic AUR assistant

In addition to what was mentioned above, I'm slightly triggered by your use of POSIX [ in a bash script...

Either use bash [[ or declare your script to run with #!/bin/sh and scrupulously avoid bashisms.

...

You're also *extremely inconsistent about quoting, as in you'll take the same command and quote it once, then fail to quote it the next time. FWIW you can just standardize on *not* quoting inside a bash [[ keyword, since that is one of the significant reasons why the [[ keyword exists in preference to the [ builtin.


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#8 2017-12-08 02:02:49

Cody Learner
Banned
Registered: 2017-12-06
Posts: 54
Website

Re: aurt, yet another, but very minamilistic AUR assistant

OK, I revised things, implementing more KISS this time. The new version comes in at ~ 40 lines.

Again, I've done minimal testing so you all (not you guys) know the drill. Appreciate all the feedback and hope to learn enough to create a really decent quality script in the end. Need to spend some time with getopts. I removed the -l "cat pacman.log" and the -h help add on for the time being. I need to reevaluate logging implementation as well. Likely overkill other than for testing.

@Alad, Thanks for the rev-parse and other git related info. I ended up using it BIG time to get away from "Already up to date" in test. Didn't think about how fragile that was, different language would break it. Makes sense now! Got rid of all the non essential echo messages, etc.  You mentioned parsing ls. Is using test on the filesystem doing that? Echo, are you talking in just using it for messages and the clutter it can cause, or more as in redirecting it to append files. Can't think of any other possible uses or abuses off top of my head? I do reference Greg's bash page often when I get stuck. I'd actually recommend to include gregs with bash and whatever term need to know for anyone learning shell. Nice source of info. Still want to learn about getopts. I need to read and play around with it.I just spent some time with positional variables testing in mini scripts to get my head around the concept.


@Eschwartz, Lol I honestly just overlooked that. At my level of shell scripting, the thought of POSIX, bash, zsh and or any other compatibility differences are well beyond me. Just trying to get solid footing on the basics. With that said though, it would be cool to make it compatible with at least the popular ones here. You think bash and zshell would cover it? How much different for what I'm doing with this script? I've never looked into the requirements, only see it mentioned occasionally. Quoting, well I do need to get that down,. For some reason I started {using} for variables, prior to that, it was "quotes". Somehow in the transition, I think I got worse with consistent quoting. Shellcheck had me quoting where I would have not thought to, but I'm sure it's better safe than sorry. Thanks for the heads up on [[ keyword stuff. Good to know. I also hope to eventually pick up all the correct terminology so I can communicate in a meaningful way.

Keep it coming guys. Please continue to point out anything I may want to change, new concepts, sources of info, terminology etc.

Ran aurt on a google-chrome update today. Seemed like a quick update. Is it possible AUR pac-helpers could slow down the compile times. I'd think they all make use of makepkg directly. Probably just me, a my widget has to be faster than your widget thing.

EDIT: Shellcheck online, trying to get me to double quote and or escape in this line. Tried implementing their recommended, still flagged. It works OK in bash on my system. https://github.com/koalaman/shellcheck/wiki/SC1083

[[ $(git -C ${builddir} rev-parse HEAD) = $(git -C ${builddir} rev-parse @{upstream}) ]]
#!/bin/bash
# [attributes: @Arch Linux: Trilby, "Pacman Development Team", Alad]  [DEPS: sudo base-devel git]

echo "aurt AUR helper -- USAGE: $ aurt [-I]=install [-R]=remove [package]"

basedir=${HOME}/z-AUR-Auto/aurt-built
builddir=${HOME}/z-AUR-Auto/aurt-built/${2}

install() {
      if [[ -d ${builddir}/.git ]] &&
	[[ $(git -C ${builddir} rev-parse HEAD) = $(git -C ${builddir} rev-parse @{upstream}) ]]
	then
	echo; echo "    Git reports ${2} is up to date. NOTHING TO DO, EXITING." ;echo ;exit
     fi
      if [[ -d ${builddir}/.git ]] ; then
	cd "${builddir}" || exit
	"git reset --hard HEAD"
	"git merge"
      else
	cd "${basedir}" || exit
	git clone https://aur.archlinux.org/"${2}".git
     fi
	cd "${builddir}" || exit
	makepkg -si --needed
}

remove() {
	ls -al "${basedir}";
	echo ; echo "Runing sudo pacman -Rns ${2}, sudo rm -r ${builddir}" ;
	echo "Do you want to delete ${builddir} now? [Y/n]." ; echo
	"sudo pacman -Rns" "${2}"
	"sudo rm -r" "${builddir}"
}

# Run Functions
	if [[ ${1} == "-I" ]]; then
    	install "${@}"
	elif [[ ${1} == "-R" ]]; then
	remove "${@}"
	fi

Last edited by Cody Learner (2017-12-08 02:07:23)


Self designated Linux and Bash mechanic.....
I fix and build stuff hands on. I'm not opposed to creating a mess in obtaining a goal.

Offline

#9 2017-12-08 02:39:43

eschwartz
Trusted User/Bug Wrangler
Registered: 2014-08-08
Posts: 2,372

Re: aurt, yet another, but very minamilistic AUR assistant

You do not have to worry about how many shells you are compatible with, a script will only ever be run with a specific shell -- the one in your shebang, which is #!/bin/bash.

You only ever care about the shebang you specified.

While #!/bin/sh can be any of several different shells that are POSIX-compatible, including bash (using bash's POSIX sh mode), sticking to POSIX is all you need. If you are targeting some other shell, then target that shell.

Most commonly people will simply target #!/bin/bash as it is both powerful and broadly available, and they don't want to have to think about whether a specific feature is defined by POSIX.

Cody Learner wrote:

For some reason I started {using} for variables, prior to that, it was "quotes". Somehow in the transition, I think I got worse with consistent quoting.

Using {} braces is usually a stylistic choice, unless you are using the less common instances of 1) "${foo}bar" in which case the braces delimit the variable name, or 2) some variation of "${foo:-fallback value}" and other variable modifiers listed in the bash manpage under "Parameter Expansion".
On the other hand, quoting is in no way a style choice, as it is exceedingly common for variables to contain whitespace or be vulnerable to unpredictable user-supplied content. Always quote any variable that can contain unknown content, and to be extra safe you might want to get in the habit of quoting every other variable too.

...

"git reset --hard HEAD"

I have no idea what you thought this was. By quoting it, you told the shell to tokenize this as a string literal. There is no "git reset --hard HEAD" binary in your $PATH, therefore this will not work. Why on earth are you quoting non-variables now? Did you try running this?

Also please fix your indentation, the if, then, and fi keywords should always line up and the commands inside should be indented. I would reimplement your option parsing as something like:

if (( $# != 2 )); then
    echo "You need to specify exactly two arguments, aborting..."
    exit 1
fi
case $1 in
    -I)
        command=install
        ;;
    -R)
        command=remove
        ;;
esac
shift

$command "$2"

In the more general case, this general framework for option parsing (usually wrapped in `while (( $# )); do ...; done` to consume all arguments) will be far superior for tracking what you are actually doing. Also case will often be a lot nicer than if else loops, and shell arithmetic via (( $# )) to test if the number of arguments is a nonzero number is nicer than [[ $# -gt 0 ]] for testing how many options you have... so why not use it since this is bash anyway.


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#10 2017-12-08 03:00:58

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 20,119
Website

Re: aurt, yet another, but very minamilistic AUR assistant

This is a bit tangential, but I'll note that I have repented of my former ways of recommending '[[' over '[' when using bash.  It is true that bash's built in [[ is notably faster than calling /usr/bin/[, but no one ever explicitly calls /usr/bin/[.  The result of the following may come as a surprise to some (run this in bash):

type [

Whether you use [ or [[ in a script with a bash shebang is irrelevant for efficiency: bash will do the same thing with either one.  However, if you use [ then you make life easier for anyone who hopes to port your scripts to some other shell.

By all means break from POSIX conformance when it provides a benefit in the shell you use, but please do not break from POSIX for no benefit at all: use [ and bash, zsh, and mksh will use their own efficient built in test, while ash, dash, and the like will still be able to run the same code.


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

Offline

#11 2017-12-08 03:16:03

eschwartz
Trusted User/Bug Wrangler
Registered: 2014-08-08
Posts: 2,372

Re: aurt, yet another, but very minamilistic AUR assistant

I don't see anything to repent over. tongue

I'm aware that [ is a builtin, and never thought that its negatives included slowness. (I suppose it is possible that there is some incredibly insignificant implementation detail between a given builtin and a given keyword that would cause [[ to be faster, but that is a bit of a stretch....) The [[ keyword is still superior, as it elegantly handles quoted, unquoted, and empty variables, supports && as well as || thereby removing the temptation to use -a, allows pattern matching and globbing when doing string comparison, treats syntax errors as, well, syntax errors and aborts the script rather than commands failing halfway through the script with an unchecked error code, etc. Apparently the > test only supports locale collation when using bash [[ which is a feature I will probably not take advantage of, not really being a > user, but still...

It also looks nicer, and if you have any intention of porting the script you should stop playing silly games and write it in POSIX sh from the beginning.

http://mywiki.wooledge.org/BashFAQ/031

I remain adamant that you should always use [[ in bash. Half of those reasons are nice things you will almost certainly want to use, and the other half are just sane behavior in basic use.

Last edited by eschwartz (2017-12-08 03:19:35)


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#12 2017-12-08 11:44:30

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 20,119
Website

Re: aurt, yet another, but very minamilistic AUR assistant

Thanks for the explanation - that makes sense, though I still disagree about preferentially using [[ when one does not need any of those extra features of [[ - like in the context of the script this thread is about.

As for writing in POSIX sh in the first place, I fully support that!  You can still use your favorite shell to actually run the script, in which case modern feature-full shells will run the script more efficiently than older or minimal shells, but it will still run and not just completely crap out on those other shells.

My view is to write POSIX first.  Add shell-specific features only when they actually add a benefit to the script at hand (and don't hesitate to in those cases) but not just as a matter of habit.


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

Offline

#13 2017-12-08 13:16:02

eschwartz
Trusted User/Bug Wrangler
Registered: 2014-08-08
Posts: 2,372

Re: aurt, yet another, but very minamilistic AUR assistant

I'd go one step further and say that older or minimal shells will run the script more efficiently than modern featureful shells, as long as they don't completely error on incompatible syntax. tongue

It is trivial to replace /bin/sh on an Arch system with a symlink to *dash*, and possibly use a pacman hook to reset the symlink after any pacman update touches /bin/sh -- see the Dash page on our wiki. POSIX-compatible scripts will actually run quite a bit faster afterwards with a lot less overhead, although that may not be saying much considering the average speed of initializing a bash shell, and the RAM on the average system.

It's also quite useful for catching accidental bashisms in your POSIX scripts, since Arch defaults to using *bash* as the /bin/sh implementation and bash will actually offer an enhanced superset of true sh even when running in POSIX compatibility mode.

...

I can definitely get behind writing POSIX from the start. I've seen a lot of code from Earnestly recently, who claims that his new habit of trying to implement everything in pure sh has caused him to have to think about what he's doing all the time, and learn all sorts of neat tricks as well as write much cleaner code in the process. His latest project, sx, completely replaces both startx and xinit, with less than 70 lines of sh: https://github.com/Earnestly/sx
Unfortunately, POSIX still doesn't have the ability to `read -r -d ''` or use arrays other than "$@" which is disappointing... dash does implement the local keyword though, even though it isn't (yet?) POSIX.

Last edited by eschwartz (2017-12-08 13:21:28)


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#14 2017-12-08 21:15:24

Alad
Wiki Admin/IRC Op/TU
From: The Land of The Bloat
Registered: 2014-05-04
Posts: 1,858
Website

Re: aurt, yet another, but very minamilistic AUR assistant

You mentioned parsing ls. Is using test on the filesystem doing that?

Well, you didn't parse ls here (which is good), but I wanted to mention it anyway since it's one of the most common mistakes in shell scripting.

http://mywiki.wooledge.org/ParsingLs

Echo, are you talking in just using it for messages and the clutter it can cause, or more as in redirecting it to append files. Can't think of any other possible uses or abuses off top of my head?

https://unix.stackexchange.com/question … -than-echo

However I wouldn't use either echo or printf to append to files, especially if that implies adding a ">>" on every line (imagine if you want to change the output file, you'd have to change it on every line with "<<" increasing the risk of mistakes). Use cat EOF instead.

cat <<EOF
something
somethingelse
EOF >somefile

Last edited by Alad (2017-12-08 21:16:10)


Mods are just community members who have the occasionally necessary option to move threads around and edit posts. -- Trilby
Honest Alad's Package Emporium—Now with added bugs! (Closed until further notice)

Offline

#15 2017-12-08 21:31:34

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 20,119
Website

Re: aurt, yet another, but very minamilistic AUR assistant

Purely stylistic, but I've always found the following approach to be easier to read, but I post it mainly to highlight the option:

cat <<EOF > somefile
something
something else
EOF

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

Offline

#16 2017-12-09 05:15:51

Cody Learner
Banned
Registered: 2017-12-06
Posts: 54
Website

Re: aurt, yet another, but very minamilistic AUR assistant

@ echo or cat >, I found it handy for embedded ARM stuff, where I was only adding a line or two using a serial connection to try fix things.

@ heredocs,  I've done some strange (to me) things with heredocs, root user, to user and back, chroot, placing scripts within scripts. Seems like a very useful feature.

@ Style, I'm trying to make things work without quite knowing enough. Style to me is when things run as intended rather than crashing. I am making an effort to get a better understanding of whats stylish and whats not. If only it wasn't subjective.

EDIT: Strike through useless rambling below.


OK, passing the buck on those misplaced quotes, it's all my editor, shellcheck, poor eyesight and my new pup's fault, lol. Trilby, how to teach the dog to fix my scripts?


Seriously, I want to slow down a bit. Getting in a big rush, minimal testing and review, (leading to errors.)


running it online shellcheck with a strange editor, posting it without further review or testing, is obviously not going well. I'll hold off posting aurt until it's ready for review by some very smart programmers, without further embarrassing myself! I'll post the search script though.


I've deleted pacaur to see how things go without it. Feeling pretty confident that aurt slim version is ready for real testing. Did a little more work on it, added back cat pacman.log, made up little search script that lets aurt use cower for basic AUR searching. Put a little temp "rm .log" band-aide on the .log thing till I do a little more research. 

After spending some time with cower, thinking I can get all the functionality of using (pacman with pkgbrowser + pacaur), with (pacman and aurt + cower).


It goes without saying though, it takes very little, to glue together pacman, makepkg, and git for a very nice AUR handler. Likely depends on ones personal preferences more than anything. Has the switch to git for AUR made things a bunch simpler than prior to it? If so, it's ironic that git has made it easier. I've always thought of git off as something to look into after you've mastered Linux, shell, Python, C, and half a dozen others as a test, to indicate if you're smart enough to get it. One more thing. To test outdated AUR package updating, I tried editing pkgname/.git/refs/heads/master directly, and somewhat predictably, it just errors git. Is it possible roll back git repo or package so it resembles an outdated condition for testing?EDIT: Never mind git question. Found a solution.


Follow up on post #8 above shellcheck issue, I ended up escaping the curly brackets (code below) so shellcheck stops complaining. It still works for me. I then went to Alad's github to look at similar code, to see how he did it, and it's slightly different from what I did. I plan to follow up with some reading so I know for sure whats going on.

From this line:

 [[ $(git -C ${builddir} rev-parse HEAD) = $(git -C ${builddir} rev-parse @{upstream}) ]] 

Edited this part:

 @\{upstream\} 

Edit for clarity:  Cower is amazingly fast at AUR searches. It seems I may have unintentionally slowed it down via the script implementing cower use in aurt. More testing is needed to verify. If testing proves it has slowed down, my first thought would be to focus on the line count and wc.
See anything obviously wrong with this?

#!/bin/sh
# This script is a wrapper for cower: [url]https://github.com/falconindy[/url]
# Attribute: Dave Reisner aka falconindy @ Arch Linux
# Please use cower directly for full feature set searches and more.

echo "Searching ............"
    echo
    cower -qs --by=name "$1"
    number=$(cower -qs --by=name "$1" | wc -l)
    echo
    echo " Found: "${number}" packages above with '"$1"' in name."
    echo
    echo " If there is an exact match, details shown below."
    echo
    cower -i "$1"
    echo

I've searched from aurt with aurt -F <package>:  a few times so far. I know the echo's = ugly. Looking for alternative to retain line spacing for readability without using them.

elif [[ $1 == -F ]]; then
    aurt-find "${2}"
$ aurt -F cower
-------------------------------------------------------------------------------------------------
 aurt, the tiny AUR helper.   UEAGE: aurt [option] [package]     
 [-I] install [-R] remove [-F] find [-h] help [-l] pacman log 
-------------------------------------------------------------------------------------------------
Searching ............
cower
cower-git

 Found: 2 packages above with 'cower' in name.

 If there is an exact match, details shown below.

Repository     : aur
Name           : cower [installed]
Version        : 17-2
URL            : [url]http://github.com/falconindy/cower[/url]
AUR Page       : [url]https://aur.archlinux.org/packages/cower[/url]
Keywords       : aur  
Depends On     : curl  pacman  yajl  
Makedepends    : perl  
License        : MIT  
Votes          : 957
Popularity     : 26.76
Out of Date    : No
Maintainer     : falconindy
Submitted      : Wed 29 Dec 2010 06:30:37 PM PST
Last Modified  : Mon 24 Apr 2017 07:27:21 AM PDT
Description    : A simple AUR agent with a pretentious name

Last edited by Cody Learner (2017-12-09 20:59:50)


Self designated Linux and Bash mechanic.....
I fix and build stuff hands on. I'm not opposed to creating a mess in obtaining a goal.

Offline

#17 2017-12-09 13:52:47

2ManyDogs
Member
Registered: 2012-01-15
Posts: 2,094

Re: aurt, yet another, but very minamilistic AUR assistant

aurt, the tiny AUR helper.   UEAGE: aurt [option] [package]  

Is this supposed to be "USAGE:" ?

Code Learner wrote:

Amazing how fast cower searches on it's own. I may have slow it down

Why would you slow it down if it works?

(or, after reading more of your long post, do you mean "slow it down" as in slow down your work on the script so you understand more)?

Last edited by 2ManyDogs (2017-12-09 13:55:10)


"The prettier the user interface, and the fewer odd replies the system allows you to make, the dumber you once appeared in the mind of the designer." -- Ellen Ullman

Offline

#18 2017-12-09 20:11:11

Cody Learner
Banned
Registered: 2017-12-06
Posts: 54
Website

Re: aurt, yet another, but very minamilistic AUR assistant

2ManyDogs wrote:

Is this supposed to be "USAGE:" ?

Code Learner wrote:

Amazing how fast cower searches on it's own. I may have slow it down

Why would you slow it down if it works?

Yea UEAGE s/b USAGE:   Yes it is very unclear, I'll edit it, and sorry at the long rambling post, I'll try to stay more focused.

2ManyDogs wrote:

do you mean "slow it down" as in slow down your work on the script so you understand more)?

Yes exactly.

Some Thoughts:  I'm obviously quite inexperienced with scripting. Part of my motivation posting the scripts here was so they would be community reviewed and critiqued, leading to improvements, all transparently. Community reviewed and input for community use.

Ultimately, I'd like to be able offer a useful solution for handling AUR stuff. Implemented in a manner that is minimalist enough so the user could easily review and edit the script for personal preferences.

This may be due to my lack coding knowledge and experience, but I find myself wondering how some of the AUR solutions ended up so complicated (from my perspective). I prefer handling AUR stuff hands on, one at a time, but have only ~ dozen or so packages installed. If one had a lot of AUR packages installed, and preferred a similar level of automation for the AUR, as pacman provides for official repos, I could imagine the complexity involved, requiring a complex solution.

My goal with the script/s is on the opposite end of the spectrum. Just bring together some existing tools, in a minimal solution, for the sake of convenience.

Last edited by Cody Learner (2017-12-09 21:19:45)


Self designated Linux and Bash mechanic.....
I fix and build stuff hands on. I'm not opposed to creating a mess in obtaining a goal.

Offline

#19 2017-12-09 23:27:06

Alad
Wiki Admin/IRC Op/TU
From: The Land of The Bloat
Registered: 2014-05-04
Posts: 1,858
Website

Re: aurt, yet another, but very minamilistic AUR assistant

This may be due to my lack coding knowledge and experience, but I find myself wondering how some of the AUR solutions ended up so complicated (from my perspective). I prefer handling AUR stuff hands on, one at a time, but have only ~ dozen or so packages installed. If one had a lot of AUR packages installed, and preferred a similar level of automation for the AUR, as pacman provides for official repos, I could imagine the complexity involved, requiring a complex solution.

I see two reasons for the complexity. One is that complex problems require complex solutions, as you put it. People with 500+ AUR packages aren't rare and effectively handling random PKGBUILDs of random quality is anything but trivial.

Second is that the AUR and makepkg itself are lacking on some aspects regarding automation, see this list: https://github.com/AladW/aurutils/issues/20

(there's also the reason that most people look for a quick fix rather than think through a proper solution... but I digress)

Ultimately, I'd like to be able offer a useful solution for handling AUR stuff. Implemented in a manner that is minimalist enough so the user could easily review and edit the script for personal preferences. (...) My goal with the script/s is on the opposite end of the spectrum. Just bring together some existing tools, in a minimal solution, for the sake of convenience.

That's pretty much why I split up aurutils in 10 different scripts - create a clear frame for every task and use whatever you need or want, including suitable modifications.

Last edited by Alad (2017-12-09 23:29:08)


Mods are just community members who have the occasionally necessary option to move threads around and edit posts. -- Trilby
Honest Alad's Package Emporium—Now with added bugs! (Closed until further notice)

Offline

#20 2017-12-11 03:27:51

Cody Learner
Banned
Registered: 2017-12-06
Posts: 54
Website

Re: aurt, yet another, but very minamilistic AUR assistant

Alad, I have very briefly looked at your scripts. I really like the concept of splitting them up for ease of implementation.  I do plan to look closer and give some of them a spin in the future.

Thanks all and ........  [CHECK] one off my bucket list.

Attempt to contribute something useful to the community that hopefully goes well.


Self designated Linux and Bash mechanic.....
I fix and build stuff hands on. I'm not opposed to creating a mess in obtaining a goal.

Offline

#21 2017-12-15 21:49:50

Cody Learner
Banned
Registered: 2017-12-06
Posts: 54
Website

Re: aurt, yet another, but very minamilistic AUR assistant

Trilby wrote:

It is true that bash's built in [[ is notably faster than calling /usr/bin/[, but no one ever explicitly calls /usr/bin/[. 

The result of the following may come as a surprise to some (run this in bash):

type [

Going back over some of the comments today. That stood out because I always wondered what " [ " was doing in bin. Now it's obviously and literally the name of a program called test. Something like " [ = test " in the manpage would have made it more obvious to me. Why the examples weren't, well .... no comment.

With this new discovery, I'm thinking someday It may become as obvious as to what  " . " and " .. " are doing everywhere. Also why looking into what they contained the first time seemed like such a big disappointment. No hidden secrets to be discovered!

Question: Would I be correct to refer to this " [[ "  as test or keyword, and if not, then what?

Last edited by Cody Learner (2017-12-15 22:02:16)


Self designated Linux and Bash mechanic.....
I fix and build stuff hands on. I'm not opposed to creating a mess in obtaining a goal.

Offline

#22 2017-12-16 00:04:29

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 20,119
Website

Re: aurt, yet another, but very minamilistic AUR assistant

`[[` is a shell builtin that, initially, was intended to eliminate the need to call out to the external binary /usr/bin/test (loading external programs is frequently a bottleneck for shell scripts).  My point, however, was quite different: there is a substantial population of *nix users who encourage the use of `[[` in place of `[` because `[` is an external binary just like test (in some systems I believe `/usr/bin/[` may even be a symlink to /usr/bin/test).  The problem is that despite /usr/bin/[ being it's own binary that does not mean your shell calls that binary when you use `[` in a conditional test.  In every shell I'm aware of `[` is a shell builtin just like `[[`, so `/usr/bin/[` may never be used at all!

Therefore arguments that favor `[[` over `[` because the former is a shell built in are just crap: they are both shell built-ins in many modern shells, and only the later is a builtin in almost every shell out there; the former would be completely unrecognized to some shells.  So neither one requires calling an external binary, but only `[` is recognizably by every shell: this is why I now favor it.  `[[` has several extra features that have been enumerated above, and if these are being relied upon, then use `[[` - but don't listen to anyone who tells you that `[[` is better just because it is a shell builtin.


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

Offline

#23 2017-12-16 04:27:08

Cody Learner
Banned
Registered: 2017-12-06
Posts: 54
Website

Re: aurt, yet another, but very minamilistic AUR assistant

Thanks Trilby, but just when I think I have it figured out, learning more leads to yet more questions!

I think I get what you're saying and and I'd also add (please point out any errors):

1) [[ is an updated, more flexible version of [. However, [ is more or POSIX complaint, therefore more universal running across different shell programs.

2) Basically, your point is I believe, don't let anyone discourage me from using [ over [[, using the argument that [[ is a shell (bash anyway) builtin,  therefore it would run more efficiently than calling an external binary version of [ or test, possibly resulting in running infinitesimally faster. In fact [ is also a shell builtin even though it is present as a separate binary in /bin, or more accurately, /usr/bin.

I was not aware until reading your reply that [ is also a bash builtin.

My confusion and questions are somewhat unrelated and far more basic. What is the differences between [ and test, as they exist in /bin? I just assumed one would be a link to the other. However, that is not the case as I just checked. So that means there are three versions of basically the same program available on my system? Not counting [[, which is definitely different from the 3 previous mentioned programs.

3) If I was discussing bash shell scripts with someone experienced with shell, if I referred to [ as test, would that be incorrect leading to confusion? What would you call it?

4) same questions for [[.

5) I have not thought about using it, but it seems a safe bet that referring to the program called test as test would be correct.

6) [[ is a bash keyword, which there are many if I'm not mistaken, so calling [[ keyword would be inaccurate. It is A keyword?


$ ls -l [ test
-rwxr-xr-x 1 root root 51K Sep  3 09:21 '['
-rwxr-xr-x 1 root root 47K Sep  3 09:21  test

$ file test
test: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=66ccd3e05111dc679d4cc4b388a741763a9842db, stripped

$ file [
[: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=7d32dcaf08fd2f793f4e919bebb20994bcfea1b9, stripped

Why so many versions and how to know which one shell would use and when (logic says the builtin every time). Although it likely wouldn't make a difference that I would ever notice with my newb level scripting skills. Likely far easier to identify and more plentiful "low hanging fruit" to go after than this test stuff?

Most pressing questions for me are the terminology related ones. And a quick search resulted in gregs at the top: http://mywiki.wooledge.org/BashFAQ/031
Now I need to read this.


Self designated Linux and Bash mechanic.....
I fix and build stuff hands on. I'm not opposed to creating a mess in obtaining a goal.

Offline

#24 2017-12-16 05:03:11

Scimmia
Bug Wrangler
Registered: 2012-09-01
Posts: 7,027

Re: aurt, yet another, but very minamilistic AUR assistant

[[ is much more flexible and powerful than [. The portability concerns are moot since you're calling bash. There is no reason to prefer [.

Offline

#25 2017-12-16 11:43:22

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 20,119
Website

Re: aurt, yet another, but very minamilistic AUR assistant

Cody Learner wrote:

1) ... [ is more or POSIX complaint, therefore more universal running across different shell programs.

I have no reason to believe that [ is more POSIX compliant in it's behavior.  POSIX defines what the conditional test must do, implementations are free to go beyond that minimum and still be compliant.  However `[` is part of the POSIX standard, `[[` is not.  This means any POSIX compliant system will have `[`, they may or may not have `[[`.

Cody Learner wrote:

2) ... What is the differences between [ and test, as they exist in /bin? I just assumed one would be a link to the other. ... there are three versions of basically the same program available on my system?

Likely they were just written by different people - which is odd as they are both part of GNU coreutils on arch.
Like I said, on some systems /usr/bin/[ is just a symlink to /usr/bin/test.  As for having three versions of basically the same thing on your system, I have at least 5 versions of it: /usr/bin/test, /usr/bin/[, and the builtin version from bash, mksh, and ash.  Different people write their own solutions to the same problem.

Cody Learner wrote:

3) If I was discussing bash shell scripts with someone experienced with shell, if I referred to [ as test, would that be incorrect leading to confusion? What would you call it?

Correct.  For confirmation see `man test`

4) This however is slightly different.  I've never had to need to refer to this with a name other than what it is.  It is a conditional test, but it is distint from test/[ as it does many additional things.  Anything that works for test/[ should work with [[, the converse is definitely not the case.  Also what [[ will do can depend very much on which [[ you use: I have three [[ on my system: one in bash, one in mksh, and one in ash.  They are each slightly different.

5) correct

6) [[ is  a shell builtin, I'd certainly never question it being called a keyword.


As for Scimmia's comment, I disagree, it is not a moot point.  He is correct that as long as you use #!/bin/bash as your shebang line your script will not be portable to other shells.  But portability is far from a binary yes/no.  If you have a habit of writing in POSIX compatible shell code and only use bashisms when they actually provide a benefit, then your script will not run as-is on another shell, but porting it to another shell could be trivial.  In the case of this script, it may be that if you used `[` instead of `[[` there'd be no detriment to your script, and porting it to another shell would require nothing beyond removing the "ba" from the shebang line.  I'd call that a very portable script.

If you write generally compatible code, but use bashisms when they really help, the porting would be a little more invovled, but not difficult: one would remove the "ba" from the shebang line and replace any bashisms with some equivalent functionality.  Not very portable, but no hurdles to portability were thrown in for no reason.

If you use `[[` when `[` will do just fine, then you are serving no purpose other than to add hurdles to portability for no benefit at all.  That's just ridiculous.

Portability is never a moot point when you share code with others.  And while I don't expect anyone to go out of their way to make their code more portable, I do find it absurd that someone would encourage you to intentionally make your code less portable for no reason.

[[ is more flexible and powerful.  If you need flexibility or power, use it.  If you don't don't.  A chainsaw is much more powerful than a butter knife.  I still use the latter to put jam on my toast.

Last edited by Trilby (2017-12-16 11:46:19)


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

Offline

Board footer

Powered by FluxBB