You are not logged in.
Pages: 1
Hi, here is my first try coding script
code contribution are welcome.
Description:
Script to retrieve the latest upstream PKGBUILD file and if new changes it will build/install/(or upload to AUR) the package or whatever.
Todo:
Parse the PKGBUILD to retrieve extra files like $pkgnam.install, patch, ect
Allow manually adding PKGBUILD address upstream.
Allow to automatically update a bunch of PKGBUILD with a loop.
Write the source address PKGBUILD upstream in a separate file into the same folder or in a global file.
#!/bin/bash
#update-pkgbuild.sh
# Todo:
# Parse the PKGBUILD to retrieve extra files like $pkgnam.install, patch, ect
# Allow manually adding PKGBUILD address upstream.
# Allow to automatically update a bunch of PKGBUILD with a loop.
# Write the source address PKGBUILD upstream in a separate file into the same folder or in a global file.
#
set -x
old_md5="$(md5sum 'PKGBUILD' 2>/dev/null | cut -d ' ' -f 1 )"
# del old source packages
if [[ -d "src" ]]; then
rm -r "src"
fi
if [[ -d "pkg" ]]; then
rm -r "pkg"
fi
# check if tmp folder exist. If so then delete
if [[ -d "tmp" ]]; then
# Control will enter here if DIRECTORY exists.
rm -r "tmp"
fi
mkdir "tmp"
cd tmp || { echo 'failed to cd'; exit 1; }
curl -O https://raw.githubusercontent.com/felixonmars/aur-mirror/master/pamac-aur/PKGBUILD || { echo 'failed to curl'; exit 1; }
new_md5="$(md5sum 'PKGBUILD' | cut -d ' ' -f 1 )"
# check if file exist
if [ -f ../PKGBUILD ]; then
echo 'check if md5sum are equal'
# check if md5sum are equal
if [[ $old_md5 == $new_md5 ]]; then
# nothing to do
echo 'No update available'
else
# backup the old file
cp ../PKGBUILD ../PKGBUILD-"$(date +'%Y%m%d-%H%M%S')"
# replace old
mv PKGBUILD ../PKGBUILD
# Todo
# read the pkgbuild to list available extra files like patchs and then curl that needed files
#
# back to previous dir
cd -
# Build & Install the package
# makepkg -i -s -f --noconfirm
# Build only
echo 'makepkg -s -f --noconfirm'
fi
else
# move
mv PKGBUILD ../PKGBUILD
# Todo
# read the pkgbuild to list available extra files like patchs and then curl that needed files
#
# back to previous dir
cd -
# Build & Install the package
# makepkg -i -s -f --noconfirm
# Build only
echo 'makepkg -s -f --noconfirm'
fi
Edit: the code can be forked from this link https://gist.github.com/mawekuwe/38befce82878e83ab376
Updated the description.
Thanks for reading
Last edited by zegoti (2015-04-25 00:42:14)
Offline
Is there a reason for a PKGBUILD not to be available in the AUR?
Offline
Is there a reason for a PKGBUILD not to be available in the AUR?
What makes this question here?
The script can be used to help to maintain the downstream PKGBUILD no matter where it is located.
Last edited by zegoti (2015-04-24 23:58:14)
Offline
I understand that you want to have it your way, I'm just asking is there anything that the existing tools and methods are lacking.
AUR has AUR helpers, stuff (e.g. PKGBUILDs) that are kept in git repos (github etc.) can use git ...
Offline
# del old source packages
if [[ -d "src" ]]; then
rm -r "src"
fi
if [[ -d "pkg" ]]; then
rm -r "pkg"
fi
You should look in /etc/makepkg.conf (and ~/.makepkg.conf) and take into account $BUILDDIR instead of assuming src/ and pkg/.
For example, my $BUILDDIR in ~/.makepkg.conf points to a path in /mnt that is a RAID-10 array of SSD's.
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
# del old source packages if [[ -d "src" ]]; then rm -r "src" fi if [[ -d "pkg" ]]; then rm -r "pkg" fi
You should look in /etc/makepkg.conf (and ~/.makepkg.conf) and take into account $BUILDDIR instead of assuming src/ and pkg/.
For example, my $BUILDDIR in ~/.makepkg.conf points to a path in /mnt that is a RAID-10 array of SSD's.
Great suggestion, I will look at it. Thanks
Offline
EDIT: oops, missed the TODO list... Nevermind!
Also, you're only fetching a PKGBUILD. What happens if an additional non-downloadable source (eg, a patch) is added?
An example: the "xinetd.amanda" file in this package: https://aur.archlinux.org/packages/amanda/
Last edited by fukawi2 (2015-04-25 05:11:41)
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
It's in OP's todo list - see the first post.
Offline
Pages: 1