Changeset 4818


Ignore:
Timestamp:
11/24/08 07:44:12 (9 years ago)
Author:
tick
Message:

opkg: add a simple way to pass a path environment for pre/post scription execution when in offline mode.

Thanks for Christopher Hall <hsw@…>

Location:
trunk/src/target/opkg
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/target/opkg/configure.ac

    r4459 r4818  
    11# Process this file with autoconf to produce a configure script 
    22AC_INIT(libopkg/libopkg.c) 
    3 AM_INIT_AUTOMAKE([opkg], [0.1.5]) 
     3 
     4AC_CONFIG_AUX_DIR([conf]) 
     5AC_CONFIG_MACRO_DIR([m4]) 
     6 
     7AM_INIT_AUTOMAKE([opkg], [0.1.6]) 
    48AM_CONFIG_HEADER(libopkg/config.h) 
    59 
  • trunk/src/target/opkg/libopkg/args.c

    r4808 r4818  
    7777     args->verbosity = ARGS_DEFAULT_VERBOSITY; 
    7878     args->offline_root = ARGS_DEFAULT_OFFLINE_ROOT; 
     79     args->offline_root_path = ARGS_DEFAULT_OFFLINE_ROOT_PATH; 
    7980     args->offline_root_pre_script_cmd = ARGS_DEFAULT_OFFLINE_ROOT_PRE_SCRIPT_CMD; 
    8081     args->offline_root_post_script_cmd = ARGS_DEFAULT_OFFLINE_ROOT_POST_SCRIPT_CMD; 
     
    8990{ 
    9091     free (args->offline_root); 
     92     free (args->offline_root_path); 
    9193     free (args->offline_root_pre_script_cmd); 
    9294     free (args->offline_root_post_script_cmd); 
     
    139141          {"offline", 1, 0, 'o'}, 
    140142          {"offline-root", 1, 0, 'o'}, 
     143          {"offline-path", 1, 0, 'p'}, 
     144          {"offline-root-path", 1, 0, 'p'}, 
    141145          {"test", 0, 0, ARGS_OPT_NOACTION}, 
    142146          {"tmp-dir", 1, 0, 't'}, 
     
    147151 
    148152     while (1) { 
    149           c = getopt_long_only(argc, argv, "Ad:f:no:t:vV:", long_options, &option_index); 
     153          c = getopt_long_only(argc, argv, "Ad:f:no:p:t:vV:", long_options, &option_index); 
    150154          if (c == -1) 
    151155               break; 
     
    164168          case 'o': 
    165169               args->offline_root = strdup (optarg); 
     170               break; 
     171          case 'p': 
     172               args->offline_root_path = strdup (optarg); 
    166173               break; 
    167174          case 'n': 
     
    295302     printf("\t-o <offline_root>        Use <offline_root> as the root directory for\n"); 
    296303     printf("\t-offline <offline_root>  offline installation of packages.\n"); 
    297      
    298      printf("\tForce Options (use when opkg is too smart for its own good):\n"); 
     304     printf("\t-p <path>                Path to utilities for runing postinst\n"); 
     305     printf("\t-offline-path <path>     script in offline mode.\n"); 
     306 
     307     printf("\nForce Options (use when opkg is too smart for its own good):\n"); 
    299308     printf("\t-force-depends           Make dependency checks warnings instead of errors\n"); 
    300309     printf("\t                         Install/remove package in spite of failed dependences\n"); 
  • trunk/src/target/opkg/libopkg/args.h

    r4808 r4818  
    4141    int autoremove; 
    4242    char *offline_root; 
     43    char *offline_root_path; 
    4344    char *offline_root_pre_script_cmd; 
    4445    char *offline_root_post_script_cmd; 
     
    5960#define ARGS_DEFAULT_FORCE_SPACE 0 
    6061#define ARGS_DEFAULT_OFFLINE_ROOT NULL 
     62#define ARGS_DEFAULT_OFFLINE_ROOT_PATH NULL 
    6163#define ARGS_DEFAULT_OFFLINE_ROOT_PRE_SCRIPT_CMD NULL 
    6264#define ARGS_DEFAULT_OFFLINE_ROOT_POST_SCRIPT_CMD NULL 
  • trunk/src/target/opkg/libopkg/opkg_conf.c

    r4808 r4818  
    6464          { "nodeps", OPKG_OPT_TYPE_BOOL, &conf->nodeps }, 
    6565          { "offline_root", OPKG_OPT_TYPE_STRING, &conf->offline_root }, 
     66          { "offline_root_path", OPKG_OPT_TYPE_STRING, &conf->offline_root_path }, 
    6667          { "offline_root_post_script_cmd", OPKG_OPT_TYPE_STRING, &conf->offline_root_post_script_cmd }, 
    6768          { "offline_root_pre_script_cmd", OPKG_OPT_TYPE_STRING, &conf->offline_root_pre_script_cmd }, 
     
    267268     opkg_conf_override_string(&conf->offline_root,  
    268269                               args->offline_root); 
     270     opkg_conf_override_string(&conf->offline_root_path,  
     271                               args->offline_root_path); 
    269272     opkg_conf_override_string(&conf->offline_root_pre_script_cmd,  
    270273                               args->offline_root_pre_script_cmd); 
     
    339342 
    340343     opkg_conf_free_string(&conf->offline_root); 
     344     opkg_conf_free_string(&conf->offline_root_path); 
    341345     opkg_conf_free_string(&conf->offline_root_pre_script_cmd); 
    342346     opkg_conf_free_string(&conf->offline_root_post_script_cmd); 
  • trunk/src/target/opkg/libopkg/opkg_conf.h

    r4808 r4818  
    6666     int nodeps; /* do not follow dependences */ 
    6767     char *offline_root; 
     68     char *offline_root_path; 
    6869     char *offline_root_pre_script_cmd; 
    6970     char *offline_root_post_script_cmd; 
  • trunk/src/target/opkg/libopkg/pkg.c

    r4671 r4818  
    1919#include <ctype.h> 
    2020#include <string.h> 
     21#include <stdbool.h> 
    2122#include <errno.h> 
    2223 
     
    14951496        than '/'. I've been playing around with some clever chroot 
    14961497        tricks and I might come up with something workable. */ 
     1498     /* 
     1499      * Attempt to provide a restricted environment for offline operation 
     1500      * Need the following set as a minimum: 
     1501      * OPKG_OFFLINE_ROOT = absolute path to root dir 
     1502      * D                 = absolute path to root dir (for OE generated postinst) 
     1503      * PATH              = something safe (a restricted set of utilities) 
     1504      */ 
     1505 
     1506     bool AllowOfflineMode = false; 
    14971507     if (conf->offline_root) { 
    14981508          setenv("OPKG_OFFLINE_ROOT", conf->offline_root, 1); 
     1509          setenv("D", conf->offline_root, 1); 
     1510          if (NULL == conf->offline_root_path || '\0' == conf->offline_root_path[0]) { 
     1511            setenv("PATH", "/dev/null", 1); 
     1512          } else { 
     1513            setenv("PATH", conf->offline_root_path, 1); 
     1514            AllowOfflineMode = true; 
     1515          } 
    14991516     } 
    15001517 
     
    15071524     } 
    15081525 
    1509      if (conf->offline_root) { 
     1526     if (conf->offline_root && !AllowOfflineMode) { 
    15101527          fprintf(stderr, "(offline root mode: not running %s.%s)\n", pkg->name, script); 
    15111528          free(path); 
Note: See TracChangeset for help on using the changeset viewer.