Revert previous commit, was incorrect
[amarok.git] / release_scripts / release_amarok.rb
blob64756d6ab03fb1b7fcc0df2f75d3d82ea0697d93
1 #!/usr/bin/env ruby
3 # Ruby script for generating Amarok tarball releases from KDE SVN
5 # (C) 2006-2007 Harald Sitter <sitter.harald@gmail.com>
6 # (C) 2005 Mark Kretschmann <kretschmann@kde.org>
7 # Some parts of this code taken from cvs2dist
8 # License: GNU General Public License V2
10 require 'fileutils'
12 tag             = nil
13 useStableBranch = false
15 # Ask whether using branch or trunk
16 location = `kdialog --combobox "Select checkout's place:" "Trunk" "Stable" "Tag"`.chomp()
17 if location == "Tag"
18   tag = `kdialog --inputbox "Enter tag name: "`.chomp()
19 elsif location == "Stable"
20   useStableBranch = true
21 end
23 # Ask user for targeted application version
24 if tag and not tag.empty?()
25   version = tag
26 else
27   version  = `kdialog --inputbox "Enter Amarok version: "`.chomp()
28 end
30 user     = `kdialog --inputbox "Your SVN user:"`.chomp()
31 protocol = `kdialog --radiolist "Do you use https or svn+ssh?" https https 0 "svn+ssh" "svn+ssh" 1`.chomp()
33 name         = "amarok"
34 folder       = "amarok-#{version}"
35 l10n_branch  = true
38 # Prevent using unsermake
39 oldmake = ENV["UNSERMAKE"]
40 ENV["UNSERMAKE"] = "no"
43 # Remove old folder, if exists
44 FileUtils.rm_rf( folder )
45 FileUtils.rm_rf( "#{folder}.tar.bz2" )
47 Dir.mkdir( folder )
48 Dir.chdir( folder )
50 branch="trunk"
52 if useStableBranch
53   branch = "branches/stable/"
54   `svn co -N #{protocol}://#{user}@svn.kde.org/home/kde/#{branch}/extragear/multimedia/`
55   Dir.chdir( "multimedia" )
56 elsif not tag.empty?()
57   l10n = `kdialog --combobox "Get translation from:" "Trunk" "Stable" "Not at all"`.chomp()
58   if l10n == "Trunk"
59     l10n_branch = "trunk"
60   elsif l10n == "Stable"
61     l10n_branch = "branches/stable/"
62   else
63     l10n_branch = nil
64   end
65   `svn co -N #{protocol}://#{user}@svn.kde.org/home/kde/#{branch}/extragear/multimedia`
66   Dir.chdir( "multimedia" )
67 else
68   `svn co -N #{protocol}://#{user}@svn.kde.org/home/kde/trunk/extragear/multimedia`
69   Dir.chdir( "multimedia" )
70 end
72 `svn up amarok`
73 `svn up -N doc`
74 `svn up doc/amarok`
75 `svn co #{protocol}://#{user}@svn.kde.org/home/kde/branches/KDE/3.5/kde-common/admin`
78 unless l10n_branch == nil
79   unless l10n_branch == true
80     branch = l10n_branch
81   end
82   puts "\n"
83   puts "**** l10n ****"
84   puts "\n"
86   i18nlangs = `svn cat #{protocol}://#{user}@svn.kde.org/home/kde/#{branch}/l10n/subdirs`
87   Dir.mkdir( "l10n" )
88   Dir.chdir( "l10n" )
90   # docs
91   for lang in i18nlangs
92     lang.chomp!()
93     FileUtils.rm_rf( "../doc/#{lang}" )
94     FileUtils.rm_rf( name )
95     docdirname = "l10n/#{lang}/docs/extragear-multimedia/amarok"
96     `svn co -q #{protocol}://#{user}@svn.kde.org/home/kde/#{branch}/#{docdirname} > /dev/null 2>&1`
97     next unless FileTest.exists?( "amarok" )
98     print "Copying #{lang}'s #{name} documentation over..  "
99     `cp -R amarok/ ../doc/#{lang}`
101     # we don't want KDE_DOCS = AUTO, cause that makes the
102     # build system assume that the name of the app is the
103     # same as the name of the dir the Makefile.am is in.
104     # Instead, we explicitly pass the name..
105     makefile = File.new( "../doc/#{lang}/Makefile.am", File::CREAT | File::RDWR | File::TRUNC )
106     makefile << "KDE_LANG = #{lang}\n"
107     makefile << "KDE_DOCS = #{name}\n"
108     makefile.close()
110     puts( "done.\n" )
111   end
113   Dir.chdir( ".." ) # multimedia
114   puts "\n"
116   $subdirs = false
117   Dir.mkdir( "po" )
119   for lang in i18nlangs
120     lang.chomp!()
121     pofilename = "l10n/#{lang}/messages/extragear-multimedia/amarok.po"
122     `svn cat #{protocol}://#{user}@svn.kde.org/home/kde/#{branch}/#{pofilename} 2> /dev/null | tee l10n/amarok.po`
123     next if FileTest.size( "l10n/amarok.po" ) == 0
125     dest = "po/#{lang}"
126     Dir.mkdir( dest )
127     print "Copying #{lang}'s #{name}.po over ..  "
128     FileUtils.mv( "l10n/amarok.po", dest )
129     puts( "done.\n" )
131     makefile = File.new( "#{dest}/Makefile.am", File::CREAT | File::RDWR | File::TRUNC )
132     makefile << "KDE_LANG = #{lang}\n"
133     makefile << "SUBDIRS  = $(AUTODIRS)\n"
134     makefile << "POFILES  = AUTO\n"
135     makefile.close()
137     $subdirs = true
138   end
140   if $subdirs
141     makefile = File.new( "po/Makefile.am", File::CREAT | File::RDWR | File::TRUNC )
142     makefile << "SUBDIRS = $(AUTODIRS)\n"
143     makefile.close()
144     # Remove xx language
145     FileUtils.rm_rf( "po/xx" )
146   else
147     FileUtils.rm_rf( "po" )
148   end
150   FileUtils.rm_rf( "l10n" )
153 puts "\n"
156 # Remove SVN data folder
157 `find -name ".svn" | xargs rm -rf`
159 # TODO: what is this supposed to do, why did we include it, and does the script
160 #       actually work without it?
161 # if useStableBranch
162 #     `svn co -N #{protocol}://#{user}@svn.kde.org/home/kde/trunk/extragear/multimedia`
163 #     `mv multimedia/* .`
164 #     FileUtils.rm_rf( "multimedia" )
165 # end
167 Dir.chdir( "amarok" )
169 # Move some important files to the root folder
170 FileUtils.mv( "AUTHORS", ".." )
171 FileUtils.mv( "ChangeLog", ".." )
172 FileUtils.mv( "COPYING", ".." )
173 FileUtils.mv( "COPYING.LGPL", ".." )
174 FileUtils.mv( "COPYING-DOCS", ".." )
175 FileUtils.mv( "INSTALL", ".." )
176 FileUtils.mv( "README", ".." )
177 FileUtils.mv( "TODO", ".." )
179 # This stuff doesn't belong in the tarball
180 FileUtils.rm_rf( "release_scripts" )
181 FileUtils.rm_rf( "src/engine/gst10" ) #Removed for now
182 FileUtils.rm_rf( "supplementary_scripts" )
184 Dir.chdir( "src" )
186 # Exchange APP_VERSION string with targeted version
187 file = File.new( "amarok.h", File::RDWR )
188 str = file.read()
189 file.rewind()
190 file.truncate( 0 )
191 str.sub!( /APP_VERSION \".*\"/, "APP_VERSION \"#{version}\"" )
192 file << str
193 file.close()
196 Dir.chdir( ".." ) # amarok
197 Dir.chdir( ".." ) # multimedia
198 puts( "\n" )
200 `find | xargs touch`
201 puts "**** Generating Makefiles..  "
202 `make -f Makefile.cvs`
203 puts "done.\n"
205 FileUtils.rm_rf( "autom4te.cache" )
206 FileUtils.rm_rf( "stamp-h.in" )
209 puts "**** Compressing..  "
210 `mv * ..`
211 Dir.chdir( ".." ) # Amarok-foo
212 FileUtils.rm_rf( "multimedia" )
213 Dir.chdir( ".." ) # root folder
214 `tar -cf #{folder}.tar #{folder}`
215 `bzip2 #{folder}.tar`
216 FileUtils.rm_rf( folder )
217 puts "done.\n"
220 ENV["UNSERMAKE"] = oldmake
223 puts "\n"
224 puts "====================================================="
225 puts "Congratulations :) Amarok #{version} tarball generated.\n"
226 puts "Now follow the steps in the RELEASE_HOWTO, from\n"
227 puts "SECTION 3 onwards.\n"
228 puts "\n"
229 puts "Then drink a few pints and have some fun on #amarok\n"
230 puts "\n"
231 puts "MD5 checksum: " + `md5sum #{folder}.tar.bz2`
232 puts "\n"
233 puts "\n"