File: bump_plugin_version.rb

package info (click to toggle)
amarok 3.3.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 112,168 kB
  • sloc: cpp: 195,056; xml: 4,322; ansic: 2,634; javascript: 673; ruby: 528; python: 507; sh: 252; makefile: 12
file content (83 lines) | stat: -rwxr-xr-x 2,359 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env ruby
#
# This is a convenience script for bumping Amarok's plugin framework version
# in the various engine desktop files and in pluginmanager.h.
#
# The script should be run once before each release, in order to ensure that
# no old and perhaps incompatible engines are getting loaded. After running, don't
# forget to commit and push. The script must be started from the amarok/ folder.
#
# (c) 2005-2010 Mark Kretschmann <kretschmann@kde.org>
# License: GNU General Public License V2


def bump_desktop_files
    files = Dir["**/*.desktop"]

    files.each do |path|
        file = File.new(path, File::RDWR)
        str = file.read
        unless str[/X-KDE-Amarok-framework-version=[0-9]*/].nil?
            puts path
            str.sub!( /X-KDE-Amarok-framework-version=[0-9]*/, "X-KDE-Amarok-framework-version=#{@version}" )
            file.rewind
            file.truncate(0)
            file << str
        end
        file.close
    end
end

def bump_json_files
    files = Dir["**/*.json"]

    files.each do |path|
        file = File.new(path, File::RDWR)
        str = file.read
        unless str[/X-KDE-Amarok-framework-version": [0-9]*/].nil?
            puts path
            str.sub!( /X-KDE-Amarok-framework-version": [0-9]*/, "X-KDE-Amarok-framework-version\": #{@version}" )
            file.rewind
            file.truncate(0)
            file << str
        end
        file.close
    end
end

# Make sure the current working directory is amarok
if not Dir::getwd().split( "/" ).last() == "amarok"
    print "ERROR: This script must be started from the amarok/ folder. Aborting.\n\n"
    exit()
end


# Bump s_pluginFrameworkVersion in PluginManager.h
file = File.new( "src/PluginManager.cpp", File::RDWR )
str = file.read()
file.rewind()
file.truncate( 0 )
temp = str.scan( /const int Plugins::PluginManager::s_pluginFrameworkVersion = [0-9]*;/ )
@version = temp.join().scan( /[0-9]*/ ).join().to_i()
@version = @version + 1

print "Bumping the plugin framework version to: #{@version}"

str.sub!( /const int Plugins::PluginManager::s_pluginFrameworkVersion = [0-9]*;/, "const int Plugins::PluginManager::s_pluginFrameworkVersion = #{@version};" )
file << str
file.close()


# Bump plugin desktop files
puts
puts
bump_desktop_files
bump_json_files


puts
puts
print "Done :) Now commit the source to git."
puts
puts