forked from lhcb-org/lbpkr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lhcbconfig.go
151 lines (128 loc) · 2.67 KB
/
lhcbconfig.go
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
package main
import (
"fmt"
"os"
"path/filepath"
"strings"
)
type lhcbConfig struct {
ConfigBase
}
func newLHCbConfig(siteroot string) *lhcbConfig {
cfg := &lhcbConfig{
ConfigBase: ConfigBase{
siteroot: siteroot,
repourl: "http://cern.ch/lhcbproject/dist/rpm",
},
}
if siteroot == "" {
cfg.siteroot = cfg.DefaultSiteroot()
}
return cfg
}
func (cfg *lhcbConfig) Name() string {
return "lhcb"
}
func (cfg *lhcbConfig) DefaultSiteroot() string {
return "/opt/LHCbSoft"
}
// RelocateArgs returns the arguments to be passed to RPM for the repositories
func (cfg *lhcbConfig) RelocateArgs(siteroot string) []string {
return []string{
"--relocate", fmt.Sprintf("%s=%s", "/opt/lcg/external", filepath.Join(siteroot, "lcg", "external")),
"--relocate", fmt.Sprintf("%s=%s", "/opt/lcg", filepath.Join(siteroot, "lcg", "releases")),
"--relocate", fmt.Sprintf("%s=%s", "/opt/LHCbSoft", siteroot),
"--badreloc",
}
}
// RelocateFile returns the relocated file path
func (cfg *lhcbConfig) RelocateFile(fname, siteroot string) string {
fname = strings.Replace(fname, "/opt/lcg", filepath.Join(siteroot, "lcg", "releases"), 1)
fname = strings.Replace(fname, "/opt/LHCbSoft", siteroot, 1)
return fname
}
func (cfg *lhcbConfig) InitYum(ctx *Context) error {
var err error
repourl := cfg.RepoUrl()
if repourl[len(repourl)-1] == '/' {
repourl = repourl[:len(repourl)-1]
}
repodir := ctx.yumreposd
err = os.MkdirAll(repodir, 0644)
if err != nil {
return err
}
// lcg stuff
{
repo := filepath.Join(repodir, "lcg.repo")
f, err := os.Create(repo)
if err != nil {
return err
}
defer f.Close()
err = ctx.writeYumRepo(f, map[string]string{
"name": "lcg",
"url": "http://cern.ch/service-spi/external/rpms/lcg",
})
if err != nil {
return err
}
err = f.Sync()
if err != nil {
return err
}
err = f.Close()
if err != nil {
return err
}
}
// lhcb stuff
{
repo := filepath.Join(repodir, "lhcb.repo")
f, err := os.Create(repo)
if err != nil {
return err
}
defer f.Close()
err = ctx.writeYumRepo(f, map[string]string{
"name": "lhcb",
"url": repourl + "/lhcb",
})
if err != nil {
return err
}
err = f.Sync()
if err != nil {
return err
}
err = f.Close()
if err != nil {
return err
}
}
// lhcb ext stuff
{
repo := filepath.Join(repodir, "lhcbext.repo")
f, err := os.Create(repo)
if err != nil {
return err
}
defer f.Close()
err = ctx.writeYumRepo(f, map[string]string{
"name": "lhcbext",
"url": repourl + "/lcg",
})
if err != nil {
return err
}
err = f.Sync()
if err != nil {
return err
}
err = f.Close()
if err != nil {
return err
}
}
return err
}