2
* Copyright (C) 2003 Robert Collins <robertc@squid-cache.org>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
* DO NOT ALTER THE NEXT LINE
20
* arch-tag: 21df1c64-1d6a-4476-ad3a-e451889d3da8
24
#include "ConfigArchSource.h"
32
/* ConfigArchSource */
33
StringOption ConfigArchSource::buildOptions("",'a',"arch-build-options", "Options to pass to tla get.");
35
ConfigArchSource::ConfigArchSource() : theUrl(), location()
39
ConfigArchSource::ConfigArchSource(string const &aUrl) : theUrl(aUrl)
41
if (theUrl.find("arch://") == 0)
43
/* We only support @ location syntax in full archive paths */
44
if (theUrl.find("@") != theUrl.rfind("@"))
46
string::size_type pos = theUrl.find("@", theUrl.find("@") + 1);
47
location = theUrl.substr(pos + 1);
50
cout << "Found archive " << theUrl << " location at " << location << endl;
55
ConfigArchSource::url(bool const &stripScheme) const
57
return (stripScheme ? "" : "arch://") + theUrl;
61
ConfigArchSource::archive() const
67
ConfigArchSource::maybeRegister() const
69
string command = "tla whereis-archive `tla parse-package-name -a " + archive() + "` > /dev/null";
70
if (run_query (command, "tla") != 0)
71
run ("tla register-archive `tla parse-package-name -a " + archive() + "` " + location , "tla");
75
ConfigArchSource::get (string const &where) const throw(std::exception *)
78
string command = "tla get " + (string)buildOptions + " " + archive() + " " + where;
83
ConfigArchSource::update (string const &where) const throw(std::exception *)
86
string command = "tla update " + (string)buildOptions + " -d " + where + " " + archive();
91
ConfigArchSource::missing (string const &where) const throw(std::exception *)
94
string command = "tla missing " + (string)buildOptions + " -d " + where + " " + archive();
95
return run_query (command, "tla");
99
ConfigArchSource::changes (string const &where) const throw(std::exception *)
102
string command = "tla changes " + (string)buildOptions + " -d " + where + " " + archive();
103
return run_query (command, "tla");
107
ConfigArchSource::treeVersion(string const &where) const
109
string command = "tla logs -f -r -d " + where + " | head -n1 > ,,config-tree";
112
ifstream resultbuffer(",,config-tree");
114
resultbuffer >> result;
115
resultbuffer.close();
116
unlink(",,config-tree");
121
ConfigArchSource::ignore (ConfigSource const* aSource, string const &where) const throw (std::exception *)
123
if (dynamic_cast<ConfigArchSource const *>( aSource))
126
ifstream projtreetest((where + "/{arch}/.arch-project-tree").c_str());
127
if (projtreetest.is_open())
129
std::cerr << "Warning: '" << where << "' is already an arch project tree. Consider using an arch:// source in the config." << std::endl;
132
string command = "tla init-tree --nested -d " + where;
133
run (command, "tla");
134
ofstream taggingMethod((where + "/{arch}/=tagging-method").c_str());
135
taggingMethod << dummyTaggingText;
136
std::cout << "Created a dummy tagging file for " << where << "/{arch}/=tagging-method" << endl;
139
char const * ConfigArchSource::dummyTaggingText=
140
"# this is a GNU Arch configuration file. It's been placed here by\n"
141
"# config-manager because this directory was created as part of a\n"
142
"# build operation, to ensure that Arch ignores this sub-tree.\n"
144
"untagged-source precious\n"
153
ConfigArchSource::Create(Path const &location) throw (std::exception *)
155
ifstream projtreetest((location.fullName() + "/{arch}/++default-version").c_str());
156
if (!projtreetest.is_open())
159
ConfigArchSource *result = new ConfigArchSource;
160
result->theUrl = result->treeVersion(location.fullName());
161
result->location = "";