Last active
February 24, 2017 18:14
-
-
Save manvari/8075201 to your computer and use it in GitHub Desktop.
Script to update AUR packages through cower.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# cowerupdate | |
# | |
# Script to update AUR packages installed through cower. | |
# | |
# Copyright 2013-2015, iceTwy | |
# Licensed under the WTFPLv2 (http://www.wtfpl.net/about/) | |
cower_updatesearch_cmd="cower -u" | |
cower_update_cmd="cower -uddf" | |
makepkg_cmd="makepkg -ci --check" | |
cower_conf_file="$XDG_CONFIG_HOME/cower/config" | |
cower_conf_file_fallback="$HOME/.config/cower/config" | |
if [ ! -f $cower_conf_file ] && [ ! -f $cower_conf_file_fallback ]; then | |
echo No cower configuration file was found. | |
echo Falling back to current directory | |
cower_dl_dir="." | |
else | |
if [ ! -f $cower_conf_file ]; then | |
$cower_conf_file = $cower_conf_file_fallback | |
fi | |
cower_dl_dir=$( cat $cower_conf_file | grep 'TargetDir' ) | |
if [[ $cower_dl_dir == *'#'* ]]; then | |
echo TargetDir commented out in $cower_dl_dir | |
echo Falling back to current directory | |
cower_dl_dir="." | |
else | |
cower_dl_dir=$( cat $cower_conf_file | grep 'TargetDir' | awk '{ print $3 }' ) | |
echo cower DL directory: $cower_dl_dir | |
fi | |
fi | |
echo Packages to update: | |
$cower_updatesearch_cmd | |
if [ $? == 0 ]; then | |
echo No packages to update. | |
exit 0 | |
else | |
error=0 | |
$cower_update_cmd | |
for package in $( $cower_updatesearch_cmd | awk '{ print $2 }'); do | |
cd $cower_dl_dir/$package | |
if [ ! -f PKGBUILD ]; then | |
echo No PKGBUILD found in $package | |
else | |
echo Found PKGBUILD in $package | |
echo Building and installing... | |
$makepkg_cmd | |
if [ $? == 0 ]; then | |
echo Built and installed. | |
else | |
echo There was an error when running makepkg. | |
(( error++ )) | |
fi | |
fi | |
done | |
if [ error == 0 ]; then | |
echo All packages have been built and installed. | |
exit 0 | |
else | |
echo makepkg reported $error errors! | |
exit 1 | |
fi | |
fi |
Hey thanks! This fits my needs nicely. I'm having problems with variable $cower_dl_dir/
in line 44 however. When I run the script it turns up blank (a scoping issue?) and so the script tries to cd in $HOME (I think) rather than my "Builds" folder.
I've hard-coded the correct path to my "Builds" folder at that point (in place of the variable) and the script works as expected. I have set my TargetDir in cower's config.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A little note; be careful with this script if you have no default download directory set in the cower config file (i.e. missing TargetDir). PKGBUILDs will be downloaded to the current directory.
The default behaviour is to retrieve the updates then to build and install the packages.