Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
9619657f17 | |||
de7e9b6a1e |
6
INSTALL
6
INSTALL
@ -1,6 +1,6 @@
|
||||
Installing prt-get
|
||||
------------------
|
||||
Installing prt-get is just a matter of
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
meson setup bld --prefix=/usr
|
||||
ninja -C bld
|
||||
ninja -C bld install
|
||||
|
@ -115,6 +115,18 @@ See the \fBEXAMPLES\fP section below for details.
|
||||
.B remove <package1> [<package2> ...]
|
||||
Remove packages listed in this order
|
||||
|
||||
.TP
|
||||
.B sync [\-\-install\-root=<dir>] [collection1 ... collectionN]
|
||||
Reach out to remote servers defined in \fB/etc/ports\fP (or \fB<dir>/etc/ports\fP if
|
||||
\-\-install\-root is given), and bring the local ports collections up to date. The sync
|
||||
command processes all sync files whose suffix matches an executable file in
|
||||
\fB/etc/ports/drivers\fP, unless specific collections are passed as arguments, in which case
|
||||
only those collections are synchronized. If the same collection is listed in \fB/etc/ports\fP
|
||||
with different suffixes, then the matching drivers are called in lexographic order. This
|
||||
feature allows for multi-stage processing, e.g. if you want to apply local patches and then
|
||||
update the manifests. For further details on the ports system and the format of the
|
||||
{httpup,rsync,git} files, see \fBports(8)\fB.
|
||||
|
||||
.TP
|
||||
.B sysup [\-\-softdeps] [\-\-nodeps]
|
||||
Update all installed packages which are outdated. Sorts by hard dependencies
|
||||
|
@ -128,7 +128,7 @@ const string& ArgParser::alternateConfigFile() const
|
||||
*/
|
||||
bool ArgParser::parse()
|
||||
{
|
||||
const int commandCount = 34;
|
||||
const int commandCount = 35;
|
||||
string commands[commandCount] = { "list", "search", "dsearch",
|
||||
"info", "version", "cache",
|
||||
"depends", "install", "depinst",
|
||||
@ -139,7 +139,7 @@ bool ArgParser::parse()
|
||||
"fsearch", "lock", "unlock",
|
||||
"listlocked", "cat", "ls", "edit",
|
||||
"remove", "deptree", "dumpconfig",
|
||||
"listorphans" };
|
||||
"listorphans", "sync" };
|
||||
|
||||
Type commandID[commandCount] = { LIST, SEARCH, DSEARCH, INFO,
|
||||
SHOW_VERSION, CREATE_CACHE,
|
||||
@ -150,7 +150,7 @@ bool ArgParser::parse()
|
||||
DEPENDENT, SYSUP, CURRENT,
|
||||
FSEARCH, LOCK, UNLOCK, LISTLOCKED,
|
||||
CAT, LS, EDIT, REMOVE, DEPTREE,
|
||||
DUMPCONFIG, LISTORPHANS };
|
||||
DUMPCONFIG, LISTORPHANS, SYNC };
|
||||
if ( m_argc < 2 ) {
|
||||
return false;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
LISTINST, PRINTF, README, DEPENDENT, SYSUP,
|
||||
CURRENT, FSEARCH, LOCK, UNLOCK, LISTLOCKED,
|
||||
CAT, LS, EDIT, REMOVE,
|
||||
DEPTREE, DUMPCONFIG, LISTORPHANS };
|
||||
DEPTREE, DUMPCONFIG, LISTORPHANS, SYNC };
|
||||
|
||||
bool isCommandGiven() const;
|
||||
bool isTest() const;
|
||||
|
@ -161,6 +161,9 @@ int main( int argc, char** argv )
|
||||
case ArgParser::LISTORPHANS:
|
||||
prtGet.listOrphans();
|
||||
break;
|
||||
case ArgParser::SYNC:
|
||||
prtGet.syncPorts();
|
||||
break;
|
||||
default:
|
||||
cerr << "unknown command" << endl;
|
||||
break;
|
||||
|
@ -70,8 +70,8 @@ PrtGet::PrtGet( const ArgParser* parser )
|
||||
m_pkgDB = new PkgDB(m_parser->installRoot());
|
||||
readConfig();
|
||||
|
||||
m_useRegex = m_config->useRegex() || m_parser->useRegex();
|
||||
m_followSoftdeps = m_config->followSoftdeps() || m_parser->followSoftdeps();
|
||||
m_useRegex = ( m_config->useRegex() || m_parser->useRegex() );
|
||||
m_followSoftdeps = ( m_config->followSoftdeps() || m_parser->followSoftdeps() );
|
||||
}
|
||||
|
||||
/*! destruct PrtGet object */
|
||||
@ -1263,7 +1263,7 @@ void PrtGet::printf()
|
||||
assertExactArgCount(1);
|
||||
|
||||
initRepo();
|
||||
string filter = m_parser->useRegex() ? "." : "*";
|
||||
string filter = m_useRegex ? ".*" : "*";
|
||||
if ( m_parser->hasFilter() ) {
|
||||
filter = m_parser->filter();
|
||||
}
|
||||
@ -2294,3 +2294,81 @@ void PrtGet::dumpConfig()
|
||||
cout << endl;
|
||||
}
|
||||
}
|
||||
|
||||
void PrtGet::syncPorts()
|
||||
{
|
||||
const string sup_path = m_parser->installRoot() + "/etc/ports";
|
||||
const string driver_path = sup_path + "/drivers";
|
||||
DIR* d = opendir(driver_path.c_str());
|
||||
if (d == NULL) {
|
||||
cerr << "Ports drivers directory " << driver_path.c_str()
|
||||
<< " not found. Aborting sync." << endl;
|
||||
m_returnValue = PG_GENERAL_ERROR;
|
||||
return;
|
||||
}
|
||||
struct dirent* de;
|
||||
struct stat buf;
|
||||
list<string> drivers;
|
||||
while ( (de = readdir(d)) ) {
|
||||
string drvName = de->d_name;
|
||||
if (drvName != "." && drvName != ".." && stat((driver_path + "/" + drvName).c_str(), &buf) == 0
|
||||
&& buf.st_mode & S_IXUSR ) {
|
||||
drivers.push_back(drvName);
|
||||
}
|
||||
}
|
||||
closedir(d);
|
||||
|
||||
if (drivers.size() == 0) {
|
||||
cerr << "No valid ports drivers. Aborting sync." << endl;
|
||||
m_returnValue = PG_GENERAL_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_parser->otherArgs().size()) { // sync selected repositories, with
|
||||
drivers.sort(); // multi-stage processing done predictably
|
||||
bool repo_active;
|
||||
list<char*>::const_iterator itc = m_parser->otherArgs().begin();
|
||||
list<string>::const_iterator itd;
|
||||
for (; itc != m_parser->otherArgs().end(); ++itc) {
|
||||
repo_active = false;
|
||||
for (itd = drivers.begin(); itd != drivers.end(); ++itd) {
|
||||
if (stat((sup_path + "/" + *itc + "." + *itd).c_str(),&buf) == 0) {
|
||||
repo_active = true;
|
||||
Process syncProc( driver_path + "/" + *itd,
|
||||
sup_path + "/" + *itc + "." + *itd, -1 );
|
||||
if (syncProc.execute()) {
|
||||
m_returnValue = PG_GENERAL_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (! repo_active) {
|
||||
cerr << *itc << ": not a valid port collection" << endl;
|
||||
}
|
||||
}
|
||||
} else { // sync all active repositories
|
||||
list<string> activeRepos;
|
||||
size_t pos;
|
||||
d = opendir(sup_path.c_str());
|
||||
while ( (de = readdir(d)) ) {
|
||||
string rName = de->d_name;
|
||||
pos = rName.find_last_of(".");
|
||||
if ( pos != string::npos && find(drivers.begin(), drivers.end(),
|
||||
rName.substr(pos+1)) != drivers.end() ) {
|
||||
activeRepos.push_back(rName);
|
||||
}
|
||||
}
|
||||
closedir(d);
|
||||
|
||||
activeRepos.sort();
|
||||
list<string>::const_iterator ite = activeRepos.begin();
|
||||
for ( ; ite != activeRepos.end(); ++ite) {
|
||||
pos = (*ite).find_last_of(".");
|
||||
Process syncProc( driver_path + "/" + (*ite).substr(pos+1),
|
||||
sup_path + "/" + *ite, -1 );
|
||||
if (syncProc.execute()) {
|
||||
m_returnValue = PG_GENERAL_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,6 +71,7 @@ public:
|
||||
void printDiff();
|
||||
void printQuickDiff();
|
||||
void listOrphans();
|
||||
void syncPorts();
|
||||
|
||||
void createCache();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user