2008-11-27 19:35:38 +00:00
|
|
|
=begin
|
|
|
|
***************************************************************************
|
2009-01-10 09:26:34 +00:00
|
|
|
* Copyright (C) 2008-2009 by Volker Lanz <vl@fidra.de> *
|
2008-11-27 19:35:38 +00:00
|
|
|
* Copyright (C) 2007-2008 by Harald Sitter <harald@getamarok.com> *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the *
|
|
|
|
* Free Software Foundation, Inc., *
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
|
|
|
|
***************************************************************************
|
|
|
|
=end
|
|
|
|
|
2008-11-28 15:01:31 +00:00
|
|
|
require 'application.rb'
|
2008-11-27 19:35:38 +00:00
|
|
|
require 'tagger.rb'
|
|
|
|
require 'translationstatsbuilder.rb'
|
|
|
|
require 'fileutils'
|
|
|
|
require 'getoptlong'
|
|
|
|
|
|
|
|
class ReleaseBuilder
|
2008-11-28 15:01:31 +00:00
|
|
|
|
|
|
|
public
|
2008-12-11 14:50:49 +00:00
|
|
|
def initialize(app, workingDir, repository, version)
|
|
|
|
@app = app
|
2008-11-27 19:35:38 +00:00
|
|
|
@workingDir = workingDir
|
|
|
|
@repository = repository
|
|
|
|
@version = version
|
2008-11-28 15:01:31 +00:00
|
|
|
|
|
|
|
@outputDir = "#{@app.name}-#{@version}"
|
|
|
|
|
2008-11-27 19:35:38 +00:00
|
|
|
FileUtils.rm_rf @outputDir
|
|
|
|
FileUtils.rm_rf "#{@outputDir}.tar.bz2"
|
|
|
|
end
|
|
|
|
|
2008-12-11 14:50:49 +00:00
|
|
|
def run(protocol, user, createTarball, getTranslations, skipBelow, getDocs, createTag, applyFixes)
|
2008-11-27 19:35:38 +00:00
|
|
|
checkoutSource
|
2008-11-28 16:28:17 +00:00
|
|
|
translations = checkoutTranslations(skipBelow) if getTranslations
|
2008-11-27 19:35:38 +00:00
|
|
|
docs = checkoutDocumentation if getDocs
|
|
|
|
|
|
|
|
if createTag
|
2009-01-10 10:44:48 +00:00
|
|
|
repositoryTags = ReleaseBuilder.repository(@app, protocol, user, @version)
|
2008-11-28 15:01:31 +00:00
|
|
|
tagger = Tagger.new(@repository, repositoryTags, @app, @version)
|
2008-11-27 19:35:38 +00:00
|
|
|
tagger.tagSource
|
|
|
|
tagger.tagTranslations(translations)
|
|
|
|
tagger.tagDocumentation(docs)
|
|
|
|
end
|
2008-12-11 14:50:49 +00:00
|
|
|
|
|
|
|
@app.applyFixes(@workingDir, @outputDir) if applyFixes
|
2008-11-27 19:35:38 +00:00
|
|
|
|
|
|
|
self.createTarball if createTarball
|
|
|
|
end
|
|
|
|
|
|
|
|
def checkoutSource
|
|
|
|
Dir.chdir @workingDir
|
2008-11-28 15:01:31 +00:00
|
|
|
svnDir = "#{@app.component}/#{@app.section}/#{@app.name}"
|
2008-11-27 19:35:38 +00:00
|
|
|
|
|
|
|
puts "Checking out source from #{@repository}/#{svnDir}..."
|
|
|
|
|
|
|
|
system "svn co #{@repository}/#{svnDir} #{@outputDir} >/dev/null 2>&1"
|
|
|
|
end
|
|
|
|
|
2008-11-28 16:28:17 +00:00
|
|
|
def checkoutTranslations(skipBelow)
|
2008-11-27 19:35:38 +00:00
|
|
|
Dir.chdir "#{@workingDir}/#{@outputDir}"
|
|
|
|
|
|
|
|
FileUtils.rm_rf 'l10n'
|
|
|
|
FileUtils.rm_rf 'po'
|
|
|
|
|
|
|
|
Dir.mkdir 'l10n'
|
|
|
|
Dir.mkdir 'po'
|
|
|
|
|
|
|
|
subdirs = `svn cat #{@repository}/l10n-kde4/subdirs 2>/dev/null`.chomp!
|
|
|
|
translations = []
|
|
|
|
|
|
|
|
subdirs.each do |lang|
|
|
|
|
lang.chomp!
|
|
|
|
next if lang == 'x-test'
|
|
|
|
|
|
|
|
FileUtils.rm_rf 'l10n'
|
2008-11-28 15:01:31 +00:00
|
|
|
system "svn co #{@repository}/l10n-kde4/#{lang}/messages/#{@app.component}-#{@app.section} l10n >/dev/null 2>&1"
|
|
|
|
next unless FileTest.exists? "l10n/#{@app.name}.po"
|
2008-11-27 19:35:38 +00:00
|
|
|
|
2008-11-28 16:28:17 +00:00
|
|
|
if skipBelow > 0
|
|
|
|
fuzzy, untranslated, per = TranslationStatsBuilder.fileStats("l10n/#{@app.name}.po")
|
|
|
|
puts "Language #{lang} is #{per} % complete."
|
|
|
|
next if per < skipBelow
|
|
|
|
end
|
|
|
|
|
2008-11-27 19:35:38 +00:00
|
|
|
puts "Adding translations for #{lang}..."
|
|
|
|
|
|
|
|
dest = "po/#{lang}"
|
|
|
|
Dir.mkdir dest
|
|
|
|
|
2008-11-28 15:01:31 +00:00
|
|
|
FileUtils.mv("l10n/#{@app.name}.po", dest)
|
2008-11-27 19:35:38 +00:00
|
|
|
FileUtils.mv('l10n/.svn', dest)
|
|
|
|
|
|
|
|
File.open("#{dest}/CMakeLists.txt", File::CREAT | File::RDWR | File::TRUNC) do |f|
|
|
|
|
f.print <<END_OF_TEXT
|
|
|
|
file(GLOB _po_files *.po)
|
|
|
|
GETTEXT_PROCESS_PO_FILES(#{lang} ALL INSTALL_DESTINATION ${LOCALE_INSTALL_DIR} ${_po_files})
|
|
|
|
END_OF_TEXT
|
|
|
|
end
|
|
|
|
|
|
|
|
system "svn add #{dest}/CMakeLists.txt >/dev/null 2>&1"
|
2008-11-28 15:01:31 +00:00
|
|
|
translations << lang
|
2008-11-27 19:35:38 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
if translations.length > 0
|
|
|
|
File.open('po/CMakeLists.txt', File::CREAT | File::RDWR | File::TRUNC) do |f|
|
|
|
|
f.print <<END_OF_TEXT
|
|
|
|
|
|
|
|
find_package(Gettext REQUIRED)
|
|
|
|
|
|
|
|
if (NOT GETTEXT_MSGMERGE_EXECUTABLE)
|
|
|
|
message(FATAL_ERROR "Please install the msgmerge program from the gettext package.")
|
|
|
|
endif (NOT GETTEXT_MSGMERGE_EXECUTABLE)
|
|
|
|
|
|
|
|
if (NOT GETTEXT_MSGFMT_EXECUTABLE)
|
|
|
|
message(FATAL_ERROR "Please install the msgfmt program from the gettext package.")
|
|
|
|
endif (NOT GETTEXT_MSGFMT_EXECUTABLE)
|
|
|
|
|
|
|
|
END_OF_TEXT
|
|
|
|
|
|
|
|
translations.each { |lang| f.print "add_subdirectory(#{lang})\n" }
|
|
|
|
end
|
|
|
|
|
|
|
|
File.open('CMakeLists.txt', File::APPEND | File::RDWR) do |f|
|
|
|
|
f.print <<END_OF_TEXT
|
|
|
|
include(MacroOptionalAddSubdirectory)
|
|
|
|
macro_optional_add_subdirectory(po)
|
|
|
|
END_OF_TEXT
|
|
|
|
end
|
|
|
|
|
2008-11-28 15:01:31 +00:00
|
|
|
TranslationStatsBuilder.new(@app.name, @version, @workingDir, @outputDir).run
|
2008-11-27 19:35:38 +00:00
|
|
|
else
|
|
|
|
FileUtils.rm_rf 'po'
|
|
|
|
end
|
|
|
|
|
|
|
|
FileUtils.rm_rf 'l10n'
|
|
|
|
|
|
|
|
return translations
|
|
|
|
end
|
|
|
|
|
|
|
|
def checkoutDocumentation
|
|
|
|
Dir.chdir "#{@workingDir}/#{@outputDir}"
|
|
|
|
|
2008-11-28 15:01:31 +00:00
|
|
|
system "svn co #{@repository}/#{@app.component}/#{@app.section}/doc/#{@app.name} doc/en_US >/dev/null 2>&1"
|
2008-11-27 19:35:38 +00:00
|
|
|
|
|
|
|
if not File.exists? 'doc/en_US/index.docbook'
|
|
|
|
FileUtils.rm_rf 'doc'
|
|
|
|
return nil
|
|
|
|
end
|
|
|
|
|
|
|
|
File.open("doc/en_US/CMakeLists.txt", File::CREAT | File::RDWR | File::TRUNC) do |f|
|
2008-11-28 15:01:31 +00:00
|
|
|
f << "kde4_create_handbook(index.docbook INSTALL_DESTINATION \${HTML_INSTALL_DIR}/en_US/ SUBDIR #{@app.name})\n"
|
2008-11-27 19:35:38 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
docs = [ "en_US" ]
|
|
|
|
|
|
|
|
subdirs = `svn cat #{@repository}/l10n-kde4/subdirs 2>/dev/null`.chomp!
|
|
|
|
|
|
|
|
subdirs.each do |lang|
|
|
|
|
lang.chomp!
|
|
|
|
|
|
|
|
FileUtils.rm_rf 'l10n'
|
2008-11-28 15:01:31 +00:00
|
|
|
system "svn co #{@repository}/l10n-kde4/#{lang}/docs/#{@app.component}-#{@app.section}/#{@app.name} l10n >/dev/null 2>&1"
|
2008-11-27 19:35:38 +00:00
|
|
|
next unless FileTest.exists? 'l10n/index.docbook'
|
|
|
|
|
|
|
|
puts "Adding documentation for #{lang}..."
|
|
|
|
|
|
|
|
dest = "doc/#{lang}"
|
|
|
|
FileUtils.mv('l10n', dest)
|
|
|
|
|
|
|
|
File.open("doc/#{lang}/CMakeLists.txt", File::CREAT | File::RDWR | File::TRUNC) do |f|
|
2008-11-28 15:01:31 +00:00
|
|
|
f << "kde4_create_handbook(index.docbook INSTALL_DESTINATION \${HTML_INSTALL_DIR}/#{lang}/ SUBDIR #{@app.name})\n"
|
2008-11-27 19:35:38 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
system "svn add doc/#{lang}/CMakeLists.txt >/dev/null 2>&1"
|
2008-11-28 15:01:31 +00:00
|
|
|
docs << lang
|
2008-11-27 19:35:38 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
File.open('doc/CMakeLists.txt', File::CREAT | File::RDWR | File::TRUNC) do |f|
|
|
|
|
docs.each { |lang| f << "add_subdirectory(#{lang})\n" }
|
|
|
|
end
|
|
|
|
|
|
|
|
File.open('CMakeLists.txt', File::APPEND | File::RDWR) do |f|
|
|
|
|
f << "include(MacroOptionalAddSubdirectory)\n" unless File.exists? 'po'
|
|
|
|
f << "macro_optional_add_subdirectory(doc)\n"
|
|
|
|
end
|
|
|
|
|
|
|
|
FileUtils.rm_rf 'l10n'
|
|
|
|
|
|
|
|
return docs
|
|
|
|
end
|
|
|
|
|
|
|
|
def createTarball
|
|
|
|
Dir.chdir @workingDir
|
|
|
|
|
|
|
|
tarFileName = "#{@outputDir}.tar.bz2"
|
2008-12-11 14:50:49 +00:00
|
|
|
|
2008-11-27 19:35:38 +00:00
|
|
|
system "find #{@outputDir} -name .svn | xargs rm -rf"
|
|
|
|
system "tar cfj #{tarFileName} #{@outputDir}"
|
|
|
|
|
|
|
|
FileUtils.rm_rf @outputDir
|
|
|
|
|
|
|
|
puts "MD5: " + `md5sum #{tarFileName}`.split[0]
|
|
|
|
puts "SHA1: " + `sha1sum #{tarFileName}`.split[0]
|
|
|
|
end
|
|
|
|
|
2008-12-11 14:50:49 +00:00
|
|
|
def self.repository(app, protocol, user, tag)
|
2008-11-27 19:35:38 +00:00
|
|
|
if protocol == 'anonsvn'
|
|
|
|
protocol = 'svn'
|
|
|
|
user = 'anon'
|
|
|
|
else
|
|
|
|
user += "@"
|
|
|
|
end
|
|
|
|
|
|
|
|
if tag == 'stable'
|
|
|
|
branch = 'branches/stable'
|
|
|
|
elsif tag == 'trunk'
|
|
|
|
branch = 'trunk'
|
|
|
|
else
|
2008-12-11 14:50:49 +00:00
|
|
|
branch = "tags/#{app.name}/#{tag}"
|
2008-11-27 19:35:38 +00:00
|
|
|
end
|
|
|
|
|
2008-12-11 16:24:31 +00:00
|
|
|
# return "file://localhost/home/vl/tmp/svn/#{branch}"
|
|
|
|
return "#{protocol}://#{user}svn.kde.org/home/kde/#{branch}"
|
2008-11-27 19:35:38 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|