6 #include <zypp/base/Logger.h>
8 #include <zypp/ZYppFactory.h>
10 #include "zypp/Product.h"
11 #include "zypp/Package.h"
13 #include "zypp/TmpPath.h"
14 #include "zypp/ExternalProgram.h"
15 #include "zypp/ProgressData.h"
16 #include "zypp/repo/yum/Downloader.h"
18 #include "zypp/sat/Pool.h"
20 #include "zypp/PoolQuery.h"
24 using namespace zypp::repo;
25 using namespace zypp::filesystem;
32 Pathname top = _tmptop.path();
33 Pathname rcpath = _tmprc.path();
35 assert_dir(top / "build" );
36 assert_dir(top / "rpms" );
38 /* create a rpm configuration file and
39 setup the macros file */
40 std::ofstream rcfile(rcpath.c_str());
42 ZYPP_THROW (Exception( "Can't open " + rcpath.asString() ) );
44 rcfile << "macrofiles: " << _tmpmacros.path() << endl;
48 Pathname rpmsDir() const
50 return _tmptop.path() / "rpms";
53 void createRpmMetadata() const
61 ExternalProgram prog(argv,ExternalProgram::Normal_Stderr, false, -1, true);
64 for(line = prog.receiveLine(), count=0; !line.empty(); line = prog.receiveLine(), count++ )
72 void buildSpec( const Pathname &spec )
74 Pathname basedir = spec.dirname();
75 Pathname rcpath = _tmprc.path();
76 Pathname macrospath = _tmpmacros.path();
78 std::ofstream macrosfile(macrospath.c_str());
80 ZYPP_THROW (Exception( "Can't open " + macrospath.asString() ) );
82 macrosfile << "%topdir " << _tmptop.path() << endl;
83 macrosfile << "%_builddir %{topdir}/build" << endl;
84 macrosfile << "%_rpmdir %{topdir}/rpms" << endl;
85 macrosfile << "%_srcrpmdir %{topdir}/rpms" << endl;
86 macrosfile << "%_sourcedir " << basedir << endl;
87 macrosfile << "%_specdir " << basedir << endl;
99 _tmpbuildroot.path().c_str(),
103 ExternalProgram prog(argv,ExternalProgram::Normal_Stderr, false, -1, true);
106 for(line = prog.receiveLine(), count=0; !line.empty(); line = prog.receiveLine(), count++ )
118 TmpDir _tmpbuildroot;
121 int main(int argc, char **argv)
125 ZYpp::Ptr z = getZYpp();
127 //z->initializeTarget("/");
128 //z->target()->load();
130 //sat::Pool::instance().addRepoSolv("./foo.solv");
132 // for ( ResPool::const_iterator it = z->pool().begin(); it != z->pool().end(); ++it )
134 // ResObject::constPtr res = it->resolvable();
135 // if ( res->name() == "kde4-kcolorchooser")
137 // cout << res << endl;
138 // cout << res->summary() << " | " << res->size() << endl;
142 //query.execute("kde", &result_cb);
145 builder.buildSpec("/space/git/hwenable/spec/testdriver.spec");
146 builder.createRpmMetadata();
150 catch ( const Exception &e )
153 cout << e.msg() << endl;