Add new class to represent an application.

More command line options to turn on and off switches. Also, let the user
specify an application name ("partitionmanager") or product name ("Partition
Manager").

Use proper syntax to append to arrays.

svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=890194
This commit is contained in:
Volker Lanz 2008-11-28 15:01:31 +00:00
parent 69cf01c7fb
commit 222f0e321c
5 changed files with 151 additions and 68 deletions

View File

@ -0,0 +1,30 @@
=begin
***************************************************************************
* Copyright (C) 2008 by Volker Lanz <vl@fidra.de> *
* *
* 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
class Application
attr_reader :product, :component, :section, :name
def initialize(product, component, section, name)
@product = product
@component = component
@section = section
@name = name
end
end

View File

@ -20,27 +20,32 @@
***************************************************************************
=end
Apps = {
'Amarok' => [ 'amarok2', 'extragear', 'multimedia' ],
'Digikam' => [ 'digikam', 'extragear', 'graphics' ],
'Partition Manager' => [ 'partitionmanager', 'extragear', 'sysadmin' ]
}
require 'application.rb'
require 'tagger.rb'
require 'translationstatsbuilder.rb'
require 'fileutils'
require 'getoptlong'
class ReleaseBuilder
def initialize(workingDir, repository, component, section, appName, version)
private
Apps = [
Application.new('Amarok', 'extragear', 'multimedia', 'amarok'),
Application.new('Digikam', 'extragear', 'graphics', 'digikam'),
Application.new('Partition Manager', 'extragear', 'sysadmin', 'partitionmanager')
]
public
def initialize(workingDir, repository, product, version)
@workingDir = workingDir
@repository = repository
@component = component
@section = section
@appName = appName
@version = version
@outputDir = "#{@appName}-#{@version}"
@app = ReleaseBuilder.findAppByProduct(product)
if not @app then raise "Product #{product} not found" end
@outputDir = "#{@app.name}-#{@version}"
FileUtils.rm_rf @outputDir
FileUtils.rm_rf "#{@outputDir}.tar.bz2"
end
@ -51,8 +56,8 @@ class ReleaseBuilder
docs = checkoutDocumentation if getDocs
if createTag
repositoryTags = ReleaseBuilder.repository(@appName, protocol, user, @version)
tagger = Tagger.new(@repository, repositoryTags, @component, @section, @appName, @version)
repositoryTags = ReleaseBuilder.repository(@app.product, protocol, user, @version)
tagger = Tagger.new(@repository, repositoryTags, @app, @version)
tagger.tagSource
tagger.tagTranslations(translations)
tagger.tagDocumentation(docs)
@ -63,7 +68,7 @@ class ReleaseBuilder
def checkoutSource
Dir.chdir @workingDir
svnDir = "#{@component}/#{@section}/#{@appName}"
svnDir = "#{@app.component}/#{@app.section}/#{@app.name}"
puts "Checking out source from #{@repository}/#{svnDir}..."
@ -87,15 +92,15 @@ class ReleaseBuilder
next if lang == 'x-test'
FileUtils.rm_rf 'l10n'
system "svn co #{@repository}/l10n-kde4/#{lang}/messages/#{@component}-#{@section} l10n >/dev/null 2>&1"
next unless FileTest.exists? "l10n/#{@appName}.po"
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"
puts "Adding translations for #{lang}..."
dest = "po/#{lang}"
Dir.mkdir dest
FileUtils.mv("l10n/#{@appName}.po", dest)
FileUtils.mv("l10n/#{@app.name}.po", dest)
FileUtils.mv('l10n/.svn', dest)
File.open("#{dest}/CMakeLists.txt", File::CREAT | File::RDWR | File::TRUNC) do |f|
@ -106,7 +111,7 @@ END_OF_TEXT
end
system "svn add #{dest}/CMakeLists.txt >/dev/null 2>&1"
translations += [lang]
translations << lang
end
if translations.length > 0
@ -135,7 +140,7 @@ macro_optional_add_subdirectory(po)
END_OF_TEXT
end
TranslationStatsBuilder.new(@appName, @version, @workingDir, @outputDir).run
TranslationStatsBuilder.new(@app.name, @version, @workingDir, @outputDir).run
else
FileUtils.rm_rf 'po'
end
@ -148,7 +153,7 @@ END_OF_TEXT
def checkoutDocumentation
Dir.chdir "#{@workingDir}/#{@outputDir}"
system "svn co #{@repository}/#{@component}/#{@section}/doc/#{@appName} doc/en_US >/dev/null 2>&1"
system "svn co #{@repository}/#{@app.component}/#{@app.section}/doc/#{@app.name} doc/en_US >/dev/null 2>&1"
if not File.exists? 'doc/en_US/index.docbook'
FileUtils.rm_rf 'doc'
@ -156,7 +161,7 @@ END_OF_TEXT
end
File.open("doc/en_US/CMakeLists.txt", File::CREAT | File::RDWR | File::TRUNC) do |f|
f << "kde4_create_handbook(index.docbook INSTALL_DESTINATION \${HTML_INSTALL_DIR}/en_US/ SUBDIR #{@appName})\n"
f << "kde4_create_handbook(index.docbook INSTALL_DESTINATION \${HTML_INSTALL_DIR}/en_US/ SUBDIR #{@app.name})\n"
end
docs = [ "en_US" ]
@ -167,7 +172,7 @@ END_OF_TEXT
lang.chomp!
FileUtils.rm_rf 'l10n'
system "svn co #{@repository}/l10n-kde4/#{lang}/docs/#{@component}-#{@section}/#{@appName} l10n >/dev/null 2>&1"
system "svn co #{@repository}/l10n-kde4/#{lang}/docs/#{@app.component}-#{@app.section}/#{@app.name} l10n >/dev/null 2>&1"
next unless FileTest.exists? 'l10n/index.docbook'
puts "Adding documentation for #{lang}..."
@ -176,11 +181,11 @@ END_OF_TEXT
FileUtils.mv('l10n', dest)
File.open("doc/#{lang}/CMakeLists.txt", File::CREAT | File::RDWR | File::TRUNC) do |f|
f << "kde4_create_handbook(index.docbook INSTALL_DESTINATION \${HTML_INSTALL_DIR}/#{lang}/ SUBDIR #{@appName})\n"
f << "kde4_create_handbook(index.docbook INSTALL_DESTINATION \${HTML_INSTALL_DIR}/#{lang}/ SUBDIR #{@app.name})\n"
end
system "svn add doc/#{lang}/CMakeLists.txt >/dev/null 2>&1"
docs += [lang]
docs << lang
end
File.open('doc/CMakeLists.txt', File::CREAT | File::RDWR | File::TRUNC) do |f|
@ -211,7 +216,9 @@ END_OF_TEXT
puts "SHA1: " + `sha1sum #{tarFileName}`.split[0]
end
def self.repository(appName, protocol, user, tag)
def self.repository(product, protocol, user, tag)
appName = findAppByProduct(product).name
if protocol == 'anonsvn'
protocol = 'svn'
user = 'anon'
@ -227,12 +234,42 @@ END_OF_TEXT
branch = "tags/#{appName}/#{tag}"
end
# return "file://localhost/home/vl/tmp/svn/#{branch}"
return "#{protocol}://#{user}svn.kde.org/home/kde/#{branch}"
return "file://localhost/home/vl/tmp/svn/#{branch}"
# return "#{protocol}://#{user}svn.kde.org/home/kde/#{branch}"
end
def self.apps
return Apps
end
def self.sortedProducts
rval = []
Apps.each { |a| rval << a.product }
return rval.sort
end
def self.sortedAppNames
rval = []
Apps.each { |a| rval << a.name }
return rval.sort
end
def self.findAppByProduct(product)
Apps.each do |a|
if a.product == product
return a
end
end
return nil
end
def self.findAppByName(name)
Apps.each do |a|
if a.name == name
return a
end
end
return nil
end
end

View File

@ -26,23 +26,30 @@ def usage
puts <<END_OF_TEXT
#{$0} [options]
where options are:
--application-name (-a)*
--version (-v)*
--checkout-from (-c): trunk, stable, tag
--product-name (-p)
--application-name (-a)
--version (-v)
--checkout-from (-c): trunk (default), stable, tag
--tag (-t): name of tag
--svn-access (-s): (https, svn+ssh, anonsvn)
--get-docs (-d): also get documentation
--get-translations (-r): also get translations
--svn-access (-s): https, svn+ssh, anonsvn (default)
--get-docs (-d): also get documentation (default)
--no-get-docs (-D): do not get documentation
--get-translations (-r): also get translations (default)
--no-get-translations (-R): do not get translations
--create-tag (-e): create a new tag
--create-tarball (-b): create a tarball
--no-create-tag (-E): do not create a new tag (default)
--create-tarball (-b): create a tarball (default)
--no-create-tarball (-B): do not create a tarball
--help (-h): show this usage
Options with an asterisk are required.
Possible values for application-name:
Possible values for product-name:
END_OF_TEXT
ReleaseBuilder.apps.sort.each { |a| puts '"' + a[0] + '"' }
ReleaseBuilder.sortedProducts.each { |p| puts ' "' + p + '"' }
puts 'Possible values for application-name:'
ReleaseBuilder.sortedAppNames.each { |a| puts ' "' + a + '"' }
end
opts = GetoptLong.new(
[ '--product-name', '-p', GetoptLong::REQUIRED_ARGUMENT ],
[ '--application-name', '-a', GetoptLong::REQUIRED_ARGUMENT ],
[ '--version', '-v', GetoptLong::REQUIRED_ARGUMENT ],
[ '--checkout-from', '-c', GetoptLong::REQUIRED_ARGUMENT ],
@ -50,25 +57,31 @@ opts = GetoptLong.new(
[ '--svn-access', '-s', GetoptLong::REQUIRED_ARGUMENT ],
[ '--svn-user', '-u', GetoptLong::REQUIRED_ARGUMENT ],
[ '--get-docs', '-d', GetoptLong::NO_ARGUMENT ],
[ '--no-get-docs', '-D', GetoptLong::NO_ARGUMENT ],
[ '--get-translations', '-r', GetoptLong::NO_ARGUMENT ],
[ '--no-get-translations', '-R', GetoptLong::NO_ARGUMENT ],
[ '--create-tag', '-e', GetoptLong::NO_ARGUMENT ],
[ '--no-create-tag', '-E', GetoptLong::NO_ARGUMENT ],
[ '--create-tarball', '-b', GetoptLong::NO_ARGUMENT ],
[ '--np-create-tarball', '-B', GetoptLong::NO_ARGUMENT ],
[ '--help', '-h', GetoptLong::NO_ARGUMENT ]
)
appName = ''
version = ''
productName = nil
appName = nil
version = nil
checkoutFrom = 'trunk'
tag = ''
protocol = 'anonsvn'
user = ''
getDocs = false
getTranslations = false
getDocs = true
getTranslations = true
createTag = false
createTarball = false
createTarball = true
opts.each do |opt, arg|
case opt
when '--product-name' then productName = arg
when '--application-name' then appName = arg
when '--version' then version = arg
when '--checkout-from' then checkoutFrom = arg
@ -76,25 +89,35 @@ opts.each do |opt, arg|
when '--svn-access' then protocol = arg
when '--svn-user' then user = arg
when '--get-docs' then getDocs = true
when '--no-get-docs' then getDocs = false
when '--get-translations' then getTranslations = true
when '--no-get-translations' then getTranslations = false
when '--create-tag' then createTag = true
when '--no-create-tag' then createTag = false
when '--create-tarball' then createTarball = true
when '--no-create-tarball' then createTarball = false
when '--help' then usage; exit
end
end
if appName.empty? or version.empty?
puts "Application and version can not be empty."
if not productName and not appName
puts "You must either specify a product name or an application name."
exit
end
if not ReleaseBuilder.apps.key?(appName)
puts "Unknown application '#{appName}'"
if not version
puts "Version can not be empty."
exit
end
app = productName ? ReleaseBuilder.findAppByProduct(productName) : ReleaseBuilder.findAppByName(appName)
if not app
puts "Could not find product."
exit
end
if protocol != 'anonsvn' and user.empty?
puts "The selected SVN access protocol requires a user name."
puts "The SVN protocol '#{protocol}' requires a user name."
exit
end
@ -103,11 +126,8 @@ if checkoutFrom == 'tag' and tag.empty?
exit
end
component = ReleaseBuilder.apps[appName][1]
section = ReleaseBuilder.apps[appName][2]
repository = ReleaseBuilder.repository(app.product, protocol, user, checkoutFrom != 'tag' ? checkoutFrom : tag)
repository = ReleaseBuilder.repository(ReleaseBuilder.apps[appName][0], protocol, user, checkoutFrom != 'tag' ? checkoutFrom : tag)
releaseBuilder = ReleaseBuilder.new(Dir.getwd, repository, component, section, ReleaseBuilder.apps[appName][0], version)
releaseBuilder = ReleaseBuilder.new(Dir.getwd, repository, app.product, version)
releaseBuilder.run(protocol, user, createTarball, getTranslations, getDocs, createTag)

View File

@ -41,7 +41,7 @@ class ReleaseDialog < Qt::Dialog
@ui = Ui_ReleaseDialog.new()
@ui.setupUi(self)
ReleaseBuilder.apps.sort.each { |key, value| @ui.comboName.addItem(key) }
ReleaseBuilder.sortedProducts.each { |key, value| @ui.comboName.addItem(key) }
end
def validate
@ -61,14 +61,9 @@ class ReleaseDialog < Qt::Dialog
def accept
return if not validate
component = ReleaseBuilder.apps[@ui.comboName.currentText][1]
section = ReleaseBuilder.apps[@ui.comboName.currentText][2]
appName = ReleaseBuilder.apps[@ui.comboName.currentText][0]
version = @ui.editVersion.text
repository = ReleaseBuilder.repository(@ui.comboName.currentText, @ui.comboAccess.currentText, @ui.editUser.text, @ui.comboCheckout.currentText != 'tag' ? @ui.comboCheckout.currentText : @ui.comboTag.currentText)
repository = ReleaseBuilder.repository(ReleaseBuilder.apps[@ui.comboName.currentText][0], @ui.comboAccess.currentText, @ui.editUser.text, @ui.comboCheckout.currentText != 'tag' ? @ui.comboCheckout.currentText : @ui.comboTag.currentText)
releaseBuilder = ReleaseBuilder.new(Dir.getwd, repository, component, section, appName, version)
releaseBuilder = ReleaseBuilder.new(Dir.getwd, repository, @ui.comboName.currentText, @ui.editVersion.text)
releaseBuilder.run(@ui.comboAccess.currentText, @ui.editUser.text, @ui.checkTarball.isChecked, @ui.checkTranslations.isChecked, @ui.checkDocs.isChecked, @ui.checkTag.isChecked)
super
@ -91,10 +86,10 @@ private
def updateTags
@ui.comboTag.clear
appName = ReleaseBuilder.apps[@ui.comboName.currentText][0]
appName = ReleaseBuilder.findAppByProduct(@ui.comboName.currentText).name
# tags = `svn ls file://localhost/home/vl/tmp/svn/tags/#{appName}`.chomp!
tags = `svn ls svn://anonsvn.kde.org/home/kde/tags/#{appName}`.chomp!
tags = `svn ls file://localhost/home/vl/tmp/svn/tags/#{appName}`.chomp!
# tags = `svn ls svn://anonsvn.kde.org/home/kde/tags/#{appName}`.chomp!
return false if not tags or tags.length == 0

View File

@ -21,12 +21,13 @@
=end
require 'fileutils'
require 'application.rb'
class Tagger
def initialize(repositorySource, repositoryTag, component, section, appName, version)
@appName = appName
def initialize(repositorySource, repositoryTag, app, version)
@app = app
@version = version
@repositorySource = "#{repositorySource}/#{component}/#{section}/#{@appName}"
@repositorySource = "#{repositorySource}/#{@app.component}/#{@app.section}/#{@app.name}"
@repositoryTag = repositoryTag
@tmpDirName = 'tagging_dir'
end
@ -49,7 +50,7 @@ class Tagger
translations.each do |trans|
system "svn mkdir #{@tmpDirName}/po/#{trans} >/dev/null 2>&1 >/dev/null 2>&1"
system "svn cp po/#{trans}/#{@appName}.po #{@tmpDirName}/po/#{trans}/ >/dev/null 2>&1"
system "svn cp po/#{trans}/#{@app.name}.po #{@tmpDirName}/po/#{trans}/ >/dev/null 2>&1"
end
system "svn ci -m 'Tag translations for #{@version}' #{@tmpDirName}/po >/dev/null 2>&1"