diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c00d68d41..919fa8276c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -130,8 +130,23 @@ INSTALL( DESTINATION ${SYSCONFDIR}/zypp/apt-packagemap.d ) + # installation_sources script (deprecated) INSTALL( PROGRAMS deprecated/installation_sources DESTINATION ${INSTALL_PREFIX}/bin ) + +# zypp-refresh script (deprecated) +INSTALL( + PROGRAMS deprecated/zypp-refresh + DESTINATION ${INSTALL_PREFIX}/sbin +) +INSTALL ( + FILES deprecated/zypp-refresh.8 + DESTINATION "${INSTALL_PREFIX}/share/man/man8" +) +INSTALL( + FILES deprecated/zypp-refresh.lr + DESTINATION ${SYSCONFDIR}/logrotate.d +) diff --git a/deprecated/zypp-refresh b/deprecated/zypp-refresh new file mode 100644 index 0000000000..0ea1769efd --- /dev/null +++ b/deprecated/zypp-refresh @@ -0,0 +1,9 @@ +#!/bin/bash +export ZYPP_LOGFILE=${ZYPP_LOGFILE:-/var/log/zypp-refresh.log} +/usr/bin/zypper --non-interactive refresh --force +cat >&2 < +.\" Date: 03/18/2020 +.\" Manual: ZYPPER +.\" Source: SUSE Linux +.\" Language: English +.\" +.TH "ZYPP\-REFRESH" "8" "03/18/2020" "SUSE Linux" "ZYPPER" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +zypp-refresh \- Autorefresh metadata of all enabled repositories +.SH "SYNOPSIS" +.sp +\fBzypp\-refresh\fR +.SH "DESCRIPTION" +.sp +\fBzypp\-refresh\fR refreshes metadata of all enabled repositories which have \fBautorefresh\fR turned on (see \fBzypper lr\fR)\&. For use e\&.g\&. in cron jobs or scripts\&. +.SH "FILES" +.PP +\fB/var/log/zypp\-refresh\&.log\fR +.RS 4 +\fBzypp\-refresh\fR +logfile +.RE +.SH "AUTHORS" +.sp +.if n \{\ +.RS 4 +.\} +.nf +Jan Kupec <> +Michael Andres +.fi +.if n \{\ +.RE +.\} +.SH "SEE ALSO" +.sp +zypper(8) diff --git a/src/zypp-refresh.lr b/deprecated/zypp-refresh.lr similarity index 100% rename from src/zypp-refresh.lr rename to deprecated/zypp-refresh.lr diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index b255062ad1..9dcf5e4041 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -54,7 +54,7 @@ SET (my_MAN1 needs-restarting.1) SET (my_MAN8 - zypper.8 zypper-log.8 zypp-refresh.8) + zypper.8 zypper-log.8) ADD_A2X_MANPAGES( MAN_INST_PATH ${MANDIR} diff --git a/doc/zypp-refresh.8.txt b/doc/zypp-refresh.8.txt deleted file mode 100644 index 77b93016a9..0000000000 --- a/doc/zypp-refresh.8.txt +++ /dev/null @@ -1,34 +0,0 @@ -ZYPP-REFRESH(8) -============== -:man manual: ZYPPER -:man source: SUSE Linux - - -NAME ----- -zypp-refresh - Autorefresh metadata of all enabled repositories - - -SYNOPSIS --------- -*zypp-refresh* - - -DESCRIPTION ------------ -*zypp-refresh* refreshes metadata of all enabled repositories which have *autorefresh* turned on (see *zypper lr*). For use e.g. in cron jobs or scripts. - - -FILES ------ -*/var/log/zypp-refresh.log*:: - *zypp-refresh* logfile - -AUTHORS -------- - Jan Kupec <> - Michael Andres - -SEE ALSO --------- -zypper(8) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 91aa859ca5..dcc7057114 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -250,16 +250,6 @@ INSTALL( FILES DESTINATION ${CMAKE_INSTALL_PREFIX}/share/zypper/xml ) -# zypp-refresh utility -ADD_EXECUTABLE( zypp-refresh zypp-refresh.cc ) -TARGET_LINK_LIBRARIES( zypp-refresh ${ZYPP_LIBRARY} ) -SET_TARGET_PROPERTIES( zypp-refresh PROPERTIES LINK_FLAGS "-pie -Wl,-z,relro,-z,now") -SET_TARGET_PROPERTIES( zypp-refresh PROPERTIES COMPILE_FLAGS "-fwhole-program -fpie -fPIE") -INSTALL( - TARGETS zypp-refresh - RUNTIME DESTINATION ${INSTALL_PREFIX}/sbin -) - # bash completion script INSTALL( FILES bash-completion.sh @@ -269,7 +259,7 @@ INSTALL( # logrotate config file INSTALL( - FILES zypper.lr zypp-refresh.lr + FILES zypper.lr DESTINATION ${SYSCONFDIR}/logrotate.d ) diff --git a/src/zypp-refresh.cc b/src/zypp-refresh.cc deleted file mode 100644 index aee6045539..0000000000 --- a/src/zypp-refresh.cc +++ /dev/null @@ -1,190 +0,0 @@ -/*---------------------------------------------------------------------\ -| ____ _ __ __ ___ | -| |__ / \ / / . \ . \ | -| / / \ V /| _/ _/ | -| / /__ | | | | | | | -| /_____||_| |_| |_| | -| | -\---------------------------------------------------------------------*/ - -/* (c) Novell Inc. */ - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -using std::cout; -using std::cerr; -using std::endl; -using namespace zypp; - -#undef ZYPP_BASE_LOGGER_LOGGROUP -#define ZYPP_BASE_LOGGER_LOGGROUP "zypp-refresh" - -#define ZYPP_REFRESH_LOG "/var/log/zypp-refresh.log" - -// keyring and digest callbacks: accept everything, but don't import any keys - - -/////////////////////////////////////////////////////////////////// -namespace zypp { -/////////////////////////////////////////////////////////////////// - - static bool readCallbackAnswer() - { return false; } - - /////////////////////////////////////////////////////////////////// - // KeyRingReceive - /////////////////////////////////////////////////////////////////// - struct KeyRingReceive : public callback::ReceiveReport - { - virtual bool askUserToAcceptUnsignedFile( const std::string &file, const KeyContext & context ) - { cerr << ". Error:" << endl << "refusing unsigned file " << file << endl; return readCallbackAnswer(); } - virtual bool askUserToAcceptUnknownKey( const std::string &file, const std::string &id, const KeyContext & context ) - { cerr << ". Error:" << endl << "refusing unknown key, id: '" << id << "' from file '" << file << "'" << endl; return readCallbackAnswer(); } - virtual KeyRingReport::KeyTrust askUserToAcceptKey( const PublicKey &key, const KeyContext & context ) - { cerr << ". Error:" << endl << "not trusting key '" << key << "'" << endl; return KeyRingReport::KEY_DONT_TRUST; } - virtual bool askUserToAcceptVerificationFailed( const std::string &file, const PublicKey &key, const KeyContext & context ) - { cerr << ". Error:" << endl << "verification of '" << file << "' with key '" << key << "' failed" << endl; return readCallbackAnswer(); } - }; - - struct DigestReceive : public callback::ReceiveReport - { - virtual bool askUserToAcceptNoDigest( const Pathname &file ) - { cerr << ". Error:" << endl << "refusing file '" << file << "': no digest" << endl; return readCallbackAnswer(); } - virtual bool askUserToAccepUnknownDigest( const Pathname &file, const std::string &name ) - { cerr << ". Error:" << endl << "refusing file '" << file << "': unknown digest" << endl; return readCallbackAnswer(); } - virtual bool askUserToAcceptWrongDigest( const Pathname &file, const std::string &requested, const std::string &found ) - { cerr << ". Error:" << endl << "refusing file '" << file << "': wrong digest" << endl; return readCallbackAnswer(); } - }; - /////////////////////////////////////////////////////////////////// -}; // namespace zypp -/////////////////////////////////////////////////////////////////// - -class KeyRingCallbacks -{ - private: - KeyRingReceive _keyRingReport; - public: - KeyRingCallbacks() { _keyRingReport.connect(); } - ~KeyRingCallbacks() { _keyRingReport.disconnect(); } -}; - -class DigestCallbacks -{ - private: - DigestReceive _digestReport; - public: - DigestCallbacks() { _digestReport.connect(); } - ~DigestCallbacks() { _digestReport.disconnect(); } -}; - -int main( int argc, char **argv ) -{ - const char *logfile = getenv("ZYPP_LOGFILE"); - if ( logfile != NULL ) - base::LogControl::instance().logfile( logfile ); - else - base::LogControl::instance().logfile( ZYPP_REFRESH_LOG ); - - ZYpp::Ptr God; - try - { - God = getZYpp(); - } - catch ( const ZYppFactoryException & excpt_r ) - { - ZYPP_CAUGHT( excpt_r ); - cerr << - "Could not access the package manager engine." - " This usually happens when you have another application (like YaST)" - " using it at the same time. Close the other applications and try again."; - return 1; // the whole operation failed - } - catch ( const Exception & excpt_r) - { - ZYPP_CAUGHT( excpt_r ); - cerr << excpt_r.msg() << endl; - return 1; // the whole operation failed - } - - God->initializeTarget( "/" ); - RepoManager manager; - - KeyRingCallbacks keyring_callbacks; - DigestCallbacks digest_callbacks; - - std::list repos; - repos.insert( repos.end(), manager.repoBegin(), manager.repoEnd() ); - MIL << "Found " << repos.size() << " repos." << endl; - - unsigned repocount = 0, errcount = 0; - for( std::list::iterator it = repos.begin(); it != repos.end(); ++it, ++repocount ) - { - Url url = it->url(); - std::string scheme( url.getScheme() ); - - if ( url.schemeIsVolatile() ) // cd/dvd - { - MIL << "Skipping CD/DVD repository: " - "alias:[" << it->alias() << "] " - "url:[" << url << "] " << endl; - continue; - } - - // refresh only enabled repos with enabled autorefresh (bnc #410791) - if ( !( it->enabled() && it->autorefresh() ) ) - { - MIL << "Skipping disabled/no-autorefresh repository: " - "alias:[" << it->alias() << "] " - "url:[" << url << "] " << endl; - continue; - } - - MIL << "Going to refresh repository: " - "alias:[" << it->alias() << "] " - "url:[" << url << "] " << endl; - - try - { - cout << "refreshing '" << it->alias() << "' ." << std::flush; - manager.refreshMetadata(*it); - cout << "." << std::flush; - manager.buildCache(*it); - cout << ". Done." << endl; - } - catch ( const Exception &excpt_r ) - { - cerr - << " Error:" << endl - << str::form( - "Could not refresh repository '%s':\n%s\n%s", - it->name().c_str(), excpt_r.asUserString().c_str(), excpt_r.historyAsString().c_str()) - << endl; - ++errcount; - } - } - - if ( errcount ) - { - if ( repocount == errcount ) - return 1; // the whole operation failed (all of the repos) - - if ( repocount > errcount ) - return 2; // some of the repos failed - } - - // all right - return 0; -}