You are not logged in.

#1 2015-04-24 21:36:03

zegoti
Member
Registered: 2015-03-01
Posts: 5

pkgbuild upstream updater

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

#2 2015-04-24 22:47:22

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: pkgbuild upstream updater

Is there a reason for a PKGBUILD not to be available in the AUR?

Offline

#3 2015-04-24 23:53:12

zegoti
Member
Registered: 2015-03-01
Posts: 5

Re: pkgbuild upstream updater

karol wrote:

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

#4 2015-04-25 00:00:12

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: pkgbuild upstream updater

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

#5 2015-04-25 00:08:14

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,231
Website

Re: pkgbuild upstream updater

# 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.

Offline

#6 2015-04-25 00:42:55

zegoti
Member
Registered: 2015-03-01
Posts: 5

Re: pkgbuild upstream updater

fukawi2 wrote:
# 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 smile

Offline

#7 2015-04-25 02:07:33

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,231
Website

Re: pkgbuild upstream updater

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)

Offline

#8 2015-04-25 02:16:25

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: pkgbuild upstream updater

It's in OP's todo list - see the first post.

Offline

Board footer

Powered by FluxBB