aboutsummaryrefslogtreecommitdiff
blob: af57af2510a04d780175e5bf4ab1d7fbd12ebd4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/bash
source /etc/init.d/functions.sh

########################## VARIABLES ############################
PVER="4.9.2" # PyQt4 current working version
SVER="4.13.3" #$ Sip current working version
DATE="$(date +%F|sed 's/-//g')" # date to be added to ebuilds
TARGET="www.gentoo-el.org:~/public_html/distfiles/"
TEMP="/tmp/qt-python-bump/"
OVERLAY="../../" # ugly but hey dont shoot me
####################################################################

usage() {
	echo """

./bump-python-revisions <PyQt4-rev> <sip-rev>

Example: ./bump-python-revisions 11cc33 22bba4
	
This will bump PyQt4 ebuild to 11cc33 revision,
and Sip ebuild to snapshot to 22bba4 revision

Use -h option to display this message
Use -c option to skip bumping operation and do 
	directly the merge operation
	"""
}


dosip(){
	SIPKG="sip-${SVER}-snapshot-${new_sip}" # Format Sip package
	ebegin "Downloading ${SIPKG} tarball..."
	wget -P ${TEMP} http://www.riverbankcomputing.co.uk/static/Downloads/sip4/${SIPKG}.tar.gz || exit 2
	eend $?
	ebegin "Copying ${SIPKG} to ${TARGET}"
	eend $?
	scp ${TEMP}/${SIPKG}.tar.gz ${TARGET} || exit
	cp ${TEMP}/${SIPKG}.tar.gz $(portageq envvar DISTDIR) || exit
	pushd ${OVERLAY}/dev-python/sip/
	tomove=$(find '.' -type f -name "sip-*_pre*.ebuild"|tail -1)
	einfo "Previous ebuild: ${tomove#./}"
	mv ${tomove#./} sip-${SVER}_pre${DATE}.ebuild || exit "Failed to bump sip"
	ebegin "Changing revision number to: ${new_sip}"
	sed -i "/^HG_REVISION/s:=.*:=${new_sip}:" sip-${SVER}_pre${DATE}.ebuild
	eend $?
	repoman manifest
	git add .
	popd
}

dopyqt4(){
	PYPKG="PyQt-x11-gpl-snapshot-${PVER}-${new_pyqt4}" #Format PyQt4 package
	ebegin "Downloading ${PYPKG} tarball..."
	wget -P ${TEMP} http://www.riverbankcomputing.co.uk/static/Downloads/PyQt4/${PYPKG}.tar.gz || exit 2
	eend $?
	einfo "Copying ${PYPKG} to ${TARGET} ..."
	scp ${TEMP}/${PYPKG}.tar.gz ${TARGET} || exit
	cp ${TEMP}/${PYPKG}.tar.gz $(portageq envvar DISTDIR) || exit
	pushd ${OVERLAY}/dev-python/PyQt4/
	tomove=$(find '.' -type f -name "PyQt4-*_pre*.ebuild"|tail -1)
	einfo "Previous ebuild: ${tomove#./}"
	mv ${tomove#./} PyQt4-${PVER}_pre${DATE}.ebuild || exit "Failed to bump PyQt4"
	ebegin "Changing revision number to: ${new_pyqt4}"
	sed -i "/^REVISION/s:=.*:=${new_pyqt4}:" PyQt4-${PVER}_pre${DATE}.ebuild
	eend $?
	repoman manifest
	git add .
	popd
}



commit() {
ewarn "Your changes are ready to be merged. However I strongly recommend you to review your changes."
ewarn ""
einfo "Press 'r' to review your changes or 'y' to merge them to master branch (default 'r')."
read choice
case "$choice" in
        y)      ewarn "Your changes will be merged now. Don't break the overlay or I will shoot you down!"
		git commit -a -m "PyQt4/sip: Automatic version bump, remove old" || exit 2
                git push || exit 2
                ;;
	
        r|"")   git diff
                ;;
	*)	eerror ""
		eerror "Invalid option. Are you stupid or something?"
		eerror ""
		exit 3
esac
}

getrevisions(){
	pushd ${OVERLAY}/dev-python/PyQt4/ >> /dev/null
	pyqt4_tomove=$(find '.' -type f -name "PyQt4-*_pre*.ebuild"|tail -1)
	pyqt4_revision=$(grep ^REVISION ${pyqt4_tomove}|sed "s:^REVISION=::")
	popd >> /dev/null
	pushd ${OVERLAY}/dev-python/sip/ >> /dev/null
	sip_tomove=$(find '.' -type f -name "sip-*_pre*.ebuild"|tail -1)
	sip_revision=$(grep ^HG_REVISION ${sip_tomove}|sed "s:^HG_REVISION=::")
	popd >> /dev/null

	einfo "Old Revisions: PyQt4 ${pyqt4_revision}, SIP: ${sip_revision}"

	# Find new revisions
	new_pyqt4=$(curl -s http://www.riverbankcomputing.com/software/pyqt/download|grep "x11-gpl-snapshot-.*.tar.gz"|cut -d '/' -f 5|cut -d '-' -f 6|sed "s:\..*::")
	new_sip=$(curl -s http://www.riverbankcomputing.com/software/sip/download|grep "snapshot-.*.tar.gz"|cut -d '/' -f 5|cut -d '-' -f 7|sed "s:\..*::")
	
	# Decide what to bump"
	[[ ${pyqt4_revision} != ${new_pyqt4} ]] && dopyqt4 && FOUND=true;
	[[ ${sip_revision} != ${new_sip} ]] && dosip && FOUND=true;

	if [[ -n $FOUND ]]; then
		commit
		# clean up
		ebegin "Cleaning up tarballs..."
		rm ${TEMP}/${SIPKG}.tar.gz || exit
		rm ${TEMP}/${PYPKG}.tar.gz || exit
		rm -r ${TEMP}
		dst=$(portageq envvar DISTDIR)
		rm ${dst}/${SIPKG}.tar.gz
		rm ${dst}/${PYPKG}.tar.gz
		eend $?
	fi
	exit 0

}

einfo """
	###########################################################
	# Automatic PyQt4/sip bumping tool for qt overlay         #
	# Author: Markos Chandras <hwoarang@gentoo.org>	          #
	#						                                  #
	# Use ./bump-python-revisions -h for a usage example      #
	###########################################################
"""
getrevisions