File: autobuild.sh

package info (click to toggle)
pulseeffects 4.8.7-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 8,952 kB
  • sloc: cpp: 18,501; xml: 3,821; sh: 228; python: 56; makefile: 4
file content (148 lines) | stat: -rwxr-xr-x 3,414 bytes parent folder | download | duplicates (3)
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
138
139
140
141
142
143
144
145
146
147
148
#!/usr/bin/env bash
# This ugly script helps to build a new version of PulseEffects
# Currently for DEB package only
# Author: Mikhail Novosyolov <mikhailnov@dumalogiya.ru>

pkg_name="pulseeffects"
git_upstream_url="https://github.com/wwmm/pulseeffects.git"
stdate="$(date +%s)"
day_name="$(env LANG=c date --date="@${stdate}" +%a)"
month_name="$(env LANG=c date --date="@${stdate}" +%b)"
year="$(env LANG=c date --date="@${stdate}" +%Y)"
day_month="$(env LANG=c date --date="@${stdate}" +%d)"
time="$(env LANG=c date --date="@${stdate}" +%H:%m:%S)"
timezone="$(env LANG=c date --date="@${stdate}" +%z)"

dir_start="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ "$(basename "${dir_start}")" = 'util' ]; then
	cd ..
fi
dir0="$(pwd)"

echo_help(){
	echo "Usage: nv|nw|new_version, ppa, lc|local_test, check_fuzzy|check_fuzzy_po|cf, full"
}

git_sync_upstream(){
	if ! git remote -v | grep -q "$git_upstream_url"; then
		git remote add upstream "$git_upstream_url"
	fi
	
	git fetch upstream
	
	# git merge returns 0 only if merge was successful
	if git merge upstream/master
		then
			:
		else
			echo ""
			echo "Merge conflicts! Cannot continue!"
			echo ""
			exit 1
	fi
}

debian_changelog_new_entry(){
	if [ ! -f debian/changelog.tpl ]; then
		echo "No debian/changelog.tpl, cannot continue!"
		exit 1
	fi
	if [ -z "$new_version" ]; then echo "new_version is empty"; exit 1; fi
	cat debian/changelog.tpl | \
		sed "s/%new_version%/${new_version}/g" | \
		sed "s/%day_name%/${day_name}/g" | \
		sed "s/%day_month%/${day_month}/g" | \
		sed "s/%month_name%/${month_name}/g" | \
		sed "s/%year%/${year}/g" | \
		sed "s/%time%/${time}/g" | \
		sed "s/%timezone%/${timezone}/g" | \
		tee -a "${dir0}/debian/changelog.new"
	mv debian/changelog debian/changelog.old
	echo " " >> debian/changelog.new
	cat debian/changelog.new debian/changelog.old > debian/changelog
	rm -f debian/changelog.new debian/changelog.old
}

check_fuzzy_po(){
	for lang in ru
	do
		if grep -q "^#, fuzzy" "po/${lang}.po"
			then
				read -p "Fuzzies FOUND in localization ${lang}"
			else
				echo "No fuzzies found in localization ${lang}"
		fi
		
		if grep -q "^#, fuzzy" "help/${lang}/${lang}.po"
			then
				read -p "Fuzzies FOUND in help ${lang}"
				echo "No fuzzies found in help ${lang}"
			else
				echo "No fuzzies found in help ${lang}"
		fi
	done
}

new_version(){
	# env USCAN=0 util/autobuild.sh
	if [ ! "$USCAN" = '0' ]
		then
			if env LANG=c uscan | grep -qi 'Newer package available'; then
				new_version="$(env LANG=c uscan --no-download | grep 'Newest version of' | awk -F ', ' '{print $1}' | awk -F ' ' '{print $NF}')"
			fi
		else
			:
	fi
	git_sync_upstream
	git commit -m "Updated to ${new_version} (autobuild)" debian/changelog
	debian_changelog_new_entry
	check_fuzzy_po
}

ppa(){
	pushd debian
	./build-ppa.sh
	popd
}

git_push(){
	git push
}

local_test(){
	dpkg-buildpackage
	last_version="$(head -n 1 debian/changelog | tr -d "()" | awk -F ' ' '{print $2}')"
	sudo apt install ../*${pkg_name}*${last_version}*.deb -y && \
	if pulseeffects
		then return 0
		else return 1
	fi
	debian/rules clean
}

case "$1" in
	nv|nw|new_version )
		new_version
	;;
	ppa )
		ppa
	;;
	full )
		new_version
		if local_test; then
			ppa
			git_push
		fi
	;;
	lc|local_test )
		#new_version
		local_test
	;;
	check_fuzzy|check_fuzzy_po|cf )
		check_fuzzy_po
	;;
	* )
		echo "Current dir is: $(pwd) ."
		echo_help
	;;
esac