SOURCES: poldek-20060726cvs.patch (NEW) - new

arekm arekm at pld-linux.org
Wed Jul 26 20:21:32 CEST 2006


Author: arekm                        Date: Wed Jul 26 18:21:32 2006 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- new

---- Files affected:
SOURCES:
   poldek-20060726cvs.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/poldek-20060726cvs.patch
diff -u /dev/null SOURCES/poldek-20060726cvs.patch:1.1
--- /dev/null	Wed Jul 26 20:21:32 2006
+++ SOURCES/poldek-20060726cvs.patch	Wed Jul 26 20:21:26 2006
@@ -0,0 +1,10793 @@
+diff -urN poldek-0.20.org/arg_packages.c poldek-0.20/arg_packages.c
+--- poldek-0.20.org/arg_packages.c	2005-10-07 21:00:16.000000000 +0200
++++ poldek-0.20/arg_packages.c	2006-04-02 21:10:36.000000000 +0200
+@@ -11,7 +11,7 @@
+ */
+ 
+ /*
+-  $Id$
++  $Id$
+ */
+ 
+ #include <limits.h>
+@@ -42,6 +42,8 @@
+ #include "pkgset.h"
+ #include "pm/pm.h"
+ 
++extern int poldek_conf_MULTILIB;
++
+ #define ARG_PACKAGES_SETUPDONE    (1 << 0)
+ 
+ /* @VIRTUAL [DEFAULT_MASK [EVR]] */
+@@ -227,36 +229,6 @@
+ //        n_hash_size(aps->resolved_caps);
+ }
+ 
+-#if 0  /* XXX: disabled, #5702  */
+-/* tries to convert N-[E:]V-R to N#[E:]V-R */
+-static char *mask2evrhashedmask(const char *mask) 
+-{
+-    const char *name, *ver, *rel, *p;
+-    char nmask[1024], e[32] = "", *tmp;
+-    int32_t epoch = 0;
+-    int n;
+-    
+-    n_strdupap(mask, &tmp);
+-    if (!poldek_util_parse_nevr(tmp, &name, &epoch, &ver, &rel))
+-        return NULL;
+-    
+-    p = ver;          /* check if it is really version */
+-    while (*p) {
+-        if (isdigit(*p))
+-            break;
+-        p++;
+-    }
+-    
+-    if (*p == '\0')    /* no digits => part of name propably */
+-        return NULL;
+-            
+-    if (epoch)
+-        snprintf(e, sizeof(e), "%d:", epoch);
+-    n = n_snprintf(nmask, sizeof(nmask), "%s#%s%s-%s", name, e, ver, rel);
+-    return n_strdupl(nmask, n);
+-}
+-#endif
+-
+ tn_array *arg_packages_get_masks(struct arg_packages *aps, int hashed)
+ {
+     tn_array *masks;
+@@ -264,19 +236,11 @@
+ 
+     masks = n_array_clone(aps->package_masks);
+     for (i=0; i < n_array_size(aps->package_masks); i++) {
+-        const char *mask;
+-
+-        mask = n_array_nth(aps->package_masks, i);
+-        if (hashed && strchr(mask, '-') && strchr(mask, '*') == NULL) {
+-#if 0  /* XXX: disabled so smart NEVR parsing, #5702  */
+-            char *nmask;
+-            if ((nmask = mask2evrhashedmask(mask)))
+-                mask = nmask;
+-#endif            
+-        }
++        const char *mask = n_array_nth(aps->package_masks, i);
+         n_array_push(masks, n_strdup(mask));
+     }
+-    
++
++    hashed = 0;                 /* disabled for a while */
+     for (i=0; i < n_array_size(aps->packages); i++) {
+         struct pkg *pkg = n_array_nth(aps->packages, i);
+         char mask[1024], e[32] = "";
+@@ -284,9 +248,13 @@
+         
+         if (pkg->epoch)
+             snprintf(e, sizeof(e), "%d:", pkg->epoch);
+-        
++
+         n = n_snprintf(mask, sizeof(mask), "%s%s%s%s-%s", pkg->name,
+-                   hashed ? "#" : "-", e, pkg->ver, pkg->rel);
++                       hashed ? "#" : "-", e, pkg->ver, pkg->rel);
++
++        if (0 && poldek_conf_MULTILIB && pkg_arch(pkg))
++            n += n_snprintf(&mask[n], sizeof(mask) - n, ".%s", pkg_arch(pkg));
++        
+         n_array_push(masks, n_strdupl(mask, n));
+     }
+                    
+@@ -532,7 +500,7 @@
+         if (matches[j] == 0 && (flags & ARG_PACKAGES_RESOLV_MISSINGOK) == 0) {
+             logn(LOGERR, _("%s: no such package"), mask);
+             rc = 0;
+-        }
++        } 
+ 
+         if ((flags & ARG_PACKAGES_RESOLV_UNAMBIGUOUS) == 0 && matches_bycmp[j] > 1) {
+             int pri = (flags & ARG_PACKAGES_RESOLV_EXACT) ? LOGERR : LOGWARN;
+@@ -675,7 +643,7 @@
+ int arg_packages_resolve(struct arg_packages *aps, tn_array *avpkgs,
+                          struct pkgset *ps, unsigned flags)
+ {
+-    int i, j, nmasks, rc = 0;
++    int i, j, nmasks, rc = 1;
+ 
+     n_hash_clean(aps->resolved_caps);
+     n_array_clean(aps->resolved_pkgs);
+@@ -697,12 +665,16 @@
+         }
+     }
+     
+-    rc = resolve_pkgs(aps->resolved_pkgs, aps, avpkgs, flags);
+-    if (rc)                     /* continue with masks */
+-        rc = resolve_masks(aps->resolved_pkgs, aps, avpkgs, ps, flags);
++    if (!resolve_pkgs(aps->resolved_pkgs, aps, avpkgs, flags))
++        rc = 0;
++
++    if (!resolve_masks(aps->resolved_pkgs, aps, avpkgs, ps, flags))
++        rc = 0;
+     
+-    if (rc && ps && aps->pset_virtuals)
+-        rc = resolve_pset_virtuals(aps, ps, flags);
++    if (ps && aps->pset_virtuals) {
++        if (!resolve_pset_virtuals(aps, ps, flags))
++            rc = 0;
++    }
+ 
+     if (!rc) {
+         n_array_clean(aps->resolved_pkgs);
+diff -urN poldek-0.20.org/arg_packages.h poldek-0.20/arg_packages.h
+--- poldek-0.20.org/arg_packages.h	2005-05-25 19:53:19.000000000 +0200
++++ poldek-0.20/arg_packages.h	2006-04-02 21:10:36.000000000 +0200
+@@ -1,4 +1,4 @@
+-/* $Id$ */
++/* $Id$ */
+ #ifndef POLDEK_USRSET_H
+ #define POLDEK_USRSET_H
+ 
+@@ -15,6 +15,7 @@
+ 
+ void arg_packages_clean(struct arg_packages *aps);
+ int arg_packages_size(struct arg_packages *aps);
++
+ tn_array *arg_packages_get_masks(struct arg_packages *aps, int hashed);
+ 
+ int arg_packages_add_pkgmask(struct arg_packages *aps, const char *mask);
+diff -urN poldek-0.20.org/ask.c poldek-0.20/ask.c
+--- poldek-0.20.org/ask.c	2003-04-14 18:28:09.000000000 +0200
++++ poldek-0.20/ask.c	2005-11-03 01:16:58.000000000 +0100
+@@ -11,7 +11,7 @@
+ */
+ 
+ /*
+-  $Id$
++  $Id$
+ */
+ 
+ #ifdef HAVE_CONFIG_H
+@@ -92,13 +92,18 @@
+         *p++ = 'a' + i;
+         i++;
+     }
++    *p++ = 'Q';
+     
+-    msg(-1, _("Which one do you want to install? [%c]"), 'a' + default_i); 
++    msg(-1, _("Which one do you want to install ('Q' to abort)? [%c]"),
++        'a' + default_i); 
+     a = poldek_term_ask(STDIN_FILENO, validchrs, NULL);
+     msg(-1, "_\n");
+     
+     if (a == '\n')
+         return default_i;
++
++    if (a == 'Q')
++        return -1;
+     
+     a -= 'a';
+     //printf("Selected %d\n", a);
+diff -urN poldek-0.20.org/cli/alias.c poldek-0.20/cli/alias.c
+--- poldek-0.20.org/cli/alias.c	2005-05-24 21:54:22.000000000 +0200
++++ poldek-0.20/cli/alias.c	2005-11-06 20:26:27.000000000 +0100
+@@ -7,13 +7,13 @@
+ */
+ 
+ /*
+-  $Id$
++  $Id$
+ */
+ 
++#include <errno.h>
+ #include <limits.h>
+ #include <stdint.h>
+ #include <string.h>
+-#include <errno.h>
+ #include <unistd.h>
+ 
+ #include <trurl/nassert.h>
+@@ -24,6 +24,7 @@
+ #include "i18n.h"
+ #include "log.h"
+ #include "cli.h"
++#include "cmd_chain.h"
+ #include "conf.h"
+ 
+ 
+@@ -33,7 +34,7 @@
+     COMMAND_NOARGS | COMMAND_NOOPTS, 
+     "alias", NULL, N_("Print defined command aliases"), 
+     NULL, NULL, NULL, alias,
+-    NULL, NULL, NULL, NULL, 0, 0
++    NULL, NULL, NULL, NULL, NULL, 0, 0
+ };
+ 
+ static int alias(struct cmdctx *cmdctx) 
+@@ -53,6 +54,7 @@
+     if (cmd->flags & COMMAND_IS_ALIAS) {
+         n_cfree(&cmd->cmdline);
+         n_cfree(&cmd->name);
++        n_cfree(&cmd->aliasto);
+         memset(cmd, 0, sizeof(*cmd));
+     }
+ }
+@@ -68,7 +70,10 @@
+     alias->flags = COMMAND_IS_ALIAS | COMMAND__MALLOCED;
+     alias->name = n_strdup(name);
+     alias->cmdline = n_strdup(cmdline);
++    alias->aliasto = NULL;
+     alias->_free = free_alias;
++    if (strchr(alias->cmdline, '%'))
++        alias->flags |= COMMAND_PARAMETERIZED;
+     return alias;
+ }
+ 
+@@ -77,17 +82,18 @@
+ int add_alias(struct poclidek_ctx *cctx,
+               const char *aliasname, const char *cmdline)
+ {
+-	struct poclidek_cmd          *cmd;
+-    struct poclidek_cmd          tmpcmd;
+-
++    struct poclidek_cmd *cmd, tmpcmd;
++    int rc = 1;
+     
+ 	tmpcmd.name = (char*)aliasname;
+-	if ((cmd = n_array_bsearch(cctx->commands, &tmpcmd)) == NULL) {
+-        n_array_push(cctx->commands, command_new_alias(aliasname, cmdline));
++    if ((cmd = n_array_bsearch(cctx->commands, &tmpcmd)) == NULL) {
++        cmd = command_new_alias(aliasname, cmdline);
++        n_array_push(cctx->commands, cmd);
+         
+     } else {
+         if ((cmd->flags & COMMAND_IS_ALIAS) == 0) {
+             logn(LOGWARN, _("%s: alias could not shadow a command"), aliasname);
++            rc = 0;
+             
+         } else {
+             if (poldek_verbose() > 1)
+@@ -102,15 +108,61 @@
+ 	}
+     
+ 	n_array_sort(cctx->commands);
+-	return 1;
++	return rc;
++}
++
++/* determine to what command alias is aliased */
++static char *alias_to(struct poclidek_ctx *cctx, const char *cmdline) 
++{
++    tn_array *ents;
++    char *p, *cmd = NULL;
++
++    if (strchr(cmdline, '|') == NULL) {
++        cmd = n_strdup(cmdline);
++        
++    } else if ((ents = poclidek_prepare_cmdline(cctx, cmdline))) {
++        struct cmd_chain_ent *ent = n_array_nth(ents, 0);
++        while (ent->next_piped)
++            ent = ent->next_piped;
++        
++        cmd = n_strdup(ent->cmd->name);
++        n_array_free(ents);
++    }
++
++    if (cmd == NULL)
++        return NULL;
++
++    if ((p = strchr(cmd, ' ')))
++        *p = '\0';
++
++    return cmd;
+ }
+ 
++static void find_aliased_commands(struct poclidek_ctx *cctx) 
++{
++    struct poclidek_cmd *cmd;
++    int i;
++    
++    for (i=0; i < n_array_size(cctx->commands); i++) {
++        cmd = n_array_nth(cctx->commands, i);
++        
++        if ((cmd->flags & COMMAND_IS_ALIAS) == 0)
++            continue;
++
++        cmd->aliasto = alias_to(cctx, cmd->cmdline);
++        if (cmd->aliasto == NULL)
++            logn(LOGWARN, _("%s: could not determine aliased command"),
++                 cmd->name);
++        else
++            msgn(3, "%s => aliased %s", cmd->name, cmd->aliasto);
++    }
++}
+ 
+ int poclidek_load_aliases(struct poclidek_ctx *cctx, const char *path) 
+ {
+     tn_hash *aliases_htcnf, *ht;
+     tn_array *keys;
+-    int i;
++    int i, n = 0;
+     
+     if (access(path, R_OK) != 0)
+         return 0;
+@@ -126,16 +178,22 @@
+         const char *name, *cmdline;
+ 
+         name = n_array_nth(keys, i);
++        if (*name == '_')       /* config macro */
++            continue;
++        
+         if ((cmdline = poldek_conf_get(ht, name, NULL)))
+-            add_alias(cctx, name, cmdline);
++            if (add_alias(cctx, name, cmdline))
++                n++;
+     }
+     
+     n_array_free(keys);
+     n_hash_free(aliases_htcnf);
++    
++    if (n)
++        find_aliased_commands(cctx);
++        
+     return 1;
+ }
+ 
+ 
+ 
+-
+-
+diff -urN poldek-0.20.org/cli/cd.c poldek-0.20/cli/cd.c
+--- poldek-0.20.org/cli/cd.c	2005-06-12 23:11:08.000000000 +0200
++++ poldek-0.20/cli/cd.c	2005-11-06 20:26:27.000000000 +0100
+@@ -11,7 +11,7 @@
+ */
+ 
+ /*
+-  $Id$
++  $Id$
+ */
+ 
+ #include <sys/param.h>          /* for PATH_MAX */
+@@ -30,14 +30,14 @@
+     COMMAND_SELFARGS | COMMAND_EMPTYARGS | COMMAND_NOOPTS, 
+     "cd", N_("[PATH]"), N_("Change current package directory"), 
+     NULL, parse_opt, NULL, cd,
+-    NULL, NULL, NULL, NULL, 0, 0
++    NULL, NULL, NULL, NULL, NULL, 0, 0
+ };
+ 
+ struct poclidek_cmd command_pwd = {
+     COMMAND_NOARGS | COMMAND_NOOPTS, 
+     "pwd", NULL, N_("Print name of current directory"), 
+     NULL, NULL, NULL, pwd,
+-    NULL, NULL, NULL, NULL, 0, 0
++    NULL, NULL, NULL, NULL, NULL, 0, 0
+ };
+ 
+ 
+diff -urN poldek-0.20.org/cli/cli.c poldek-0.20/cli/cli.c
+--- poldek-0.20.org/cli/cli.c	2005-10-12 01:20:12.000000000 +0200
++++ poldek-0.20/cli/cli.c	2005-11-06 20:26:27.000000000 +0100
+@@ -1,5 +1,5 @@
+ /*
+-  Copyright (C) 2000 - 2004 Pawel A. Gajda <mis at pld.org.pl>
++  Copyright (C) 2000 - 2005 Pawel A. Gajda <mis at k2.net.pl>
+ 
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License, version 2 as
+@@ -11,23 +11,23 @@
+ */
+ 
+ /*
+-  $Id$
++  $Id$
+ */
+ 
+ #ifdef HAVE_CONFIG_H
+ # include "config.h"
+ #endif
+ 
++#include <signal.h>
++#include <stdint.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+-#include <stdint.h>
+ #include <string.h>
+-#include <sys/param.h>
+-#include <sys/types.h>
++#include <sys/errno.h>
+ #include <sys/file.h>
++#include <sys/param.h>
+ #include <sys/stat.h>
+-#include <sys/errno.h>
+-#include <signal.h>
++#include <sys/types.h>
+ #include <time.h>
+ #include <argp.h>
+ 
+@@ -161,14 +161,22 @@
+     
+     if (cmd->flags & COMMAND_IS_ALIAS)
+         return NULL;
+-    
++
+     n = n_snprintf(nam, sizeof(nam), "%s ", cmd->name);
+     for (i=0; i < n_array_size(cctx->commands); i++) {
+         struct poclidek_cmd *cm = n_array_nth(cctx->commands, i);
++        int found = 0;
++        
+         if ((cm->flags & COMMAND_IS_ALIAS) == 0)
+             continue;
++        
++        if (cm->aliasto && n_str_eq(cmd->name, cm->aliasto))
++            found = 1;
++        
++        else if (strncmp(nam, cm->cmdline, n) == 0)
++            found = 1;
+ 
+-        if (strncmp(nam, cm->cmdline, n) == 0) {
++        if (found) {
+             if (aliases == NULL)
+                 aliases = n_array_new(4, NULL, (tn_fn_cmp)command_cmp);
+             n_array_push(aliases, cm);
+@@ -316,45 +324,50 @@
+     return *fmt == '!';
+ }
+ 
+-int cmdctx_printf(struct cmdctx *cmdctx, const char *fmt, ...)
++static
++int do_cmdctx_printf(struct cmdctx *cmdctx, int color, const char *fmt,
++                     va_list args)
+ {
+-    va_list args;
+-    int n = 0;
++    int is_ctrl, n = 0;
+     
+-    if (cmdctx_isctrlmsg(fmt)) {
++    if ((is_ctrl = cmdctx_isctrlmsg(fmt))) {
+         if (cmdctx->rtflags & CMDCTX_NOCTRLMSGS)
+             return 1;
+         fmt++;
+     }
+ 
+-    va_start(args, fmt);
+-    if (cmdctx->pipe_right)
++    if (cmdctx->pipe_right == NULL || is_ctrl) {
++        n = color ? poldek_term_vprintf_c(color, fmt, args) :
++            vfprintf(stdout, fmt, args);
++        
++    } else {
+         n = cmd_pipe_vprintf(cmdctx->pipe_right, fmt, args);
+-    else 
+-        n = vfprintf(stdout, fmt, args);
++    }
+ 
+-    va_end(args);
+     return n;
++}
++
++int cmdctx_printf(struct cmdctx *cmdctx, const char *fmt, ...)
++{
++    va_list args;
++    int n;
+     
++    va_start(args, fmt);
++    n = do_cmdctx_printf(cmdctx, 0, fmt, args);
++    va_end(args);
++    
++    return n;
+ }
+ 
+ int cmdctx_printf_c(struct cmdctx *cmdctx, int color, const char *fmt, ...)
+ {
+     va_list args;
+-    int n = 0;
+-
+-    if (cmdctx_isctrlmsg(fmt)) {
+-        if (cmdctx->rtflags & CMDCTX_NOCTRLMSGS)
+-            return 1;
+-        fmt++;
+-    }
+-
++    int n;
++    
+     va_start(args, fmt);
+-    if (cmdctx->pipe_right)
+-        n = cmd_pipe_vprintf(cmdctx->pipe_right, fmt, args);
+-    else 
+-        n = poldek_term_vprintf_c(color, fmt, args);
+-
++    n = do_cmdctx_printf(cmdctx, color, fmt, args);
++    va_end(args);
++    
+     return n;
+ }
+ 
+@@ -577,25 +590,22 @@
+     return argv;
+ }
+ 
+-tn_array *poclidek_prepare_cmdline(struct poclidek_ctx *cctx, const char *line);
+-
+-
++/* executes command chain (a pipeline) */
+ static
+ int poclidek_exec_cmd_ent(struct poclidek_ctx *cctx, struct poldek_ts *ts,
+                           struct cmd_chain_ent *ent, struct cmd_pipe *cmd_pipe)
+ {
+     struct cmdctx  cmdctx;
+     char **argv;
+-    int rc = 0;
++    int rc = 0, runit = 1;
+     
+     DBGF("ent %s, %d, %p\n", ent->cmd->name, n_array_size(ent->a_argv),
+          ent->next_piped);
+-
+-    
+     
+     memset(&cmdctx, 0, sizeof(cmdctx));
+     cmdctx.cmd = ent->cmd;
+     cmdctx.cctx = cctx;
++
+     if ((cmdctx.ts = ts) == NULL)
+         cmdctx.ts = poldek_ts_new(cctx->ctx, 0);
+ 
+@@ -609,7 +619,7 @@
+         cmdctx.pipe_right = ent->pipe_right;
+     }
+ 
+-    if (ent->prev_piped) {
++    if (ent->prev_piped) {      /* | cmd */
+         struct cmd_pipe *pipe;
+         tn_array *pipe_args = NULL;
+ 
+@@ -624,9 +634,15 @@
+             else
+                 pipe_args = cmd_pipe_xargs(pipe, CMD_PIPE_CTX_ASCII);
+             
+-            if (pipe_args) {
++            if (pipe_args == NULL) {
++                runit = 0;      /* do not execute command if pipe is empty */
++                rc = 0;
++                goto l_end;
++                
++            } else {
+                 while (n_array_size(pipe_args))
+                     n_array_push(ent->a_argv, n_array_shift(pipe_args));
++                n_array_free(pipe_args);
+             }
+         }
+     }
+@@ -636,11 +652,12 @@
+     a_argv_to_argv(ent->a_argv, argv);
+ 
+     rc = do_exec_cmd_ent(&cmdctx, n_array_size(ent->a_argv), argv);
+-    
++
++ l_end:
+     if (ts == NULL) 
+         poldek_ts_free(cmdctx.ts);
+ 
+-    if (ent->next_piped)
++    if (runit && ent->next_piped)
+         return poclidek_exec_cmd_ent(cctx, ts, ent->next_piped, cmd_pipe);
+     
<<Diff was trimmed, longer than 597 lines>>


More information about the pld-cvs-commit mailing list