From 934e044f86ad4ff4465e0659734f2008f85cc461 Mon Sep 17 00:00:00 2001 From: John McQuah Date: Mon, 19 Jun 2023 14:44:03 -0400 Subject: [PATCH] fix misc compile warnings document the interaction between --install-root and 'runscripts yes' --- doc/prt-get.8 | 17 +++++++---------- src/installtransaction.cpp | 10 +++++----- src/package.cpp | 14 ++++++-------- src/package.h | 6 +++--- src/prtget.cpp | 2 +- src/prtget.h | 2 +- src/signaldispatcher.cpp | 2 +- src/signaldispatcher.h | 2 +- 8 files changed, 25 insertions(+), 30 deletions(-) diff --git a/doc/prt-get.8 b/doc/prt-get.8 index 9b2fa29..5fc04d4 100644 --- a/doc/prt-get.8 +++ b/doc/prt-get.8 @@ -549,19 +549,16 @@ the requested packages onto a different directory than '/'. In daily usage, this option is not required; it's primarily interesting if you're developing an independent installation. -Some pre- or post-install scripts might not have the intended effect if -invoked as -.B chroot /bin/sh -(the naive way to respect --install-root). -So if you're maintaining an installation on a volume mounted somewhere -other than '/', it might be safer to ensure that your \fBprt\-get.conf(5)\fP -has the line -.B runscripts no -and then run any pre- or post-install scripts by hand. +Pre- and post-install scripts will not be executed if the target root directory +lacks a copy of the ports tree. So if you're maintaining an installation on a +volume mounted somewhere other than '/', it's not enough to have the line +.B runscripts yes +in your prt-get.conf; you also have to ensure that the pre- and post-install +scripts can be found in the same location relative to . The setting for --install-root determines which package database is used for reading/writing (so /var/lib/pkg/db must exist), and where the pkg.tar.?z -archives get unpacked, but the relevant prt\-get.conf and ports tree are those +archives get unpacked, but the relevant prt-get.conf and ports tree are those on the parent filesystem. Therefore it is not necessary for to contain its own copy of the ports tree, or even a copy of prt-get.conf. However, if /etc/pkgadd.conf exists and is different from /etc/pkgadd.conf, diff --git a/src/installtransaction.cpp b/src/installtransaction.cpp index fde3897..31f66c9 100644 --- a/src/installtransaction.cpp +++ b/src/installtransaction.cpp @@ -313,7 +313,7 @@ InstallTransaction::installPackage( const Package* package, // -- pre-install struct stat statData; if ((parser->execPreInstall() || m_config->runScripts()) && - stat((pkgdir + "/" + "pre-install").c_str(), &statData) == 0) { + stat((parser->installRoot() + pkgdir + "/" + "pre-install").c_str(), &statData) == 0) { Process preProc( runscriptCommand, pkgdir + "/" + "pre-install", fdlog ); @@ -421,9 +421,9 @@ InstallTransaction::installPackage( const Package* package, } else { // exec post install if ((parser->execPostInstall() || m_config->runScripts() ) && - stat((package->path() + "/" + package->name() + - "/" + "post-install").c_str(), &statData) - == 0) { + stat((parser->installRoot() + package->path() + + "/" + package->name() + "/" + "post-install").c_str(), + &statData) == 0) { // Work around the pkgdir variable change Process postProc( runscriptCommand, package->path() + "/" + package->name()+ @@ -717,7 +717,7 @@ string InstallTransaction::getPkgmkSettingFromFile(const string& setting, const if (p) { fgets(line, 256, p); value = StringHelper::stripWhiteSpace(line); - fclose(p); + pclose(p); } } diff --git a/src/package.cpp b/src/package.cpp index f547658..ce484ac 100644 --- a/src/package.cpp +++ b/src/package.cpp @@ -124,7 +124,7 @@ const string& Package::maintainer() const } /*! \return whether or not this package has a readme file */ -const bool Package::hasReadme() const +bool Package::hasReadme() const { load(); return m_data->hasReadme; @@ -137,12 +137,12 @@ string Package::versionReleaseString() const return m_data->versionReleaseString; } -const bool Package::hasPreInstall() const +bool Package::hasPreInstall() const { return m_data->hasPreInstall; } -const bool Package::hasPostInstall() const +bool Package::hasPostInstall() const { return m_data->hasPostInstall; } @@ -345,11 +345,9 @@ void Package::expandShellCommands(std::string& input, pos = 0; while ((pos = input.find(startTag[i], pos)) != string::npos) { - if (unameBuf.release) { - input = replaceAll(input, - startTag[i] + "uname -r" + endTag[i], - unameBuf.release); - } + input = replaceAll(input, + startTag[i] + "uname -r" + endTag[i], + unameBuf.release); dpos = input.find(startTag[i] + "date"); if (dpos != string::npos) { diff --git a/src/package.h b/src/package.h index 2bcf1e9..d59d727 100644 --- a/src/package.h +++ b/src/package.h @@ -52,9 +52,9 @@ public: const std::string& url() const; const std::string& optionals() const; const std::string& maintainer() const; - const bool hasReadme() const; - const bool hasPreInstall() const; - const bool hasPostInstall() const; + bool hasReadme() const; + bool hasPreInstall() const; + bool hasPostInstall() const; std::string versionReleaseString() const; diff --git a/src/prtget.cpp b/src/prtget.cpp index 5c0a59b..12ac51c 100644 --- a/src/prtget.cpp +++ b/src/prtget.cpp @@ -1676,7 +1676,7 @@ void PrtGet::current() m_returnValue = 1; } -SignalHandler::HandlerResult PrtGet::handleSignal( int signal ) +SignalHandler::HandlerResult PrtGet::handleSignal() { // TODO: second argument could also be true: // TODO: kill installtransaction diff --git a/src/prtget.h b/src/prtget.h index 1bba138..9356a4b 100644 --- a/src/prtget.h +++ b/src/prtget.h @@ -92,7 +92,7 @@ public: int returnValue() const; - SignalHandler::HandlerResult handleSignal( int signal ); + SignalHandler::HandlerResult handleSignal(); protected: diff --git a/src/signaldispatcher.cpp b/src/signaldispatcher.cpp index 0c717a3..9db4363 100644 --- a/src/signaldispatcher.cpp +++ b/src/signaldispatcher.cpp @@ -36,7 +36,7 @@ void SignalDispatcher::dispatch( int signalNumber ) map::iterator it = SignalDispatcher::instance()->m_signalHandlers.find( signalNumber ); if ( it != SignalDispatcher::instance()->m_signalHandlers.end() ) { - it->second->handleSignal( signalNumber ); + it->second->handleSignal(); } else { cerr << "prt-get: caught signal " << signalNumber << endl; } diff --git a/src/signaldispatcher.h b/src/signaldispatcher.h index d29cdab..0902796 100644 --- a/src/signaldispatcher.h +++ b/src/signaldispatcher.h @@ -28,7 +28,7 @@ public: EXIT, /*!< signal handled, exit now */ CONTINUE /*!< signal handled, don't exit */ }; - virtual HandlerResult handleSignal( int signalNumber ) = 0; + virtual HandlerResult handleSignal() = 0; }; /*!