3
# Ruby script for generating tarball releases of the Plan repository
4
# This script can create signed tarballs with source code and translations.
5
# Documentation is not supported atm.
7
# (c) 2017 Dag Andersen <danders@get2net.dk>
8
# (c) 2016 Dag Andersen <danders@get2net.dk>
10
# Parts of this script is from create_tarball_kf5.rb, copyright by:
11
# (c) 2005 Mark Kretschmann <markey@web.de>
12
# (c) 2006-2008 Tom Albers <tomalbers@kde.nl>
13
# (c) 2007 Angelo Naselli <anaselli@linux.it> (command line parameters)
14
# Some parts of this code taken from cvs2dist
16
# License: GNU General Public License V2
23
# check command line parameters
24
options = OpenStruct.new
27
options.program = "gpg2"
28
options.translations = true
30
options.languages = []
31
options.branch = "trunk"
33
options.checkversion = true
38
opts = OptionParser.new do |opts|
39
opts.on_tail("-h", "--help", "Show this usage statement") do |h|
42
opts.on("-v", "--version <version>", "Package version (Default: no version)") do |v|
45
opts.on("-c", "--cstring <version string>", "Version string to check against version string in CMakeList.txt (Default: use version given in --version option)") do |c|
48
opts.on("-n", "--no-check", "Disable version check") do |n|
49
options.checkversion = false;
51
opts.on("-g", "--gittag <tag>", "Git tag (Default: 'HEAD')") do |g|
54
opts.on("-t", "--no-translations", "Do not include translations (Default: translations included)") do |t|
55
options.translations = false
57
opts.on("-b", "--branch", "Translation branch [trunk/stable] (Default: 'trunk')") do |t|
58
options.translations = false
60
# opts.on("-d", "--docs", "TODO Include documentation (Default: docs not included)") do |d|
62
#options.translations = true
64
opts.on("-s", "--no-sign", "Do not sign tarball (Default: tarball is signed)") do |s|
67
opts.on("-p", "--program <program>", "Which program to use for signing (Default: gpg2)") do |p|
70
opts.on("-l", "--languages <language,..>", "Include comma separated list of languages only (Default: All available languages)") do |l|
71
options.languages = l.split(/\s*,\s*/)
73
opts.on("-i", "--infolevel <level>", "Select amount of info to print during processing (0-2) (Default: 0)") do |i|
74
options.infolevel = i.to_i
93
############# START #############
97
if options.checkversion
98
if options.cstring.empty?
99
options.cstring = options.version
102
options.cstring = "No check"
106
puts "-> Processing " + app
107
puts " Git tag: #{options.tag}"
108
puts " Version: #{options.version}"
109
puts " Version check: #{options.cstring}"
110
puts " Signed: #{options.sign}"
111
puts " Program: #{options.program}"
112
puts " Translations: #{options.translations}"
113
puts " Branch: #{options.branch}"
115
if options.translations
116
if (options.languages.empty?)
119
puts "#{options.languages}"
122
# no translation, so no languages
126
# puts " Documentation: #{options.docs}"
129
print "Continue? [Y/n]: "
131
answer = answer.lstrip.rstrip.chomp
140
gitdir = "calligraplan"
142
gitdir += "-" + options.version
144
gittar = "#{gitdir}.tar.xz"
145
gitsig = "#{gittar}.sig"
146
sumsfile = "#{gittar}.sums"
148
puts "-- Create tarball of Calligra Plan: " + gittar
150
# clean up first, in case
151
calligradir = ".calligra"
152
`rm -rf #{calligradir} 2> /dev/null`
153
`rm -rf #{gitdir} 2> /dev/null`
154
if File.exist?(gittar)
157
if File.exist?(gitsig)
160
if File.exist?(sumsfile)
161
File.delete(sumsfile)
164
Dir.mkdir(calligradir)
165
Dir.chdir(calligradir)
166
puts "-> Fetching git archive tag=#{options.tag} .."
167
`git archive --remote git://anongit.kde.org/calligra.git #{options.tag} | tar -x`
170
# get plan and get rid of rest of calligra
171
`mv #{calligradir}/plan #{gitdir}`
172
`rm -rf #{calligradir}`
176
if !File.exist?("CMakeLists.txt")
178
puts "Failed: 'git archive' failed to fetch repository"
183
if options.checkversion
184
cversion=`grep '(PLAN_VERSION_STRING' CMakeLists.txt | cut -d'"' -f2`
185
cversion = cversion.delete("\n").delete("\r").strip
186
cstring = options.version
188
cstring = options.cstring
190
if cversion != cstring
192
puts "Failed: Specified version is not the same as in CMakeLists.txt"
193
puts " Specified version: '#{cstring}'"
194
puts " CMakeLists.txt : '#{cversion}'"
196
puts " Did you forget to update version in CMakeLists.txt?"
198
puts " You can disable this test with the option: --no-check"
205
if options.translations
207
svnbase = "svn+ssh://svn@svn.kde.org/home/kde"
209
if options.branch == "trunk"
210
svnroot = "#{svnbase}/trunk"
212
svnroot = "#{svnbase}/branches/stable"
216
puts "-> Fetching po file names .."
218
if FileTest.exist?("po_tmp")
222
pofilenames = "po_tmp/pofilenames"
223
`x=$(find $gitdir -name 'Messages.sh' | while read messagefile; do \
224
if grep -q '^potfilename=' $messagefile; then \
225
cat $messagefile | grep '^potfilename=' | cut -d'=' -f2 | cut -d'.' -f1; \
228
echo "$x" >#{pofilenames}`
230
if !File.size?(pofilenames)
231
puts "Failed: Could not fetch any po file names"
234
if options.infolevel > 0
235
c = `wc -l #{pofilenames} | cut -d' ' -f1`
236
puts " Number of po file names found: " + c
239
puts "-> Fetching translations .."
242
i18nlangs = `svn cat #{svnroot}/l10n-kf5/subdirs #{rev}`.split
243
i18nlangsCleaned = []
244
for lang in i18nlangs
246
if !options.languages.empty?
247
if options.languages.include?(l)
248
i18nlangsCleaned += [l]
250
else l != "x-test" && !i18nlangsCleaned.include?(l)
251
i18nlangsCleaned += [l]
254
i18nlangs = i18nlangsCleaned
256
if FileTest.exist?("po")
260
for lang in i18nlangs
262
tmp = "po_tmp/#{lang}"
265
# always checkout all po-files
266
print " -> Fetching #{lang} from repository ..\n"
267
pofolder = "l10n-kf5/#{lang}/messages/calligra"
268
if options.infolevel > 0
269
`svn co #{svnroot}/#{pofolder} #{tmp}`
271
`svn co #{svnroot}/#{pofolder} #{tmp} 2>/dev/null`
274
# copy over the po-files we actually use in calligraplan
275
File.foreach(pofilenames) do |pofile|
277
pofilepath = "#{tmp}/#{pofile}.po"
278
if !FileTest.exist?(pofilepath)
279
# all files have not always been translated
280
if options.infolevel > 1
281
puts " Skipping #{pofilepath} .."
285
if !FileTest.exist?(dest)
288
if FileTest.exist?(pofilepath)
289
if options.infolevel > 0
290
puts " Copying #{pofile}.po .."
292
`mv #{pofilepath} #{dest}`
296
# remove temporary po dir
299
# add l10n to compilation.
300
`echo "find_package(KF5I18n CONFIG REQUIRED)" >> CMakeLists.txt`
301
`echo "ki18n_install(po)" >> CMakeLists.txt`
304
# add docs to compilation.
305
`echo "find_package(KF5DocTools CONFIG REQUIRED)" >> CMakeLists.txt`
306
`echo "kdoctools_install(po)" >> CMakeLists.txt`
311
`find -name ".svn" | xargs rm -rf`
313
Dir.chdir( ".." ) # root folder
315
print "-> Compressing .. "
316
`tar -Jcf #{gittar} --group=root --owner=root #{gitdir}`
320
sums = File.open(sumsfile, 'w')
321
sums << "sha1sum : " << `sha1sum #{gittar}`
322
sums << "sha256sum: " << `sha256sum #{gittar}`
325
puts "-> Signing .. "
326
`#{options.program} -a --output #{gitsig} --detach-sign #{gittar}`
328
sums << "sha1sum : " << `sha1sum #{gitsig}`
329
sums << "sha256sum: " << `sha256sum #{gitsig}`
334
puts "Sums have been written too: #{sumsfile}"