Ticket #35852: patch-macports-customizations.diff

File patch-macports-customizations.diff, 26.5 KB (added by cawka (Alex Afanasyev), 12 years ago)

Combined patch of the source code

  • Makefile

    diff --git Makefile Makefile
    index 2748ac8..cf3292a 100644
     
    1313#
    1414
    1515# Subdirectories we build in
    16 TOPSUBDIRS = doc/manpages doc/technical csrc schema javasrc apps `cat local.subdirs 2>/dev/null || :`
     16TOPSUBDIRS = doc/manpages doc/technical csrc schema `cat local.subdirs 2>/dev/null || :`
    1717# Packing list for packaging
    1818PACKLIST = Makefile README LICENSE NEWS NOTICES configure doc/index.txt $(TOPSUBDIRS) android experiments
    1919BLDMSG = printf '=== %s ' 'Building $@ in' && pwd
    2020
     21# Include build parameters
     22include csrc/conf.mk
     23
    2124default all: _always
    2225        for i in $(TOPSUBDIRS); do         \
    2326          (cd "$$i" && pwd && $(MAKE) $@) || exit 1;    \
    2427        done
    25         (cd csrc/lib && { test -f "$$HOME/.ccnx/.ccnx_keystore" || $(MAKE) test; }; )
     28        if [ "x$(BUILD_JAVA)" = "xtrue" ]; then \
     29          (cd javasrc && $(MAKE) $@); \
     30          if [ "x$(BUILD_APPS)" = "xtrue" ]; then \
     31            (cd apps && $(MAKE) $@); \
     32          fi; \
     33        fi
    2634        mkdir -p ./lib ./bin
    2735        test -d ./include || ln -s ./csrc/include
    2836        (cd csrc && $(MAKE) install INSTALL_BASE=`pwd`/..)
    29         (cd javasrc && $(MAKE) install INSTALL_BASE=`pwd`/..)
    30         (cd apps && $(MAKE) install INSTALL_BASE=`pwd`/..)
     37        if [ "x$(BUILD_JAVA)" = "xtrue" ]; then \
     38          (cd javasrc && $(MAKE) install INSTALL_BASE=`pwd`/..); \
     39          if [ "x$(BUILD_APPS)" = "xtrue" ]; then \
     40            (cd apps && $(MAKE) install INSTALL_BASE=`pwd`/..); \
     41          fi ;\
     42        fi
    3143
    3244clean depend test check shared: _always
    33         for i in $(TOPSUBDIRS); do         \
     45        for i in $(TOPSUBDIRS) javasrc apps; do         \
    3446          (cd "$$i" && pwd && $(MAKE) $@) || exit 1;    \
    3547        done
    3648        @rm -f _always
    3749
    3850testinstall install uninstall: _always
    39         IB=`[ -z '$(INSTALL_BASE)' ] && grep ^INSTALL_BASE csrc/conf.mk 2>/dev/null | sed -e 's/ //g' || echo INSTALL_BASE=$(INSTALL_BASE)`; \
    40         for i in $(TOPSUBDIRS); do         \
    41           (cd "$$i" && pwd && $(MAKE) $$IB $@) || exit 1;       \
     51        for i in $(TOPSUBDIRS) javasrc apps; do         \
     52          (cd "$$i" && pwd && $(MAKE) $@) || exit 1;    \
    4253        done
    4354        @rm -f _always
    4455
    4556documentation dist-docs: _always
    46         for i in $(TOPSUBDIRS) android; do         \
     57        for i in $(TOPSUBDIRS) javasrc apps android; do         \
    4758          (cd "$$i" && pwd && $(MAKE) $@) || exit 1;    \
    4859        done
    4960        @rm -f _always
  • apps/Makefile

    diff --git apps/Makefile apps/Makefile
    index acc347c..f0d8638 100644
     
    1919
    2020SUBDIRS = HttpProxy ccnChat ccnFileProxy `cat local.subdirs 2>/dev/null || :`
    2121MAKEF =  -f ../conf.mk -f dir.mk -f ../subr.mk $(PASSTHRU)
    22 PASSTHRU = `[ -z '$(INSTALL_BASE)' ] || echo INSTALL_BASE=$(INSTALL_BASE)`
     22PASSTHRU = `[ -z '$(INSTALL_BASE)' ] || echo INSTALL_BASE=$(DESTDIR)$(INSTALL_BASE)`
    2323CFLAGS = -g
    2424CSRCDIR = ../csrc
    2525
  • apps/java.mk

    diff --git apps/java.mk apps/java.mk
    index df9358e..d1cf718 100644
     
    1212# FOR A PARTICULAR PURPOSE.
    1313#
    1414
     15include ../conf.mk
     16
    1517ANT = `command -v ant || echo echo SKIPPING ant`
    1618LIBS = $(JAR)
    1719WHINE = sh -c "type $(ANT) 2>/dev/null ||                  \
    1820               echo Skipping java build in $$(pwd -L) -    \
    1921                    $(ANT) is not installed; "
    20 # Default, the top-level Makefile default target will
    21 # call the install target here but override INSTALL_BASE
    22 # with dir in the source tree
    23 INSTALL_LIB = $(INSTALL_BASE)/lib
    24 INSTALL_BIN = $(INSTALL_BASE)/bin
    25 INSTALL = cp
    26 CP = cp
    27 LS = /bin/ls
    2822
    2923default all: jar
    3024check: test
    3125
    3226install:
    3327        @test -f $(JAR) && $(MAKE) real_install \
    34             INSTALL_BASE=$(INSTALL_BASE)        \
    35             INSTALL_LIB=$(INSTALL_LIB)          \
    36             INSTALL_BIN=$(INSTALL_BIN) || $(WARN_NO_INSTALL)
     28            INSTALL_BASE=$(DESTDIR)$(INSTALL_BASE)        \
     29            INSTALL_LIB=$(DESTDIR)$(INSTALL_LIB)          \
     30            INSTALL_BIN=$(DESTDIR)$(INSTALL_BIN) || $(WARN_NO_INSTALL)
    3731
    3832real_install: _always
    3933        test -d $(INSTALL_LIB)
    real_install: _always 
    4337        $(CP) -R tools/. $(INSTALL_BIN)
    4438
    4539uninstall:
    46         for i in $(LIBS) ""; do test -z "$$i" || rm -f $(INSTALL_LIB)/`basename $$i`; done
    47         for i in `$(LS) tools` "" ; do test -z "$$i" || rm -f $(INSTALL_BIN)/`basename $$i`; done
     40        for i in $(LIBS) ""; do test -z "$$i" || rm -f $(DESTDIR)$(INSTALL_LIB)/`basename $$i`; done
     41        for i in `$(LS) tools` "" ; do test -z "$$i" || rm -f $(DESTDIR)$(INSTALL_BIN)/`basename $$i`; done
    4842
    4943# Use ant to actually do the work for these targets
    5044jar test: _always
  • deleted file csrc/ccnd/ccnd-init-keystore-helper.sh

    diff --git csrc/ccnd/ccnd-init-keystore-helper.sh csrc/ccnd/ccnd-init-keystore-helper.sh
    deleted file mode 100755
    index ede0153..0000000
    + -  
    1 #!/bin/sh
    2 # ccnd/ccnd-init-keystore-helper.sh
    3 #
    4 # Part of the CCNx distribution.
    5 #
    6 # Copyright (C) 2009 Palo Alto Research Center, Inc.
    7 #
    8 # This work is free software; you can redistribute it and/or modify it under
    9 # the terms of the GNU General Public License version 2 as published by the
    10 # Free Software Foundation.
    11 # This work is distributed in the hope that it will be useful, but WITHOUT ANY
    12 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    13 # FOR A PARTICULAR PURPOSE.
    14 #
    15 : ${RSA_KEYSIZE:=1024}
    16 exec >&2
    17 Fail () {
    18   echo '*** Failed' "$*"
    19   exit 1
    20 }
    21 cd `dirname "$1"` || Fail bad setup
    22 umask 077
    23 trap 'rm -f *.pem openssl.cnf p' 0
    24 cat <<EOF >openssl.cnf
    25 # This is not really relevant because we're not sending cert requests anywhere,
    26 # but openssl req can refuse to go on if it has no config file.
    27 [ req ]
    28 distinguished_name      = req_distinguished_name
    29 [ req_distinguished_name ]
    30 countryName                     = Country Name (2 letter code)
    31 countryName_default             = AU
    32 countryName_min                 = 2
    33 countryName_max                 = 2
    34 EOF
    35 openssl req -config openssl.cnf       \
    36             -newkey rsa:$RSA_KEYSIZE  \
    37             -x509                     \
    38             -keyout private_key.pem   \
    39             -out certout.pem          \
    40             -subj /CN="CCND-internal" \
    41             -nodes                   || Fail openssl req
    42 openssl pkcs12 -export                \
    43             -name "CCND"              \
    44             -out "$1"                 \
    45             -in certout.pem           \
    46             -inkey private_key.pem    \
    47             -password file:p         || Fail openssl pkcs12
  • csrc/ccnd/dir.mk

    diff --git csrc/ccnd/dir.mk csrc/ccnd/dir.mk
    index 72c8438..2ec0946 100644
     
    1515LDLIBS = -L$(CCNLIBDIR) $(MORE_LDLIBS) -lccn
    1616CCNLIBDIR = ../lib
    1717
    18 INSTALLED_PROGRAMS = ccnd ccndsmoketest ccnd-init-keystore-helper
     18INSTALLED_PROGRAMS = ccnd ccndsmoketest
    1919PROGRAMS = $(INSTALLED_PROGRAMS)
    2020DEBRIS = anything.ccnb contentobjecthash.ccnb contentmishash.ccnb \
    2121         contenthash.ccnb
    BROKEN_PROGRAMS = 
    2424CSRC = ccnd_main.c ccnd.c ccnd_msg.c ccnd_stats.c ccnd_internal_client.c ccndsmoketest.c
    2525HSRC = ccnd_private.h
    2626SCRIPTSRC = testbasics fortunes.ccnb contentobjecthash.ref anything.ref \
    27             ccnd-init-keystore-helper.sh minsuffix.ref
     27            minsuffix.ref
    2828 
    2929default: $(PROGRAMS)
    3030
    ccnd: $(CCND_OBJ) ccnd_built.sh 
    4040ccnd_built.sh:
    4141        touch ccnd_built.sh
    4242
    43 ccnd-init-keystore-helper: ccnd-init-keystore-helper.sh
    44         sed -e 's@/bin/sh@'`which sh`'@g' ccnd-init-keystore-helper.sh > $@
    45         chmod +x $@
    46 
    4743ccndsmoketest: ccndsmoketest.o
    4844        $(CC) $(CFLAGS) -o $@ ccndsmoketest.o $(LDLIBS)
    4945
  • csrc/configure

    diff --git csrc/configure csrc/configure
    index 962d76a..e838792 100755
    TryAppend "`uname -sr | sed -e 's/ /-/g'`" 
    3939TryAppend "local"
    4040TryScript "`uname`" "$@"
    4141TryScript "local" "$@"
    42 ProvideDefault CPREFLAGS = -I../include
    43 ProvideDefault PCAP_PROGRAMS = ccndumppcap
    44 ProvideDefault RESOLV_LIBS = -lresolv
     42ProvideDefault CC = ${CC:=cc}
     43ProvideDefault CPREFLAGS = -I../include ${CFLAGS:-}
     44ProvideDefault PCAP_PROGRAMS = ${PCAP_PROGRAMS:-ccndumppcap}
     45ProvideDefault RESOLV_LIBS = ${RESOLV_LIBS:--lresolv}
    4546ProvideDefault INSTALL_BASE = ${INSTALL_BASE:-/usr/local}
    46 ProvideDefault INSTALL_INCLUDE = '$(INSTALL_BASE)/include'
    47 ProvideDefault INSTALL_LIB = '$(INSTALL_BASE)/lib'
    48 ProvideDefault INSTALL_BIN = '$(INSTALL_BASE)/bin'
    49 ProvideDefault INSTALL = install
    50 ProvideDefault RM = rm -f
    51 ProvideDefault SH = /bin/sh
     47ProvideDefault INSTALL_INCLUDE = ${INSTALL_INCLUDE:-\$(INSTALL_BASE)/include}
     48ProvideDefault INSTALL_LIB = ${INSTALL_LIB:-\$(INSTALL_BASE)/lib}
     49ProvideDefault INSTALL_BIN = ${INSTALL_BIN:-\$(INSTALL_BASE)/bin}
     50ProvideDefault INSTALL = ${INSTALL:-install}
     51ProvideDefault CP = ${CP:-cp}
     52ProvideDefault RM = ${RM:-rm -f}
     53ProvideDefault SH = ${SH:-/bin/sh}
     54ProvideDefault LS = ${LS:-/bin/ls}
     55
     56ProvideDefault BUILD_JAVA = ${BUILD_JAVA:-true}
     57ProvideDefault BUILD_APPS = ${BUILD_APPS:-true}
    5258
    5359echo ============= conf.mk =============>&2
    5460cat conf.mk                             >&2
  • csrc/include/ccn/ccn.h

    diff --git csrc/include/ccn/ccn.h csrc/include/ccn/ccn.h
    index 548d5d4..22990fb 100644
    int ccn_encode_StatusResponse(struct ccn_charbuf *buf, 
    911911 * error encountered during a call using the given handle.
    912912 * ccn_seterror records error info, ccn_geterror gets it.
    913913 */
    914 void ccn_perror(struct ccn *h, const char *s);
     914void ccn_perror(struct ccn *h, const char *s, ...);
    915915int ccn_seterror(struct ccn *h, int error_code);
    916916int ccn_geterror(struct ccn *h);
    917917
  • csrc/lib/ccn_client.c

    diff --git csrc/lib/ccn_client.c csrc/lib/ccn_client.c
    index 606fd36..35f2b43 100644
    tv_earlier(const struct timeval *a, const struct timeval *b) 
    163163 *        where available.
    164164 */
    165165void
    166 ccn_perror(struct ccn *h, const char *s)
     166ccn_perror(struct ccn *h, const char *s, ...)
    167167{
    168168    const char *dlm = ": ";
     169    va_list ap;
     170    va_start(ap, s);
     171   
    169172    if (s == NULL) {
    170173        if (h->err > 0)
    171174            s = strerror(h->err);
    ccn_perror(struct ccn *h, const char *s) 
    173176            dlm = s = "";
    174177    }
    175178    // XXX - time stamp
    176     fprintf(stderr, "ccn_client.c:%d[%d] - error %d%s%s\n",
    177                         h->errline, (int)getpid(), h->err, dlm, s);
     179    fprintf(stderr, "ccn_client.c:%d[%d] - error %d%s",
     180                        h->errline, (int)getpid(), h->err, dlm);
     181    vfprintf(stderr, s, ap);
     182    fprintf(stderr, "\n");
    178183}
    179184
    180185static int
    ccn_get_public_key(struct ccn *h, 
    25622567    return(res);
    25632568}
    25642569
     2570int
     2571ccn_load_key_or_create(struct ccn *h,
     2572                       const char *keystore,
     2573                       struct ccn_charbuf *default_pubid,
     2574                       size_t key_size)
     2575{
     2576  const char *password = NULL;
     2577  int res = 0;
     2578 
     2579  password = getenv ("CCNX_KEYSTORE_PASSWORD");
     2580  if (password == 0) {
     2581    password = "Th1s1sn0t8g00dp8ssw0rd.";
     2582  }
     2583           
     2584  res = ccn_load_private_key(h,
     2585                             keystore,
     2586                             password,
     2587                             default_pubid);
     2588             
     2589  if (res != 0 || default_pubid->length != key_size) {
     2590    // two cases, either file exists and we password is wrong or file does not exist
     2591
     2592    if (access (keystore, R_OK) == 0) {
     2593      ccn_perror (h, "Keystore file [%s] exists, but private key cannot be loaded.  "
     2594                  "Check if CCNX_KEYSTORE_PASSWORD is set to a correct password, "
     2595                  "otherwise remove [%s] and it will be automatically created.",
     2596                  keystore, keystore);
     2597      res = NOTE_ERR (h, -1);
     2598      return res;
     2599    }
     2600   
     2601    ccn_perror (h, "Keystore [%s] does not exist and will be automatically created", keystore);
     2602   
     2603    res = ccn_keystore_file_init ((char*)keystore, (char*)password,
     2604                                  "ccnxuser", 0, 3650); // create a key valid for 10 years
     2605    if (res != 0) {
     2606      ccn_perror (h, "Cannot create keystore [%s]", keystore);
     2607      res = NOTE_ERRNO (h);
     2608      return res;
     2609    }
     2610   
     2611    res = ccn_load_private_key(h,
     2612                               keystore,
     2613                               password,
     2614                               default_pubid);
     2615    if (res != 0 || default_pubid->length != key_size) {
     2616      // this definitely should not happen
     2617      ccn_perror (h, "Cannot load keystore [%s] just after it has been created", keystore);
     2618      res = NOTE_ERRNO (h);
     2619      return res;
     2620    }
     2621  }
     2622
     2623  return res;
     2624}
     2625
    25652626/**
    25662627 * This is mostly for use within the library,
    25672628 * but may be useful for some clients.
    ccn_chk_signing_params(struct ccn *h, 
    25822643    int i;
    25832644    int conflicting;
    25842645    int needed;
     2646    struct stat sb;
    25852647   
    25862648    if (params != NULL)
    25872649        *result = *params;
    ccn_chk_signing_params(struct ccn *h, 
    26072669            temp = ccn_charbuf_create();
    26082670            if (default_pubid == NULL || temp == NULL)
    26092671                return(NOTE_ERRNO(h));
     2672
     2673            res = -1;
     2674           
     2675            // check CCNX_DIR
    26102676            ccnx_dir = getenv("CCNX_DIR");
    2611             if (ccnx_dir == NULL || ccnx_dir[0] == 0) {
    2612                 home = getenv("HOME");
    2613                 if (home == NULL)
    2614                     home = "";
     2677            if (ccnx_dir != NULL && ccnx_dir[0] != 0) {
     2678              ccn_charbuf_reset(temp);
     2679              ccn_charbuf_putf(temp, "%s/.ccnx_keystore", ccnx_dir);
     2680
     2681              res = ccn_load_key_or_create (h,
     2682                                            ccn_charbuf_as_string (temp),
     2683                                            default_pubid,
     2684                                            sizeof(result->pubid));
     2685            }
     2686           
     2687            if (res < 0) {
     2688              // check HOME
     2689              home = getenv("HOME");
     2690              if (home != NULL) {
     2691                // step 1. Check if home directory exists
     2692                ccn_charbuf_reset(temp);
     2693                ccn_charbuf_putf(temp, "%s/.ccnx", home);
     2694               
     2695                res = stat (ccn_charbuf_as_string (temp), &sb);
     2696                if (res != 0 || !(sb.st_mode & S_IFDIR))
     2697                  {
     2698                    res = mkdir (ccn_charbuf_as_string (temp), S_IRWXU);
     2699                    if (res != 0)
     2700                      {
     2701                        ccn_perror (h, "Failed to create directory [%s]", ccn_charbuf_as_string (temp));
     2702                      }
     2703                  }
     2704               
     2705                ccn_charbuf_reset(temp);
    26152706                ccn_charbuf_putf(temp, "%s/.ccnx/.ccnx_keystore", home);
     2707               
     2708                res = ccn_load_key_or_create (h,
     2709                                              ccn_charbuf_as_string (temp),
     2710                                              default_pubid,
     2711                                              sizeof(result->pubid));
     2712              }
    26162713            }
    2617             else
    2618                 ccn_charbuf_putf(temp, "%s/.ccnx_keystore", ccnx_dir);
    2619             res = ccn_load_private_key(h,
    2620                                        ccn_charbuf_as_string(temp),
    2621                                        "Th1s1sn0t8g00dp8ssw0rd.",
    2622                                        default_pubid);
    2623             if (res == 0 && default_pubid->length == sizeof(result->pubid)) {
     2714
     2715            if (res == 0) {
    26242716                h->default_pubid = default_pubid;
    26252717                default_pubid = NULL;
    26262718            }
     2719            else {
     2720              ccn_perror(h, "Fail to load private key from keystore");
     2721              res = NOTE_ERRNO (h);
     2722            }
    26272723        }
    26282724        if (h->default_pubid == NULL)
    26292725            res = NOTE_ERRNO(h);
  • deleted file csrc/lib/ccn_initkeystore.sh

    diff --git csrc/lib/ccn_initkeystore.sh csrc/lib/ccn_initkeystore.sh
    deleted file mode 100755
    index 12bc9e3..0000000
    + -  
    1 #!/bin/sh
    2 # lib/ccn_initkeystore.sh
    3 #
    4 # Part of the CCNx distribution.
    5 #
    6 # Copyright (C) 2009-2010 Palo Alto Research Center, Inc.
    7 #
    8 # This work is free software; you can redistribute it and/or modify it under
    9 # the terms of the GNU General Public License version 2 as published by the
    10 # Free Software Foundation.
    11 # This work is distributed in the hope that it will be useful, but WITHOUT ANY
    12 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    13 # FOR A PARTICULAR PURPOSE.
    14 #
    15 # Create a ccn keystore without relying on java
    16 : ${RSA_KEYSIZE:=1024}
    17 : ${CCN_USER:=`id -n -u`}
    18 Fail () {
    19   echo '*** Failed' "$*"
    20   exit 1
    21 }
    22 test -d .ccnx && rm -rf .ccnx
    23 test $RSA_KEYSIZE -ge 512 || Fail \$RSA_KEYSIZE too small to sign CCN content
    24 (umask 077 && mkdir .ccnx) || Fail $0 Unable to create .ccnx directory
    25 cd .ccnx
    26 umask 077
    27 # Set a trap to cleanup on the way out
    28 trap 'rm -f *.pem openssl.cnf' 0
    29 cat <<EOF >openssl.cnf
    30 # This is not really relevant because we're not sending cert requests anywhere,
    31 # but openssl req can refuse to go on if it has no config file.
    32 [ req ]
    33 distinguished_name      = req_distinguished_name
    34 [ req_distinguished_name ]
    35 countryName                     = Country Name (2 letter code)
    36 countryName_default             = AU
    37 countryName_min                 = 2
    38 countryName_max                 = 2
    39 EOF
    40 openssl req    -config openssl.cnf      \
    41                -newkey rsa:$RSA_KEYSIZE \
    42                -x509                    \
    43                -keyout private_key.pem  \
    44                -out certout.pem         \
    45                -subj /CN="$CCN_USER"    \
    46                -nodes                                   || Fail openssl req
    47 openssl pkcs12 -export -name "ccnxuser" \
    48                -out .ccnx_keystore      \
    49                -in certout.pem          \
    50                -inkey private_key.pem   \
    51                -password pass:'Th1s1sn0t8g00dp8ssw0rd.' || Fail openssl pkcs12
  • csrc/lib/dir.mk

    diff --git csrc/lib/dir.mk csrc/lib/dir.mk
    index 6489299..c03316d 100644
    PROGRAMS = hashtbtest skel_decode_test \ 
    2121
    2222BROKEN_PROGRAMS =
    2323DEBRIS = ccn_verifysig _bt_*
    24 SCRIPTSRC = ccn_initkeystore.sh
    2524CSRC = ccn_bloom.c \
    2625       ccn_btree.c ccn_btree_content.c ccn_btree_store.c \
    2726       ccn_buf_decoder.c ccn_buf_encoder.c ccn_bulkdata.c \
    default all: dtag_check lib $(PROGRAMS) 
    5655# Don't try to build shared libs right now.
    5756# all: shlib
    5857
    59 all: basicparsetest ccn_verifysig
     58# all: basicparsetest ccn_verifysig
    6059
    6160install: install_headers
    6261install_headers:
    63         @test -d $(INSTALL_INCLUDE) || (echo $(INSTALL_INCLUDE) does not exist.  Please mkdir -p $(INSTALL_INCLUDE) if this is what you intended. && exit 2)
    64         mkdir -p $(INSTALL_INCLUDE)/ccn
     62        @test -d $(DESTDIR)$(INSTALL_INCLUDE) || (echo $(DESTDIR)$(INSTALL_INCLUDE) does not exist.  Please mkdir -p $(DESTDIR)$(INSTALL_INCLUDE) if this is what you intended. && exit 2)
     63        mkdir -p $(DESTDIR)$(INSTALL_INCLUDE)/ccn
    6564        for i in `cd ../include/ccn && echo *.h`; do                \
    66             cmp -s ../include/ccn/$$i $(INSTALL_INCLUDE)/ccn/$$i || \
    67                 cp ../include/ccn/$$i $(INSTALL_INCLUDE)/ccn/$$i || \
     65            cmp -s ../include/ccn/$$i $(DESTDIR)$(INSTALL_INCLUDE)/ccn/$$i || \
     66                cp ../include/ccn/$$i $(DESTDIR)$(INSTALL_INCLUDE)/ccn/$$i || \
    6867                exit 1;                                             \
    6968        done
    7069
    7170uninstall: uninstall_headers
    7271uninstall_headers:
    73         test -L $(INSTALL_INCLUDE)/ccn && $(RM) $(INSTALL_INCLUDE)/ccn ||:
    74         test -L $(INSTALL_INCLUDE) || $(RM) -r $(INSTALL_INCLUDE)/ccn
     72        test -L $(DESTDIR)$(INSTALL_INCLUDE)/ccn && $(RM) $(DESTDIR)$(INSTALL_INCLUDE)/ccn ||:
     73        test -L $(DESTDIR)$(INSTALL_INCLUDE) || $(RM) -r $(DESTDIR)$(INSTALL_INCLUDE)/ccn
    7574
    7675shlib: $(SHLIBNAME)
    7776
    7877lib: libccn.a
    7978
    80 test: default keystore_check encodedecodetest ccnbtreetest
     79test: default encodedecodetest ccnbtreetest
    8180        ./encodedecodetest -o /dev/null
    8281        ./ccnbtreetest
    8382        ./ccnbtreetest - < q.dat
    test: default keystore_check encodedecodetest ccnbtreetest 
    8685dtag_check: _always
    8786        @./gen_dtag_table 2>/dev/null | diff - ccn_dtag_table.c | grep '^[<]' >/dev/null && echo '*** Warning: ccn_dtag_table.c may be out of sync with tagnames.cvsdict' || :
    8887
    89 keystore_check: ccn_initkeystore.sh
    90         test -f "$$HOME/.ccnx/.ccnx_keystore" || $(MAKE) -f dir.mk new_keystore
    91 
    92 new_keystore:
    93         @echo === CCNx Keystore not found in your home directory
    94         @echo === I will create one for you now '(^C to abort)'
    95         sleep 1 && sh ccn_initkeystore.sh && sleep 3 && mv .ccnx "$$HOME"
    96 
    9788libccn.a: $(LIB_OBJS)
    9889        ar crus $@ $(LIB_OBJS)
    9990
    skel_decode_test: skel_decode_test.o 
    113104basicparsetest: basicparsetest.o libccn.a
    114105        $(CC) $(CFLAGS) -o $@ basicparsetest.o $(LDLIBS) $(OPENSSL_LIBS) -lcrypto
    115106
    116 encodedecodetest: encodedecodetest.o
     107encodedecodetest: encodedecodetest.o libccn.a
    117108        $(CC) $(CFLAGS) -o $@ encodedecodetest.o $(LDLIBS) $(OPENSSL_LIBS) -lcrypto
    118109
    119110ccn_digest.o:
    ccn_fetch.o: 
    149140ccn_verifysig.o:
    150141        $(CC) $(CFLAGS) $(OPENSSL_CFLAGS) -c ccn_verifysig.c
    151142
    152 ccn_verifysig: ccn_verifysig.o
     143ccn_verifysig: ccn_verifysig.o libccn.a
    153144        $(CC) $(CFLAGS) -o $@ ccn_verifysig.o $(LDLIBS) $(OPENSSL_LIBS) -lcrypto
    154145
    155146signbenchtest.o:
    156147        $(CC) $(CFLAGS) $(OPENSSL_CFLAGS) -c signbenchtest.c
    157148
    158 signbenchtest: signbenchtest.o
     149signbenchtest: signbenchtest.o libccn.a
    159150        $(CC) $(CFLAGS) -o $@ signbenchtest.o $(LDLIBS) $(OPENSSL_LIBS) -lcrypto
    160151
    161 ccndumppcap: ccndumppcap.o
     152ccndumppcap: ccndumppcap.o libccn.a
    162153        $(CC) $(CFLAGS) -o $@ ccndumppcap.o $(LDLIBS) $(OPENSSL_LIBS) -lcrypto -lpcap
    163154
    164155ccnbtreetest.o:
  • csrc/lib/encodedecodetest.c

    diff --git csrc/lib/encodedecodetest.c csrc/lib/encodedecodetest.c
    index be6a853..09e02ea 100644
    main (int argc, char *argv[]) { 
    210210                       NULL};
    211211    struct path * cur_path = NULL;
    212212    struct ccn_keystore *keystore = ccn_keystore_create();
    213     char *home = getenv("HOME");
    214     char *keystore_suffix = "/.ccnx/.ccnx_keystore";
    215213    char *keystore_name = NULL;
     214    char *keystore_password = NULL;
    216215
    217216    int i;
    218217
    219     while ((i = getopt(argc, argv, "k:o:")) != -1) {
     218    while ((i = getopt(argc, argv, "k:p:o:")) != -1) {
    220219        switch (i) {
    221220            case 'k':
    222221                keystore_name = optarg;
    223222                break;
     223            case 'p':
     224                keystore_password = optarg;
     225                break;
    224226            case 'o':
    225227                outname = optarg;
    226228                break;
    main (int argc, char *argv[]) { 
    231233    }
    232234   
    233235
    234     if (keystore_name == NULL && home == NULL) {
    235         printf("Unable to determine home directory for keystore\n");
    236         exit(1);
    237     }
    238236    if (keystore_name == NULL) {
    239         keystore_name = calloc(1, strlen(home) + strlen(keystore_suffix) + 1);
    240         strcat(keystore_name, home);
    241         strcat(keystore_name, keystore_suffix);
     237      keystore_name = tmpnam (NULL); // should be ok, there is just single thread
    242238    }
    243239
    244     if (0 != ccn_keystore_init(keystore, keystore_name, "Th1s1sn0t8g00dp8ssw0rd.")) {
    245         printf("Failed to initialize keystore\n");
    246         exit(1);
     240    if (keystore_password == NULL) {
     241      keystore_password = "Th1s1sn0t8g00dp8ssw0rd.";
    247242    }
    248243
     244    res = ccn_keystore_init (keystore, keystore_name, keystore_password);
     245    if (res != 0)
     246      {
     247        printf ("Initializing keystore in %s\n", keystore_name);
     248       
     249        res = ccn_keystore_file_init (keystore_name, keystore_password,
     250                                      "ccnxuser", 0, 3650); // create a key valid for 10 years
     251        if (res != 0) {
     252          fprintf (stderr, "Cannot create keystore [%s]", keystore_name);
     253          return res;
     254        }
     255
     256        // init again
     257        res = ccn_keystore_init(keystore, keystore_name, keystore_password);
     258        if (res != 0) {
     259          printf("Failed to initialize keystore\n");
     260          exit(1);
     261        }
     262      }       
     263
     264   
     265
     266   
     267
    249268    printf("Creating signed_info\n");
    250269    res = ccn_signed_info_create(signed_info,
    251270                                 /*pubkeyid*/ccn_keystore_public_key_digest(keystore),
  • csrc/subr.mk

    diff --git csrc/subr.mk csrc/subr.mk
    index e24c230..3361a49 100644
    $(OBJDIR)/dir.mk: dir.mk 
    3131        cp -p dir.mk $(OBJDIR)/dir.mk
    3232
    3333install_libs: $(LIBS)
    34         @test -d $(INSTALL_LIB) || (echo $(INSTALL_LIB) does not exist.  Please mkdir -p $(INSTALL_LIB) if this is what you intended. && exit 2)
    35         for i in $(LIBS) ""; do test -z "$$i" || $(INSTALL) $$i $(INSTALL_LIB); done
     34        @test -d $(DESTDIR)$(INSTALL_LIB) || (echo $(DESTDIR)$(INSTALL_LIB) does not exist.  Please mkdir -p $(DESTDIR)$(INSTALL_LIB) if this is what you intended. && exit 2)
     35        for i in $(LIBS) ""; do test -z "$$i" || $(INSTALL) $$i $(DESTDIR)$(INSTALL_LIB); done
    3636
    3737install_programs: $(INSTALLED_PROGRAMS)
    38         @test -d $(INSTALL_BIN) || (echo $(INSTALL_BIN) does not exist.  Please mkdir -p $(INSTALL_BIN) if this is what you intended. && exit 2)
    39         for i in $(INSTALLED_PROGRAMS) ""; do test -z "$$i" || $(INSTALL) $$i $(INSTALL_BIN); done
     38        @test -d $(DESTDIR)$(INSTALL_BIN) || (echo $(DESTDIR)$(INSTALL_BIN) does not exist.  Please mkdir -p $(DESTDIR)$(INSTALL_BIN) if this is what you intended. && exit 2)
     39        for i in $(INSTALLED_PROGRAMS) ""; do test -z "$$i" || $(INSTALL) $$i $(DESTDIR)$(INSTALL_BIN); done
    4040
    4141install: install_libs install_programs
    4242
    4343uninstall_libs:
    44         for i in $(LIBS) ""; do test -z "$$i" || $(RM) $(INSTALL_LIB)/$$i; done
     44        for i in $(LIBS) ""; do test -z "$$i" || $(RM) $(DESTDIR)$(INSTALL_LIB)/$$i; done
    4545
    4646uninstall_programs:
    47         for i in $(PROGRAMS) ""; do test -z "$$i" || $(RM) $(INSTALL_BIN)/$$i; done
     47        for i in $(PROGRAMS) ""; do test -z "$$i" || $(RM) $(DESTDIR)$(INSTALL_BIN)/$$i; done
    4848
    4949uninstall: uninstall_libs uninstall_programs
    5050
  • javasrc/Makefile

    diff --git javasrc/Makefile javasrc/Makefile
    index c5b8444..d2237b6 100644
     
    1212# FOR A PARTICULAR PURPOSE.
    1313#
    1414
     15include ../csrc/conf.mk
     16
    1517ANT = `command -v ant || echo echo SKIPPING ant`
    1618JAR = ccn.jar
    1719LIBS = $(JAR) lib/bcprov-jdk16-143.jar lib/kxml2-2.3.0.jar $(EXTRA_LIBS)
    WARN_NO_INSTALL = echo Nothing installed from javasrc/ 
    2325# Default, the top-level Makefile default target will
    2426# call the install target here but override INSTALL_BASE
    2527# with dir in the source tree
    26 INSTALL_LIB = $(INSTALL_BASE)/lib
    27 INSTALL_BIN = $(INSTALL_BASE)/bin
    28 INSTALL = cp
    29 CP = cp
    30 LS = /bin/ls
    3128
    3229default all: jar
    3330check: test
    3431
    3532install:
    3633        @test -f $(JAR) && $(MAKE) real_install \
    37             INSTALL_BASE=$(INSTALL_BASE)        \
    38             INSTALL_LIB=$(INSTALL_LIB)          \
    39             INSTALL_BIN=$(INSTALL_BIN) || $(WARN_NO_INSTALL)
     34            INSTALL_BASE=$(DESTDIR)$(INSTALL_BASE)        \
     35            INSTALL_LIB=$(DESTDIR)$(INSTALL_LIB)          \
     36            INSTALL_BIN=$(DESTDIR)$(INSTALL_BIN) || $(WARN_NO_INSTALL)
    4037
    4138real_install: _always
    4239        test -d $(INSTALL_LIB)
    real_install: _always 
    4643        $(CP) -R tools/. $(INSTALL_BIN)
    4744
    4845uninstall:
    49         for i in $(LIBS) ""; do test -z "$$i" || rm -f $(INSTALL_LIB)/`basename $$i`; done
    50         for i in `$(LS) tools` "" ; do test -z "$$i" || rm -f $(INSTALL_BIN)/`basename $$i`; done
     46        for i in $(LIBS) ""; do test -z "$$i" || rm -f $(DESTDIR)$(INSTALL_LIB)/`basename $$i`; done
     47        for i in `$(LS) tools` "" ; do test -z "$$i" || rm -f $(DESTDIR)$(INSTALL_BIN)/`basename $$i`; done
    5148
    5249# Use ant to actually do the work for these targets
    5350jar test: _always