summaryrefslogblamecommitdiff
path: root/abump.in
blob: 32ff4af0d82a50a0225b1375daf2206ffefdfdb8 (plain) (tree)
1
2
3
4
5
6
7
8
9
10

         





                                                          

                    
 

                                                   
              


                         



                    

                                     




                           
                                         
                                                      
                              



                                          
 
                                                                
                                
                                 



                  
                       
 
                                                                                    
 



                                                  
                                                  

                        
                               

 
         

                                                                 


                                                              
                                           
                                    
                                


              

              
                               
                    
                              
                  

                           
                              



                       

                              



                                  
 
#!/bin/sh

# abump - bump pkgver in APKBUILDs
# Copyright (c) 2012 Natanael Copa <ncopa@alpinelinux.org>
#
# Distributed under GPL-2
#

abuild_ver=@VERSION@
datadir=@datadir@

if ! [ -f "$datadir/functions.sh" ]; then
	echo "$datadir/functions.sh: not found" >&2
	exit 1
fi
. "$datadir/functions.sh"


# version bump a pkg

do_bump() {
	local pkgname=${1%-[0-9]*}
	local pkgver=${1#${pkgname}-}

	APORTS=$HOME/aports

	set -e

	cd $APORTS/*/$pkgname || return 1
	local section=${PWD%/*} upgrade="upgrade" cve=
	section=${section##*/}
	if [ -n "$cvelist" ]; then
		upgrade="security upgrade"
		cve=" ($cvelist)"
	fi

	message="$section/$pkgname: $upgrade to ${pkgver}${cve}"
	if [ -n "$fixes" ]; then
		message="$message

fixes #${fixes#\#}
"
	fi
	echo "$message"

	( . ./APKBUILD; type package | grep -q function ) || die "package() missing"

	sed -i -e "s/^pkgver=.*/pkgver=$pkgver/" \
		-e "s/^pkgrel=.*/pkgrel=0/" \
		APKBUILD

	abuild $abuild_opts checksum all || exit 1

	git add APKBUILD
	git commit -m"$message"
}

usage() {
	echo "$prog - utility to bump pkgver in APKBUILDs"
	echo "usage: $prog [-hR] [-s CVE-1,CVE-2,...] [-f ISSUE]"
	echo ""
	echo "  -h  show this help"
	echo "  -R  run abuild with -R for recursive building"
	echo "  -k  keep existing packages"
	echo "  -s  security update"
	echo "  -f  fixes ISSUE"
	exit 0
}

keep=
recursive="-r"
while getopts "f:hkRs:" opt; do
	case $opt in
	f) fixes="${OPTARG}";;
	h) usage;;
	k) keep="-k";;
	R) recursive="-R";;
	s) cvelist="$OPTARG";;
	esac
done
shift $(( $OPTIND - 1))

abuild_opts="$recursive $keep"

while [ $# -gt 0 ]; do
	( do_bump "$1" ) || exit 1
	shift
done