You are not logged in.

#26 2017-12-17 06:12:45

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

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

Trilby wrote:

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

I'd question it being called a builtin. tongue

Builtins are the term used to describe programs implemented in the the shell itself for performance boosts.
Keywords are the term used to describe some form of syntax that the shell understands as part of its flow control, and have very practical differences. You can `enable -n [` or `command [` and fallback on the external binary, you cannot disable a keyword. Keywords are, as I mentioned above, considered a fatal syntax error at parse time if you use it improperly or with bad input, builtins are still commands that simply return an error code and continue with the next command.

$ bash -c '[[   ]] 
       echo "this should never be reached"'
bash: -c: line 0: syntax error near `]]'
bash: -c: line 0: `[[   ]]'

$ bash -c '[   ] 
        echo "this should never be reached"'
this should never be reached

if, do, while, until are also keywords. Keywords do things you cannot do with programs whether builtin or external. Namely, keywords are privileged and run before anything else, including word expansion.


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

Offline

#27 2017-12-17 11:54:36

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

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

I stand corrected.  I suppose I could have asked bash directly, but I just don't use it anymore!

$ type [[
[[ is a shell keyword

$ enable -n [[
bash: enable: [[: not a shell builtin

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

Offline

#28 2017-12-17 15:34:07

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

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

Anyone try this yet?

I had a glitch with aurt -C (cower -uv") indicating an update available for google-chrome in my test version. When I tried updating with aurt -S, it reported already up to date. I'd be interested to hear any feedback on similar results.

Updating went OK in prior versions for various "actual package updates" and when rolling back git repos manually for "testing updates". Testing revealed the numbers aurt is comparing in .git/refs/heads/master, locally and remotely, were the same. However after I did a git pull?, if I remember right, the numbers were in fact different from the previous pair. Seems either my method or code failed to obtain the correct "latest version" remote master number. The code I'm using is below.

Going back a bit, I changed this line, adding the escape \\ characters to appease shellcheck, even though it worked OK during testing without them. Now I suspect that may be the issue. "@" = HEAD from what I understand. If the escape characters hid the {} during execution, seems git would have thrown an error without completing. Anyway, I single quoted the command, which also appeases shellcheck, and now time and testing will tell....


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

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

And added the following near top of install function for test monitoring updates.

printf "%s\n"	"   $(cower -i ${2} --format %v)   AUR version of		${2}  via     \$(cower -i \${2} --format %v) "
printf "%s\n"	"   $(pacman -Q ${2} | cut -d " " -f2)   Installed version of	${2}  via     \$(pacman -Q \${2} | cut -d \" \" -f2) "
printf "%s\n"	"   Alternative version checks above for testing. "
printf "%s\n"	"   $(git -C ${builddir} rev-parse HEAD)			via 	\$(git -C \${builddir} rev-parse HEAD) "
printf "%s\n"	"   $(git -C ${builddir} rev-parse '@{upstream}')			via 	\$(git -C \${builddir} rev-parse '@{upstream}') "


EDIT:

Would this test result validate it wouldn't make a difference either way in the script?

$ printf "%s\n" [[ $(git rev-parse HEAD) = $(git rev-parse '@{upstream}') ]]
[[
228915e2345e00163699994ae3686889e141f1a8
=
228915e2345e00163699994ae3686889e141f1a8
]]

$ printf "%s\n" [[ $(git rev-parse HEAD) = $(git rev-parse @\{upstream\}) ]]
[[
228915e2345e00163699994ae3686889e141f1a8
=
228915e2345e00163699994ae3686889e141f1a8
]]

Last edited by Cody Learner (2017-12-18 15:15:41)


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

#29 2017-12-18 18:24:41

Alad
Wiki Admin/IRC Op
From: Bagelstan
Registered: 2014-05-04
Posts: 2,407
Website

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

I'm not sure about your issue, but you might try to cd to the build directory rather than use git -C or other tricks.


Mods are just community members who have the occasionally necessary option to move threads around and edit posts. -- Trilby

Offline

#30 2017-12-20 21:09:36

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

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

Thanks Alad,

I did implement your suggestions. The update issue is/was method related. After a journey further down the git rabbit hole than I had initially anticipated, discovered some missing git magic to make things work. Added git init and fetch, and currently testing. There may very well be more git requirements to make this work.

I've also wrote a different install/update function around cower and pacman package version numbers for updating. It started as a workaround to using git, but it does simplify things and the script doesn't need the git capabilities either way other than for downloading. I'm currently moving forward testing both versions. Holding off on posting script/s as I don't think anyone is interested at this point. When I get something tested 100% for my use, I'll post it.


[[ $(pacman -Q ${2} | cut -d " " -f2) != $(cower -i ${2} --format %v) ]] ; echo $?

$ aurt-ud-test -S cower
[[ 17-2 != 17-2 ]]
1

[[ $(pacman -Q ${2} | cut -d " " -f2) = $(cower -i ${2} --format %v) ]] ; echo $?

$ aurt-ud-test -S cower
[[ 17-2 = 17-2 ]]
0

EDIT:
With all that said, I believe I'm reinventing the wheel so to speak. There are already proven high quality AUR solutions in place. I'm also contemplating a different direction moving forward, possibly relying more so on existing proven code. I just need to invest some time to get my head around them. Not as enjoyable as scripting, but likely a more practical way forward.

Last edited by Cody Learner (2017-12-20 21:40:25)


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

#31 2017-12-20 21:43:19

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

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

Cody Learner wrote:

I believe I'm reinventing the wheel so to speak.

This is why I suspect your script in it's current or near future forms will not have users other than yourself.  But reinventing is a very good way to learn about wheels.  After you've reinvented it several times learning as you go, you might end up with a wheel that is a bit better - or at least better for some use cases - than existing wheels.


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

Offline

#32 2017-12-29 19:28:51

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

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

Working to get useful (ie: accurate) update info. This turned into much more of a task than I had anticipated. At this point, I think of the current state as a "bull in a china shop, proof of concept" for checking individual packages. I'd eventually like to get the standalone function to run through a list of all installed AUR packages, and log the results. Also rather than downloading, using, then disposing the data, figure out if anything is reusable, and use the package build directories to save reusable data rather than disposable temp files. I believe this may come down to at a minimum of learning more about git, and likely all the version control systems used on AUR packages.

I posted earlier, "why the complexity in AUR helpers"? Now picture a light bulb shinning brightly above my head... Installing them is the easy part, implementing what may seem like a simple feature turns into more of a task then the entire original concept.

I've been testing on random AUR packages. Waiting to see how update reporting and updating packages goes. Below is time to check for updates during testing.

Bottom line, still enjoying working on it. The requirements have greatly outpaced my skills at this point, so learning as I go....

Would not even be at this point without the help and inspiration of the community. Thanks to everyone !

  -------------------------------------------------------------------------------------------------------
  :	DATE		PACKAGE			  INSTALLED			  AVAILABLE		:
  -------------------------------------------------------------------------------------------------------


  : 2017-12-28		: astyle-svn		: r622-1			: r622-1

real	0m15.366s
user	0m3.815s
sys	0m1.820s

  : 2017-12-28		: aurvote-git		: r27.fd413f1-2			: r27.fd413f1-2

real	0m3.085s
user	0m1.230s
sys	0m0.490s

  : 2017-12-28		: hgsubversion-hg	: 1550.67b28d657f62-1		: 1550.67b28d657f62-1

real	0m7.136s
user	0m3.333s
sys	0m0.629s
	
  : 2017-12-28		: pacvim-git		: v1.1.1.r10.gb0934ca-1		: v1.1.1.r10.gb0934ca-1

real	0m6.031s
user	0m2.490s
sys	0m0.938s

  : 2017-12-28		: surfraw-git		: 2017.07.22.gc8a6820-1		: 2017.07.22.gc8a6820-1

real	0m6.344s
user	0m1.434s
sys	0m0.540s
			
  : 2017-12-28		: vim-markdown		: 2.0.0.r239.f416b35-1		: 2.0.0.r239.f416b35-1
	
real	0m3.461s
user	0m1.311s
sys	0m0.524s


  : 2017-12-28		: modprobed-db		: 2.37-1			: 2.37-1

real	0m3.088s
user	0m1.145s
sys	0m0.493s
			
  : 2017-12-28		: bluefish-svn		: 8781-1			: 8781-1

real	0m11.063s
user	0m2.968s
sys	0m1.516s
		
  : 2017-12-28		: aurvote-git		: r27.fd413f1-2			: r27.fd413f1-2

real	0m2.926s
user	0m1.223s
sys	0m0.480s
	
  : 2017-12-28		: you-get-git		: 0.4.1011.20171225.1865-1	: 0.4.1011.20171225.1865-1

real	0m6.323s
user	0m2.013s
sys	0m0.622s
		
  : 2017-12-28		: vim-vimproc-git	: ver.9.3.r4.81f4fa5-1		: ver.9.3.r4.81f4fa5-1
		
real	0m6.481s
user	0m2.258s
sys	0m0.822s

  : 2017-12-28		: aurora		: 20160907.16_f78867f-1		: 20160907.16_f78867f-1

real	0m3.702s
user	0m1.816s
sys	0m0.717s


Install and update function

install () {

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

	### Check if package is installed? if yes bypass, if no git clone

if	[[ $(pacman -Q ${2} 2>/dev/null | cut -d ' ' -f1) != ${2} ]]; then
	cd "${basedir}" || exit			     ####|^|####
	git clone https://aur.archlinux.org/"${2}".git
fi
	cd "${builddir}"  || exit

	### Check if PKGBUILD is present as a check for package availability....
	### If yes bypass, if no delete builddir, display message, exit

if	[[ ! -s PKGBUILD ]]; then
	echo; echo "Error: Package not found, try again."; echo
	cd "${basedir}"
	rm -rfd "${builddir}"; exit
fi
	### Check if package is installed? if yes bypass, if no next test
	### Check if PKGBUILD is present to verify package was available....
	### If yes run stopYesNo function, of no bypass

if	[[ $(pacman -Q ${2} 2>/dev/null | cut -d ' ' -f1) != ${2} ]] &&
	[[ -s PKGBUILD ]]; then

	### Run interactive function
	stopYesNo
	makepkg -si --needed
	echo; echo "  ${2} has been installed."; echo
	exit
fi

	### Set available package version in variable. Todo: suppress output to screen

	echo "  THIS NEEDS SUPPRESSED  "; echo
	rm -fdr /tmp/aurt/"${2}"
	mkdir -p /tmp/aurt/ ;  cd "$_"  || exit
	git clone https://aur.archlinux.org/"${2}".git 
	cd /tmp/aurt/"${2}"  || exit
	makepkg -so
	version=$(makepkg --printsrcinfo | sed -n '/\s*pkg[vr]e[rl]/{s/[^=]*= //;H}; ${x;s/\n//;s/\n/-/p}')
	installed=$(pacman -Q ${2} | cut -d " " -f2)


	### Check if build directory exists, if yes next, if no bypass
	### Check if package is installed, if yes next, if no bypass
	### Check if installed is different than available, if yes update, if no bypass 

if	[[ -d ${builddir} ]] &&
	[[ $(pacman -Q ${2} 2>/dev/null | cut -d " " -f1) = ${2} ]]  &&
	[[ $(pacman -Q ${2} | cut -d " " -f2) != ${version} ]]; then
	cd "${builddir}"  || exit        ####|^|####
	git reset --hard HEAD
	git merge
	echo "		Installed: $installed		Available: $version	"
	echo

	### Run interactive function
	stopYesNo 
	makepkg -fsi --needed
	echo; echo "  ${2} has been updated."; echo
    else
	echo; echo "  ${2} is up to date, nothing to do ..... Exiting "; echo
fi
}

Standalone check for updates function

avud () {

if	[[ -z "${2}" ]]; then
	exit
fi
	rm -fdr /tmp/aurt/"${2}"
	mkdir -p /tmp/aurt/ ;  cd "$_"  || exit
	git clone https://aur.archlinux.org/"${2}".git
	cd /tmp/aurt/"${2}"  || exit
	makepkg -so
	version=$(makepkg --printsrcinfo | sed -n '/\s*pkg[vr]e[rl]/{s/[^=]*= //;H}; ${x;s/\n//;s/\n/-/p}')
	installed=$(pacman -Q ${2} | cut -d " " -f2)

cat << UpdateHeader

 --------------------------------------------------------------------------------------------------------
 :  DATE		PACKAGE			INSTALLED			AVAILABLE		:
 --------------------------------------------------------------------------------------------------------
UpdateHeader
echo "    $date		${2}		$installed			$version			" |tee -a $basedir/Update.Log



aurt-help --pud	"${@}"

}

Here's results of playing with awk to set the version variable --- and Trilby's one line replacement. High on my must know priority list, learn some regex!

#	makepkg --printsrcinfo > psrc
#	pkgv=$(awk '/pkgver/{print $3}' psrc)
#	pkgr=$(awk '/pkgrel/{print $3}' psrc)
#	version="$pkgv-$pkgr"

	version=$(makepkg --printsrcinfo | sed -n '/\s*pkg[vr]e[rl]/{s/[^=]*= //;H}; ${x;s/\n//;s/\n/-/p}')

Last edited by Cody Learner (2017-12-29 19:40:14)


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

#33 2017-12-29 21:46:04

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

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

Awk can retrieve pkgv and pkgr in one pass, as it processes files line by line. So you could do something like:

version=$(awk '/^pkgver/{ver=$3}; /^pkgrel/{rel=$3}END{print ver"-"rel}' psrc)

Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#34 2017-12-30 05:29:54

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

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

I've made another effort to 'get along' with git today. A newfound discovery changes the current 'update function' status from "a bull in a china shop" to "a month old calf in a china shop."

Wrote a new test script today ... more testing ... then got lucky and found an update. Seems everything worked as expected.   Woot ... as I excitedly update!


Test script running on AUR package signal.

$ aurt-gittest -Au signal

 Remote git HEAD #:
8fdd9e663b7afd4e4a956c0e7ecdc07558b6e521

 Local git HEAD #:
9060d7ca56340a14aa7c571175ef52548f989244

 Git HEAD local and remote are the different, running checkmore.

 ----------------------------------------------------------------
  Option from command line  : -Au
  Package from command line : signal
  Base Directory            : /home/aurt/z-AUR-Aurt
  Build directory           : /home/aurt/z-AUR-Aurt/signal
  Todays date:              : 2017-12-29
  Installed version         : 1.0.41-2
  Latest available version  : 1.1.0-1
 -----------------------------------------------------------------

HEAD is now at 9060d7c Add electron as a dependency
Already up to date.

		Installed: 1.0.41-2		Available: 1.1.0-1	


 signal has an update available.

Test script:

#!/bin/bash

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

	echo; echo ' Remote git HEAD #:'
	git ls-remote https://aur.archlinux.org/"${package}".git HEAD|awk '{print $1}'
	echo; echo ' Local git HEAD #:'
	git -C "${builddir}" rev-parse HEAD; echo

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

checkmore () {

	rm -fdr "${builddir}"/"${date}"
	mkdir -p "${builddir}"/"${date}" ;  cd "$_"  || exit
	git clone --progress https://aur.archlinux.org/"${package}".git  2> /dev/null
	cd "${builddir}"/"${date}"/"${package}"  || exit
	makepkg -so 2> /dev/null

													     # "${avalver}" = current version available
avalver="$(makepkg --printsrcinfo 2> /dev/null| sed -n '/\s*pkg[vr]e[rl]/{s/[^=]*= //;H}; ${x;s/\n//;s/\n/-/p}')"
installed="$(pacman -Q ${package} | cut -d " " -f2)"                                                         # "${installed}" =  installed version

cat << ShowInfo

 ----------------------------------------------------------------
  Option from command line  : ${option}
  Package from command line : ${package}
  Base Directory            : ${basedir}
  Build directory           : ${builddir}
  Todays date:              : ${date}
  Installed version         : ${installed}
  Latest available version  : ${avalver}
 -----------------------------------------------------------------

ShowInfo
	### Check if build directory exists, if yes next, if no bypass
	### Check if package is installed, if yes next, if no bypass
	### Check if installed is different than available, if yes update, if no bypass 

if	[[ -d ${builddir} ]] &&
	[[ $(pacman -Q ${package} 2>/dev/null | awk '{print $1}') = ${package} ]]  &&                 #cut -d " " -f1
	[[ $(pacman -Q ${package} | awk '{print $2}') != ${avalver} ]]; then
	cd "${builddir}"  || exit                ####|^|####
#	git reset --hard HEAD
#	git merge
	git pull
	echo "		Installed: ${installed}		Available: ${avalver}	"
	echo

	echo; echo " ${package} has an update available."; echo
	else
	echo; echo " ${package} is up to date. "; echo
fi
}
#                                                                           add or remove  ' != '  for testing
#                                                                              ^read^ ='####|^|####'= ^above^
########################################################################################################################################

if	[[ $(git ls-remote https://aur.archlinux.org/"${package}".git HEAD|awk '{print $1}') = $(git -C ${builddir} rev-parse HEAD) ]];
	then echo " Git HEAD local and remote are the same."                            ####|^|####
	echo
	else echo ' Git HEAD local and remote are the different, running checkmore.'
	checkmore
fi

After update:

$ aurt-gittest -Au signal

 Remote git HEAD #:
8fdd9e663b7afd4e4a956c0e7ecdc07558b6e521

 Local git HEAD #:
8fdd9e663b7afd4e4a956c0e7ecdc07558b6e521

 Git HEAD local and remote are the same.

Last edited by Cody Learner (2017-12-30 06:29:13)


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

#35 2018-01-01 02:09:03

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

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

Status 12/31/17

I've returned to using git to check for update availability. Optionally have a package update version check via current pacman reported version -vs- the results of running git pull and makepkg -so. Also implemented git to use the package repo for everything. I had started testing the new package update function using a standalone /temp directory as the git repo.

Something I've only now figured out is not all my AUR packages are available via git. A few of my AUR packages fall into that category. They are however still available on the AUR web. I have a gitless version of aurt that can do installs and updates on those packages, and could implement that capability into this version.

I've also tried to cover a few user input error situations, but have a long way to go. Just today implemented, although very basic and crude, a method to track aurt installed packages. This may (or may not) be used in the future to check all aurt installed packages at once for update status, similar to the current -C operation output using cower, but using git HEAD local -vs- remote numbers.

I've also thought about stepping up the option and package parsing capacity to eventually be able to handle actual options and multiple packages. However, I've got a whole lot to do and learn before going there...

Unfortunately the current aurt script has swollen to a bloated nearly 200 line monster. That doesn't include going back to a separate 80+ line aurt-help script used for most of the text related stuff.

Still enjoying this, and hopefully learning enough along the way to end up with something that some (or any) users, would actually find useful or want to try.


Results of checking AUR packages for updates (currently using cower). Based on these results, two packages have updates available.

$ aurt.12-31-17 -C

:: Checking astyle-svn for updates...
:: Checking aurora for updates...
:: Checking aurutils for updates...
:: Checking aurvote-git for updates...
:: Checking bluefish-svn for updates...
:: Checking cower for updates...
:: Checking fman for updates...
:: Checking gedit2 for updates...
:: Checking goffice0.8 for updates...
:: Checking google-chrome for updates...
:: Checking grub-legacy for updates...
:: Checking hgsubversion-hg for updates...
:: Checking libcurl-openssl-1.0 for updates...
:: Checking linux-AURT for updates...
:: Checking linux-AURT-headers for updates...
:: Checking menulibre for updates...
:: Checking mimeo for updates...
:: Checking modprobed-db for updates...
:: Checking neofetch for updates...
:: Checking pacnews-neovim for updates...
:: Checking pacvim-git for updates...
:: Checking pkgbrowser for updates...
:: Checking plymouth for updates...
:: Checking pvim for updates...
:: fman 0.8.1-1 -> 0.8.2-1
:: Checking python2-gtkglext for updates...
:: Checking python3-memoizedb for updates...
:: Checking python3-xcgf for updates...
:: Checking python3-xcpf for updates...
:: Checking qutebrowser-git for updates...
:: Checking signal for updates...
:: Checking surfraw-git for updates...
:: Checking terminfo-neovim-tmux for updates...
:: Checking ttf-ms-fonts for updates...
:: Checking typescript-vim-git for updates...
:: Checking urxvt-vim-insert for updates...
:: Checking vi-vim-symlink for updates...
:: Checking vim-ack for updates...
:: Checking vim-apprentice for updates...
:: Checking vim-assistant for updates...
:: Checking vim-bitbake-git for updates...
:: Checking vim-brainfuck for updates...
:: Checking vim-buftabs for updates...
:: Checking vim-codepad for updates...
:: Checking vim-command-t for updates...
:: Checking vim-comments for updates...
:: Checking vim-csv-git for updates...
:: Checking vim-dein-git for updates...
:: Checking vim-diffchar for updates...
:: Checking vim-endwise for updates...
:: Checking vim-fcitx for updates...
:: Checking vim-fluxkeys for updates...
:: Checking vim-json-git for updates...
:: Checking vim-markdown for updates...
:: Checking vim-openscad for updates...
:: Checking vim-pep8 for updates...
:: Checking vim-pkgbuild for updates...
:: Checking vim-python-mode-git for updates...
:: Checking vim-rest for updates...
:: Checking vim-tern for updates...
:: Checking vim-vimproc-git for updates...
:: Checking virtualbox-ext-oracle for updates...
:: Checking you-get-git for updates...
:: vim-diffchar 7.4-2 -> 7.40-1

Here's the results of running the aurt -A operation on vim-diffchar.

The -A operation will eventually be implemented from within the -S operation after reporting update availability. If an update is available you'll be prompted to proceed to update or not and exit. Notice the info provided regarding update status.

$ aurt.12-30-17 -A vim-diffchar

 Local git HEAD #:
cd7a8a2a37e5dd5e8b13df4c68ecc80b3657fa79

 Remote git HEAD #:
7241db55db69256c6fd381d70eb0216bc19c9f0e
 Local and Remote different, running -A option.
Git repo is :
remote: Counting objects: 4, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 2), reused 0 (delta 0)
Unpacking objects: 100% (4/4), done.
From https://aur.archlinux.org/vim-diffchar
 * branch            HEAD       -> FETCH_HEAD
Updating cd7a8a2..7241db5
Fast-forward
 .SRCINFO | 8 +++-----
 PKGBUILD | 4 ++--
 2 files changed, 5 insertions(+), 7 deletions(-)

  ----------------------------------------------------------------
  Package                   : vim-diffchar
  Base Directory            : /home/aurt/z-AUR-Aurt
  Build directory           : /home/aurt/z-AUR-Aurt/vim-diffchar
  Todays date:              : 2017-12-31
  Installed version         : 7.4-2
  Latest available version  : 7.40-1
  -----------------------------------------------------------------


 Installed: 7.4-2			
 Available: 7.40-1				

================================================================================= 
# Maintainer: Rhinoceros <https://aur.archlinux.org/account/rhinoceros>

pkgname=vim-diffchar
pkgver=7.40
pkgrel=1
pkgdesc="Improve vim's diff mode, by finding exact differences between lines, character by character"
arch=('any')
url='http://www.vim.org/scripts/script.php?script_id=4932'
license=('unknown')
depends=('vim')
groups=('vim-plugins')
source=("$pkgname-$pkgver.zip::http://www.vim.org/scripts/download_script.php?src_id=25736")
sha256sums=('7a8077df2875414abcbc001e172058d556ebb1867041096ea25876d9fa83b240')

prepare() {
  rm doc/tags
}

package() {
  _installpath="${pkgdir}/usr/share/vim/vimfiles"
  mkdir -p "${_installpath}"
  cp -r autoload doc plugin "${_installpath}"
#  install -D -m644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
================================================================================= 

   Review the PKGBUILD, above prior to usage
   Proceed to PKGBUILD in leafpad editor? [Y/n] 
   If Yes, exit editor to continue.        y

==> Making package: vim-diffchar 7.40-1 (Sun Dec 31 16:10:11 PST 2017)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Found vim-diffchar-7.40.zip
==> Validating source files with sha256sums...
    vim-diffchar-7.40.zip ... Passed
==> Extracting sources...
  -> Extracting vim-diffchar-7.40.zip with bsdtar
==> Starting prepare()...
==> Removing existing $pkgdir/ directory...
==> Entering fakeroot environment...
==> Starting package()...
==> Tidying install...
  -> Removing libtool files...
  -> Purging unwanted files...
  -> Removing static library files...
  -> Stripping unneeded symbols from binaries and libraries...
  -> Compressing man and info pages...
==> Checking for packaging issue...
==> Creating package "vim-diffchar"...
  -> Generating .PKGINFO file...
  -> Generating .BUILDINFO file...
  -> Generating .MTREE file...
  -> Compressing package...
==> Leaving fakeroot environment.
==> Finished making: vim-diffchar 7.40-1 (Sun Dec 31 16:10:12 PST 2017)
==> Installing package vim-diffchar with pacman -U...
loading packages...
resolving dependencies...
looking for conflicting packages...

Packages (1) vim-diffchar-7.40-1

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

:: Proceed with installation? [Y/n] y
(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 vim-diffchar                                                                  [#######################################################] 100%
:: Running post-transaction hooks...
(1/2) Arming ConditionNeedsUpdate...
(2/2) Updating Vim help tags...

  vim-diffchar has been updated.


For now, running -S on an already installed package only reports the update status.

$ aurt.12-30-17 -S vim-diffchar

 vim-diffchar is already installed, checking for update


 Local git HEAD #:
7241db55db69256c6fd381d70eb0216bc19c9f0e

 Remote git HEAD #:
7241db55db69256c6fd381d70eb0216bc19c9f0e

 Local = Remote indicates up to date. For details run -A option.

Current Testing aurt script.

Note: I've not yet ran this through shell check as it seems to cause me as many issues as it solves ie: broken script unless I have much time to invest. I will do that when I get further along and have more time.

#!/bin/bash
# aurt 12-30-17

basedir="${HOME}"/z-AUR-Aurt                             # "${basedir}"   =  base directory for build
builddir="${HOME}"/z-AUR-Aurt/"${2}"                     # "${builddir}"  =  build directory
date=$(date '+%Y-%m-%d')                                 # "${date}"      =  todays date
iif [[ -n "${2}" ]]; then
installed=$(pacman -Q "${2}" | awk '{print $2}');  fi	 # "${installed}" =  installed version number

############################################### INSTALL FUNCTION ###############################################
install () {

	if [[ -z ${2} ]]; then echo "Error: No package"; 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 git repo is available, if yes git clone, if no, print massage and exit aurt

if	[[ $(pacman -Q ${2} 2>/dev/null | cut -d ' ' -f1) != ${2} ]]; then

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

	### 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 package and exit aurt 
		### if no display message, exit

if	[[ $(pacman -Q ${2} 2>/dev/null | cut -d ' ' -f1) != ${2} ]]; then

	if	[[ -s PKGBUILD ]]; then
		stopYesNo  ### Run interactive function #--noconfirm
		makepkg -si --needed --noconfirm 			&& echo "${2}" >> "${basedir}"/installed.log

		echo; echo "  ${2} has been installed."; echo; exit
		else
		echo; echo "Error: PKGBUILD unavailable, to restore, remove then reinstall package with aurt"; echo; exit
	fi

	else echo; echo " ${2} is already installed, checking for update"; echo
fi
	gitcheck "${@}"
}
############################################### CHECK UPDATE FUNCTION ###############################################
checkupdate () {

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

	gitcheck "${@}"
	echo "Git repo is :"
	### Check builddir present, if no message & exit aurt
if	[[ ! -d ${builddir} ]]; then
	echo " Build directory is not present, reinstall package." ; exit
fi
	### Check if .git dir available, if yes, git pull & makepkg to get latest available version number
if	[[  -d  ${builddir}/.git ]]; then
	cd "${builddir}"  || exit
	git pull --progress https://aur.archlinux.org/"${2}".git  #2> /dev/null
	makepkg -so 2> /dev/null
fi
	### ${avalver}=current version available
	avalver="$(makepkg --printsrcinfo 2> /dev/null|sed -n '/\s*pkg[vr]e[rl]/{s/[^=]*= //;H}; ${x;s/\n//;s/\n/-/p}')"
	### Print info message from aurt-help file				
 	 . aurt-help --pud "${2}"						
	### Compare version numbers, if different, rebuild and install update
if	[[ $(pacman -Q ${2} | awk '{print $2}') != ${avalver} ]]; then
				           ####|^|#### default present
	echo; echo " Installed: ${installed}			"
	echo " Available: ${avalver}				"
	### Run interactive function
	stopYesNo
	cd "${builddir}"  || exit
	makepkg -fsi --needed
	echo updated on ${date} >> ${builddir}/Aurt-Update.log
	echo; echo "  ${2} has been updated."; echo
	else
	echo checked on ${date} >> ${builddir}/Aurt-Update.log
	echo " ${2} is up to date, Exiting. "; echo
fi
}
############################################### GIT CHECK FUNCTION ###############################################
gitcheck () {
	echo; echo ' Local git HEAD #:'
	git -C "${builddir}" rev-parse HEAD; echo
	echo ' Remote git HEAD #:'
	git ls-remote https://aur.archlinux.org/"${2}".git HEAD|awk '{print $1}'
if	[[ $(git ls-remote https://aur.archlinux.org/${2}.git HEAD | awk '{print $1}') = $(git -C ${builddir} rev-parse HEAD) ]]; then 
										  ####|^|####  absent
	echo; echo " Local = Remote indicates up to date. For details run -A option."         
	echo
	else echo  " Local and Remote different, running -A option."
fi
}
############################################### STOP YES NO FUNCTION ##############################################
stopYesNo () {
	echo; echo "================================================================================= "
	cat PKGBUILD
	echo       "================================================================================= "; echo
	echo "   Review the PKGBUILD, above prior to usage"
while true; do
	   echo       "   Proceed to PKGBUILD in $EDITOR editor? [Y/n] "
	   read -r -p "   If Yes, exit editor to continue.        " yn; echo
	case $yn in
		y|yes) $EDITOR PKGBUILD; break
		;;
		n|no) break
		;;
		* ) echo "y-n ?"
		;;
	esac
done
}
############################################### REMOVE FUNCTION ###############################################
remove () {

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

	exec &> >(tee -i "${basedir}/${2}.log")
#	ls -la "${basedir}"; echo                 # --noconfirm
	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}" && sed -i 's/\<'"$2"'\>//g;/^\s*$/d' "${2}" "${basedir}"/installed.log
	
}
############################################### SEARCH FUNCTION ###############################################
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}"; echo
}
############################################### DOWNLOAD DEP FUNCTION #########################################
downloaddep () {
	mkdir "${basedir}"/"${2}" 2> /dev/null || exit
	cower -fdd "${2}" -t "${basedir}"/"${2}"
	dpkgs=$(ls "${basedir}"/"${2}"); echo
	echo "Downloaded:          Note: Function runs 'cower -fdd', -f opt forces overwrite. "; echo
	echo "$dpkgs"
	echo "   Downloaded packages base dir: ${basedir}/${2}"; echo
	echo "   cd to 'base dir'/pkg.name and use makepkg to build "
	echo "   Note: The deps must be installed in correct order, or all same time"; echo
}
############################################### RUN FUNCTIONS ##################################################
if 		[[ -z "$*" ]]; then
		. aurt-help --header	"${@}"
fi
while :; do
	case "${1}" in
	    -S|--install)
		install				"${@}"		; break		;;
	    -R|--remove)
		remove				"${@}"		; break		;;
	    -C|--cupdate)
		echo; cower -uv; echo				; break		;;
	    -D|--download)
		downloaddep			"${@}"		; break		;;
	    -s|--search)
		search				"${@}"		; break		;;
	    -p|--pacmanlog)
		cat /var/log/pacman.log				; break		;;
	   -ch|--cowerhelp)
		cower -h					; break		;;
     	    -h|--help)
		. aurt-help --help		"${@}"		; break		;;
	    -A|--available)
		checkupdate			"${@}"		; break		;;
	   -?*)
		echo; echo " Error - Please try again or try: aurt --help"; echo
		. aurt-help --header		"${@}"		; break		;;
	     *)
		break
	esac
	shift
