]>
git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/lib/linux/rpmfactory/RpmBuildEnvironment.java
2 * Copyright (C) 2007-2012 Argeo GmbH
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org
.argeo
.slc
.lib
.linux
.rpmfactory
;
19 import java
.io
.IOException
;
20 import java
.util
.ArrayList
;
21 import java
.util
.HashMap
;
22 import java
.util
.List
;
25 import org
.apache
.commons
.io
.FileUtils
;
26 import org
.argeo
.slc
.SlcException
;
29 * Defines a build environment. This information is typically used by other
30 * components performing the various actions related to RPM build.
32 public class RpmBuildEnvironment
{
33 static String defaultMacroFiles
= "/usr/lib/rpm/macros:/usr/lib/rpm/ia32e-linux/macros:/usr/lib/rpm/redhat/macros:/etc/rpm/macros.*:/etc/rpm/macros:/etc/rpm/ia32e-linux/macros:~/.rpmmacros";
35 private Map
<String
, String
> rpmmacros
= new HashMap
<String
, String
>();
37 private List
<String
> archs
= new ArrayList
<String
>();
39 private String stagingBase
= "/srv/rpmfactory";
41 /** Write (topdir)/rpmmacros and (topdir)/rpmrc */
42 public void writeRpmbuildConfigFiles(File topdir
) {
43 writeRpmbuildConfigFiles(topdir
, new File(topdir
, "rpmmacros"),
44 new File(topdir
, "rpmrc"));
47 public void writeRpmbuildConfigFiles(File topdir
, File rpmmacroFile
,
50 List
<String
> macroLines
= new ArrayList
<String
>();
51 macroLines
.add("%_topdir " + topdir
.getCanonicalPath());
52 for (String macroKey
: rpmmacros
.keySet()) {
53 macroLines
.add(macroKey
+ " " + rpmmacros
.get(macroKey
));
55 FileUtils
.writeLines(rpmmacroFile
, macroLines
);
57 List
<String
> rpmrcLines
= new ArrayList
<String
>();
58 rpmrcLines
.add("include: /usr/lib/rpm/rpmrc");
59 rpmrcLines
.add("macrofiles: " + defaultMacroFiles
+ ":"
60 + rpmmacroFile
.getCanonicalPath());
61 FileUtils
.writeLines(rpmrcFile
, rpmrcLines
);
62 } catch (IOException e
) {
63 throw new SlcException("Cannot write rpmbuild config files", e
);
68 public Map
<String
, String
> getRpmmacros() {
72 public void setRpmmacros(Map
<String
, String
> rpmmacros
) {
73 this.rpmmacros
= rpmmacros
;
76 public String
getDefaultMacroFiles() {
77 return defaultMacroFiles
;
80 public void setDefaultMacroFiles(String defaultMacroFiles
) {
81 this.defaultMacroFiles
= defaultMacroFiles
;
84 public void setArchs(List
<String
> archs
) {
88 public List
<String
> getArchs() {
92 public String
getStagingBase() {
96 public void setStagingBase(String stagingBase
) {
97 this.stagingBase
= stagingBase
;