From 8d7ae2ee2e40661839f3e4ecd1517b678323143e Mon Sep 17 00:00:00 2001 From: Juraj Lutter Date: Thu, 26 Nov 2020 17:30:58 +0100 Subject: [PATCH 1/4] pkg: Implement message type "before" to display a pre-(install|upgrade) message. --- libpkg/pkg.c | 7 +++ libpkg/pkg_add.c | 103 +++++++++++++++++++++++++------------------ libpkg/pkg_jobs.c | 2 +- libpkg/pkg_ports.c | 2 + libpkg/pkg_printf.c | 3 ++ libpkg/private/pkg.h | 7 +++ 6 files changed, 81 insertions(+), 43 deletions(-) diff --git a/libpkg/pkg.c b/libpkg/pkg.c index 8a02085644..334146130d 100644 --- a/libpkg/pkg.c +++ b/libpkg/pkg.c @@ -1735,6 +1735,8 @@ pkg_message_from_ucl(struct pkg *pkg, const ucl_object_t *obj) msg->type = PKG_MESSAGE_REMOVE; else if (strcasecmp(ucl_object_tostring(elt), "upgrade") == 0) msg->type = PKG_MESSAGE_UPGRADE; + else if (strcasecmp(ucl_object_tostring(elt), "before") == 0) + msg->type = PKG_MESSAGE_BEFORE; else pkg_emit_error("Unknown message type," " message will always be printed"); @@ -1830,6 +1832,11 @@ pkg_message_to_ucl(const struct pkg *pkg) ucl_object_fromstring("remove"), "type", 0, false); break; + case PKG_MESSAGE_BEFORE: + ucl_object_insert_key(obj, + ucl_object_fromstring("before"), + "type", 0, false); + break; } if (msg->maximum_version) { ucl_object_insert_key(obj, diff --git a/libpkg/pkg_add.c b/libpkg/pkg_add.c index 9a7c23c7bb..d363783d2d 100644 --- a/libpkg/pkg_add.c +++ b/libpkg/pkg_add.c @@ -1029,6 +1029,64 @@ pkg_rollback_cb(void *data) pkg_rollback_pkg((struct pkg *)data); } +static void +pkg_print_message(struct pkg *pkg, struct pkg *local, struct pkg *remote, + pkg_printmessage_t prepost) +{ + xstring *message = NULL; + struct pkg_message *msg; + const char *msgstr; + + LL_FOREACH(pkg->message, msg) { + msgstr = NULL; + if (prepost == PKG_PRINTMESSAGE_POST) { + if (msg->type == PKG_MESSAGE_ALWAYS) { + msgstr = msg->str; + } else if (local != NULL && + msg->type == PKG_MESSAGE_UPGRADE) { + if (msg->maximum_version == NULL && + msg->minimum_version == NULL) { + msgstr = msg->str; + } else if (msg->maximum_version == NULL) { + if (pkg_version_cmp(local->version, msg->minimum_version) == 1) { + msgstr = msg->str; + } + } else if (msg->minimum_version == NULL) { + if (pkg_version_cmp(local->version, msg->maximum_version) == -1) { + msgstr = msg->str; + } + } else if (pkg_version_cmp(local->version, msg->maximum_version) == -1 && + pkg_version_cmp(local->version, msg->minimum_version) == 1) { + msgstr = msg->str; + } + } else if (local == NULL && + msg->type == PKG_MESSAGE_INSTALL) { + msgstr = msg->str; + } + } else + if (msg->type == PKG_MESSAGE_BEFORE) + msgstr = msg->str; + if (msgstr != NULL) { + if (message == NULL) { + message = xstring_new(); + pkg_fprintf(message->fp, "=====\nMessage from " + "%n-%v:\n\n", pkg, pkg); + } + fprintf(message->fp, "--\n%s\n", msgstr); + } + } + if (pkg->message != NULL && message != NULL) { + fflush(message->fp); + if (prepost == PKG_PRINTMESSAGE_POST) + pkg_emit_message(message->buf); + else { + pkg_emit_notice(message->buf); + sleep(10); + } + xstring_free(message); + } +} + static int pkg_add_common(struct pkgdb *db, const char *path, unsigned flags, struct pkg_manifest_key *keys, const char *reloc, struct pkg *remote, @@ -1037,10 +1095,7 @@ pkg_add_common(struct pkgdb *db, const char *path, unsigned flags, struct archive *a; struct archive_entry *ae; struct pkg *pkg = NULL; - xstring *message = NULL; - struct pkg_message *msg; struct pkg_file *f; - const char *msgstr; bool extract = true; int retcode = EPKG_OK; int ret; @@ -1130,6 +1185,8 @@ pkg_add_common(struct pkgdb *db, const char *path, unsigned flags, if (retcode != EPKG_OK) goto cleanup; + pkg_print_message(pkg, local, remote, PKG_PRINTMESSAGE_PRE); + /* * Execute pre-install scripts */ @@ -1204,45 +1261,7 @@ pkg_add_common(struct pkgdb *db, const char *path, unsigned flags, pkg_emit_install_finished(pkg, local); } - LL_FOREACH(pkg->message, msg) { - msgstr = NULL; - if (msg->type == PKG_MESSAGE_ALWAYS) { - msgstr = msg->str; - } else if (local != NULL && - msg->type == PKG_MESSAGE_UPGRADE) { - if (msg->maximum_version == NULL && - msg->minimum_version == NULL) { - msgstr = msg->str; - } else if (msg->maximum_version == NULL) { - if (pkg_version_cmp(local->version, msg->minimum_version) == 1) { - msgstr = msg->str; - } - } else if (msg->minimum_version == NULL) { - if (pkg_version_cmp(local->version, msg->maximum_version) == -1) { - msgstr = msg->str; - } - } else if (pkg_version_cmp(local->version, msg->maximum_version) == -1 && - pkg_version_cmp(local->version, msg->minimum_version) == 1) { - msgstr = msg->str; - } - } else if (local == NULL && - msg->type == PKG_MESSAGE_INSTALL) { - msgstr = msg->str; - } - if (msgstr != NULL) { - if (message == NULL) { - message = xstring_new(); - pkg_fprintf(message->fp, "=====\nMessage from " - "%n-%v:\n\n", pkg, pkg); - } - fprintf(message->fp, "--\n%s\n", msgstr); - } - } - if (pkg->message != NULL && message != NULL) { - fflush(message->fp); - pkg_emit_message(message->buf); - xstring_free(message); - } + pkg_print_message(pkg, local, remote, PKG_PRINTMESSAGE_POST); cleanup: if (a != NULL) { diff --git a/libpkg/pkg_jobs.c b/libpkg/pkg_jobs.c index 02eb5de121..2b5a4bd8c0 100644 --- a/libpkg/pkg_jobs.c +++ b/libpkg/pkg_jobs.c @@ -76,7 +76,7 @@ struct pkg_jobs_locked { int (*locked_pkg_cb)(struct pkg *, void *); void *context; }; -static __thread struct pkg_jobs_locked *pkgs_job_lockedpkg; +static struct pkg_jobs_locked *pkgs_job_lockedpkg; #define IS_DELETE(j) ((j)->type == PKG_JOBS_DEINSTALL || (j)->type == PKG_JOBS_AUTOREMOVE) diff --git a/libpkg/pkg_ports.c b/libpkg/pkg_ports.c index 4580f0a324..85deb79eaf 100644 --- a/libpkg/pkg_ports.c +++ b/libpkg/pkg_ports.c @@ -984,6 +984,8 @@ apply_keyword_file(ucl_object_t *obj, struct plist *p, char *line, struct file_a msg->type = PKG_MESSAGE_REMOVE; else if (strcasecmp(ucl_object_tostring(elt), "upgrade") == 0) msg->type = PKG_MESSAGE_UPGRADE; + else if (strcasecmp(ucl_object_tostring(elt), "before") == 0) + msg->type = PKG_MESSAGE_BEFORE; } DL_APPEND(p->pkg->message, msg); } diff --git a/libpkg/pkg_printf.c b/libpkg/pkg_printf.c index 83e43ee937..a9e816c65d 100644 --- a/libpkg/pkg_printf.c +++ b/libpkg/pkg_printf.c @@ -1308,6 +1308,9 @@ format_message(xstring *buffer, const void *data, struct percent_esc *p) case PKG_MESSAGE_REMOVE: fprintf(bufmsg->fp, "On remove:\n"); break; + case PKG_MESSAGE_BEFORE: + fprintf(bufmsg->fp, "Before install or upgrade:\n"); + break; } fprintf(bufmsg->fp, "%s\n", msg->str); } diff --git a/libpkg/private/pkg.h b/libpkg/private/pkg.h index 9bcd96fa70..ce8ba07038 100644 --- a/libpkg/private/pkg.h +++ b/libpkg/private/pkg.h @@ -392,8 +392,15 @@ typedef enum { PKG_MESSAGE_INSTALL, PKG_MESSAGE_REMOVE, PKG_MESSAGE_UPGRADE, + PKG_MESSAGE_BEFORE, } pkg_message_t; +typedef enum { + PKG_PRINTMESSAGE_ALWAYS = 0, + PKG_PRINTMESSAGE_PRE, + PKG_PRINTMESSAGE_POST, +} pkg_printmessage_t; + struct pkg_message { char *str; char *minimum_version; From a49f3403c4d21929ba1befa3b0f0a6fc9b3ed1ba Mon Sep 17 00:00:00 2001 From: Juraj Lutter Date: Thu, 26 Nov 2020 19:57:17 +0100 Subject: [PATCH 2/4] pkg: Cleanup after tests - Update test suite to include also "before" - Update the keywords to include "before"-type message - Fix manual page pkg-keywords.5 --- docs/pkg-keywords.5 | 10 +++++++--- libpkg/pkg_ports.c | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/pkg-keywords.5 b/docs/pkg-keywords.5 index 65ffa7cee4..84e45be873 100644 --- a/docs/pkg-keywords.5 +++ b/docs/pkg-keywords.5 @@ -96,9 +96,13 @@ Valid information by entry in the array are: .Bl -tag .It Cm message Ar string actual message to be shown to the users. -.It Cm type Op Ar upgrade | Ar remove | Ar install -defines in which contect the message should be shown to the users. -If not set, the message will always be printed +.It Cm type Op Ar upgrade | Ar remove | Ar install | Ar before +defines in which context the message should be shown to the users. +If not set, the message will always be printed, when set to +.Va before , +message will be printed before install or upgrade and +.Xr pkg 8 +will sleep for 10 seconds. .El .El .Sh SEE ALSO diff --git a/libpkg/pkg_ports.c b/libpkg/pkg_ports.c index 85deb79eaf..14b02efa95 100644 --- a/libpkg/pkg_ports.c +++ b/libpkg/pkg_ports.c @@ -133,7 +133,7 @@ keyword_open_schema(void) " type = object;" " properties {" " message = { type = string };" - " type = { enum = [ upgrade, remove, install ] };" + " type = { enum = [ upgrade, remove, install, before ] };" " };" " required [ message ];" " };" From 682c9194ce5b90a714378d42677ac0deab2ed22b Mon Sep 17 00:00:00 2001 From: Juraj Lutter Date: Thu, 26 Nov 2020 20:29:11 +0100 Subject: [PATCH 3/4] pkg: Update tests and revert accidential removel of __thread --- libpkg/pkg_jobs.c | 2 +- tests/frontend/create.sh | 6 +++++- tests/frontend/messages.sh | 4 ++++ tests/frontend/register.sh | 4 ++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/libpkg/pkg_jobs.c b/libpkg/pkg_jobs.c index 2b5a4bd8c0..02eb5de121 100644 --- a/libpkg/pkg_jobs.c +++ b/libpkg/pkg_jobs.c @@ -76,7 +76,7 @@ struct pkg_jobs_locked { int (*locked_pkg_cb)(struct pkg *, void *); void *context; }; -static struct pkg_jobs_locked *pkgs_job_lockedpkg; +static __thread struct pkg_jobs_locked *pkgs_job_lockedpkg; #define IS_DELETE(j) ((j)->type == PKG_JOBS_DEINSTALL || (j)->type == PKG_JOBS_AUTOREMOVE) diff --git a/tests/frontend/create.sh b/tests/frontend/create.sh index 7d544ddc9d..ea7c09c014 100755 --- a/tests/frontend/create.sh +++ b/tests/frontend/create.sh @@ -558,8 +558,9 @@ cat << EOF > showmsg.ucl actions: [] messages: [ { message: "always" }, - { message: "on upgrade";type = "upgrade" }, + { message: "on upgrade"; type = "upgrade" }, { message: "on install"; type = "install" }, + { message: "before operation"; type = "before" }, ] EOF cat << EOF > +DISPLAY @@ -579,6 +580,9 @@ on upgrade On install: on install +Before install or upgrade: +before operation + ' atf_check pkg -o PLIST_KEYWORDS_DIR=. create -m . -r ${TMPDIR} -p test.plist atf_check -o inline:"${OUTPUT}" pkg info -D -F ./test-1.txz diff --git a/tests/frontend/messages.sh b/tests/frontend/messages.sh index 83608d2fa0..d47250d7ea 100755 --- a/tests/frontend/messages.sh +++ b/tests/frontend/messages.sh @@ -18,6 +18,7 @@ comment: "need one" desc: "also need one" message: [ { message: "Always print" }, + { message: "Before operation", type: before }, { message: "package being removed", type: remove }, { message: "package being installed", type: install }, { message: "package is being upgraded", type: upgrade }, @@ -97,6 +98,9 @@ OUTPUT='test-5.20_3: Always: Always print +Before install or upgrade: +Before operation + On remove: package being removed diff --git a/tests/frontend/register.sh b/tests/frontend/register.sh index db02c2435e..aaf11ae0e8 100755 --- a/tests/frontend/register.sh +++ b/tests/frontend/register.sh @@ -62,6 +62,7 @@ message { message: "hey"}, { message: "install", type = install}, { message: "remove", type = remove}, + { message: "before", type = before}, ] EOF OUTPUT='test2-1: @@ -74,6 +75,9 @@ install On remove: remove +Before install or upgrade: +before + ' atf_check -o match:"hey" -o match:"install" -o not-match:"remove" pkg register -m . atf_check -o inline:"${OUTPUT}" pkg info -D test2 From ce057e46e7eaf25d5d0b50b5d6934b4a71472277 Mon Sep 17 00:00:00 2001 From: Juraj Lutter Date: Fri, 4 Dec 2020 23:19:59 +0100 Subject: [PATCH 4/4] pkg: Implement pre-install, pre-remove, pre-upgrade messages. --- libpkg/pkg.c | 22 ++++++++++++++---- libpkg/pkg_add.c | 47 +++++++++++++++++++------------------- libpkg/pkg_delete.c | 20 ++++++++++++++-- libpkg/pkg_ports.c | 10 +++++--- libpkg/pkg_printf.c | 10 ++++++-- libpkg/private/pkg.h | 4 +++- tests/frontend/create.sh | 10 +++++--- tests/frontend/messages.sh | 14 +++++++++--- tests/frontend/register.sh | 10 +++++--- 9 files changed, 103 insertions(+), 44 deletions(-) diff --git a/libpkg/pkg.c b/libpkg/pkg.c index 334146130d..a432c4b11d 100644 --- a/libpkg/pkg.c +++ b/libpkg/pkg.c @@ -1735,8 +1735,12 @@ pkg_message_from_ucl(struct pkg *pkg, const ucl_object_t *obj) msg->type = PKG_MESSAGE_REMOVE; else if (strcasecmp(ucl_object_tostring(elt), "upgrade") == 0) msg->type = PKG_MESSAGE_UPGRADE; - else if (strcasecmp(ucl_object_tostring(elt), "before") == 0) - msg->type = PKG_MESSAGE_BEFORE; + else if (strcasecmp(ucl_object_tostring(elt), "pre-install") == 0) + msg->type = PKG_MESSAGE_PREINSTALL; + else if (strcasecmp(ucl_object_tostring(elt), "pre-remove") == 0) + msg->type = PKG_MESSAGE_PREREMOVE; + else if (strcasecmp(ucl_object_tostring(elt), "pre-upgrade") == 0) + msg->type = PKG_MESSAGE_PREUPGRADE; else pkg_emit_error("Unknown message type," " message will always be printed"); @@ -1832,9 +1836,19 @@ pkg_message_to_ucl(const struct pkg *pkg) ucl_object_fromstring("remove"), "type", 0, false); break; - case PKG_MESSAGE_BEFORE: + case PKG_MESSAGE_PREINSTALL: ucl_object_insert_key(obj, - ucl_object_fromstring("before"), + ucl_object_fromstring("pre-install"), + "type", 0, false); + break; + case PKG_MESSAGE_PREUPGRADE: + ucl_object_insert_key(obj, + ucl_object_fromstring("pre-upgrade"), + "type", 0, false); + break; + case PKG_MESSAGE_PREREMOVE: + ucl_object_insert_key(obj, + ucl_object_fromstring("pre-remove"), "type", 0, false); break; } diff --git a/libpkg/pkg_add.c b/libpkg/pkg_add.c index d363783d2d..a7b20ca8ff 100644 --- a/libpkg/pkg_add.c +++ b/libpkg/pkg_add.c @@ -1039,33 +1039,34 @@ pkg_print_message(struct pkg *pkg, struct pkg *local, struct pkg *remote, LL_FOREACH(pkg->message, msg) { msgstr = NULL; - if (prepost == PKG_PRINTMESSAGE_POST) { - if (msg->type == PKG_MESSAGE_ALWAYS) { + /* Print "always"-type only post-operation */ + if ((msg->type == PKG_MESSAGE_ALWAYS) && + (prepost == PKG_PRINTMESSAGE_POST)) { + msgstr = msg->str; + } else if (local != NULL && + msg->type == ((prepost == PKG_PRINTMESSAGE_POST) ? + PKG_MESSAGE_UPGRADE : PKG_MESSAGE_PREUPGRADE)) { + if (msg->maximum_version == NULL && + msg->minimum_version == NULL) { msgstr = msg->str; - } else if (local != NULL && - msg->type == PKG_MESSAGE_UPGRADE) { - if (msg->maximum_version == NULL && - msg->minimum_version == NULL) { - msgstr = msg->str; - } else if (msg->maximum_version == NULL) { - if (pkg_version_cmp(local->version, msg->minimum_version) == 1) { - msgstr = msg->str; - } - } else if (msg->minimum_version == NULL) { - if (pkg_version_cmp(local->version, msg->maximum_version) == -1) { - msgstr = msg->str; - } - } else if (pkg_version_cmp(local->version, msg->maximum_version) == -1 && - pkg_version_cmp(local->version, msg->minimum_version) == 1) { + } else if (msg->maximum_version == NULL) { + if (pkg_version_cmp(local->version, msg->minimum_version) == 1) { msgstr = msg->str; } - } else if (local == NULL && - msg->type == PKG_MESSAGE_INSTALL) { + } else if (msg->minimum_version == NULL) { + if (pkg_version_cmp(local->version, msg->maximum_version) == -1) { msgstr = msg->str; + } + } else if (pkg_version_cmp(local->version, msg->maximum_version) == -1 && + pkg_version_cmp(local->version, msg->minimum_version) == 1) { + msgstr = msg->str; } - } else - if (msg->type == PKG_MESSAGE_BEFORE) - msgstr = msg->str; + } else if (local == NULL && + msg->type == ( + (prepost == PKG_PRINTMESSAGE_POST ? + PKG_MESSAGE_INSTALL : PKG_MESSAGE_PREINSTALL))) { + msgstr = msg->str; + } if (msgstr != NULL) { if (message == NULL) { message = xstring_new(); @@ -1080,7 +1081,7 @@ pkg_print_message(struct pkg *pkg, struct pkg *local, struct pkg *remote, if (prepost == PKG_PRINTMESSAGE_POST) pkg_emit_message(message->buf); else { - pkg_emit_notice(message->buf); + pkg_emit_notice("%s", message->buf); sleep(10); } xstring_free(message); diff --git a/libpkg/pkg_delete.c b/libpkg/pkg_delete.c index 20141eef9f..4b75d7416f 100644 --- a/libpkg/pkg_delete.c +++ b/libpkg/pkg_delete.c @@ -62,7 +62,6 @@ pkg_delete(struct pkg *pkg, struct pkgdb *db, unsigned flags) bool handle_rc = false; const unsigned load_flags = PKG_LOAD_RDEPS|PKG_LOAD_FILES|PKG_LOAD_DIRS| PKG_LOAD_SCRIPTS|PKG_LOAD_ANNOTATIONS|PKG_LOAD_LUA_SCRIPTS; - bool head = true; assert(pkg != NULL); assert(db != NULL); @@ -81,6 +80,24 @@ pkg_delete(struct pkg *pkg, struct pkgdb *db, unsigned flags) return (EPKG_LOCKED); } + /* Print pre-action message(s), if any */ + LL_FOREACH(pkg->message, msg) { + if (msg->type == PKG_MESSAGE_PREREMOVE) { + if (message == NULL) { + message = xstring_new(); + pkg_fprintf(message->fp, "Message from " + "%n-%v:\n", pkg, pkg); + } + fprintf(message->fp, "%s\n", msg->str); + } + } + if (pkg->message != NULL && message != NULL) { + fflush(message->fp); + pkg_emit_notice("%s", message->buf); + xstring_free(message); + message = NULL; + } + /* * stop the different related services if the users do want that * and that the service is running @@ -122,7 +139,6 @@ pkg_delete(struct pkg *pkg, struct pkgdb *db, unsigned flags) message = xstring_new(); pkg_fprintf(message->fp, "Message from " "%n-%v:\n", pkg, pkg); - head = false; } fprintf(message->fp, "%s\n", msg->str); } diff --git a/libpkg/pkg_ports.c b/libpkg/pkg_ports.c index 14b02efa95..8634c787d7 100644 --- a/libpkg/pkg_ports.c +++ b/libpkg/pkg_ports.c @@ -133,7 +133,7 @@ keyword_open_schema(void) " type = object;" " properties {" " message = { type = string };" - " type = { enum = [ upgrade, remove, install, before ] };" + " type = { enum = [ upgrade, remove, install, pre-upgrade, pre-remove, pre-install ] };" " };" " required [ message ];" " };" @@ -984,8 +984,12 @@ apply_keyword_file(ucl_object_t *obj, struct plist *p, char *line, struct file_a msg->type = PKG_MESSAGE_REMOVE; else if (strcasecmp(ucl_object_tostring(elt), "upgrade") == 0) msg->type = PKG_MESSAGE_UPGRADE; - else if (strcasecmp(ucl_object_tostring(elt), "before") == 0) - msg->type = PKG_MESSAGE_BEFORE; + else if (strcasecmp(ucl_object_tostring(elt), "pre-install") == 0) + msg->type = PKG_MESSAGE_PREINSTALL; + else if (strcasecmp(ucl_object_tostring(elt), "pre-remove") == 0) + msg->type = PKG_MESSAGE_PREREMOVE; + else if (strcasecmp(ucl_object_tostring(elt), "pre-upgrade") == 0) + msg->type = PKG_MESSAGE_PREUPGRADE; } DL_APPEND(p->pkg->message, msg); } diff --git a/libpkg/pkg_printf.c b/libpkg/pkg_printf.c index a9e816c65d..b3e6deb945 100644 --- a/libpkg/pkg_printf.c +++ b/libpkg/pkg_printf.c @@ -1308,8 +1308,14 @@ format_message(xstring *buffer, const void *data, struct percent_esc *p) case PKG_MESSAGE_REMOVE: fprintf(bufmsg->fp, "On remove:\n"); break; - case PKG_MESSAGE_BEFORE: - fprintf(bufmsg->fp, "Before install or upgrade:\n"); + case PKG_MESSAGE_PREINSTALL: + fprintf(bufmsg->fp, "Before install:\n"); + break; + case PKG_MESSAGE_PREREMOVE: + fprintf(bufmsg->fp, "Before remove:\n"); + break; + case PKG_MESSAGE_PREUPGRADE: + fprintf(bufmsg->fp, "Before upgrade:\n"); break; } fprintf(bufmsg->fp, "%s\n", msg->str); diff --git a/libpkg/private/pkg.h b/libpkg/private/pkg.h index ce8ba07038..63ad75353b 100644 --- a/libpkg/private/pkg.h +++ b/libpkg/private/pkg.h @@ -392,7 +392,9 @@ typedef enum { PKG_MESSAGE_INSTALL, PKG_MESSAGE_REMOVE, PKG_MESSAGE_UPGRADE, - PKG_MESSAGE_BEFORE, + PKG_MESSAGE_PREINSTALL, + PKG_MESSAGE_PREREMOVE, + PKG_MESSAGE_PREUPGRADE, } pkg_message_t; typedef enum { diff --git a/tests/frontend/create.sh b/tests/frontend/create.sh index ea7c09c014..89c7604436 100755 --- a/tests/frontend/create.sh +++ b/tests/frontend/create.sh @@ -560,7 +560,8 @@ messages: [ { message: "always" }, { message: "on upgrade"; type = "upgrade" }, { message: "on install"; type = "install" }, - { message: "before operation"; type = "before" }, + { message: "before upgrade"; type = "pre-upgrade" }, + { message: "before install"; type = "pre-install" }, ] EOF cat << EOF > +DISPLAY @@ -580,8 +581,11 @@ on upgrade On install: on install -Before install or upgrade: -before operation +Before upgrade: +before upgrade + +Before install: +before install ' atf_check pkg -o PLIST_KEYWORDS_DIR=. create -m . -r ${TMPDIR} -p test.plist diff --git a/tests/frontend/messages.sh b/tests/frontend/messages.sh index d47250d7ea..ab2b79d1cd 100755 --- a/tests/frontend/messages.sh +++ b/tests/frontend/messages.sh @@ -18,7 +18,9 @@ comment: "need one" desc: "also need one" message: [ { message: "Always print" }, - { message: "Before operation", type: before }, + { message: "Before remove", type: pre-remove }, + { message: "Before install", type: pre-install }, + { message: "Before upgrade", type: pre-upgrade }, { message: "package being removed", type: remove }, { message: "package being installed", type: install }, { message: "package is being upgraded", type: upgrade }, @@ -98,8 +100,14 @@ OUTPUT='test-5.20_3: Always: Always print -Before install or upgrade: -Before operation +Before remove: +Before remove + +Before install: +Before install + +Before upgrade: +Before upgrade On remove: package being removed diff --git a/tests/frontend/register.sh b/tests/frontend/register.sh index aaf11ae0e8..2114eebfe6 100755 --- a/tests/frontend/register.sh +++ b/tests/frontend/register.sh @@ -62,7 +62,8 @@ message { message: "hey"}, { message: "install", type = install}, { message: "remove", type = remove}, - { message: "before", type = before}, + { message: "before install", type = pre-install}, + { message: "before remove", type = pre-remove}, ] EOF OUTPUT='test2-1: @@ -75,8 +76,11 @@ install On remove: remove -Before install or upgrade: -before +Before install: +before install + +Before remove: +before remove ' atf_check -o match:"hey" -o match:"install" -o not-match:"remove" pkg register -m .