From allan at archlinux.org Mon Dec 2 03:49:54 2019 From: allan at archlinux.org (Allan McRae) Date: Mon, 2 Dec 2019 13:49:54 +1000 Subject: [pacman-dev] [PATCH v2] pacman: print error when -Fx is given invalid regex In-Reply-To: <20191127174519.267931-1-morganamilo@archlinux.org> References: <20191127174519.267931-1-morganamilo@archlinux.org> Message-ID: <1e5a1776-09bb-19e2-a67e-f1a6a08b62f1@archlinux.org> On 28/11/19 3:45 am, morganamilo wrote: > When processing the targets for -Fx, compile all the regex ahead of > time, printing an error for each that failed to compile. Then, if they all > compiled successfully, continue with printing files. > > Signed-off-by: morganamilo > > --- > > v2: > Add comment about why we don't free targ > Fix whitespace error > > I have vim set to display trialing whitespace so normally I catch it. > Not sure why I didn't this time. > > Also I agree that running all the regex against each target before > moving on to the next is a good improvement. This patch is already kinda > long though, so I'll do it another time. > > diff --git a/src/pacman/files.c b/src/pacman/files.c > index 3b6dc23b..6fcc6e9b 100644 > --- a/src/pacman/files.c > +++ b/src/pacman/files.c > @@ -94,17 +94,27 @@ static void print_match(alpm_list_t *match, alpm_db_t *repo, alpm_pkg_t *pkg, in > } > } > > +struct filetarget { > + char *targ; > + int exact_file; > + regex_t reg; > +}; > + > +static void filetarget_free(struct filetarget *ftarg) { > + regfree(&ftarg->reg); > + /* we don't own ftarg->targ so don't free it */ Patch looks good. I changed that comment to: do not free ftarg->targ as it is owned by the caller of files_search This does a few useful things: 1) gets the "do not free" right at the start of the comment 2) specifies where the memory is owned 3) does not use contractions - apparently the use of "not" make the negative clearer for non-native speakers, although I am not sure what sort of evidence is behind that is claim... Allan From allan at archlinux.org Mon Dec 2 04:08:44 2019 From: allan at archlinux.org (Allan McRae) Date: Mon, 2 Dec 2019 14:08:44 +1000 Subject: [pacman-dev] [PATCH 1/3] libmakepkg: use extraction commands instead of file to find archive type In-Reply-To: <20191126212957.29031-1-e5ten.arch@gmail.com> References: <20191126212957.29031-1-e5ten.arch@gmail.com> Message-ID: <939f4cf7-cee3-68e8-2aa5-5ad5567f672d@archlinux.org> On 27/11/19 7:29 am, Ethan Sommer wrote: > Previously, to determine which command we should use to extract an > archive, we would run file and match the output against our list of > possible extraction commands > > Instead, run the archive through each extraction command's -t (--test) > flag, if this succeeds then we know that the command is able to extract > the file and is the one to use > Apart from the issues Eli brought up, there is a large performance regression on large source files. $ time file -bizL libreoffice-6.3.4.1.tar.xz application/x-tar; charset=binary compressed-encoding=application/x-xz; charset=binary real 0m0.034s user 0m0.031s sys 0m0.004s $ time xz -t libreoffice-6.3.4.1.tar.xz real 0m11.970s user 0m11.898s sys 0m0.057s Allan From allan at archlinux.org Mon Dec 2 05:44:07 2019 From: allan at archlinux.org (Allan McRae) Date: Mon, 2 Dec 2019 15:44:07 +1000 Subject: [pacman-dev] [PATCH 2/2] remove: Don't follow symlinks in checking if a file can be removed In-Reply-To: <20191127204051.782-2-rymg19@gmail.com> References: <20191127204051.782-1-rymg19@gmail.com> <20191127204051.782-2-rymg19@gmail.com> Message-ID: <20f09ed1-3088-7e0a-84ad-5fb6efbc7f64@archlinux.org> On 28/11/19 6:40 am, Ryan Gonzalez wrote: > Otherwise, symlinks to non-removable files will be logged as unable to > be removed. > > Signed-off-by: Ryan Gonzalez > --- > lib/libalpm/remove.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c > index 9030bfee..bb980e7d 100644 > --- a/lib/libalpm/remove.c > +++ b/lib/libalpm/remove.c > @@ -339,7 +339,7 @@ static int can_remove_file(alpm_handle_t *handle, const alpm_file_t *file) > > /* If we fail write permissions due to a read-only filesystem, abort. > * Assume all other possible failures are covered somewhere else */ > - if(_alpm_access(handle, NULL, filepath, W_OK) == -1) { > + if(_alpm_access_flags(handle, NULL, filepath, W_OK, AT_SYMLINK_NOFOLLOW) == -1) { AT_SYMLINK_NOFOLLOW is available on Linux and MSYS2 (which are the largest users of pacman), but not BSD/OSX and we do have some users there. > if(errno != EACCES && errno != ETXTBSY && access(filepath, F_OK) == 0) { > /* only return failure if the file ACTUALLY exists and we can't write to > * it - ignore "chmod -w" simple permission failures */ > From allan at archlinux.org Wed Dec 11 00:22:22 2019 From: allan at archlinux.org (Allan McRae) Date: Wed, 11 Dec 2019 00:22:22 +0000 (UTC) Subject: [pacman-dev] [GIT] The official pacman repository branch, master, updated. v5.2.1-26-gb7f61aa5 Message-ID: <20191211002222.B3A5D2B78F@luna.archlinux.org> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "The official pacman repository". The branch, master has been updated via b7f61aa55755d95d2e3a6dd7058971c68276c369 (commit) from 0428f6213bcb5586d4ec9feb18af9a883c463793 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit b7f61aa55755d95d2e3a6dd7058971c68276c369 Author: morganamilo Date: Wed Nov 27 17:45:20 2019 +0000 pacman: print error when -Fx is given invalid regex When processing the targets for -Fx, compile all the regex ahead of time, printing an error for each that failed to compile. Then, if they all compiled successfully, continue with printing files. Signed-off-by: morganamilo Signed-off-by: Allan McRae ----------------------------------------------------------------------- Summary of changes: src/pacman/files.c | 57 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 44 insertions(+), 13 deletions(-) hooks/post-receive -- The official pacman repository From allan at archlinux.org Wed Dec 11 00:22:38 2019 From: allan at archlinux.org (Allan McRae) Date: Wed, 11 Dec 2019 10:22:38 +1000 Subject: [pacman-dev] [PATCH v2] pacman+libalpm: print version names for conflicting packages In-Reply-To: <20191127204045.501505-1-morganamilo@archlinux.org> References: <20191127204045.501505-1-morganamilo@archlinux.org> Message-ID: On 28/11/19 6:40 am, morganamilo wrote: > When ever pacman prints a conflict, it now prints pkgname-version, > instead of just pkgname. > > alpm_conflict_t now carries pointers to alpm_pkg_t instead of just the > names of each package. > > Fixes FS#12536 (point 2) > > --- > > v2: dupe each alpm_pkg_t One typo spotted, and a suggestion for improving output. Allan > > diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h > index 956284bd..b0aa0671 100644 > --- a/lib/libalpm/alpm.h > +++ b/lib/libalpm/alpm.h > @@ -247,10 +247,8 @@ typedef struct _alpm_depmissing_t { > > /** Conflict */ > typedef struct _alpm_conflict_t { > - unsigned long package1_hash; > - unsigned long package2_hash; > - char *package1; > - char *package2; > + alpm_pkg_t *package1; > + alpm_pkg_t *package2; > alpm_depend_t *reason; > } alpm_conflict_t; > OK > diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c > index 80827ed6..08ae86cb 100644 > --- a/lib/libalpm/conflict.c > +++ b/lib/libalpm/conflict.c > @@ -49,11 +49,8 @@ static alpm_conflict_t *conflict_new(alpm_pkg_t *pkg1, alpm_pkg_t *pkg2, > alpm_conflict_t *conflict; > > CALLOC(conflict, 1, sizeof(alpm_conflict_t), return NULL); > - > - conflict->package1_hash = pkg1->name_hash; > - conflict->package2_hash = pkg2->name_hash; > - STRDUP(conflict->package1, pkg1->name, goto error); > - STRDUP(conflict->package2, pkg2->name, goto error); > + ASSERT(_alpm_pkg_dup(pkg1, &conflict->package1) == 0, goto error); > + ASSERT(_alpm_pkg_dup(pkg2, &conflict->package2) == 0, goto error); > conflict->reason = reason; > OK > return conflict; > @@ -69,8 +66,8 @@ error: > void SYMEXPORT alpm_conflict_free(alpm_conflict_t *conflict) > { > ASSERT(conflict != NULL, return); > - FREE(conflict->package2); > - FREE(conflict->package1); > + _alpm_pkg_free(conflict->package1); > + _alpm_pkg_free(conflict->package2); > FREE(conflict); > } > OK > @@ -79,20 +76,7 @@ void SYMEXPORT alpm_conflict_free(alpm_conflict_t *conflict) > */ > alpm_conflict_t *_alpm_conflict_dup(const alpm_conflict_t *conflict) > { > - alpm_conflict_t *newconflict; > - CALLOC(newconflict, 1, sizeof(alpm_conflict_t), return NULL); > - > - newconflict->package1_hash = conflict->package1_hash; > - newconflict->package2_hash = conflict->package2_hash; > - STRDUP(newconflict->package1, conflict->package1, goto error); > - STRDUP(newconflict->package2, conflict->package2, goto error); > - newconflict->reason = conflict->reason; > - > - return newconflict; > - > -error: > - alpm_conflict_free(newconflict); > - return NULL; > + return conflict_new(conflict->package1, conflict->package2, conflict->reason); OK - now a one line function! > } > > /** > @@ -108,10 +92,10 @@ static int conflict_isin(alpm_conflict_t *needle, alpm_list_t *haystack) > alpm_list_t *i; > for(i = haystack; i; i = i->next) { > alpm_conflict_t *conflict = i->data; > - if(needle->package1_hash == conflict->package1_hash > - && needle->package2_hash == conflict->package2_hash > - && strcmp(needle->package1, conflict->package1) == 0 > - && strcmp(needle->package2, conflict->package2) == 0) { > + if(needle->package1->name_hash == conflict->package2->name_hash conflict->package1->name_hash > + && needle->package2->name_hash == conflict->package2->name_hash > + && strcmp(needle->package1->name, conflict->package1->name) == 0 > + && strcmp(needle->package2->name, conflict->package2->name) == 0) { > return 1; > } > } > diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c > index 97a351fe..d26a1323 100644 > --- a/lib/libalpm/sync.c > +++ b/lib/libalpm/sync.c > @@ -510,21 +510,23 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data) > > for(i = deps; i; i = i->next) { > alpm_conflict_t *conflict = i->data; > + const char *name1 = conflict->package1->name; > + const char *name2 = conflict->package2->name; > alpm_pkg_t *rsync, *sync, *sync1, *sync2; > > /* have we already removed one of the conflicting targets? */ > - sync1 = alpm_pkg_find(trans->add, conflict->package1); > - sync2 = alpm_pkg_find(trans->add, conflict->package2); > + sync1 = alpm_pkg_find(trans->add, name1); > + sync2 = alpm_pkg_find(trans->add, name2); > if(!sync1 || !sync2) { > continue; > } > > _alpm_log(handle, ALPM_LOG_DEBUG, "conflicting packages in the sync list: '%s' <-> '%s'\n", > - conflict->package1, conflict->package2); > + name1, name2); > > /* if sync1 provides sync2, we remove sync2 from the targets, and vice versa */ > - alpm_depend_t *dep1 = alpm_dep_from_string(conflict->package1); > - alpm_depend_t *dep2 = alpm_dep_from_string(conflict->package2); > + alpm_depend_t *dep1 = alpm_dep_from_string(name1); > + alpm_depend_t *dep2 = alpm_dep_from_string(name2); > if(_alpm_depcmp(sync1, dep2)) { > rsync = sync2; > sync = sync1; OK > @@ -552,8 +554,8 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data) > > /* Prints warning */ > _alpm_log(handle, ALPM_LOG_WARNING, > - _("removing '%s' from target list because it conflicts with '%s'\n"), > - rsync->name, sync->name); > + _("removing '%s-%s' from target list because it conflicts with '%s-%s'\n"), > + rsync->name, rsync->version, sync->name, sync->version); > trans->add = alpm_list_remove(trans->add, rsync, _alpm_pkg_cmp, NULL); > /* rsync is not a transaction target anymore */ > trans->unresolvable = alpm_list_add(trans->unresolvable, rsync); OK > @@ -574,16 +576,18 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data) > .conflict = i->data > }; > alpm_conflict_t *conflict = i->data; > + const char *name1 = conflict->package1->name; > + const char *name2 = conflict->package2->name; > int found = 0; > > - /* if conflict->package2 (the local package) is not elected for removal, > + /* if name2 (the local package) is not elected for removal, > we ask the user */ > - if(alpm_pkg_find(trans->remove, conflict->package2)) { > + if(alpm_pkg_find(trans->remove, name2)) { > found = 1; > } > for(j = trans->add; j && !found; j = j->next) { > alpm_pkg_t *spkg = j->data; > - if(alpm_pkg_find(spkg->removes, conflict->package2)) { > + if(alpm_pkg_find(spkg->removes, name2)) { > found = 1; > } > } OK > @@ -592,14 +596,14 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data) > } > > _alpm_log(handle, ALPM_LOG_DEBUG, "package '%s' conflicts with '%s'\n", > - conflict->package1, conflict->package2); > + name1, name2); > > QUESTION(handle, &question); > if(question.remove) { > /* append to the removes list */ > - alpm_pkg_t *sync = alpm_pkg_find(trans->add, conflict->package1); > - alpm_pkg_t *local = _alpm_db_get_pkgfromcache(handle->db_local, conflict->package2); > - _alpm_log(handle, ALPM_LOG_DEBUG, "electing '%s' for removal\n", conflict->package2); > + alpm_pkg_t *sync = alpm_pkg_find(trans->add, name1); > + alpm_pkg_t *local = _alpm_db_get_pkgfromcache(handle->db_local, name2); > + _alpm_log(handle, ALPM_LOG_DEBUG, "electing '%s' for removal\n", name2); > sync->removes = alpm_list_add(sync->removes, local); > } else { /* abort */ > _alpm_log(handle, ALPM_LOG_ERROR, _("unresolvable package conflicts detected\n")); OK > diff --git a/src/pacman/callback.c b/src/pacman/callback.c > index 08da4bb7..812b64e3 100644 > --- a/src/pacman/callback.c > +++ b/src/pacman/callback.c > @@ -393,18 +393,22 @@ void cb_question(alpm_question_t *question) > { > alpm_question_conflict_t *q = &question->conflict; > /* print conflict only if it contains new information */ > - if(strcmp(q->conflict->package1, q->conflict->reason->name) == 0 > - || strcmp(q->conflict->package2, q->conflict->reason->name) == 0) { > - q->remove = noyes(_("%s and %s are in conflict. Remove %s?"), > - q->conflict->package1, > - q->conflict->package2, > - q->conflict->package2); > + if(strcmp(alpm_pkg_get_name(q->conflict->package1), q->conflict->reason->name) == 0 > + || strcmp(alpm_pkg_get_name(q->conflict->package2), q->conflict->reason->name) == 0) { > + q->remove = noyes(_("%s-%s and %s-%s are in conflict. Remove %s?"), > + alpm_pkg_get_name(q->conflict->package1), > + alpm_pkg_get_version(q->conflict->package1), > + alpm_pkg_get_name(q->conflict->package2), > + alpm_pkg_get_version(q->conflict->package2), > + alpm_pkg_get_name(q->conflict->package2)); I had a look at this and the line is getting too long with the extra information. How about splitting the line like this: colon_printf(_("%s-%s and %s-%s are in conflict\n"), alpm_pkg_get_name(q->conflict->package1), alpm_pkg_get_version(q->conflict->package1), alpm_pkg_get_name(q->conflict->package2), alpm_pkg_get_version(q->conflict->package2)); q->remove = noyes(_("Remove %s?"), alpm_pkg_get_name(q->conflict->package2)); > } else { > - q->remove = noyes(_("%s and %s are in conflict (%s). Remove %s?"), > - q->conflict->package1, > - q->conflict->package2, > + q->remove = noyes(_("%s-%s and %s-%s are in conflict (%s). Remove %s?"), > + alpm_pkg_get_name(q->conflict->package1), > + alpm_pkg_get_version(q->conflict->package1), > + alpm_pkg_get_name(q->conflict->package2), > + alpm_pkg_get_version(q->conflict->package2), > q->conflict->reason->name, > - q->conflict->package2); > + alpm_pkg_get_name(q->conflict->package2)); > } > } > break; > diff --git a/src/pacman/database.c b/src/pacman/database.c > index 378edc8c..db8ed2de 100644 > --- a/src/pacman/database.c > +++ b/src/pacman/database.c > @@ -157,7 +157,7 @@ static int check_db_local_package_conflicts(alpm_list_t *pkglist) > for(i = data; i; i = i->next) { > alpm_conflict_t *conflict = i->data; > pm_printf(ALPM_LOG_ERROR, "'%s' conflicts with '%s'\n", > - conflict->package1, conflict->package2); > + alpm_pkg_get_name(conflict->package1), alpm_pkg_get_name(conflict->package2)); > ret++; > } > alpm_list_free_inner(data, (alpm_list_fn_free)alpm_conflict_free); OK > diff --git a/src/pacman/sync.c b/src/pacman/sync.c > index 4bdeff7b..73e0496e 100644 > --- a/src/pacman/sync.c > +++ b/src/pacman/sync.c > @@ -777,12 +777,19 @@ int sync_prepare_execute(void) > alpm_conflict_t *conflict = i->data; > /* only print reason if it contains new information */ > if(conflict->reason->mod == ALPM_DEP_MOD_ANY) { > - colon_printf(_("%s and %s are in conflict\n"), > - conflict->package1, conflict->package2); > + colon_printf(_("%s-%s and %s-%s are in conflict\n"), > + alpm_pkg_get_name(conflict->package1), > + alpm_pkg_get_version(conflict->package1), > + alpm_pkg_get_name(conflict->package2), > + alpm_pkg_get_version(conflict->package2)); > } else { > char *reason = alpm_dep_compute_string(conflict->reason); > - colon_printf(_("%s and %s are in conflict (%s)\n"), > - conflict->package1, conflict->package2, reason); > + colon_printf(_("%s-%s and %s-%s are in conflict (%s)\n"), > + alpm_pkg_get_name(conflict->package1), > + alpm_pkg_get_version(conflict->package1), > + alpm_pkg_get_name(conflict->package2), > + alpm_pkg_get_version(conflict->package2), > + reason); OK From allan at archlinux.org Wed Dec 11 01:02:02 2019 From: allan at archlinux.org (Allan McRae) Date: Wed, 11 Dec 2019 11:02:02 +1000 Subject: [pacman-dev] [PATCH 2/3] libmakepkg: use readelf instead of file for finding ELF file types In-Reply-To: <20191126212957.29031-2-e5ten.arch@gmail.com> References: <20191126212957.29031-1-e5ten.arch@gmail.com> <20191126212957.29031-2-e5ten.arch@gmail.com> Message-ID: <6916628c-5ef2-120c-d9b4-368eff332f56@archlinux.org> On 27/11/19 7:29 am, Ethan Sommer wrote: > Signed-off-by: Ethan Sommer > --- > scripts/libmakepkg/tidy/strip.sh.in | 26 ++++++++++++-------------- > 1 file changed, 12 insertions(+), 14 deletions(-) > This diff is an absolute pain to read! I went through all files on my system, and confirmed this change does what it is supposed to. Files are all stripped the same way. Onto the issues Eli brought up: 1) Hiding errors from readelf. If readelf errors in any way, we are not going to be stripping the file anyway. So I am fine with that. 2) Format of output. I am OK with this given multiple implementations use the same format, and we already rely on parsing the readelf output when making debug packages. In summmary. Ack. A > diff --git a/scripts/libmakepkg/tidy/strip.sh.in b/scripts/libmakepkg/tidy/strip.sh.in > index 1bd810f0..301d1989 100644 > --- a/scripts/libmakepkg/tidy/strip.sh.in > +++ b/scripts/libmakepkg/tidy/strip.sh.in > @@ -111,22 +111,20 @@ tidy_strip() { > > local binary strip_flags > find . -type f -perm -u+w -print0 2>/dev/null | while IFS= read -rd '' binary ; do > - case "$(file -bi "$binary")" in > - *application/x-sharedlib*) # Libraries (.so) > + case "$(LC_ALL=C readelf -h "$binary" 2>/dev/null)" in > + *Type:*'DYN (Shared object file)'*) # Libraries (.so) or Relocatable binaries > strip_flags="$STRIP_SHARED";; > - *application/x-archive*) # Libraries (.a) > - strip_flags="$STRIP_STATIC";; > - *application/x-object*) > - case "$binary" in > - *.ko) # Kernel module > - strip_flags="$STRIP_SHARED";; > - *) > - continue;; > - esac;; > - *application/x-executable*) # Binaries > + *Type:*'EXEC (Executable file)'*) # Binaries > strip_flags="$STRIP_BINARIES";; > - *application/x-pie-executable*) # Relocatable binaries > - strip_flags="$STRIP_SHARED";; > + *Type:*'REL (Relocatable file)'*) # Libraries (.a) or objects > + if ar t "$binary" &>/dev/null; then # Libraries (.a) > + strip_flags="$STRIP_STATIC" > + elif [[ $binary = *'.ko' ]]; then # Kernel module > + strip_flags="$STRIP_SHARED" > + else > + continue > + fi > + ;; > *) > continue ;; > esac >