[devel] [PATCH for apt] Implemented generic callback system for package manager transactions

Dmitry V. Levin ldv на altlinux.org
Вт Дек 10 03:30:42 MSK 2019


On Fri, Dec 06, 2019 at 04:12:01PM +0300, Oleg Solovyov wrote:
> ---
>  apt/apt-pkg/packagemanager.cc |   4 +-
>  apt/apt-pkg/packagemanager.h  |  30 +++++++-
>  apt/apt-pkg/rpm/rpmpm.cc      | 137 ++++++++++++++++++++++++++++++++--
>  apt/apt-pkg/rpm/rpmpm.h       |  16 ++--
>  4 files changed, 170 insertions(+), 17 deletions(-)

I agree the code should speak for itself, but it would be great
if you could shed some light on what's going on.

[...]
> +   aptCallbackType callbackType = APTCALLBACK_UNKNOWN;
> +   switch (what) {
> +      case RPMCALLBACK_INST_PROGRESS:
> +         callbackType = APTCALLBACK_INST_PROGRESS;
> +         break;
> +      case RPMCALLBACK_INST_START:
> +         callbackType = APTCALLBACK_INST_START;
> +         break;
> +      case RPMCALLBACK_TRANS_PROGRESS:
> +         callbackType = APTCALLBACK_TRANS_PROGRESS;
> +         break;
> +      case RPMCALLBACK_TRANS_START:
> +         callbackType = APTCALLBACK_TRANS_START;
> +         break;
> +      case RPMCALLBACK_TRANS_STOP:
> +         callbackType = APTCALLBACK_TRANS_STOP;
> +         break;
> +      case RPMCALLBACK_UNINST_PROGRESS:
> +         callbackType = APTCALLBACK_UNINST_PROGRESS;
> +         break;
> +      case RPMCALLBACK_UNINST_START:
> +         callbackType = APTCALLBACK_UNINST_START;
> +         break;
> +      case RPMCALLBACK_UNINST_STOP:
> +         callbackType = APTCALLBACK_UNINST_STOP;
> +         break;
> +      case RPMCALLBACK_UNPACK_ERROR:
> +         callbackType = APTCALLBACK_UNPACK_ERROR;
> +         break;
> +      case RPMCALLBACK_CPIO_ERROR:
> +         callbackType = APTCALLBACK_CPIO_ERROR;
> +         break;
> +      case RPMCALLBACK_SCRIPT_ERROR:
> +         callbackType = APTCALLBACK_SCRIPT_ERROR;
> +         break;
> +      case RPMCALLBACK_SCRIPT_START:
> +         callbackType = APTCALLBACK_SCRIPT_START;
> +         break;
> +      case RPMCALLBACK_SCRIPT_STOP:
> +         callbackType = APTCALLBACK_SCRIPT_STOP;
> +         break;
> +      case RPMCALLBACK_INST_STOP:
> +         callbackType = APTCALLBACK_INST_STOP;
> +         break;
> +      case RPMCALLBACK_ELEM_PROGRESS:
> +         callbackType = APTCALLBACK_ELEM_PROGRESS;
> +         break;
> +      default:
> +         break;
> +   }

This looks ugly.  Could we use the same values for corresponding
APTCALLBACK_* and RPMCALLBACK_* constants instead?


-- 
ldv
----------- следующая часть -----------
Было удалено вложение не в текстовом формате...
Имя     : signature.asc
Тип     : application/pgp-signature
Размер  : 801 байтов
Описание: отсутствует
Url     : <http://lists.altlinux.org/pipermail/devel/attachments/20191210/87d5095f/attachment-0001.bin>


Подробная информация о списке рассылки Devel