From 927cfdb43a87ef0f822c01a433f252a3982252ff Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Mon, 6 Apr 2020 15:04:17 +0200 Subject: [PATCH 1/3] Remove unneeded files --- src/ZCOMMAND.cc | 57 ------------------------------------------- src/ZCOMMAND.h | 33 ------------------------- tools/zypper-help-all | 30 ----------------------- 3 files changed, 120 deletions(-) delete mode 100644 src/ZCOMMAND.cc delete mode 100644 src/ZCOMMAND.h delete mode 100755 tools/zypper-help-all diff --git a/src/ZCOMMAND.cc b/src/ZCOMMAND.cc deleted file mode 100644 index 1bdb43c1f4..0000000000 --- a/src/ZCOMMAND.cc +++ /dev/null @@ -1,57 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ____ _ _ __ _ __ ___ _ _ - |_ / || | '_ \ '_ \/ -_) '_| - /__|\_, | .__/ .__/\___|_| - |__/|_| |_| -\*---------------------------------------------------------------------------*/ - -#include -#include - -#include "Zypper.h" -#include "@command@.h" - -/////////////////////////////////////////////////////////////////// -// @Command@Options -/////////////////////////////////////////////////////////////////// - -inline std::ostream & operator<<( std::ostream & str, const @Command@Options & obj ) -{ return str << "@Command@Options"; } - -/////////////////////////////////////////////////////////////////// -namespace -{ - /////////////////////////////////////////////////////////////////// - /// \class @Command@Impl - /// \brief Implementation of @command@ - /////////////////////////////////////////////////////////////////// - class @Command@Impl : public CommandBase<@Command@Impl,@Command@Options> - { - typedef CommandBase<@Command@Impl,@Command@Options> CommandBase; - public: - @Command@Impl( Zypper & zypper_r ) : CommandBase( zypper_r ) {} - // CommandBase::_zypper - // CommandBase::options; // access/manip command options - // CommandBase::run; // action + catch and repost Out::Error - // CommandBase::execute; // run + final "Done"/"Finished with error" message - // CommandBase::showHelp; // Show user help on command - public: - /** default action */ - void action(); - }; - /////////////////////////////////////////////////////////////////// - - void @Command@Impl::action() - { - if ( true ) - throw( Out::Error( ZYPPER_EXIT_ERR_ZYPP, "error", "detail" ) ); - else - _zypper.setExitCode( ZYPPER_EXIT_ERR_ZYPP ); - } -} // namespace -/////////////////////////////////////////////////////////////////// - -int @command@( Zypper & zypper_r ) -{ - return @Command@Impl( zypper_r ).execute(); -} diff --git a/src/ZCOMMAND.h b/src/ZCOMMAND.h deleted file mode 100644 index 6d73808daf..0000000000 --- a/src/ZCOMMAND.h +++ /dev/null @@ -1,33 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ____ _ _ __ _ __ ___ _ _ - |_ / || | '_ \ '_ \/ -_) '_| - /__|\_, | .__/ .__/\___|_| - |__/|_| |_| -\*---------------------------------------------------------------------------*/ -#ifndef ZYPPER_@COMMAND@_H -#define ZYPPER_@COMMAND@_H - -#include -class Zypper; - -/* - @command@ ... -*/ - -/** @command@ specific options */ -struct @Command@Options : public MixinOptions -{ - @Command@Options() - {} - - //** @Command@ user help (translated). */ - //virtual std::ostream & showHelpOn( std::ostream & out ) const; - - bool _myopt = true; //< opts go here... -}; - -/** Execute @command@. - */ -int @command@( Zypper & zypper_r ); - -#endif // ZYPPER_@COMMAND@_H diff --git a/tools/zypper-help-all b/tools/zypper-help-all deleted file mode 100755 index 189ceda491..0000000000 --- a/tools/zypper-help-all +++ /dev/null @@ -1,30 +0,0 @@ -#! /bin/sh -# -# Prints zypper's main help and help texts of all commands. -# -# The script relies on 'zypper help' commands listed with one tab character at -# the beginning of line and containing only lowercase ascii letters and dashes. -# -# Disclaimer: this script is provided for case someone finds it useful. There -# is absolutely no warranty that it will do what you expect. - -ZYPPER=zypper -GREP=grep -SED=sed - -function printline () -{ - echo "-------------------------------------------------------------------------------" - echo -} - -$ZYPPER -V -echo -$ZYPPER help - -COMMANDS=$(LC_ALL=C $ZYPPER | $SED -e '1,/Repository Management:/d' | $GREP -P '^\t\w+' | $SED -e 's/^\t\([a-z-]\+\).*/\1/') -for CMD in $COMMANDS; do - printline - $ZYPPER help $CMD; -done - From 7ae72074db7c2e7a97bf97dce3e7adf1ded2c031 Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Mon, 6 Apr 2020 15:14:55 +0200 Subject: [PATCH 2/3] Deprecate legacy installation_sources script --- CMakeLists.txt | 5 +++++ {src => deprecated}/installation_sources | 6 ++++++ src/CMakeLists.txt | 7 ------- 3 files changed, 11 insertions(+), 7 deletions(-) rename {src => deprecated}/installation_sources (88%) diff --git a/CMakeLists.txt b/CMakeLists.txt index e44fd7bf18..6c00d68d41 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -130,3 +130,8 @@ INSTALL( DESTINATION ${SYSCONFDIR}/zypp/apt-packagemap.d ) +# installation_sources script (deprecated) +INSTALL( + PROGRAMS deprecated/installation_sources + DESTINATION ${INSTALL_PREFIX}/bin +) diff --git a/src/installation_sources b/deprecated/installation_sources similarity index 88% rename from src/installation_sources rename to deprecated/installation_sources index edf30dfea5..4ef04a5069 100644 --- a/src/installation_sources +++ b/deprecated/installation_sources @@ -2,6 +2,12 @@ # this is a compatibility replacement for a C++ program # that was in yast2-packagemanager.rpm +cat >&2 < Date: Mon, 6 Apr 2020 16:38:12 +0200 Subject: [PATCH 3/3] Deprecate legacy zypp-refresh script --- CMakeLists.txt | 15 +++ deprecated/zypp-refresh | 9 ++ deprecated/zypp-refresh.8 | 59 +++++++++ {src => deprecated}/zypp-refresh.lr | 0 doc/CMakeLists.txt | 2 +- doc/zypp-refresh.8.txt | 34 ----- src/CMakeLists.txt | 12 +- src/zypp-refresh.cc | 190 ---------------------------- 8 files changed, 85 insertions(+), 236 deletions(-) create mode 100644 deprecated/zypp-refresh create mode 100644 deprecated/zypp-refresh.8 rename {src => deprecated}/zypp-refresh.lr (100%) delete mode 100644 doc/zypp-refresh.8.txt delete mode 100644 src/zypp-refresh.cc 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; -}