summaryrefslogtreecommitdiffstats
path: root/puppet/modules/squish/manifests/init.pp
blob: 0e145635c0151017a9c20388ddf74c649cb84fd0 (plain)
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# This cross-platform module downloads the given $version of Squish and installs it to the specified $path.

class squish {

    $path = $::operatingsystem ? {
        windows => "c:\\utils\\squish",
        default => "/opt/squish",
    }

    file { "${path}":
        ensure => directory,
    }

    # Download squish license
    secret_file { "${path}/.squish-3-license":
        source    => "squish/.squish-3-license",
        subscribe => File["${path}"],
    }

    # Squish have separate packages for x86 and x64 architectures in Windows 7, Windows 8 and Ubuntu
    $msvc12_pkg_name = $::architecture ? {
        x64     => "squish-5.1.1-qt53x-win64-msvc12",
        default => "squish-5.1.1-qt53x-win32-msvc12",
    }

    $msvc11_pkg_name = $::architecture ? {
        x64     => "squish-5.0.2-qt51x-win64-msvc11",
        default => "squish-5.1.1-qt53x-win32-msvc11",
    }

    $msvc11_version = $::architecture ? {
        x64     => "5.0.2",
        default => "5.1.1",
    }

    $mingw_pkg_name = "squish-5.1.1-qt53x-win32-mingw_gcc482_posix_dwarf"

    $msvc10_pkg_name = $::architecture ? {
        x64     => "squish-5.0.1-qt51x-win64-msvc10",
        default => "squish-5.1.1-qt53x-win32-msvc10",
    }

    $msvc10_version = $::architecture ? {
        x64     => "5.0.1",
        default => "5.1.1",
    }

    $linux_pkg_name = $::architecture ? {
        i386    => "squish-5.1-20140320-1446-qt52x-linux32",
        default => "squish-5.1-20140320-1154-qt52x-linux64",
    }

    $darwin_pkg_name = "squish-5.1-20140320-1447-qt52x-macx86_64"

    case $::operatingsystem {
        windows: {
            if ($kernelmajversion >= "6.2") {
                squish_install {
                    "msvc11":
                        pkg_name => "$msvc11_pkg_name",
                        path     => "$path",
                        version  => "$msvc11_version",
                    ;
                    "msvc12":
                        pkg_name => "$msvc12_pkg_name",
                        path     => "$path",
                        version  => "5.1.1",
                    }
            }
            else {
                squish_install {
                    "mingw":
                        pkg_name => "$mingw_pkg_name",
                        path     => "$path",
                        version  => "5.1.1",
                    ;
                    "msvc10":
                        pkg_name => "$msvc10_pkg_name",
                        path     => "$path",
                        version  => "$msvc10_version",
                    ;
                    "msvc11":
                        pkg_name => "$msvc11_pkg_name",
                        path     => "$path",
                        version  => "$msvc11_version",
                    ;
                    "msvc12":
                        pkg_name => "$msvc12_pkg_name",
                        path     => "$path",
                        version  => "5.1.1",
                    }
                }
        }
        Ubuntu: {
            squish_install {
                "package":
                    pkg_name => "$linux_pkg_name",
                    path     => "$path",
                    version  => "5.1.0",
            }
        }
        OpenSuSE: {
            squish_install {
                "package":
                    pkg_name => "$linux_pkg_name",
                    path     => "$path",
                    version  => "5.1.0",
            }
        }
        Darwin: {
            exec { "Enable Accessibility API":
                command => "/bin/sh -c \"touch /private/var/db/.AccessibilityAPIEnabled\"",
            }

            squish_install {
                "package":
                    pkg_name => "$darwin_pkg_name",
                    path     => "$path",
                    version  => "5.1.0",
            }
        }
    }

    define squish_install ($path,$pkg_name,$version) {

        $binary      = "\"${path}/${name}/bin/squishserver\""
        $unzip_flags = "x -o$path"
        $base_url    = "$input/squish"

        unzip_package { "$name":
            url         => "${base_url}/${pkg_name}.zip",
            version     => $version,
            path        => "${path}/${name}",
            unzip_flags => $unzip_flags,
            binary      => $binary,
        }

        # Remove not_configured file. Required for squish manual setup.
        file { "${path}/${pkg_name}/bin/.not_configured":
            ensure  => absent,
            notify  => Exec[ "rename $pkg_name as $name" ],
            require => Unzip_package["$name"],
        }

        # Rename squish package name as '$name' so the path to squish won't change after version update.
        if $::operatingsystem == 'windows' {
            exec { "rename $pkg_name as $name":
                command     => "C:\\Windows\\system32\\cmd.exe /C \"rename ${path}\\${pkg_name} $name\"",
                refreshonly => true
            }
        }
        else {
            exec { "rename $pkg_name as $name":
                command     => "/bin/sh -c \"mv ${path}/${pkg_name} ${path}/${name} && chown -R $testuser: $path\"",
                refreshonly => true,
            }
            file { "/etc/profile.d/squish_env.sh":
                ensure   =>  present,
                content  => template("squish/squish_env.sh.erb"),
            }
        }
    }
}