## Process this file with automake to produce Makefile.in
## ##################################################
-noinst_PROGRAMS = zmart
+noinst_PROGRAMS = zmart zypp-checkpatches
## ##################################################
-zmartincludedir = $(pkgincludedir)/source
-
-zmartinclude_HEADERS = \
- AliveCursor.h \
- zmart-keyring-callbacks.h \
- zmart-rpm-callbacks.h \
- zmart-source-callbacks.h \
- zmart-sources.h \
- zmart-misc.h \
- zmart.h
-
INCLUDES = -I$(top_srcdir)/tools/zmart -I$(oldincludedir)/libxml2
AM_LDFLAGS =
## ##################################################
-zmart_SOURCES = zmart.cc zmart-sources.cc zmart-misc.cc
+zmart_SOURCES = zmart.cc zmart-sources.cc zmart-misc.cc \
+ AliveCursor.h \
+ zmart-keyring-callbacks.h \
+ zmart-rpm-callbacks.h \
+ zmart-media-callbacks.h \
+ zmart-source-callbacks.h \
+ zmart-sources.h \
+ zmart-misc.h \
+ zmart.h
+
+zypp_checkpatches_SOURCES = zypp-checkpatches.cc zmart-sources.cc \
+ checkpatches-keyring-callbacks.h
#zmart_LDFLAGS = -static
.PHONY: always
#include <zypp/KeyRing.h>
#include <zypp/Digest.h>
+#include "zmart-misc.h"
+
///////////////////////////////////////////////////////////////////
namespace zypp {
-///////////////////////////////////////////////////////////////////
-
-
- // read callback answer
- // can either be '0\n' -> false
- // or '1\n' -> true
- // reads characters from stdin until newline. Defaults to 'false'
- static bool
- readBoolAnswer()
- {
- char c = 0;
- int count = 0;
- while ( (c != 'y') && (c != 'Y') && (c != 'N') && (c != 'n') )
- cin >> c ;
-
- if ( ( c == 'y' ) || ( c == 'Y' ) )
- return true;
- else
- return false;
- }
+/////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// KeyRingReceive
extern RuntimeData gData;
extern Settings gSettings;
+// read callback answer
+// can either be '0\n' -> false
+// or '1\n' -> true
+// reads characters from stdin until newline. Defaults to 'false'
+bool readBoolAnswer()
+{
+ char c = 0;
+ int count = 0;
+ while ( (c != 'y') && (c != 'Y') && (c != 'N') && (c != 'n') )
+ cin >> c ;
+
+ if ( ( c == 'y' ) || ( c == 'Y' ) )
+ return true;
+ else
+ return false;
+}
+
void mark_package_for_install( const std::string &name )
{
CapSet capset;
#include <string>
#include "zypp/Url.h"
+bool readBoolAnswer();
void mark_package_for_install( const std::string &name );
void show_summary();
std::string calculate_token();
| /_____||_| |_| |_| |
| |
\---------------------------------------------------------------------*/
-/** \file zmd/backend/RpmCallbacks.cc
- *
-*/
-#ifndef ZMD_BACKEND_RPMCALLBACKS_H
-#define ZMD_BACKEND_RPMCALLBACKS_H
+#ifndef ZMART_RPM_CALLBACKS_H
+#define ZMART_RPM_CALLBACKS_H
#include <iostream>
#include <string>
#include <zypp/base/Logger.h>
#include <zypp/ZYppCallbacks.h>
#include <zypp/Package.h>
-#include <zypp/target/rpm/RpmCallbacks.h>
+//#include <zypp/target/rpm/RpmCallbacks.h>
#include "AliveCursor.h"
namespace ZmartRecipients
{
-// // resolvable Message
-// struct MessageResolvableReportReceiver : public zypp::callback::ReceiveReport<zypp::target::MessageResolvableReport>
-// {
-// virtual void show( Message::constPtr message )
-// {
-//
-// }
-// };
+// resolvable Message
+struct MessageResolvableReportReceiver : public zypp::callback::ReceiveReport<zypp::target::MessageResolvableReport>
+{
+ virtual void show( zypp::Message::constPtr message )
+ {
+
+ }
+};
///////////////////////////////////////////////////////////////////
//
}
};
+ // progress for removing a resolvable
+struct RemoveResolvableReportReceiver : public zypp::callback::ReceiveReport<zypp::target::rpm::RemoveResolvableReport>
+{
+ virtual void start( zypp::Resolvable::constPtr resolvable )
+ {}
+
+ virtual bool progress(int value, zypp::Resolvable::constPtr resolvable)
+ { return true; }
+
+ virtual Action problem( zypp::Resolvable::constPtr resolvable, Error error, std::string description )
+ { return ABORT; }
+
+ virtual void finish( zypp::Resolvable::constPtr resolvable, Error error, std::string reason )
+ {}
+};
+
+// progress for installing a resolvable
+struct InstallResolvableReportReceiver : public zypp::callback::ReceiveReport<zypp::target::rpm::InstallResolvableReport>
+{
+ AliveCursor _cursor;
+ zypp::Resolvable::constPtr _resolvable;
+
+ void display_step( zypp::Resolvable::constPtr resolvable, int value )
+ {
+ cout << "\x1B 2K\r" << _cursor << " Installing " << resolvable << " [" << value << " %] ";
+ ++_cursor;
+ }
+
+ virtual void start( zypp::Resolvable::constPtr resolvable )
+ {
+ _resolvable = resolvable;
+ }
+
+ virtual bool progress(int value, zypp::Resolvable::constPtr resolvable)
+ {
+ display_step( resolvable, value );
+ }
+
+ virtual Action problem( zypp::Resolvable::constPtr resolvable, Error error, std::string description, RpmLevel level )
+ {
+ std::cout << resolvable << " " << description << std::endl;
+ return ABORT;
+ }
+
+ virtual void finish( zypp::Resolvable::constPtr resolvable, Error error, std::string reason, RpmLevel level )
+ {}
+};
+
+
///////////////////////////////////////////////////////////////////
}; // namespace ZyppRecipients
///////////////////////////////////////////////////////////////////
class RpmCallbacks {
private:
- //ZyppRecipients::InstallPkgReceive _installReceiver;
- //ZyppRecipients::RemovePkgReceive _removeReceiver;
+ ZmartRecipients::MessageResolvableReportReceiver _messageReceiver;
ZmartRecipients::ScanRpmDbReceive _readReceiver;
+ ZmartRecipients::RemoveResolvableReportReceiver _installReceiver;
+ ZmartRecipients::InstallResolvableReportReceiver _removeReceiver;
int _step_counter;
public:
//, _removeReceiver( _step_counter )
, _step_counter( 0 )
{
- //_installReceiver.connect();
- //_removeReceiver.connect();
+ _messageReceiver.connect();
+ _installReceiver.connect();
+ _removeReceiver.connect();
_readReceiver.connect();
}
~RpmCallbacks()
{
- //_installReceiver.disconnect();
- //_removeReceiver.disconnect();
+ _messageReceiver.disconnect();
+ _installReceiver.disconnect();
+ _removeReceiver.disconnect();
_readReceiver.connect();
}
-
};
#endif // ZMD_BACKEND_RPMCALLBACKS_H
};
-
+// progress for downloading a resolvable
+struct DownloadResolvableReportReceiver : public zypp::callback::ReceiveReport<zypp::source::DownloadResolvableReport>
+{
+ zypp::Resolvable::constPtr _resolvable_ptr;
+ zypp::Url _url;
+ AliveCursor _cursor;
+ zypp::Pathname _delta;
+ zypp::ByteCount _delta_size;
+ zypp::Pathname _patch;
+ zypp::ByteCount _patch_size;
+
+ virtual void start( zypp::Resolvable::constPtr resolvable_ptr, const zypp::Url &url )
+ {
+ _resolvable_ptr = resolvable_ptr;
+ _url = url;
+ }
+
+ void display_step( std::string what, int value )
+ {
+ cout << "\x1B 2K\r" << _cursor << " " << what << " [" << value << " %] ";
+ ++_cursor;
+ }
+
+ // Dowmload delta rpm:
+ // - path below url reported on start()
+ // - expected download size (0 if unknown)
+ // - download is interruptable
+ // - problems are just informal
+ virtual void startDeltaDownload( const zypp::Pathname & filename, const zypp::ByteCount & downloadsize )
+ {
+
+ }
+
+ virtual bool progressDeltaDownload( int value )
+ {
+ display_step( "Downloading delta " + _delta.asString(), value );
+ }
+
+ virtual void problemDeltaDownload( std::string description )
+ {
+ std::cout << description << std::endl;
+ }
+
+ virtual void finishDeltaDownload()
+ {
+ }
+
+ // Apply delta rpm:
+ // - local path of downloaded delta
+ // - aplpy is not interruptable
+ // - problems are just informal
+ virtual void startDeltaApply( const zypp::Pathname & filename )
+ {
+ _delta = filename;
+ }
+
+ virtual void progressDeltaApply( int value )
+ {
+ display_step( "Applying delta " + _delta.asString(), value );
+ }
+
+ virtual void problemDeltaApply( std::string description )
+ {
+ std::cout << description << std::endl;
+ }
+
+ virtual void finishDeltaApply()
+ {}
+
+ // Dowmload patch rpm:
+ // - path below url reported on start()
+ // - expected download size (0 if unknown)
+ // - download is interruptable
+ virtual void startPatchDownload( const zypp::Pathname & filename, const zypp::ByteCount & downloadsize )
+ {
+ _patch = filename;
+ _patch_size = downloadsize;
+ }
+
+ virtual bool progressPatchDownload( int value )
+ {
+ display_step( "Applying patchrpm " + _patch.asString(), value );
+ return true;
+ }
+
+ virtual void problemPatchDownload( std::string description )
+ {
+ std::cout << description << std::endl;
+ }
+
+ virtual void finishPatchDownload()
+ {}
+
+
+ // return false if the download should be aborted right now
+ virtual bool progress(int value, zypp::Resolvable::constPtr resolvable_ptr)
+ {
+ display_step( "Downloading " + resolvable_ptr->name(), value );
+ return true;
+ }
+
+ virtual Action problem( zypp::Resolvable::constPtr resolvable_ptr, Error error, std::string description )
+ {
+ std::cout << resolvable_ptr << " " << description << std::endl;
+ return ABORT;
+ }
+
+ virtual void finish( zypp::Resolvable::constPtr resolvable_ptr, Error error, std::string reason )
+ {}
+};
struct SourceReportReceiver : public zypp::callback::ReceiveReport<zypp::source::SourceReport>
{
private:
ZmartRecipients::ProbeSourceReceive _sourceProbeReport;
ZmartRecipients::SourceReportReceiver _SourceReport;
+ ZmartRecipients::DownloadResolvableReportReceiver _downloadReport;
public:
SourceCallbacks()
{
_sourceProbeReport.connect();
_SourceReport.connect();
+ _downloadReport.connect();
}
~SourceCallbacks()
{
_sourceProbeReport.disconnect();
_SourceReport.disconnect();
+ _downloadReport.disconnect();
}
};
#include "zmart-rpm-callbacks.h"
#include "zmart-keyring-callbacks.h"
#include "zmart-source-callbacks.h"
+#include "zmart-media-callbacks.h"
using namespace zypp::detail;
RpmCallbacks rpm_callbacks;
SourceCallbacks source_callbacks;
+MediaCallbacks media_callbacks;
int main(int argc, char **argv)
{
resolve();
show_summary();
+
+ std::cout << "Continue? [y/n] ";
+ if (readBoolAnswer())
+ {
+ ZYppCommitResult result = God->commit( ZYppCommitPolicy() );
+ std::cout << result << std::endl;
+ }
+}
- if ( gData.security_patches_count > 0 )
- return 2;
- if ( gData.patches_count > 0 )
- return 1;
- }
return 0;
}