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
;
20 import org
.argeo
.slc
.core
.execution
.tasks
.SystemCall
;
22 /** Install an SRPM into a working copy */
23 public class ImportSrpm
implements Runnable
{
25 private File srpmFile
;
26 private RpmBuildEnvironment rpmBuildEnvironment
;
29 SystemCall rpmQuery
= new SystemCall(
30 "rpm --queryformat '%{NAME}\n' -qp " + srpmFile
);
31 String packageName
= rpmQuery
.function();
33 File topdir
= new File(baseDir
, packageName
);
36 // TODO: do it with SVNKit
38 new SystemCall("svn add " + topdir
).run();
39 new SystemCall("svn propset svn:ignore rpm*\nBUILD\nSRPMS\nRPMS " + topdir
).run();
40 File sourcesDir
= new File(topdir
, "SOURCES");
42 new SystemCall("svn add " + sourcesDir
).run();
43 new SystemCall("svn propset svn:ignore *gz\n*bz2\n*.zip\n*.jar " + sourcesDir
).run();
44 File specsDir
= new File(topdir
, "SPECS");
46 new SystemCall("svn add " + specsDir
).run();
48 // Write rpm config files
49 File rpmmacroFile
= new File(topdir
, "rpmmacros");
50 File rpmrcFile
= new File(topdir
, "rpmrc");
51 rpmBuildEnvironment
.writeRpmbuildConfigFiles(topdir
, rpmmacroFile
,
55 SystemCall installSrpm
= new SystemCall();
56 installSrpm
.arg("rpm");
57 installSrpm
.arg("-Uvh");
58 installSrpm
.arg("--rcfile=" + rpmrcFile
.getAbsolutePath());
59 installSrpm
.arg(srpmFile
.getAbsolutePath());
60 installSrpm
.setExecDir(topdir
.getAbsolutePath());
61 installSrpm
.setLogCommand(true);
65 public void setBaseDir(File basedir
) {
66 this.baseDir
= basedir
;
69 public void setSrpmFile(File srpmFile
) {
70 this.srpmFile
= srpmFile
;
73 public void setRpmBuildEnvironment(RpmBuildEnvironment rpmBuildEnvironment
) {
74 this.rpmBuildEnvironment
= rpmBuildEnvironment
;