done


Current aurt-help script

#!/bin/bash
# aurt-gitless.hnhelp.12-31-17

header () {

cat << Read-Header

 |==============================================================================|
 |  Aurt, a tiny AUR helper script.       USAGE: \$ aurt [operation] [package]   |
 |------------------------------------------------------------------------------|
 |  -S Install                -s Search                thunar-base dir:     tbd |
 |  -R Remove                 -p Pacman log            leafpad-aurt:        lat |
 |  -C Check for updates     -ch Cower Help            Orphans:    R \$(p -Qtdq) |
 |  -D Download deps          -h Help        (Testing) -A Updates details       |
 |==============================================================================|

Read-Header
}

help () {

cat << Read-Help

  Usage: aurt <operation> [AUR package name]

 Operation:            Example:
 -S  = Install     : $ aurt -S [AUR package name]
 -R  = Remove      : $ aurt -R [AUR package name]
 -s  = Search      : $ aurt -s [AUR package name]
 -D  = Download    : $ aurt -D [AUR package name]
 -C  = Checks all installed AUR packages for available updates.
 -p  = Show pacman.log
 -h  = Aurt help page
 -ch = Cower help page

 Overview:
 -S   Checks if installed, builds, installs, check for updates, in this order.
 -R   Performs pacman -Rns + rm package build directory and log.
 -C   Checks installed AUR packages for update availablity.
 -D   Package + AUR dependencies placed within the package build directory. 
      These AUR packages will need manual build and installation, in order.
 -s   Performs search for package, no options.
 -p   Runs:  cat /var/log/pacman.log.
 -ch  Runs: cower -h
 -h   Displays this help page.
 -Au  Available update on a package entered.

Read-Help
}

updatemessage () {

cat << Read-update-message

  ----------------------------------------------------------------
  Package                   : ${2}
  Base Directory            : ${basedir}
  Build directory           : ${builddir}
  Todays date:              : ${date}
  Installed version         : ${installed}
  Latest available version  : ${avalver}
  -----------------------------------------------------------------

Read-update-message

}

while :; do
	case "${1}" in
	--header)
    header;	break	
	;;
	--help)
    help;	break	
	;;
	--pud)
    updatemessage	"${@}"	; break	
	;;
	esac
	shift
done

Last edited by Cody Learner (2018-01-01 20:25:54)


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

Board footer

Powered by FluxBB