https://github.com/Obarun/pacopts

A new little one on the family :).

This very simple scripts tell you if installed packages do not come from obarun repository. It can be useful when a new package is added on obarun database or when you install a new package and you do not pay attention to a dependence.
So from time to time launch it.

I do not make package for it at the moment, just copy and paste the following code below and make it executable
# !/usr/bin/bash
# This script is under license BEER-WARE
# "THE BEER-WARE LICENSE" (Revision 42):
# <eric@ obarun.org> wrote this file.  As long as you retain this notice you
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy me a beer in return.   Eric Vidal
shopt -s extglob
# set -e

# . /opt/pacopts/pacopts.conf
# . /opt/pacopts/pacopts_functions

# #		Shell color 

unset bold reset red bred green bgreen yellow byellow blue bblue
bold=$(tput bold)
reset=$(tput sgr0)
red=$(tput setaf 1)
bred=${bold}$(tput setaf 1)
green=$(tput setaf 2)
bgreen=${bold}$(tput setaf 2)
yellow=$(tput setaf 3)
byellow=${bold}$(tput setaf 3)
blue=$(tput setaf 4)
bblue=${bold}$(tput setaf 4)
readonly bold reset red bred green bgreen yellow byellow blue bblue4


# # 		Information display by the script 

echo_bold(){
	local msg=$1; shift 
	printf "${bold}${msg}${reset}\n" "${@ }" >&1
}
echo_info(){
	local msg=$1; shift 
	printf "${byellow}==>>${msg} ${reset}\n" "${@ }" >&1
}
echo_info_menu(){
	local msg=$1; shift 
	printf "${byellow}${msg} ${reset}\n" "${@ }" >&1
}
echo_retry(){
	local msg=$1; shift 
	printf "${bblue}==>>${msg} ${reset}\n" "${@ }" >&1
}
echo_valid(){
	local msg=$1; shift 
	printf "${bgreen}    ->${msg} ${reset}\n" "${@ }" >&1
}
echo_notvalid(){
	local msg=$1; shift 
	printf "${byellow}    ->${msg} ${reset}\n" "${@ }" >&1
}
echo_display(){
	local msg=$1; shift 
	printf "${bold}==>>${msg} ${reset}\n" "${@ }" >&1
}
echo_error(){
	local msg=$1; shift 
	printf "${bred}    ->${msg} ${reset}\n" "${@ }" >&2
}
answer(){
	echo_retry " Please answer y or n :"
}

find_origin(){
	local rc ori not check
	
	while read -d "," check;do
		printf "\r${bold}	-> Check %s package${reset}                                " "$check"
	
		while read ori; do
		# parse ori
			ori=${ori# #*/}
			ori=${ori%%' '*}
			ori=${ori%-nosystemd}
			case $ori in
				"$check") # echo_valid " $check come from obarun"
						unset rc
						break;;
				   "not") # echo_notvalid " $check doesn't come from obarun repository"
						unset rc
						false+=("$check")
						break;;
					   *)rc=1
					    continue;;
			esac
				
		done < <(yaourt -Qs "$check" | fgrep "obarun" || echo "not")
		if [[ $rc == 1 ]]; then 
			# echo_notvalid " $check doesn't come from obarun repository"
			unset rc
			false+=("$check")
		fi
	done <<< "${both[@ ]}"
	printf "\n${bold}==>> Finished ${reset}\n"
}

check_package(){
	
	local name item no
	local -a both false
	local -a installed obarun_db
	mapfile -t installed < <(pacman -Qsq)
	mapfile -t obarun_db < <(pacman -Slq obarun)
	
	# FILTER : Compare list of installed package and obarun database,
	# if exist on twice put it on both table
		
	while read name;do 
		for item in "${obarun_db[@ ]%-nosystemd}"; do
			if  [[ "$name" == "$item" ]]; then 
				both+=("$item,")
			fi
		done
	done < <(pacman -Qsq | sed 's:-nosystemd::')
	
	echo_display " Verifying packages repository"
	
	# check origin of package
	find_origin
	
	if ! [ -z "${false[@ ]}" ]; then 
		printf "${byellow}==>> These/those packages do not come from obarun repository :${reset}\n" 
		for no in "${false[@ ]}"; do
			echo_bold "	-> $no"
		done
	fi
	
	# Remove those following line if you want to install packages directly
	# don't forget to use sudo :)
	
	# for i in "${false[@ ]}"; do
	#	pacman -S obarun/$i
	# done
}

# (( EUID == 0 )) || die " You must be run this script with root privileges"

check_package
enjoy :)
3 months later
This scripts was improved. You can find now a package on obarun repo.

New features :
- the script allow you to install packages which doesn't come from obarun.
- applysys : you may have noticed that some time pacman complaint about sysusers.d files. So this option allow you to wrap up the sysusers.d program which install group and user during an installation process. example :
$ pacopts applysys nbd.conf
do not enter the absolut path but just the name of sysusers.d file.

For the moment you need to do it manualy by calling pacopts but this option will become a hook for pacman that will make the stuff directly when we install some package which require sysusers.d files.
a month later
New features :
- applytmp : you may have noticed that sometime pacman complaint about tmpfiles.d files. So this option allow you to wrap up the systemd-tmpfiles program which install some files/directory at the booting time.

How to use it :

when you have installed a package which require an installation of a tmpfiles just run pacopts like this :
$ sudo pacopts applytmp
So this kind of files need to be applied at every booting time. To make it , you can use rc.local for runit or s6.local for s6. Your xxx.local look like this :
# !/bin/sh
# Default s6.local for obarun; add your custom commands here.
# 
# This is run by s6 before the user services are executed.
# This file is declared as oneshot service on s6, do not try to launch any daemon with this file.
# Do not forget to define your environment by a shebang.

/usr/bin/pacopts applytmp
do not forget to add the shebang entry ( # !/bin/sh ) and obviously, add the ability to use s6.local on s6.conf for s6 users like this :
# Use /etc/s6.local [yes|no]
S6LOCAL=yes
8 days later
Improvement

The directory for files installation have changed as same as obarun-install, it means :
- pacopts_functions is now installed at /usr/lib/obarun/pacopts_functions
- tmpfiles.sh is now installed at /usr/lib/obarun/pacopts_functions
- configuration can be found at /etc/obarun/pacopts.conf
- pacman hook at /usr/share/libalpm/hooks/{applysys,applytmp}.hook
- obarun-libs was added as dependency

New features :
- hook for pacman : pacopts package install now necessary hook to perform applysys, applytmp during a package installation process.

Powered by Obarun