[pacman-dev] [PATCH] Strip leading "/" from arguments to --overwrite
Allan McRae
allan at archlinux.org
Mon Jun 4 10:22:48 UTC 2018
On 02/06/18 09:01, Joey Pabalinas wrote:
> On Fri, Jun 01, 2018 at 06:56:13PM -0400, Andrew Gregory wrote:
>> Sort of. The current --root option is a confusing mess that nobody
>> actually understands, so it will go away at some point. The
>> underlying libalpm rootdir setting isn't going anywhere though, and,
>> in the future, will be configured with a new --rootdir option.
>
> Well looking at the code it actually isn't as complicated as I thought it
> would be.
>
> How about something like this:
>
>> case OP_OVERWRITE_FILES:
>> {
>> char *i, *root = config->rootdir, *save = NULL;
>> for(i = strtok_r(optarg, ",", &save); i; i = strtok_r(NULL, ",", &save)) {
>> /* strip rootdir if applicable */
>> if (root && !memcmp(i, root, strlen(root)))
>> i += strlen(root);
>> /* strip remaining leading "/" before adding to option list */
>> i += strspn(i, "/");
>> config->overwrite_files = alpm_list_add(config->overwrite_files, strdup(i));
>> }
>> }
>
> which would strip the rootdir and then the leading "/". Although I am not
> 100% certain config->rootdir would be NULL if no argument is passed; could
> you confirm that part?
>
This will not work - we need to handle this after the config file is
read as the root dir may be set there.
A
More information about the pacman-dev
mailing list