Changeset 53509


Ignore:
Timestamp:
Jul 7, 2009, 8:20:59 AM (11 years ago)
Author:
enl@…
Message:

Merge from trunk + little code cleanups

Location:
branches/gsoc09-logging/base
Files:
3 deleted
60 edited
7 copied

Legend:

Unmodified
Added
Removed
  • branches/gsoc09-logging/base

  • branches/gsoc09-logging/base/Makefile.in

    r46954 r53509  
    11# $Id$
    22
     3PATH            = @PATH_CLEANED@
    34SUBDIR          = doc src
    45DISTDIR         = dist
     
    2930        fi
    3031
    31 
    32 include Mk/macports.upgrade.mk
    33 
    34 install:: upgrade
    35         [ ! -f ${sysconfdir}/macports/mp_version ] || rm -vf ${sysconfdir}/macports/mp_version
    36 
    3732include Mk/macports.subdir.mk
    3833
    3934install::
     35        [ ! -f ${sysconfdir}/macports/mp_version ] || rm -vf ${sysconfdir}/macports/mp_version
    4036        $(INSTALL) -o ${DSTUSR} -g ${DSTGRP} -m 444 setupenv.bash  $(DESTDIR)${datadir}/macports/
    4137# Only run these scripts when not building in a destroot
  • branches/gsoc09-logging/base/Mk/macports.autoconf.mk.in

    r43624 r53509  
    3333SHLIB_LD                = @SHLIB_LD@
    3434STLIB_LD                = @STLIB_LD@
    35 LDFLAGS                 = -L/usr/local/lib @LDFLAGS@
     35LDFLAGS                 = @LDFLAGS@
    3636SHLIB_LDFLAGS           = @SHLIB_LDFLAGS@ ${LDFLAGS}
    3737SHLIB_SUFFIX            = @SHLIB_SUFFIX@
  • branches/gsoc09-logging/base/aclocal.m4

    r52218 r53509  
    289289        ])
    290290
     291# MP_CHECK_OLDLAYOUT
     292#---------------------------------------
     293AC_DEFUN([MP_CHECK_OLDLAYOUT],[
     294        dnl Bail if there is an existing install of DP/MP older than 1.5
     295
     296        AC_MSG_CHECKING([that any existing MacPorts install can be upgraded])
     297
     298        eval dpversionfile="${sysconfdir}/ports/dp_version"
     299        if test -f $dpversionfile; then
     300                AC_MSG_ERROR([Existing MacPorts or DarwinPorts install is too old to be upgraded. Install MacPorts 1.7.1 first.])
     301        else
     302                AC_MSG_RESULT([yes])
     303        fi
     304
     305        ])
    291306
    292307# MP_CHECK_NOROOTPRIVILEGES
     
    490505#---------------------------------------
    491506AC_DEFUN([MP_UNIVERSAL_OPTIONS],[
    492 
    493     AC_ARG_WITH(universal-target,[AS_HELP_STRING([--with-universal-target=MDT],[Universal MACOSX_DEPLOYMENT_TARGET version])], UNIVERSAL_TARGET=${withval})
    494     AC_ARG_WITH(universal-sysroot,[AS_HELP_STRING([--with-universal-sysroot=SDK],[Universal SDK sysroot (with complete path)])], UNIVERSAL_SYSROOT=${withval})
    495     AC_ARG_WITH(universal-archs,[AS_HELP_STRING([--with-universal-archs="CPU"],[Universal CPU architectures (space separated)])], UNIVERSAL_ARCHS=${withval})
    496 
    497         MACOSX_MAJOR_VERSION=`$SW_VERS -productVersion | cut -f-2 -d.`
    498 
    499         if test "x$UNIVERSAL_TARGET" = "x"; then
    500             UNIVERSAL_TARGET=${MACOSX_MAJOR_VERSION}
    501         fi
    502 
    503         if test "x$UNIVERSAL_SYSROOT" = "x"; then
    504             if test "${MACOSX_MAJOR_VERSION}" = "10.4"; then
    505                 UNIVERSAL_SYSROOT=${DEVELOPER_DIR}/SDKs/MacOSX${MACOSX_MAJOR_VERSION}u.sdk
    506             else
    507                 UNIVERSAL_SYSROOT=${DEVELOPER_DIR}/SDKs/MacOSX${MACOSX_MAJOR_VERSION}.sdk
    508             fi
    509         fi
    510 
    511         if test "x$UNIVERSAL_ARCHS" = "x"; then
    512             UNIVERSAL_ARCHS="ppc i386"
    513         fi
    514    
    515     AC_MSG_CHECKING([for Universal MDT version])
    516     AC_MSG_RESULT([$UNIVERSAL_TARGET])
    517     AC_SUBST(UNIVERSAL_TARGET)
    518 
    519     AC_MSG_CHECKING([for Universal SDK sysroot])
    520     AC_MSG_RESULT([$UNIVERSAL_SYSROOT])
    521     AC_SUBST(UNIVERSAL_SYSROOT)
    522 
    523     AC_MSG_CHECKING([for Universal CPU architectures])
    524     AC_MSG_RESULT([$UNIVERSAL_ARCHS])
    525     AC_SUBST(UNIVERSAL_ARCHS)
     507  AC_ARG_WITH(universal-archs,[AS_HELP_STRING([--with-universal-archs="CPU"],[Universal CPU architectures (space separated)])], UNIVERSAL_ARCHS=${withval})
     508
     509  if test "x$UNIVERSAL_ARCHS" = "x"; then
     510    case "$MACOSX_VERSION" in
     511      10.[[0-5]]*)
     512        UNIVERSAL_ARCHS="i386 ppc"
     513        ;;
     514      *)
     515        UNIVERSAL_ARCHS="x86_64 i386"
     516        ;;
     517    esac
     518  fi
     519
     520  AC_MSG_CHECKING([for Universal CPU architectures])
     521  AC_MSG_RESULT([$UNIVERSAL_ARCHS])
     522  AC_SUBST(UNIVERSAL_ARCHS)
    526523])
    527524
     
    830827        done
    831828        PATH=$newPATH; export PATH
     829        AC_SUBST(PATH_CLEANED,$newPATH)
    832830        prefix=$oldprefix
    833831])
  • branches/gsoc09-logging/base/configure

    r52218 r53509  
    677677CPP
    678678UNIVERSAL_ARCHS
    679 UNIVERSAL_SYSROOT
    680 UNIVERSAL_TARGET
    681679MPFRAMEWORKSDIR
    682680MPAPPLICATIONSDIR
     
    767765DEFAULTS
    768766SW_VERS
     767PATH_CLEANED
    769768MACPORTS_VERSION
    770769target_os
     
    832831with_applications_dir
    833832with_frameworks_dir
    834 with_universal_target
    835 with_universal_sysroot
    836833with_universal_archs
    837834enable_readline
     
    864861MAKE
    865862GNUTAR
     863BSDMAKE
    866864GNUMAKE
    867865BZIP2
     
    15231521  --with-applications-dir Applications installation directory.
    15241522  --with-frameworks-dir   Frameworks installation directory.
    1525   --with-universal-target=MDT
    1526                           Universal MACOSX_DEPLOYMENT_TARGET version
    1527   --with-universal-sysroot=SDK
    1528                           Universal SDK sysroot (with complete path)
    15291523  --with-universal-archs="CPU"
    15301524                          Universal CPU architectures (space separated)
     
    15581552  MAKE        path to make command
    15591553  GNUTAR      path to gnutar command
     1554  BSDMAKE     path to bsdmake/pmake command
    15601555  GNUMAKE     path to gnumake command
    15611556  BZIP2       path to bzip2 command
     
    22052200        done
    22062201        PATH=$newPATH; export PATH
     2202        PATH_CLEANED=$newPATH
     2203
    22072204        prefix=$oldprefix
    22082205
     
    46074604
    46084605
    4609 # Extract the first word of "bsdmake", so it can be a program name with args.
    4610 set dummy bsdmake; ac_word=$2
     4606for ac_prog in bsdmake pmake
     4607do
     4608  # Extract the first word of "$ac_prog", so it can be a program name with args.
     4609set dummy $ac_prog; ac_word=$2
    46114610{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
    46124611$as_echo_n "checking for $ac_word... " >&6; }
     
    46464645fi
    46474646
     4647
     4648  test -n "$BSDMAKE" && break
     4649done
    46484650
    46494651# Extract the first word of "make", so it can be a program name with args.
     
    51785180
    51795181# Define some precious variables allowing user to override PATH for some programs
     5182
    51805183
    51815184
     
    80778080
    80788081
    8079 
    8080 # Check whether --with-universal-target was given.
    8081 if test "${with_universal_target+set}" = set; then
    8082   withval=$with_universal_target; UNIVERSAL_TARGET=${withval}
    8083 fi
    8084 
    8085 
    8086 # Check whether --with-universal-sysroot was given.
    8087 if test "${with_universal_sysroot+set}" = set; then
    8088   withval=$with_universal_sysroot; UNIVERSAL_SYSROOT=${withval}
    8089 fi
    8090 
    8091 
    80928082# Check whether --with-universal-archs was given.
    80938083if test "${with_universal_archs+set}" = set; then
     
    80968086
    80978087
    8098         MACOSX_MAJOR_VERSION=`$SW_VERS -productVersion | cut -f-2 -d.`
    8099 
    8100         if test "x$UNIVERSAL_TARGET" = "x"; then
    8101             UNIVERSAL_TARGET=${MACOSX_MAJOR_VERSION}
    8102         fi
    8103 
    8104         if test "x$UNIVERSAL_SYSROOT" = "x"; then
    8105             if test "${MACOSX_MAJOR_VERSION}" = "10.4"; then
    8106                 UNIVERSAL_SYSROOT=${DEVELOPER_DIR}/SDKs/MacOSX${MACOSX_MAJOR_VERSION}u.sdk
    8107             else
    8108                 UNIVERSAL_SYSROOT=${DEVELOPER_DIR}/SDKs/MacOSX${MACOSX_MAJOR_VERSION}.sdk
    8109             fi
    8110         fi
    8111 
    8112         if test "x$UNIVERSAL_ARCHS" = "x"; then
    8113             UNIVERSAL_ARCHS="ppc i386"
    8114         fi
    8115 
    8116     { $as_echo "$as_me:$LINENO: checking for Universal MDT version" >&5
    8117 $as_echo_n "checking for Universal MDT version... " >&6; }
    8118     { $as_echo "$as_me:$LINENO: result: $UNIVERSAL_TARGET" >&5
    8119 $as_echo "$UNIVERSAL_TARGET" >&6; }
    8120 
    8121 
    8122     { $as_echo "$as_me:$LINENO: checking for Universal SDK sysroot" >&5
    8123 $as_echo_n "checking for Universal SDK sysroot... " >&6; }
    8124     { $as_echo "$as_me:$LINENO: result: $UNIVERSAL_SYSROOT" >&5
    8125 $as_echo "$UNIVERSAL_SYSROOT" >&6; }
    8126 
    8127 
    8128     { $as_echo "$as_me:$LINENO: checking for Universal CPU architectures" >&5
     8088  if test "x$UNIVERSAL_ARCHS" = "x"; then
     8089    case "$MACOSX_VERSION" in
     8090      10.[0-5]*)
     8091        UNIVERSAL_ARCHS="i386 ppc"
     8092        ;;
     8093      *)
     8094        UNIVERSAL_ARCHS="x86_64 i386"
     8095        ;;
     8096    esac
     8097  fi
     8098
     8099  { $as_echo "$as_me:$LINENO: checking for Universal CPU architectures" >&5
    81298100$as_echo_n "checking for Universal CPU architectures... " >&6; }
    8130     { $as_echo "$as_me:$LINENO: result: $UNIVERSAL_ARCHS" >&5
     8101  { $as_echo "$as_me:$LINENO: result: $UNIVERSAL_ARCHS" >&5
    81318102$as_echo "$UNIVERSAL_ARCHS" >&6; }
    81328103
     
    1105311024   prefix=$ac_default_prefix
    1105411025fi
     11026
     11027# Check if there's an existing DP/MP install too old to upgrade
     11028
     11029
     11030        { $as_echo "$as_me:$LINENO: checking that any existing MacPorts install can be upgraded" >&5
     11031$as_echo_n "checking that any existing MacPorts install can be upgraded... " >&6; }
     11032
     11033        eval dpversionfile="${sysconfdir}/ports/dp_version"
     11034        if test -f $dpversionfile; then
     11035                { { $as_echo "$as_me:$LINENO: error: Existing MacPorts or DarwinPorts install is too old to be upgraded. Install MacPorts 1.7.1 first." >&5
     11036$as_echo "$as_me: error: Existing MacPorts or DarwinPorts install is too old to be upgraded. Install MacPorts 1.7.1 first." >&2;}
     11037   { (exit 1); exit 1; }; }
     11038        else
     11039                { $as_echo "$as_me:$LINENO: result: yes" >&5
     11040$as_echo "yes" >&6; }
     11041        fi
     11042
     11043
    1105511044
    1105611045eval "prefix_expanded=$prefix"
  • branches/gsoc09-logging/base/configure.ac

    r52218 r53509  
    109109AC_PATH_PROG(UNZIP, [unzip])
    110110AC_PATH_PROG(ZIP, [zip])
    111 AC_PATH_PROG(BSDMAKE, [bsdmake])
     111AC_PATH_PROGS(BSDMAKE, [bsdmake pmake], [])
    112112AC_PATH_PROG(MAKE, [make])
    113113AC_PATH_PROG(HDIUTIL, [hdiutil], [])
     
    133133AC_ARG_VAR(MAKE, [path to make command])
    134134AC_ARG_VAR(GNUTAR, [path to gnutar command])
     135AC_ARG_VAR(BSDMAKE, [path to bsdmake/pmake command])
    135136AC_ARG_VAR(GNUMAKE, [path to gnumake command])
    136137AC_ARG_VAR(BZIP2, [path to bzip2 command])
     
    362363fi
    363364
     365# Check if there's an existing DP/MP install too old to upgrade
     366MP_CHECK_OLDLAYOUT
     367
    364368eval "prefix_expanded=$prefix"
    365369AC_SUBST(prefix_expanded)
  • branches/gsoc09-logging/base/doc/macports.conf.5

    r51384 r53509  
    162162.Ic Default:
    163163yes
    164 .It Va universal_target
    165 The MACOSX_DEPLOYMENT_TARGET to use for +universal variant
    166 .br
    167 .Ic Example:
    168 10.4
    169 .It Va universal_sysroot
    170 The SDK "sysroot" full path to use for +universal variant
    171 .br
    172 .Ic Example:
    173 /Developer/SDKs/MacOSX10.4u.sdk
    174164.It Va universal_archs
    175165The machine architectures to use for +universal variant
     
    179169.br
    180170.Ic Default:
    181 ppc i386
     171x86_64 i386
     172.br
     173.Ic Default (10.5 and earlier):
     174i386 ppc
    182175.It Va startupitem_type
    183176Set the default type of startupitems to be generated, overridable by Portfiles that explicitly state a
  • branches/gsoc09-logging/base/doc/macports.conf.in

    r52218 r53509  
    5454portarchivetype         tgz
    5555
     56# CPU architecture to compile for. Defaults to i386 or ppc on Mac OS X 10.5
     57# and earlier, depending on the CPU type detected at runtime. On Mac OS X 10.6
     58# the default is x86_64 if the CPU supports it, i386 otherwise.
     59#build_arch                     i386
     60
    5661# Use ccache (C/C++ compiler cache) - see http://ccache.samba.org/
    5762configureccache         no
     
    8994
    9095# Options for Universal Binaries (+universal variant)
    91 
    92 # MACOSX_DEPLOYMENT_TARGET
    93 universal_target        @UNIVERSAL_TARGET@
    94 
    95 # the SDK "sysroot" to use
    96 universal_sysroot       @UNIVERSAL_SYSROOT@
    9796
    9897# machine architectures
  • branches/gsoc09-logging/base/doc/portfile.7

    r50875 r53509  
    19451945Compute the MD5 hashes of the file(s).
    19461946.It Ic rpm-vercomp Ar versionA Ar versionB
    1947 Compare two RPM-format versions for equality.
    1948 .It Ic sudo Ar password Ar command Ar \&...
    1949 Execute
    1950 .Ar command
    1951 using
    1952 .Cm sudo
    1953 with the provided password.
     1947Compare two RPM-format versions for equality.  The return value is like
     1948strcmp(), returning -1, 0, or 1 when versionA is earlier, equal to, or
     1949later than versionB, respectively.  Note that some comparisions featuring
     1950floating-point notation may compare incorrectly, eg, 2.101 is considered
     1951later than 2.2 (101 is larger than 2) which may be incorrect per some
     1952projects versioning methods (see ticket #11873).
    19541953.It Xo
    19551954.Ic lpush
  • branches/gsoc09-logging/base/portmgr/dmg/InstallationCheck

    • Property svn:eol-style set to native
    • Property svn:keywords set to Id
    r43954 r53509  
    1414   exit 112
    1515fi
     16
     17if [[ -f /opt/local/etc/ports/dp_version ]]; then
     18   # message 17 in InstallationCheck.strings
     19   exit 113
     20fi
     21
    1622exit 0
    1723
  • branches/gsoc09-logging/base/portmgr/dmg/InstallationCheck.strings

    • Property svn:eol-style set to native
    r43954 r53509  
    11"16" = "This package is meant to be installed on __XVERS__";
    2 
     2"17" = "Your existing MacPorts or DarwinPorts install is too old to be upgraded by this installer. Please install MacPorts 1.7.1 first."
  • branches/gsoc09-logging/base/portmgr/jobs/PortIndex2MySQL.tcl

    r52218 r53509  
    4949# (which updates the ports tree in use) and by installing the script on cron/launchd to be
    5050# run on a timely schedule (not any more frequent than the run of the PortIndexRegen.sh
    51 # script on that creates a new PortIndex file, which is every twelve hours).
     51# script on that creates a new PortIndex file).
    5252#
    5353# Remaining requirement to successfully run this script is performing the necessary
     
    7373set HEADERS "To: $SPAM_LOVERS\r\nFrom: $FROM\r\nSubject: $SUBJECT\r\n\r\n"
    7474
    75 # We first initialize the runlog with proper mail headers
    76 puts $runlog_fd $HEADERS
     75# handle command line arguments
     76set create_tables false
     77if {[llength $argv]} {
     78    if {[lindex $argv 0] == "--create-tables"} {
     79        set create_tables true
     80    }
     81}
    7782
    7883# House keeping on exit.
     
    96101    cleanup runlog
    97102    exit $exit_status
    98 }
    99 
    100 # Check if there are any stray sibling jobs before moving on, bail in such case.
    101 if {[file exists $lockfile]} {
    102     puts $runlog_fd "PortIndex2MySQL lock file found, is another job running?"
    103     terminate 1
    104 } else {
    105     set lockfile_fd [open $lockfile a]
    106 }
    107 
    108 
    109 # Load macports1.0 so that we can use some of its procs and the portinfo array.
    110 if {[catch { source [file join "@TCL_PACKAGE_DIR@" macports1.0 macports_fastload.tcl] } errstr]} {
    111     puts $runlog_fd "${::errorInfo}"
    112     puts $runlog_fd "Failed to locate the macports1.0 Tcl package file: $errstr"
    113     cleanup lockfile
    114     terminate 1
    115 }
    116 if {[catch { package require macports } errstr]} {
    117     puts $runlog_fd "${::errorInfo}"
    118     puts $runlog_fd "Failed to load the macports1.0 Tcl package: $errstr"
    119     cleanup lockfile
    120     terminate 1
    121103}
    122104
     
    158140}
    159141
     142# Procedure to catch the database password from a protected file.
     143proc getpasswd {passwdfile} {
     144    if {[catch {open $passwdfile r} passwdfile_fd]} {
     145        global lockfile lockfile_fd
     146        ui_error "${::errorCode}: $passwdfile_fd"
     147        cleanup lockfile
     148        terminate 1
     149    }
     150    if {[gets $passwdfile_fd passwd] <= 0} {
     151        global lockfile lockfile_fd
     152        close $passwdfile_fd
     153        ui_error "No password found in password file $passwdfile!"
     154        cleanup lockfile
     155        terminate 1
     156    }
     157    close $passwdfile_fd
     158    return $passwd
     159}
     160
     161# SQL string escaping.
     162proc sql_escape {str} {
     163    regsub -all -- {'} $str {\\'} str
     164    regsub -all -- {"} $str {\\"} str
     165    regsub -all -- {\n} $str {\\n} str
     166    return $str
     167}
     168
     169# We first initialize the runlog with proper mail headers
     170puts $runlog_fd $HEADERS
     171
     172# Check if there are any stray sibling jobs before moving on, bail in such case.
     173if {[file exists $lockfile]} {
     174    puts $runlog_fd "PortIndex2MySQL lock file found, is another job running?"
     175    terminate 1
     176} else {
     177    set lockfile_fd [open $lockfile a]
     178}
     179
     180# Load macports1.0 so that we can use some of its procs and the portinfo array.
     181if {[catch { source [file join "/Library/Tcl" macports1.0 macports_fastload.tcl] } errstr]} {
     182    puts $runlog_fd "${::errorInfo}"
     183    puts $runlog_fd "Failed to locate the macports1.0 Tcl package file: $errstr"
     184    cleanup lockfile
     185    terminate 1
     186}
     187if {[catch { package require macports } errstr]} {
     188    puts $runlog_fd "${::errorInfo}"
     189    puts $runlog_fd "Failed to load the macports1.0 Tcl package: $errstr"
     190    cleanup lockfile
     191    terminate 1
     192}
     193
    160194# Initialize macports1.0 and its UI, in order to find the sources.conf file
    161195# (which is what will point us to the PortIndex we're gonna use) and use
     
    170204
    171205
    172 # Procedure to catch the database password from a protected file.
    173 proc getpasswd {passwdfile} {
    174     if {[catch {open $passwdfile r} passwdfile_fd]} {
    175         global lockfile lockfile_fd
    176         ui_error "${::errorCode}: $passwdfile_fd"
    177         cleanup lockfile
    178         terminate 1
    179     }
    180     if {[gets $passwdfile_fd passwd] <= 0} {
    181         global lockfile lockfile_fd
    182         close $passwdfile_fd
    183         ui_error "No password found in password file $passwdfile!"
    184         cleanup lockfile
    185         terminate 1
    186     }
    187     close $passwdfile_fd
    188     return $passwd
    189 }
    190 
    191206# Database abstraction variables:
    192207set sqlfile "/tmp/portsdb.sql"
     
    223238}
    224239
    225 
    226 # SQL string escaping.
    227 proc sql_escape {str} {
    228     regsub -all -- {'} $str {\\'} str
    229     regsub -all -- {"} $str {\\"} str
    230     regsub -all -- {\n} $str {\\n} str
    231     return $str
    232 }
    233 
    234 # Initial creation of database tables: log, portfiles, categories, maintainers, dependencies, variants and platforms.
    235 # Do we need any other?
    236 puts $sqlfile_fd "DROP TABLE IF EXISTS log;"
    237 puts $sqlfile_fd "CREATE TABLE log (activity VARCHAR(255), activity_time TIMESTAMP(14)) DEFAULT CHARSET=utf8;"
    238 
    239 puts $sqlfile_fd "DROP TABLE IF EXISTS portfiles;"
    240 puts $sqlfile_fd "CREATE TABLE portfiles (name VARCHAR(255) PRIMARY KEY NOT NULL, path VARCHAR(255), version VARCHAR(255),  description TEXT) DEFAULT CHARSET=utf8;"
    241 
    242 puts $sqlfile_fd "DROP TABLE IF EXISTS categories;"
    243 puts $sqlfile_fd "CREATE TABLE categories (portfile VARCHAR(255), category VARCHAR(255), is_primary INTEGER) DEFAULT CHARSET=utf8;"
    244 
    245 puts $sqlfile_fd "DROP TABLE IF EXISTS maintainers;"
    246 puts $sqlfile_fd "CREATE TABLE maintainers (portfile VARCHAR(255), maintainer VARCHAR(255), is_primary INTEGER) DEFAULT CHARSET=utf8;"
    247 
    248 puts $sqlfile_fd "DROP TABLE IF EXISTS dependencies;"
    249 puts $sqlfile_fd "CREATE TABLE dependencies (portfile VARCHAR(255), library VARCHAR(255)) DEFAULT CHARSET=utf8;"
    250 
    251 puts $sqlfile_fd "DROP TABLE IF EXISTS variants;"
    252 puts $sqlfile_fd "CREATE TABLE variants (portfile VARCHAR(255), variant VARCHAR(255)) DEFAULT CHARSET=utf8;"
    253 
    254 puts $sqlfile_fd "DROP TABLE IF EXISTS platforms;"
    255 puts $sqlfile_fd "CREATE TABLE platforms (portfile VARCHAR(255), platform VARCHAR(255)) DEFAULT CHARSET=utf8;"
    256 
    257 
     240if {$create_tables} {
     241    # Initial creation of database tables: log, portfiles, categories, maintainers, dependencies, variants and platforms.
     242    # Do we need any other?
     243    puts $sqlfile_fd "DROP TABLE IF EXISTS log;"
     244    puts $sqlfile_fd "CREATE TABLE log (activity VARCHAR(255), activity_time TIMESTAMP(14)) DEFAULT CHARSET=utf8;"
     245   
     246    puts $sqlfile_fd "DROP TABLE IF EXISTS portfiles;"
     247    puts $sqlfile_fd "CREATE TABLE portfiles (name VARCHAR(255) PRIMARY KEY NOT NULL, path VARCHAR(255), version VARCHAR(255),  description TEXT) DEFAULT CHARSET=utf8;"
     248   
     249    puts $sqlfile_fd "DROP TABLE IF EXISTS categories;"
     250    puts $sqlfile_fd "CREATE TABLE categories (portfile VARCHAR(255), category VARCHAR(255), is_primary INTEGER) DEFAULT CHARSET=utf8;"
     251   
     252    puts $sqlfile_fd "DROP TABLE IF EXISTS maintainers;"
     253    puts $sqlfile_fd "CREATE TABLE maintainers (portfile VARCHAR(255), maintainer VARCHAR(255), is_primary INTEGER) DEFAULT CHARSET=utf8;"
     254   
     255    puts $sqlfile_fd "DROP TABLE IF EXISTS dependencies;"
     256    puts $sqlfile_fd "CREATE TABLE dependencies (portfile VARCHAR(255), library VARCHAR(255)) DEFAULT CHARSET=utf8;"
     257   
     258    puts $sqlfile_fd "DROP TABLE IF EXISTS variants;"
     259    puts $sqlfile_fd "CREATE TABLE variants (portfile VARCHAR(255), variant VARCHAR(255)) DEFAULT CHARSET=utf8;"
     260   
     261    puts $sqlfile_fd "DROP TABLE IF EXISTS platforms;"
     262    puts $sqlfile_fd "CREATE TABLE platforms (portfile VARCHAR(255), platform VARCHAR(255)) DEFAULT CHARSET=utf8;"
     263} else {
     264    # if we are not creating tables from scratch, remove the old data
     265    puts $sqlfile_fd "TRUNCATE log;"
     266    puts $sqlfile_fd "TRUNCATE portfiles;"
     267    puts $sqlfile_fd "TRUNCATE categories;"
     268    puts $sqlfile_fd "TRUNCATE maintainers;"
     269    puts $sqlfile_fd "TRUNCATE dependencies;"
     270    puts $sqlfile_fd "TRUNCATE variants;"
     271    puts $sqlfile_fd "TRUNCATE platforms;"
     272}
     273 
    258274# Iterate over each matching port, extracting its information from the
    259275# portinfo array.
     
    377393puts $sqlfile_fd "INSERT INTO log VALUES ('update', NOW());"
    378394
    379 
    380395# Pipe the contents of the generated sql file to the database command,
    381396# reading from the file descriptor for the raw sql file to assure completeness.
     
    385400    terminate 1
    386401}
     402
    387403if {[catch {exec -- $portsdb_cmd --host=$portsdb_host --user=$portsdb_user --password=$portsdb_passwd --database=$portsdb_name <@ $sqlfile_fd} errstr]} {
    388404    ui_error "${::errorCode}: $errstr"
     
    391407}
    392408
    393 
    394 # And we're done regen'ing the MacPorts dabase! Cleanup and exit successfully.
     409# done regenerating the database. Cleanup and exit successfully.
    395410cleanup sqlfile lockfile
    396411terminate 0
  • branches/gsoc09-logging/base/portmgr/jobs/mirror_macports.sh

    • Property svn:eol-style set to native
    • Property svn:keywords set to Id
  • branches/gsoc09-logging/base/portmgr/jobs/org.macports.PortIndexRegen.plist

    • Property svn:eol-stype deleted
    • Property svn:eol-style set to native
  • branches/gsoc09-logging/base/portmgr/jobs/org.macports.mprsyncup.plist

    • Property svn:eol-stype deleted
    • Property svn:eol-style set to native
  • branches/gsoc09-logging/base/portmgr/jobs/portfile_lint.pl

    • Property svn:eol-style set to native
    • Property svn:keywords set to Id
  • branches/gsoc09-logging/base/portmgr/jobs/portfile_mirror.pl

    • Property svn:eol-style set to native
  • branches/gsoc09-logging/base/src/dep_map_clean.tcl

    • Property svn:eol-style set to native
  • branches/gsoc09-logging/base/src/macports1.0/macports.tcl

    r53422 r53509  
    4646        rsync_dir startupitem_type place_worksymlink xcodeversion xcodebuildcmd \
    4747        mp_remote_url mp_remote_submit_url configureccache configuredistcc configurepipe buildnicevalue buildmakejobs \
    48         applications_dir frameworks_dir developer_dir universal_target universal_sysroot universal_archs \
     48        applications_dir frameworks_dir developer_dir universal_archs build_arch \
    4949        macportsuser proxy_override_env proxy_http proxy_https proxy_ftp proxy_rsync proxy_skip"
    5050    variable user_options "submitter_name submitter_email submitter_key"
     
    5555        rsync_options rsync_dir startupitem_type place_worksymlink \
    5656        mp_remote_url mp_remote_submit_url configureccache configuredistcc configurepipe buildnicevalue buildmakejobs \
    57         applications_dir current_stage frameworks_dir developer_dir universal_target universal_sysroot universal_archs $user_options"
     57        applications_dir current_stage frameworks_dir developer_dir universal_archs build_arch $user_options"
    5858
    5959    # deferred options are only computed when needed.
     
    354354    }
    355355
    356     global auto_path env
     356    global auto_path env tcl_platform
    357357    global macports::autoconf::macports_conf_path
    358358    global macports::macports_user_dir
     
    385385    global macports::buildnicevalue
    386386    global macports::buildmakejobs
    387     global macports::universal_target
    388     global macports::universal_sysroot
    389387    global macports::universal_archs
     388    global macports::build_arch
    390389
    391390    # Set the system encoding to utf-8
     
    692691
    693692    # Default mp universal options
    694     if {![info exists macports::universal_target]} {
    695         if {[file exists ${macports::developer_dir}/SDKs/MacOSX10.5.sdk]} {
    696             set macports::universal_target "10.5"
     693    if {![info exists macports::universal_archs]} {
     694        if {[lindex [split $tcl_platform(osVersion) .] 0] >= 10} {
     695            set macports::universal_archs {x86_64 i386}
    697696        } else {
    698             set macports::universal_target "10.4"
    699         }
    700     }
    701     if {![info exists macports::universal_sysroot]} {
    702         if {[file exists ${macports::developer_dir}/SDKs/MacOSX10.5.sdk]} {
    703             set macports::universal_sysroot "${macports::developer_dir}/SDKs/MacOSX10.5.sdk"
     697            set macports::universal_archs {i386 ppc}
     698        }
     699    }
     700   
     701    # Default arch to build for
     702    if {![info exists macports::build_arch]} {
     703        if {$tcl_platform(os) == "Darwin"} {
     704            if {[lindex [split $tcl_platform(osVersion) .] 0] >= 10} {
     705                if {[sysctl hw.cpu64bit_capable] == 1} {
     706                    set macports::build_arch x86_64
     707                } else {
     708                    set macports::build_arch i386
     709                }
     710            } else {
     711                if {$tcl_platform(machine) == "Power Macintosh"} {
     712                    set macports::build_arch ppc
     713                } else {
     714                    set macports::build_arch i386
     715                }
     716            }
    704717        } else {
    705             set macports::universal_sysroot "${macports::developer_dir}/SDKs/MacOSX10.4u.sdk"
    706         }
    707     }
    708     if {![info exists macports::universal_archs]} {
    709         set macports::universal_archs {ppc i386}
     718            set macports::build_arch ""
     719        }
    710720    }
    711721
     
    807817    # load the quick index
    808818    _mports_load_quickindex
     819
     820    set default_source_url [lindex ${sources_default} 0]
     821    if {[macports::getprotocol $default_source_url] == "file"} {
     822        set default_portindex [macports::getindex $default_source_url]
     823        if {[file exists $default_portindex] && [expr [clock seconds] - [file mtime $default_portindex]] > 1209600} {
     824            ui_warn "port definitions are more than two weeks old, consider using selfupdate"
     825        }
     826    }
    809827}
    810828
     
    842860    foreach priority ${macports::ui_priorities} {
    843861        $workername alias ui_$priority ui_$priority
    844     }
    845     foreach priority ${macports::ui_priorities} {
    846862        foreach stage ${macports::port_stages} {
    847863            $workername alias ui_${priority}_${stage} ui_${priority}_${stage}
    848864        }
    849     }
    850865 
     866    }
     867
    851868    $workername alias ui_prefix ui_prefix
    852869    $workername alias ui_channels ui_channels
     
    859876    $workername alias getprotocol macports::getprotocol
    860877    $workername alias getportdir macports::getportdir
     878    $workername alias findBinary macports::findBinary
     879    $workername alias binaryInPath macports::binaryInPath
    861880
    862881    # New Registry/Receipts stuff
     
    10611080}
    10621081
    1063 # mportopen
    1064 # Opens a MacPorts portfile specified by a URL.  The Portfile is
    1065 # opened with the given list of options and variations.  The result
    1066 # of this function should be treated as an opaque handle to a
    1067 # MacPorts Portfile.
    1068 
    1069 proc mportopen {porturl {options ""} {variations ""} {nocache ""}} {
    1070     global macports::portdbpath macports::portconf macports::open_mports auto_path
    1071 
    1072     # Look for an already-open MPort with the same URL.
    1073     # XXX: should compare options and variations here too.
    1074     # if found, return the existing reference and bump the refcount.
    1075     if {$nocache != ""} {
    1076         set mport {}
    1077     } else {
    1078         set mport [dlist_search $macports::open_mports porturl $porturl]
    1079     }
    1080     if {$mport != {}} {
    1081         set refcnt [ditem_key $mport refcnt]
    1082         incr refcnt
    1083         ditem_key $mport refcnt $refcnt
    1084         return $mport
    1085     }
    1086 
    1087     array set options_array $options
    1088     if {[info exists options_array(portdir)]} {
    1089         set portdir $options_array(portdir)
    1090     } else {
    1091         set portdir ""
    1092     }
    1093 
    1094     set portpath [macports::getportdir $porturl $portdir]
    1095     ui_debug "Changing to port directory: $portpath"
    1096     cd $portpath
    1097     if {![file isfile Portfile]} {
    1098         return -code error "Could not find Portfile in $portpath"
    1099     }
    1100 
    1101     # Iterate through the explicitly set/unset variants, filtering out
    1102     # implicit variants. At the moment, the only implicit variants are
     1082
     1083# mport_filtervariants
     1084# returns the given list of variants with implicitly-set ones removed
     1085proc mport_filtervariants {variations {warn yes}} {
     1086    # Iterate through the variants, filtering out
     1087    # implicit ones. At the moment, the only implicit variants are
    11031088    # platform variants.
    11041089    set filteredvariations {}
     
    11141099            ^solaris               -
    11151100            ^sunos {
    1116                 ui_debug "Implicit variants should not be explicitly set or unset. $variation will be ignored."
     1101                if {$warn} {
     1102                    ui_warn "Implicit variants should not be explicitly set or unset. $variation will be ignored."
     1103                }
    11171104            }
    11181105            default {
     
    11201107            }
    11211108        }
     1109    }
     1110    return $filteredvariations
     1111}
     1112
     1113
     1114# mportopen
     1115# Opens a MacPorts portfile specified by a URL.  The Portfile is
     1116# opened with the given list of options and variations.  The result
     1117# of this function should be treated as an opaque handle to a
     1118# MacPorts Portfile.
     1119
     1120proc mportopen {porturl {options ""} {variations ""} {nocache ""}} {
     1121    global macports::portdbpath macports::portconf macports::open_mports auto_path
     1122
     1123    # Look for an already-open MPort with the same URL.
     1124    # XXX: should compare options and variations here too.
     1125    # if found, return the existing reference and bump the refcount.
     1126    if {$nocache != ""} {
     1127        set mport {}
     1128    } else {
     1129        set mport [dlist_search $macports::open_mports porturl $porturl]
     1130    }
     1131    if {$mport != {}} {
     1132        set refcnt [ditem_key $mport refcnt]
     1133        incr refcnt
     1134        ditem_key $mport refcnt $refcnt
     1135        return $mport
     1136    }
     1137
     1138    array set options_array $options
     1139    if {[info exists options_array(portdir)]} {
     1140        set portdir $options_array(portdir)
     1141    } else {
     1142        set portdir ""
     1143    }
     1144
     1145    set portpath [macports::getportdir $porturl $portdir]
     1146    ui_debug "Changing to port directory: $portpath"
     1147    cd $portpath
     1148    if {![file isfile Portfile]} {
     1149        return -code error "Could not find Portfile in $portpath"
    11221150    }
    11231151
     
    11301158    ditem_key $mport workername $workername
    11311159    ditem_key $mport options $options
    1132     ditem_key $mport variations $filteredvariations
     1160    ditem_key $mport variations $variations
    11331161    ditem_key $mport refcnt 1
    11341162
    1135     macports::worker_init $workername $portpath $porturl [macports::getportbuildpath $portpath] $options $filteredvariations
     1163    macports::worker_init $workername $portpath $porturl [macports::getportbuildpath $portpath] $options $variations
    11361164
    11371165    $workername eval source Portfile
     
    16841712                    }
    16851713
    1686                     if { [catch { system "cd $destdir/.. && tar ${verboseflag} ${extflag} -xf $filename" } error] } {
     1714                    set tar [findBinary tar $macports::autoconf::tar_path]
     1715                    if { [catch { system "cd $destdir/.. && $tar ${verboseflag} ${extflag} -xf $filename" } error] } {
    16871716                        ui_error "Extracting $source failed ($error)"
    16881717                        incr numfailed
     
    24212450    }
    24222451
    2423     # check if the variants is present in $version_in_tree
    2424     set variant [split $oldvariant +]
     2452    # will break if we start recording negative variants (#2377)
     2453    set variant [lrange [split $oldvariant +] 1 end]
    24252454    ui_debug "Merging existing variants $variant into variants"
     2455    set oldvariantlist [list]
     2456    foreach v $variant {
     2457        lappend oldvariantlist $v "+"
     2458    }
     2459    # remove implicit variants, without printing warnings
     2460    set oldvariantlist [mport_filtervariants $oldvariantlist no]
     2461
     2462    # check if the variants are present in $version_in_tree
    24262463    if {[info exists portinfo(variants)]} {
    24272464        set avariants $portinfo(variants)
     
    24302467    }
    24312468    ui_debug "available variants are : $avariants"
    2432     foreach v $variant {
    2433         if {[lsearch $avariants $v] == -1} {
    2434         } else {
    2435             ui_debug "variant $v is present in $portname $version_in_tree"
    2436             if { ![info exists variations($v)]} {
    2437                 set variations($v) "+"
     2469    foreach {variation value} $oldvariantlist {
     2470        if {[lsearch $avariants $variation] != -1} {
     2471            ui_debug "variant $variation is present in $portname $version_in_tree"
     2472            if { ![info exists variations($variation)]} {
     2473                set variations($variation) $value
    24382474            }
    24392475        }
  • branches/gsoc09-logging/base/src/package1.0/portpkg.tcl

    r52218 r53509  
    162162}
    163163
    164 # XXX: deprecated
    165 proc portpkg::write_info_file {infofile portname portversion description} {
    166     set infofd [open ${infofile} w+]
    167     puts $infofd "Title ${portname}
    168 Version ${portversion}
    169 Description ${description}
    170 DefaultLocation /
    171 DeleteWarning
    172 
    173 ### Package Flags
    174 
    175 NeedsAuthorization YES
    176 Required NO
    177 Relocatable NO
    178 RequiresReboot NO
    179 UseUserMask YES
    180 OverwritePermissions NO
    181 InstallFat NO
    182 RootVolumeOnly NO"
    183     close $infofd
    184 }
    185 
    186164proc portpkg::xml_escape {s} {
    187165    regsub -all {&} $s {\&amp;} s
     
    229207    <string>NoRestart</string>
    230208    <key>IFPkgFlagRootVolumeOnly</key>
    231     <false/>
     209    <true/>
    232210    <key>IFPkgFlagUpdateInstalledLanguages</key>
    233211    <false/>
  • branches/gsoc09-logging/base/src/package1.0/portportpkg.tcl

    • Property svn:eol-style set to native
    • Property svn:keywords set to Id
  • branches/gsoc09-logging/base/src/pextlib1.0/Makefile

    r50962 r53509  
    22                fs-traverse.o strcasecmp.o vercomp.o filemap.o \
    33                sha1cmd.o curl.o rmd160cmd.o readline.o uid.o\
    4                 tracelib.o tty.o get_systemconfiguration_proxies.o
     4                tracelib.o tty.o get_systemconfiguration_proxies.o\
     5                sysctl.o readdir.o pipe.o
    56SHLIB_NAME=     Pextlib${SHLIB_SUFFIX}
    67INSTALLDIR= ${DESTDIR}${datadir}/macports/Tcl/pextlib1.0
  • branches/gsoc09-logging/base/src/pextlib1.0/Pextlib.c

    r52218 r53509  
    4949#endif
    5050
    51 #if HAVE_DIRENT_H
    52 #include <dirent.h>
    53 #endif
    54 
    5551#if HAVE_LIMITS_H
    5652#include <limits.h>
     
    7369#if HAVE_SYS_TYPES_H
    7470#include <sys/types.h>
    75 #endif
    76 
    77 #if HAVE_SYS_FCNTL_H
    78 #include <sys/fcntl.h>
    7971#endif
    8072
     
    114106#include "tty.h"
    115107#include "get_systemconfiguration_proxies.h"
     108#include "sysctl.h"
     109#include "strsed.h"
     110#include "readdir.h"
     111#include "pipe.h"
    116112
    117113#if HAVE_CRT_EXTERNS_H
     
    380376}
    381377
    382 int SudoCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
    383 {
    384         char *buf;
    385         struct linebuf circbuf[CBUFSIZ];
    386         size_t linelen;
    387         char *args[4];
    388         char *cmdstring, *passwd;
    389         FILE *pdes;
    390         int fdset[2];
    391         int fline, pos, ret;
    392         pid_t pid;
    393         Tcl_Obj *errbuf;
    394         Tcl_Obj *tcl_result;
    395 
    396         if (objc != 3) {
    397                 Tcl_WrongNumArgs(interp, 1, objv, "password command");
    398                 return TCL_ERROR;
    399         }
    400         passwd = Tcl_GetString(objv[1]);
    401         cmdstring = Tcl_GetString(objv[2]);
    402 
    403         if (pipe(fdset) == -1)
    404                 return TCL_ERROR;
    405 
    406         /*
    407          * Fork a child to run the command, in a popen() like fashion -
    408          * popen() itself is not used because stderr is also desired.
    409          */
    410         pid = fork();
    411         if (pid == -1)
    412                 return TCL_ERROR;
    413         if (pid == 0) {
    414                 dup2(fdset[0], STDIN_FILENO);
    415                 dup2(fdset[1], STDOUT_FILENO);
    416                 dup2(fdset[1], STDERR_FILENO);
    417                 args[0] = "sudo";
    418                 args[1] = "-S";
    419                 args[2] = cmdstring;
    420                 args[3] = NULL;
    421                 execve("/usr/bin/sudo", args, environ);
    422                 /* Now throw away the privs we just acquired */
    423                 args[1] = "-k";
    424                 args[2] = NULL;
    425                 execve("/usr/bin/sudo", args, environ);
    426                 _exit(1);
    427         } else {
    428                 write(fdset[1], passwd, strlen(passwd));
    429                 write(fdset[1], "\n", 1);
    430                 close(fdset[1]);
    431         }
    432         pdes = fdopen(fdset[0], "r");
    433 
    434         /* read from simulated popen() pipe */
    435         pos = 0;
    436         bzero(circbuf, sizeof(circbuf));
    437         while ((buf = fgetln(pdes, &linelen)) != NULL) {
    438                 char *sbuf;
    439                 int slen;
    440 
    441                 /*
    442                  * Allocate enough space to insert a terminating
    443                  * '\0' if the line is not terminated with a '\n'
    444                  */
    445                 if (buf[linelen - 1] == '\n')
    446                         slen = linelen;
    447                 else
    448                         slen = linelen + 1;
    449 
    450                 if (circbuf[pos].len == 0)
    451                         sbuf = malloc(slen);
    452                 else {
    453                         sbuf = realloc(circbuf[pos].line, slen);
    454                 }
    455 
    456                 if (sbuf == NULL) {
    457                         for (fline = pos; pos < fline + CBUFSIZ; pos++) {
    458                                 if (circbuf[pos % CBUFSIZ].len != 0)
    459                                         free(circbuf[pos % CBUFSIZ].line);
    460                         }
    461                         return TCL_ERROR;
    462                 }
    463 
    464                 memcpy(sbuf, buf, linelen);
    465                 /* terminate line with '\0',replacing '\n' if it exists */
    466                 sbuf[slen - 1] = '\0';
    467 
    468                 circbuf[pos].line = sbuf;
    469                 circbuf[pos].len = slen;
    470 
    471                 if (pos++ == CBUFSIZ - 1)
    472                         pos = 0;
    473                 ret = ui_info(interp, sbuf);
    474                 if (ret != TCL_OK) {
    475                         for (fline = pos; pos < fline + CBUFSIZ; pos++) {
    476                                 if (circbuf[pos % CBUFSIZ].len != 0)
    477                                         free(circbuf[pos % CBUFSIZ].line);
    478                         }
    479                         return ret;
    480                 }
    481         }
    482         fclose(pdes);
    483 
    484         if (wait(&ret) != pid)
    485                 return TCL_ERROR;
    486         if (WIFEXITED(ret)) {
    487                 if (WEXITSTATUS(ret) == 0)
    488                         return TCL_OK;
    489                 else {
    490                         /* Copy the contents of the circular buffer to errbuf */
    491                         Tcl_Obj* errorCode;
    492                         errbuf = Tcl_NewStringObj(NULL, 0);
    493                         for (fline = pos; pos < fline + CBUFSIZ; pos++) {
    494                                 if (circbuf[pos % CBUFSIZ].len == 0)
    495                                 continue; /* skip empty lines */
    496 
    497                                 /* Append line, minus trailing NULL */
    498                                 Tcl_AppendToObj(errbuf, circbuf[pos % CBUFSIZ].line,
    499                                                 circbuf[pos % CBUFSIZ].len - 1);
    500 
    501                                 /* Re-add previously stripped newline */
    502                                 Tcl_AppendToObj(errbuf, "\n", 1);
    503                                 free(circbuf[pos % CBUFSIZ].line);
    504                         }
    505 
    506                         /* set errorCode [list CHILDSTATUS <pid> <code>] */
    507                         errorCode = Tcl_NewListObj(0, NULL);
    508                         Tcl_ListObjAppendElement(interp, errorCode, Tcl_NewStringObj("CHILDSTATUS", -1));
    509                         Tcl_ListObjAppendElement(interp, errorCode, Tcl_NewIntObj(pid));
    510                         Tcl_ListObjAppendElement(interp, errorCode, Tcl_NewIntObj(WEXITSTATUS(ret)));
    511                         Tcl_SetObjErrorCode(interp, errorCode);
    512 
    513                         /* set result */
    514                         tcl_result = Tcl_NewStringObj("sudo command \"", -1);
    515                         Tcl_AppendToObj(tcl_result, cmdstring, -1);
    516                         Tcl_AppendToObj(tcl_result, "\" returned error ", -1);
    517                         Tcl_AppendObjToObj(tcl_result, Tcl_NewIntObj(WEXITSTATUS(ret)));
    518                         Tcl_AppendToObj(tcl_result, "\nCommand output: ", -1);
    519                         Tcl_AppendObjToObj(tcl_result, errbuf);
    520                         Tcl_SetObjResult(interp, tcl_result);
    521                         return TCL_ERROR;
    522                 }
    523         } else
    524                 return TCL_ERROR;
    525 }
    526 
    527378int FlockCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
    528379{
     
    662513}
    663514
    664 /**
    665  *
    666  * Return the list of elements in a directory.
    667  * Since 1.60.4.2, the list doesn't include . and ..
    668  *
    669  * Synopsis: readdir directory
    670  */
    671 int ReaddirCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
    672 {
    673         DIR *dirp;
    674         struct dirent *mp;
    675         Tcl_Obj *tcl_result;
    676         char *path;
    677 
    678         if (objc != 2) {
    679                 Tcl_WrongNumArgs(interp, 1, objv, "directory");
    680                 return TCL_ERROR;
    681         }
    682 
    683         path = Tcl_GetString(objv[1]);
    684         dirp = opendir(path);
    685         if (!dirp) {
    686                 Tcl_SetResult(interp, "Cannot read directory", TCL_STATIC);
    687                 return TCL_ERROR;
    688         }
    689         tcl_result = Tcl_NewListObj(0, NULL);
    690         while ((mp = readdir(dirp))) {
    691                 /* Skip . and .. */
    692                 if ((mp->d_name[0] != '.') ||
    693                         ((mp->d_name[1] != 0)   /* "." */
    694                                 &&
    695                         ((mp->d_name[1] != '.') || (mp->d_name[2] != 0)))) /* ".." */ {
    696                         Tcl_ListObjAppendElement(interp, tcl_result, Tcl_NewStringObj(mp->d_name, -1));
    697                 }
    698         }
    699         closedir(dirp);
    700         Tcl_SetObjResult(interp, tcl_result);
    701        
    702         return TCL_OK;
    703 }
    704 
    705515int StrsedCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
    706516{
    707517        char *pattern, *string, *res;
    708518        int range[2];
    709         extern char *strsed(char *str, char *pat, int *range);
    710519        Tcl_Obj *tcl_result;
    711520
     
    949758
    950759        Tcl_SetObjResult(interp, tcl_result);
    951         return TCL_OK;
    952 }
    953 
    954 /**
    955  * Call pipe(2) to create a pipe.
    956  * Syntax is:
    957  * pipe
    958  *
    959  * Generate a Tcl error if something goes wrong.
    960  * Return a list with the file descriptors of the pipe. The first item is the
    961  * readable fd.
    962  */
    963 int PipeCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
    964 {
    965         Tcl_Obj* result;
    966         int fildes[2];
    967 
    968         if (objc != 1) {
    969                 Tcl_WrongNumArgs(interp, 1, objv, NULL);
    970                 return TCL_ERROR;
    971         }
    972        
    973         if (pipe(fildes) < 0) {
    974                 Tcl_AppendResult(interp, "pipe failed: ", strerror(errno), NULL);
    975                 return TCL_ERROR;
    976         }
    977        
    978         /* build a list out of the couple */
    979         result = Tcl_NewListObj(0, NULL);
    980         Tcl_ListObjAppendElement(interp, result, Tcl_NewIntObj(fildes[0]));
    981         Tcl_ListObjAppendElement(interp, result, Tcl_NewIntObj(fildes[1]));
    982         Tcl_SetObjResult(interp, result);
    983 
    984760        return TCL_OK;
    985761}
     
    1146922        Tcl_CreateObjCommand(interp, "sha1", SHA1Cmd, NULL, NULL);
    1147923        Tcl_CreateObjCommand(interp, "umask", UmaskCmd, NULL, NULL);
    1148         Tcl_CreateObjCommand(interp, "sudo", SudoCmd, NULL, NULL);
    1149924        Tcl_CreateObjCommand(interp, "pipe", PipeCmd, NULL, NULL);
    1150925        Tcl_CreateObjCommand(interp, "curl", CurlCmd, NULL, NULL);
     
    1152927        Tcl_CreateObjCommand(interp, "unsetenv", UnsetEnvCmd, NULL, NULL);
    1153928        Tcl_CreateObjCommand(interp, "lchown", lchownCmd, NULL, NULL);
     929        Tcl_CreateObjCommand(interp, "sysctl", SysctlCmd, NULL, NULL);
    1154930       
    1155931        Tcl_CreateObjCommand(interp, "readline", ReadlineCmd, NULL, NULL);
  • branches/gsoc09-logging/base/src/pextlib1.0/curl.c

    r51384 r53509  
    5555 * empirical data.  These represent "best guess" values for now.
    5656 */
    57 #define _CURL_CONNECTION_TIMEOUT        ((long)(5 * 60))        /* 5 minutes */
     57#define _CURL_CONNECTION_TIMEOUT        ((long)(30))            /* 30 seconds */
    5858#define _CURL_MINIMUM_XFER_SPEED        ((long)1024)            /* 1Kb/sec */
    59 #define _CURL_MINIMUM_XFER_TIMEOUT      ((long)(10 * 60))       /* 10 minutes */
     59#define _CURL_MINIMUM_XFER_TIMEOUT      ((long)(60))            /* 1 minute */
    6060
    6161/* ========================================================================= **
  • branches/gsoc09-logging/base/src/pextlib1.0/filemap.c

    r52218 r53509  
    3535#endif
    3636
    37 #include <ctype.h>
     37#include <sys/stat.h>
    3838#include <errno.h>
    39 #include <grp.h>
    40 #include <stdio.h>
    41 #include <stdlib.h>
    42 #include <string.h>
    43 
    44 #if HAVE_STRINGS_H
    45 #include <strings.h>
    46 #endif
    47 
    48 #if HAVE_DIRENT_H
    49 #include <dirent.h>
    50 #endif
    51 
    52 #if HAVE_LIMITS_H
     39#include <fcntl.h>
    5340#include <limits.h>
    54 #endif
    55 
    56 #if HAVE_PATHS_H
    57 #include <paths.h>
    58 #endif
    59 
    60 #ifndef _PATH_DEVNULL
    61 #define _PATH_DEVNULL   "/dev/null"
    62 #endif
    63 
    64 #include <pwd.h>
    65 
    66 #if HAVE_SYS_FILE_H
    67 #include <sys/file.h>
    68 #endif
    69 
    70 #if HAVE_SYS_TYPES_H
    71 #include <sys/types.h>
    72 #endif
    73 
    74 #if HAVE_SYS_FCNTL_H
    75 #include <sys/fcntl.h>
    76 #endif
    77 
    78 #if HAVE_FCNTL_H
    79 #include <fcntl.h>
    80 #endif
    81 
    82 #if HAVE_SYS_STAT_H
    83 #include <sys/stat.h>
    84 #endif
    85 
    86 #if HAVE_SYS_WAIT_H
    87 #include <sys/wait.h>
    88 #endif
    89 
    90 #if HAVE_UNISTD_H
    9141#include <unistd.h>
    92 #endif
    9342
    9443#include <tcl.h>
     
    9645#include "filemap.h"
    9746#include "strcasecmp.h"
    98 
    99 /* Avoid a warning with Tcl < 8.4, even if Tcl_GetIndexFromObj's tablePtr
    100 probably isn't modified. */
    101 #if (TCL_MAJOR_VERSION > 8) || (TCL_MINOR_VERSION >= 4)
    102 typedef CONST char* tableEntryString;
    103 #else
    104 typedef char* tableEntryString;
    105 #endif
    10647
    10748/* ========================================================================= **
     
    20211962    } EOption;
    20221963   
    2023         static tableEntryString options[] = {
     1964        static const char *options[] = {
    20241965                "close", "create", "exists", "get", "list", "open", "revert", "save",
    20251966                "set", "unset", "isreadonly", NULL
  • branches/gsoc09-logging/base/src/pextlib1.0/md5cmd.c

    r51384 r53509  
    3939#include <tcl.h>
    4040
     41#include "md5cmd.h"
     42
    4143#if defined(HAVE_LIBCRYPTO) && !defined(HAVE_LIBMD)
    4244
     
    6466CHECKSUMEnd(MD5, MD5_CTX, LENGTH)
    6567CHECKSUMFile(MD5, MD5_CTX)
    66 CHECKSUMData(MD5, MD5_CTX)
    6768
    6869#elif defined(HAVE_LIBMD)
  • branches/gsoc09-logging/base/src/pextlib1.0/md_wrappers.h

    r19376 r53509  
    3535
    3636/* wrappers for libmd-like functions:
    37  * char* ALGOData(const unsigned char* data, unsigned int len, char* buf)
    3837 * char* ALGOFile(const char* filename, char* buf)
    3938 * char* ALGOEnd(ALGO_CTX, char* buf)
     
    4140
    4241#define CHECKSUMEnd(algo, ctxtype, digest_length)               \
    43 char *                                                                                                  \
     42static char *                                                                                                   \
    4443algo##End(ctxtype *ctx, char *buf)                                              \
    4544{                                                                                                               \
     
    6261
    6362#define CHECKSUMFile(algo, ctxtype)                                             \
    64 char *algo##File(const char *filename, char *buf)               \
     63static char *algo##File(const char *filename, char *buf)                \
    6564{                                                                                                               \
    6665    unsigned char buffer[BUFSIZ];                                               \
     
    8180}
    8281
    83 #define CHECKSUMData(algo, ctxtype)                                             \
    84 char *algo##Data(const unsigned char *data, unsigned int len, char *buf)        \
    85 {                                                                                                               \
    86         ctxtype ctx;                                                                            \
    87         algo##Init(&ctx);                                                                       \
    88         algo##Update(&ctx, data, len);                                          \
    89         return algo##End(&ctx, buf);                                            \
    90 }
    91 
    92 
    9382#endif
    94         /* _MD_WRAPPERS_H */
     83/* _MD_WRAPPERS_H */
  • branches/gsoc09-logging/base/src/pextlib1.0/rmd160cmd.c

    r51384 r53509  
    3939#include <tcl.h>
    4040
     41#include "rmd160cmd.h"
     42
    4143#if !defined(HAVE_LIBMD)
    4244
     
    5860CHECKSUMEnd(RMD160, RMD160_CTX, RIPEMD160_DIGEST_LENGTH)
    5961CHECKSUMFile(RMD160, RMD160_CTX)
    60 CHECKSUMData(RMD160, RMD160_CTX)
    6162
    6263#elif defined(HAVE_LIBMD)
  • branches/gsoc09-logging/base/src/pextlib1.0/sha1cmd.c

    r51384 r53509  
    4040#include <tcl.h>
    4141
     42#include "sha1cmd.h"
     43
    4244#if defined(HAVE_LIBCRYPTO) && !defined(HAVE_LIBMD)
    4345
     
    6264CHECKSUMEnd(SHA1, SHA_CTX, SHA_DIGEST_LENGTH)
    6365CHECKSUMFile(SHA1, SHA_CTX)
    64 CHECKSUMData(SHA1, SHA_CTX)
    6566
    6667#elif defined(HAVE_LIBMD)
  • branches/gsoc09-logging/base/src/pextlib1.0/strsed.c

    r19376 r53509  
    130130#define HS_REGEX        1
    131131
     132#include "strsed.h"
     133
    132134#include <ctype.h>
    133135#include <string.h>
     
    216218 * Prototypes
    217219 * ------------------------------------------------------------------------- */
    218 static char *mem();
    219 static void mem_init();
    220 static void mem_free();
    221 static char *build_map();
    222 static char nextch();
    223 static void mem_save();
    224 static int mem_find();
     220static char *mem(int, int);
     221static void mem_init(void);
     222static void mem_free(char *);
     223static char *build_map(char *, char *);
     224static char nextch(char *, int);
     225static void mem_save(int);
     226static int mem_find(int);
     227char *backslash_eliminate(char *, int, int);
    225228
    226229/* ------------------------------------------------------------------------- **
     
    246249    static regex_t exp;
    247250#endif
    248 
    249     char *backslash_eliminate();
    250251   
    251252    char *from;
  • branches/gsoc09-logging/base/src/pextlib1.0/tracelib.c

    • Property svn:eol-style set to native
    r52218 r53509  
    8383       
    8484        name=strdup(Tcl_GetString(objv[2]));
     85        if (!name) {
     86            Tcl_SetResult(interp, "memory allocation failed", TCL_STATIC);
     87            return TCL_ERROR;
     88        }
    8589       
    8690        return TCL_OK;
     
    108112        len=strlen(Tcl_GetString(objv[2]))+2;
    109113        sandbox=(char*)malloc(len);
     114        if (!sandbox) {
     115            Tcl_SetResult(interp, "memory allocation failed", TCL_STATIC);
     116            return TCL_ERROR;
     117        }
    110118        memset(sandbox, 0, len);
    111         strcpy(sandbox, Tcl_GetString(objv[2]));
     119        strlcpy(sandbox, Tcl_GetString(objv[2]), len);
    112120        for(t=sandbox;(t=strchr(t+1, ':'));)
    113121        {
     
    211219                char * t, * _;
    212220               
    213                 filemap=(char*)malloc(1024);
     221                size_t remaining = 1024;
     222                filemap=(char*)malloc(remaining);
     223                if (!filemap) {
     224                    ui_warn("send_file_map: memory allocation failed");
     225                return;
     226                }
    214227                t=filemap;
    215228               
    216                 #define append_allow(path, resolution) do{strcpy(t, path); t+=strlen(t)+1; *t++=resolution; *t++=0;}while(0);
     229                #define append_allow(path, resolution) do { strlcpy(t, path, remaining); \
     230                                                            if (remaining < (strlen(t)+3)) \
     231                                                                remaining=0; \
     232                                                            else \
     233                                                                remaining-=strlen(t)+3; \
     234                                                            t+=strlen(t)+1; \
     235                                                            *t++=resolution; \
     236                                                            *t++=0; \
     237                                                          } while(0);
    217238                if(enable_fence)
    218239                {
     
    227248                        if(sdk&&*sdk)
    228249                        {
    229                                 char buf[260]="/Developer/SDKs/";
    230                                 strcat(buf, sdk);
     250                                char buf[260];
     251                                buf[0] = '\0';
     252                                strlcat(buf, Tcl_GetVar(interp, "macports::developer_dir", TCL_GLOBAL_ONLY), 260);
     253                                strlcat(buf, "/SDKs/", 260);
     254                                strlcat(buf, sdk, 260);
    231255                       
    232256                                append_allow("/usr/bin", 0);
     
    235259                                append_allow("/System/Library/Perl", 0);
    236260                                append_allow("/", 1);
    237                                 strcpy(t-1, buf);
     261                                strlcpy(t-1, buf, remaining);
    238262                                t+=strlen(t)+1;
    239263                        }else
     
    242266                                append_allow("/System/Library", 0);
    243267                                append_allow("/Library", 0);
    244                                 append_allow("/Developer", 0);
     268                                append_allow(Tcl_GetVar(interp, "macports::developer_dir", TCL_GLOBAL_ONLY), 0);
    245269                        }
    246270                }else
     
    268292        char * port=0;
    269293        size_t len=1;
    270         char resolution;
    271        
    272         /* If there aren't deps then allow anything. (Useful for extract) */
    273         if(!depends)
    274                 resolution='+';
    275         else
    276         {
    277                 resolution='!';
     294        char resolution='!';
    278295               
    279                 Tcl_SetVar(interp, "path", path, 0);
    280                 Tcl_Eval(interp, "registry::file_registered $path");
    281                 port=strdup(Tcl_GetStringResult(interp));
    282                 Tcl_UnsetVar(interp, "path", 0);
    283        
    284                 if(*port!='0'||port[1])
    285                 {
    286                         char * t;
    287                
    288                         t=depends;
    289                         for(;*t;t+=strlen(t)+1)
     296        Tcl_SetVar(interp, "path", path, 0);
     297        Tcl_Eval(interp, "registry::file_registered $path");
     298        port=strdup(Tcl_GetStringResult(interp));
     299        if (!port) {
     300                ui_warn("dep_check: memory allocation failed");
     301            return;
     302        }
     303        Tcl_UnsetVar(interp, "path", 0);
     304       
     305        if(*port!='0'||port[1])
     306        {
     307                char * t;
     308       
     309                t=depends;
     310                for(;*t;t+=strlen(t)+1)
     311                {
     312                        if(!strcmp(t, port))
    290313                        {
    291                                 if(!strcmp(t, port))
    292                                 {
    293                                         resolution='+';
    294                                         break;
    295                                 }
     314                                resolution='+';
     315                                break;
    296316                        }
    297                 }else if(*port=='0'&&!port[1])
    298                         strcpy(port, "*unknown*");
    299         }
    300        
    301         if(resolution!='+')
    302                 ui_info("trace: access denied to %s (%s)", path, port);
    303 
    304         if(port)
    305                 free(port);
     317                }
     318        }
     319       
     320        if(resolution!='+') {
     321            if(*port=='0'&&!port[1])
     322                    ui_info("trace: access denied to %s (*unknown*)", path);
     323                else
     324                    ui_info("trace: access denied to %s (%s)", path, port);
     325    }
     326
     327        free(port);
    306328       
    307329        if(send(sock, &len, sizeof(len), 0)==-1)
     
    375397       
    376398        sun.sun_family=AF_UNIX;
    377         strcpy(sun.sun_path, name);
     399        strlcpy(sun.sun_path, name, sizeof(sun.sun_path));
    378400        if(bind(sock, (struct sockaddr*)&sun, sizeof(sun))==-1)
    379401        {
     
    519541        l=strlen(d);
    520542        depends=malloc(l+2);
     543        if (!depends) {
     544            Tcl_SetResult(interp, "memory allocation failed", TCL_STATIC);
     545            return TCL_ERROR;
     546        }
    521547        depends[l+1]=0;
    522         strcpy(depends, d);
     548        strlcpy(depends, d, l+2);
    523549        for(t=depends;*t;++t)
    524550                if(*t==' ')
  • branches/gsoc09-logging/base/src/pextlib1.0/tracelib.h

    • Property svn:eol-style set to native
    • Property svn:keywords set to Id
  • branches/gsoc09-logging/base/src/port/port.tcl

    r53481 r53509  
    20772077            # Global variations will have to be merged into the specified
    20782078            # variations, but perhaps after the installed variations are
    2079             # merged. So we pass them into upgrade:
    2080             macports::upgrade $portname "port:$portname" [array get global_variations] [array get variations] [array get options] depscache
     2079            # merged. So we pass them into upgrade.
     2080           
     2081            # First filter out implicit variants from the explicitly set/unset variants.
     2082            set global_variations_list [mport_filtervariants [array get global_variations] yes]
     2083            set variations_list [mport_filtervariants [array get variations] yes]
     2084           
     2085            macports::upgrade $portname "port:$portname" $global_variations_list $variations_list [array get options] depscache
    20812086        }
    20822087    }
     
    29472952            if { ![info exists variations($variation)] } {
    29482953                set variations($variation) $value
     2954            }
     2955        }
     2956        # Filter out implicit variants from the explicitly set/unset variants.
     2957        # Except we need to keep them for some targets to work right...
     2958        switch -exact $target {
     2959            distfiles -
     2960            mirror {}
     2961            default {
     2962                set variationslist [mport_filtervariants [array get variations] yes]
     2963                array unset variations
     2964                array set variations $variationslist
    29492965            }
    29502966        }
  • branches/gsoc09-logging/base/src/port1.0/portbuild.tcl

    r52218 r53509  
    5454default build.cmd {[portbuild::build_getmaketype]}
    5555default build.nice {${buildnicevalue}}
    56 default build.jobs {${buildmakejobs}}
     56default build.jobs {[portbuild::build_getjobs]}
    5757default build.pre_args {${build.target}}
    5858default build.target "all"
     
    7070                return [findBinary bsdmake $portutil::autoconf::bsdmake_path]
    7171            } elseif {[option os.platform] == "freebsd"} {
    72                 return [binaryInPath make]
     72                return [findBinary make $portutil::autoconf::make_path]
    7373            } else {
    74                 return [binaryInPath pmake]
     74                return [findBinary pmake $portutil::autoconf::bsdmake_path]
    7575            }
    7676        }
     
    7979                return [findBinary gnumake $portutil::autoconf::gnumake_path]
    8080            } elseif {[option os.platform] == "linux"} {
    81                 return [binaryInPath make]
     81                return [findBinary make $portutil::autoconf::make_path]
    8282            } else {
    83                 return [binaryInPath gmake]
     83                return [findBinary gmake $portutil::autoconf::gnumake_path]
    8484            }
    8585        }
     
    115115}
    116116
    117 proc portbuild::build_getmakejobs {args} {
     117proc portbuild::build_getjobs {args} {
     118    global buildmakejobs
     119    set jobs $buildmakejobs
     120    # if set to '0', use the number of cores for the number of jobs
     121    if {$jobs == 0} {
     122        if {[catch {set jobs [sysctl hw.activecpu]}]} {
     123            set jobs 2
     124            ui_warn "failed to determine the number of available CPUs (probably not supported on this platform)"
     125            ui_warn "defaulting to $jobs jobs, consider setting buildmakejobs to a nonzero value in macports.conf"
     126        }
     127    }
     128    if {![string is integer -strict $jobs] || $jobs <= 1} {
     129        set jobs 1
     130    }
     131    return $jobs
     132}
     133
     134proc portbuild::build_getjobsarg {args} {
    118135    # check if port allows a parallel build
    119136    global use_parallel_build
     
    126143        return ""
    127144    }
    128     set jobs [option build.jobs]
    129     # if set to '0', use the number of cores for the number of jobs
    130     if {$jobs == 0} {
    131         if {[catch {set jobs [exec "/usr/sbin/sysctl" "-n" "hw.availcpu"]}]} {
    132             set jobs 2
    133             ui_warn "failed to determine the number of available CPUs (probably not supported on this platform)"
    134             ui_warn "defaulting to $jobs jobs, consider setting buildmakejobs to a nonzero value in macports.conf"
    135         }
    136     }
    137     if {![string is integer -strict $jobs] || $jobs <= 1} {
    138         return ""
    139     }
    140     return " -j$jobs"
     145    return " -j[option build.jobs]"
    141146}
    142147
     
    151156
    152157    set nice_prefix [build_getnicevalue]
    153     set jobs_suffix [build_getmakejobs]
     158    set jobs_suffix [build_getjobsarg]
    154159
    155160    set realcmd ${build.cmd}
  • branches/gsoc09-logging/base/src/port1.0/portconfigure.tcl

    r52218 r53509  
    8888default configure.optflags  {-O2}
    8989# compiler flags section
    90 default configure.cflags    {[portconfigure::configure_get_cflags]}
    91 default configure.cppflags  {"-I${prefix}/include"}
    92 default configure.cxxflags  {[portconfigure::configure_get_cflags]}
    93 default configure.objcflags {[portconfigure::configure_get_cflags]}
    94 default configure.ldflags   {"-L${prefix}/lib"}
     90default configure.cflags    {${configure.optflags}}
     91default configure.cppflags  {-I${prefix}/include}
     92default configure.cxxflags  {${configure.optflags}}
     93default configure.objcflags {${configure.optflags}}
     94default configure.ldflags   {-L${prefix}/lib}
    9595default configure.libs      {}
    96 default configure.fflags    {[portconfigure::configure_get_cflags]}
    97 default configure.f90flags  {[portconfigure::configure_get_cflags]}
    98 default configure.fcflags   {[portconfigure::configure_get_cflags]}
     96default configure.fflags    {${configure.optflags}}
     97default configure.f90flags  {${configure.optflags}}
     98default configure.fcflags   {${configure.optflags}}
    9999default configure.classpath {}
    100 
    101 # internal function to return the system value for CFLAGS/CXXFLAGS/etc
    102 proc portconfigure::configure_get_cflags {args} {
    103     global configure.optflags
    104     global configure.m32 configure.m64 configure.march configure.mtune
    105     set flags "${configure.optflags}"
    106     if {[tbool configure.m64]} {
    107         set flags "-m64 ${flags}"
    108     } elseif {[tbool configure.m32]} {
    109         set flags "-m32 ${flags}"
    110     }
    111     if {[info exists configure.march] && ${configure.march} != {}} {
    112         set flags "${flags} -march=${configure.march}"
    113     }
    114     if {[info exists configure.mtune] && ${configure.mtune} != {}} {
    115         set flags "${flags} -mtune=${configure.mtune}"
    116     }
    117     return $flags
    118 }
    119100
    120101# tools section
     
    129110default configure.pkg_config_path   {}
    130111
    131 options configure.universal_target configure.universal_sysroot configure.universal_archs configure.universal_args configure.universal_cflags configure.universal_cppflags configure.universal_cxxflags configure.universal_ldflags
    132 default configure.universal_target      {${universal_target}}
    133 default configure.universal_sysroot     {${universal_sysroot}}
     112options configure.build_arch configure.archflags
     113default configure.build_arch {${build_arch}}
     114default configure.archflags  {[portconfigure::configure_get_archflags]}
     115
     116options configure.universal_archs configure.universal_args configure.universal_cflags configure.universal_cppflags configure.universal_cxxflags configure.universal_ldflags
    134117default configure.universal_archs       {${universal_archs}}
    135118default configure.universal_args        {--disable-dependency-tracking}
     
    157140
    158141proc portconfigure::configure_start {args} {
    159     global UI_PREFIX
    160     global configure.compiler
     142    global UI_PREFIX configure.compiler configure.optflags configure.archflags
     143    global configure.march configure.mtune configure.universal_cflags
     144    global configure.universal_cxxflags configure.universal_cppflags
     145    global configure.universal_ldflags configure.universal_args
    161146   
    162147    ui_msg "$UI_PREFIX [format [msgcat::mc "Configuring %s"] [option name]]"
     
    183168    }
    184169    ui_debug "Using compiler '$name'"
     170   
     171    # add in extra CFLAGS etc
     172    if {[variant_exists universal] && [variant_isset universal]} {
     173        foreach flag {cflags objcflags fflags f90flags fcflags} {
     174            eval configure.${flag}-append ${configure.universal_cflags}
     175        }
     176        eval configure.cxxflags-append ${configure.universal_cxxflags}
     177        eval configure.cppflags-append ${configure.universal_cppflags}
     178        eval configure.ldflags-append ${configure.universal_ldflags}
     179        eval configure.pre_args-append ${configure.universal_args}
     180    } else {
     181        foreach flag {cflags cxxflags objcflags fflags f90flags fcflags} {
     182            eval configure.${flag}-append ${configure.archflags}
     183            if {${configure.march} != {}} {
     184                configure.${flag}-append "-march=${configure.march}"
     185            }
     186            if {${configure.mtune} != {}} {
     187                configure.${flag}-append "-mtune=${configure.mtune}"
     188            }
     189        }
     190        eval configure.ldflags-append ${configure.archflags}
     191    }
     192}
     193
     194# internal function to determine the compiler flags to select an arch
     195proc portconfigure::configure_get_archflags {args} {
     196    global configure.build_arch configure.m32 configure.m64 configure.compiler
     197    set flags ""
     198    if {[tbool configure.m64]} {
     199        set flags "-m64"
     200    } elseif {[tbool configure.m32]} {
     201        set flags "-m32"
     202    } elseif {${configure.build_arch} != ""} {
     203        if {[arch_flag_supported]} {
     204            set flags "-arch ${configure.build_arch}"
     205        } elseif {${configure.build_arch} == "x86_64" || ${configure.build_arch} == "ppc64"} {
     206            set flags "-m64"
     207        } elseif {${configure.compiler} != "gcc-3.3"} {
     208            set flags "-m32"
     209        }
     210    }
     211    return $flags
    185212}
    186213
     
    190217    set flags ""
    191218    foreach arch ${configure.universal_archs} {
    192         set flags "$flags -arch $arch"
     219        if {$flags == ""} {
     220            set flags "-arch $arch"
     221        } else {
     222            append flags " -arch $arch"
     223        }
    193224    }
    194225    return $flags
     
    197228# internal function to determine the CPPFLAGS for the compiler
    198229proc portconfigure::configure_get_universal_cppflags {args} {
    199     global configure.universal_sysroot
     230    global os.arch os.major developer_dir
    200231    set flags ""
    201232    # include sysroot in CPPFLAGS too (twice), for the benefit of autoconf
    202     if {[info exists configure.universal_sysroot]} {
    203         set flags "-isysroot ${configure.universal_sysroot}"
     233    if {${os.arch} == "powerpc" && ${os.major} == "8"} {
     234        set flags "-isysroot ${developer_dir}/SDKs/MacOSX10.4u.sdk"
    204235    }
    205236    return $flags
     
    208239# internal function to determine the CFLAGS for the compiler
    209240proc portconfigure::configure_get_universal_cflags {args} {
    210     global configure.universal_sysroot configure.universal_target
     241    global os.arch os.major developer_dir
    211242    set flags [configure_get_universal_archflags]
    212243    # these flags should be valid for C/C++ and similar compiler frontends
    213     if {[info exists configure.universal_sysroot]} {
    214         set flags "-isysroot ${configure.universal_sysroot} ${flags}"
     244    if {${os.arch} == "powerpc" && ${os.major} == "8"} {
     245        set flags "-isysroot ${developer_dir}/SDKs/MacOSX10.4u.sdk ${flags}"
    215246    }
    216247    return $flags
     
    219250# internal function to determine the LDFLAGS for the compiler
    220251proc portconfigure::configure_get_universal_ldflags {args} {
    221     global configure.universal_sysroot configure.universal_target
    222     global os.arch
     252    global os.arch os.major developer_dir
    223253    set flags [configure_get_universal_archflags]
    224254    # works around linking without using the CFLAGS, outside of automake
    225     if {${os.arch} == "powerpc"} {
    226         set flags "-Wl,-syslibroot,${configure.universal_sysroot} ${flags}"
     255    if {${os.arch} == "powerpc" && ${os.major} == "8"} {
     256        set flags "-Wl,-syslibroot,${developer_dir}/SDKs/MacOSX10.4u.sdk ${flags}"
    227257    }
    228258    return $flags
     259}
     260
     261# internal proc to determine if the compiler supports -arch
     262proc portconfigure::arch_flag_supported {args} {
     263    global configure.compiler
     264    switch -exact ${configure.compiler} {
     265        gcc-4.0 -
     266        gcc-4.2 -
     267        llvm-gcc-4.2 -
     268        clang -
     269        apple-gcc-4.0 -
     270        apple-gcc-4.2 {
     271            return yes
     272        }
     273        default {
     274            return no
     275        }
     276    }
    229277}
    230278
     
    284332                objc { set ret ${developer_dir}/usr/llvm-gcc-4.2/bin/llvm-gcc-4.2 }
    285333                cxx  { set ret ${developer_dir}/usr/llvm-gcc-4.2/bin/llvm-g++-4.2 }
    286                 cpp  { set ret ${developer_dir}/usr/llvm-gcc-4.2/bin/llvm-cpp-4.2 }
    287334            }
    288335        }
  • branches/gsoc09-logging/base/src/port1.0/portdestroot.tcl

    r52218 r53509  
    9696
    9797    # start gsoc08-privileges
    98     if { [getuid] == 0 && [geteuid] == [name_to_uid "$macportsuser"] } {
     98    if { [getuid] == 0 && [geteuid] != 0 } {
    9999    # if started with sudo but have dropped the privileges
    100100        ui_debug "Can't run destroot under sudo without elevated privileges (due to mtree)."
     
    171171    }
    172172    fs-traverse -depth dir ${destroot} {
    173         if {[file isdirectory $dir]} {
     173        if {[file type $dir] == "directory"} {
    174174            catch {file delete $dir}
    175175        }
     
    230230                # if link destination is not gzipped, check it
    231231                set manlinksrc [file readlink $manlinkpath]
    232                 # if link destination is an absolute path, convert it to a
    233                 # relative path
    234                 if {[file pathtype $manlinksrc] eq "absolute"} {
    235                     set manlinksrc [file tail $manlinksrc]
    236                 }
    237232                if {![regexp "\[.\]gz\$" ${manlinksrc}]} {
    238233                    set mandir [file dirname $manlink]
     
    243238                        return
    244239                    }
     240                    # if link source is an absolute path, check for it under destroot
     241                    set mls_check "$manlinksrc"
     242                    if {[file pathtype $mls_check] eq "absolute"} {
     243                        set mls_check "${destroot}${mls_check}"
     244                    }
    245245                    # if gzipped destination exists, fix link
    246                     if {[file isfile ${manlinksrc}.gz]} {
     246                    if {[file isfile ${mls_check}.gz]} {
    247247                        # if actual link name does not end with gz, rename it
    248248                        if {![regexp "\[.\]gz\$" ${manlink}]} {
  • branches/gsoc09-logging/base/src/port1.0/portdistcheck.tcl

    r52218 r53509  
    6565        && "${fetch.type}" == "standard"} {
    6666        # portfetch 1.0::checkfiles sets fetch_urls list.
    67         global fetch_urls
    68         checkfiles
     67        set fetch_urls {}
     68        portfetch::checkfiles fetch_urls
    6969        set totalsize 0
    7070
    7171        # Check all the files.
    7272        foreach {url_var distfile} $fetch_urls {
    73             global portfetch::$url_var
    74             if {![info exists $url_var]} {
     73            global portfetch::urlmap
     74            if {![info exists urlmap($url_var)]} {
    7575                ui_error [format [msgcat::mc "No defined site for tag: %s, using master_sites"] $url_var]
    76                 set url_var master_sites
    77                 global portfetch::$url_var
     76                set urlmap($url_var) $master_sites
    7877            }
    7978            if {${distcheck.check} == "moddate"} {
    8079                set count 0
    81                 foreach site [set $url_var] {
     80                foreach site $urlmap($url_var) {
    8281                    ui_debug [format [msgcat::mc "Checking %s from %s"] $distfile $site]
    8382                    set file_url [portfetch::assemble_url $site $distfile]
     
    9695            } elseif {${distcheck.check} == "filesize"} {
    9796                set count 0
    98                 foreach site [set $url_var] {
     97                foreach site $urlmap($url_var) {
    9998                    ui_debug [format [msgcat::mc "Checking %s from %s"] $distfile $site]
    10099                    set file_url [portfetch::assemble_url $site $distfile]
  • branches/gsoc09-logging/base/src/port1.0/portdistfiles.tcl

    r52218 r53509  
    5454
    5555proc portdistfiles::distfiles_main {args} {
    56     global UI_PREFIX master_sites fetch_urls url_var distfile checksums_array
     56    global UI_PREFIX master_sites checksums_array
    5757   
    5858    # give up on ports that do not provide URLs
     
    6262
    6363    # from portfetch... process the sites, files and patches
    64     portfetch::checkfiles
     64    set fetch_urls {}
     65    portfetch::checkfiles fetch_urls
    6566
    6667    # get checksum data from the portfile and parse it
     
    6869    set result [portchecksum::parse_checksums $checksums_str]
    6970
    70     foreach {url_var distfile} $portfetch::fetch_urls {
     71    foreach {url_var distfile} $fetch_urls {
     72        global portfetch::urlmap
    7173
    7274        ui_msg "\[$distfile\]"
     
    8082
    8183        # determine sites to download from
    82         namespace import ::portfetch::$url_var
    83         if {![info exists $url_var]} {
    84             set url_var master_sites
     84        if {![info exists urlmap($url_var)]} {
     85            set urlmap($url_var) $master_sites
    8586        }
    8687       
    8788        # determine URLs to download
    88         foreach site [set $url_var] {
     89        foreach site $urlmap($url_var) {
    8990            set file_url [portfetch::assemble_url $site $distfile]
    9091            ui_msg "  $file_url"
  • branches/gsoc09-logging/base/src/port1.0/portfetch.tcl

    r52218 r53509  
    4444    namespace export suffix
    4545    variable fetch_urls {}
     46    variable urlmap
     47    array set urlmap {}
    4648}
    4749
     
    226228    foreach element $portfetch::mirror_sites::sites($mirrors) {
    227229
    228     # here we have the chance to take a look at tags, that possibly
    229     # have been assigned in mirror_sites.tcl
    230     set splitlist [split $element :]
    231     # every element is a URL, so we'll always have multiple elements. no need to check
    232     set element "[lindex $splitlist 0]:[lindex $splitlist 1]"
    233     set mirror_tag "[lindex $splitlist 2]"
    234 
    235     set name_re {\$(?:name\y|\{name\})}
    236     # if the URL has $name embedded, kill any mirror_tag that may have been added
    237     # since a mirror_tag and $name are incompatible
    238     if {[regexp $name_re $element]} {
    239         set mirror_tag ""
    240     }
    241 
    242     if {$mirror_tag == "mirror"} {
    243         set thesubdir ${dist_subdir}
    244     } elseif {$subdir == "" && $mirror_tag != "nosubdir"} {
    245         set thesubdir ${name}
    246     } else {
    247         set thesubdir ${subdir}
    248     }
    249 
    250     # parse an embedded $name. if present, remove the subdir
    251     if {[regsub $name_re $element $thesubdir element] > 0} {
    252         set thesubdir ""
    253     }
    254 
    255     if {"$tag" != ""} {
    256         eval append element "${thesubdir}:${tag}"
    257     } else {
    258         eval append element "${thesubdir}"
    259     }
     230        # here we have the chance to take a look at tags, that possibly
     231        # have been assigned in mirror_sites.tcl
     232        set splitlist [split $element :]
     233        # every element is a URL, so we'll always have multiple elements. no need to check
     234        set element "[lindex $splitlist 0]:[lindex $splitlist 1]"
     235        set mirror_tag "[lindex $splitlist 2]"
     236
     237        set name_re {\$(?:name\y|\{name\})}
     238        # if the URL has $name embedded, kill any mirror_tag that may have been added
     239        # since a mirror_tag and $name are incompatible
     240        if {[regexp $name_re $element]} {
     241            set mirror_tag ""
     242        }
     243
     244        if {$mirror_tag == "mirror"} {
     245            set thesubdir ${dist_subdir}
     246        } elseif {$subdir == "" && $mirror_tag != "nosubdir"} {
     247            set thesubdir ${name}
     248        } else {
     249            set thesubdir ${subdir}
     250        }
     251
     252        # parse an embedded $name. if present, remove the subdir
     253        if {[regsub $name_re $element $thesubdir element] > 0} {
     254            set thesubdir ""
     255        }
     256
     257        if {"$tag" != ""} {
     258            eval append element "${thesubdir}:${tag}"
     259        } else {
     260            eval append element "${thesubdir}"
     261        }
     262
    260263        eval lappend ret $element
    261264    }
     
    272275    global patch_sites master_sites master_sites.mirror_subdir \
    273276        patch_sites.mirror_subdir fallback_mirror_site global_mirror_site env
     277    variable urlmap
    274278
    275279    append master_sites " ${global_mirror_site} ${fallback_mirror_site}"
     
    325329        foreach site $site_list {
    326330        if {[regexp {([a-zA-Z]+://.+/?):([0-9A-Za-z_-]+)$} $site match site tag]} {
    327                 lappend portfetch::$tag $site
     331                lappend urlmap($tag) $site
    328332            } else {
    329                 lappend portfetch::$list $site
     333                lappend urlmap($list) $site
    330334            }
    331335        }
     
    334338
    335339# Checks patch files and their tags to assemble url lists for later fetching
    336 proc portfetch::checkpatchfiles {args} {
     340proc portfetch::checkpatchfiles {urls} {
    337341    global patchfiles all_dist_files patch_sites filespath
    338     variable fetch_urls
     342    upvar $urls fetch_urls
    339343
    340344    if {[info exists patchfiles]} {
     
    357361
    358362# Checks dist files and their tags to assemble url lists for later fetching
    359 proc portfetch::checkdistfiles {args} {
     363proc portfetch::checkdistfiles {urls} {
    360364    global distfiles all_dist_files master_sites filespath
    361     variable fetch_urls
     365    upvar $urls fetch_urls
    362366
    363367    if {[info exists distfiles]} {
     
    378382
    379383# sorts fetch_urls in order of ping time
    380 proc portfetch::sortsites {args} {
    381     global fallback_mirror_site
    382     variable fetch_urls
     384proc portfetch::sortsites {urls} {
     385    global fallback_mirror_site master_sites
     386    upvar $urls fetch_urls
     387    variable urlmap
    383388
    384389    set fallback_mirror_list [mirror_sites $fallback_mirror_site {} {}]
    385390
    386391    foreach {url_var distfile} $fetch_urls {
    387         variable portfetch::$url_var
    388         if {![info exists $url_var]} {
     392        if {![info exists urlmap($url_var)]} {
    389393            ui_error [format [msgcat::mc "No defined site for tag: %s, using master_sites"] $url_var]
    390             set url_var master_sites
    391             variable portfetch::$url_var
    392         }
    393         set urllist [set $url_var]
     394            set urlmap($url_var) $master_sites
     395        }
     396        set urllist $urlmap($url_var)
    394397        set hosts {}
    395398        set hostregex {[a-zA-Z]+://([a-zA-Z0-9\.\-_]+)}
     
    445448        set pinglist [ lsort -real -index 1 $pinglist ]
    446449
    447         set $url_var {}
     450        set urlmap($url_var) {}
    448451        foreach pair $pinglist {
    449             lappend $url_var [lindex $pair 0]
     452            lappend urlmap($url_var) [lindex $pair 0]
    450453        }
    451454    }
     
    454457# Perform the full checksites/checkpatchfiles/checkdistfiles sequence.
    455458# This method is used by distcheck target.
    456 proc portfetch::checkfiles {args} {
    457     variable fetch_urls
     459proc portfetch::checkfiles {urls} {
     460    upvar $urls fetch_urls
    458461
    459462    checksites
    460     checkpatchfiles
    461     checkdistfiles
     463    checkpatchfiles fetch_urls
     464    checkdistfiles fetch_urls
    462465}
    463466
     
    587590    global portverbose
    588591    variable fetch_urls
     592    variable urlmap
    589593
    590594    if {![file isdirectory $distpath]} {
     
    628632            }
    629633            if {!$sorted} {
    630                 sortsites
     634                sortsites fetch_urls
    631635                set sorted yes
    632636            }
    633             variable portfetch::$url_var
    634             if {![info exists $url_var]} {
     637            if {![info exists urlmap($url_var)]} {
    635638                ui_error [format [msgcat::mc "No defined site for tag: %s, using master_sites"] $url_var]
    636                 set url_var master_sites
    637                 variable portfetch::$url_var
     639                set urlmap($url_var) $master_sites
    638640            }
    639641            unset -nocomplain fetched
    640             foreach site [set $url_var] {
     642            foreach site $urlmap($url_var) {
    641643                ui_msg "$UI_PREFIX [format [msgcat::mc "Attempting to fetch %s from %s"] $distfile $site]"
    642644                set file_url [portfetch::assemble_url $site $distfile]
     
    703705    global distfiles distname distpath all_dist_files dist_subdir fetch.type fetch_init_done
    704706    global altprefix usealtworkpath
     707    variable fetch_urls
    705708
    706709    if {[info exists distpath] && [info exists dist_subdir] && ![info exists fetch_init_done]} {
     
    717720        set fetch_init_done yes
    718721    }
    719     portfetch::checkfiles
     722    portfetch::checkfiles fetch_urls
    720723}
    721724
  • branches/gsoc09-logging/base/src/port1.0/portlint.tcl

    r52218 r53509  
    240240            }
    241241        }
     242       
     243        if {[string match "platform\[ \t\]*" $line]} {
     244            regexp {platform\s+(?:\w+\s+(?:\w+\s+)?)?(\w+)} $line -> platform_arch
     245            if {$platform_arch == "ppc"} {
     246                ui_error "Arch 'ppc' in platform variant on line $lineno should be 'powerpc'"
     247                incr errors
     248            }
     249        }
    242250
    243251        if {[regexp {(^|\s)configure\s+\{\s*\}} $line]} {
  • branches/gsoc09-logging/base/src/port1.0/portlivecheck.tcl

    r52218 r53509  
    123123        }
    124124    }
    125     # If livecheck.name is still "default", set it to $name.
    126     if {${livecheck.name} eq "default"} {
    127         set livecheck.name $name
    128     }
    129125    if {[lsearch -exact [split $available_types "|"] ${livecheck.type}] != -1} {
    130126        # Load the defaults from _resources/port1.0/livecheck/${livecheck.type}.tcl.
  • branches/gsoc09-logging/base/src/port1.0/portmain.tcl

    r52218 r53509  
    123123    # add_default_universal_variant, which is called from mportopen
    124124    option os.universal_supported yes
    125 
    126     if {[info exists variations(universal)] && $variations(universal) == "+"} {
    127         # cannot go into the variant, due to the amount of ports overriding it
    128         eval macosx_deployment_target ${universal_target}
    129     }
    130125}
    131126
  • branches/gsoc09-logging/base/src/port1.0/porttrace.tcl

    r50562 r53509  
    4545            ui_warn "trace requires Tcl Thread package ($error)"
    4646        } else {
    47             global env trace_fifo trace_sandboxbounds portpath
     47            global env trace_fifo trace_sandboxbounds portpath distpath
    4848            # Create a fifo.
    4949            # path in unix socket limited to 109 chars
     
    7979            # $CCACHE_DIR
    8080            # $HOMEDIR/.ccache
    81             set trace_sandboxbounds "/tmp:/private/tmp:/var/tmp:/private/var/tmp:/dev/:/etc/passwd:/etc/groups:/etc/localtime:/Library/Caches/com.apple.Xcode:$env(HOME)/.ccache:${workpath}:$portpath"
     81            set trace_sandboxbounds "/tmp:/private/tmp:/var/tmp:/private/var/tmp:/dev/:/etc/passwd:/etc/groups:/etc/localtime:/Library/Caches/com.apple.Xcode:$env(HOME)/.ccache:${workpath}:${portpath}:${distpath}"
    8282            if {[info exists env(TMPDIR)]} {
    8383                set trace_sandboxbounds "${trace_sandboxbounds}:$env(TMPDIR)"
     
    105105    if [info exists env(DARWINTRACE_SANDBOX_BOUNDS)] {
    106106        unset env(DARWINTRACE_SANDBOX_BOUNDS)
     107        unsetenv DARWINTRACE_SANDBOX_BOUNDS
    107108    }
    108109}
     
    148149    if {${os.platform} == "darwin"} {
    149150        global env trace_fifo
    150         unset env(DYLD_INSERT_LIBRARIES)
    151         unset env(DYLD_FORCE_FLAT_NAMESPACE)
    152         unset env(DARWINTRACE_LOG)
    153         if [info exists env(DARWINTRACE_SANDBOX_BOUNDS)] {
    154             unset env(DARWINTRACE_SANDBOX_BOUNDS)
     151        foreach var {DYLD_INSERT_LIBRARIES DYLD_FORCE_FLAT_NAMESPACE DARWINTRACE_LOG DARWINTRACE_SANDBOX_BOUNDS} {
     152            array unset env $var
     153            unsetenv $var
    155154        }
    156155
     
    214213# Private.
    215214# Slave method to read a line from the trace.
    216 proc porttrace::lave_read_line {chan} {
     215proc porttrace::slave_read_line {chan} {
    217216    global ports_list trace_filemap sandbox_violation_list workpath
    218217    global env
  • branches/gsoc09-logging/base/src/port1.0/portutil.tcl

    r53422 r53509  
    682682    if {[variant_exists $platform]} {
    683683        set suffix 1
    684         while {[variant_exists "$platform-$suffix"]} {
     684        while {[variant_exists "${platform}_${suffix}"]} {
    685685            incr suffix
    686686        }
    687687
    688         set platform "$platform-$suffix"
     688        set platform "${platform}_${suffix}"
    689689    }
    690690    variant $platform $code
     
    12701270                    if {$target != "activate"
    12711271                      && $target != "archive"
    1272                       && $target != "fetch"
    12731272                      && $target != "install"} {
    12741273                        porttrace::trace_enable_fence
     
    17011700    foreach v [ditem_key $ditem conflicts] {
    17021701        if {[variant_isset $v]} {
    1703             ui_error "Variant $name conflicts with $v"
     1702            ui_error "[option name]: Variant $name conflicts with $v"
    17041703            return 1
    17051704        }
     
    17101709        global errorInfo
    17111710        ui_debug "$errorInfo"
    1712         ui_error "Error executing $name: $result"
     1711        ui_error "[option name]: Error executing $name: $result"
    17131712        return 1
    17141713    }
     
    17221721    # characterized by the set of variants that are *on*. Thus, record those
    17231722    # variants in a string in a standard order as +var1+var2 etc.
    1724     # We can skip the platform and architecture since those are always
    1725     # requested.  XXX: Is that really true? What if the user explicitly
    1726     # overrides the platform and architecture variants? Will the registry get
    1727     # bollixed? It would seem safer to me to just leave in all the variants that
    1728     # are on, but for now I'm just leaving the skipping code as it was in the
    1729     # previous version.
     1723    # XXX: this doesn't quite work because of default variants, see ticket #2377
    17301724proc canonicalize_variants {variants} {
    17311725    array set vara $variants
     
    17331727    set vlist [lsort -ascii [array names vara]]
    17341728    foreach v $vlist {
    1735         if {$vara($v) == "+" && $v ne [option os.platform] && $v ne [option os.arch]} {
     1729        if {$vara($v) == "+"} {
    17361730            append result +$v
    17371731        }
     
    18841878
    18851879proc add_default_universal_variant {args} {
    1886     # Declare default universal variant if universal SDK is installed
    1887     variant universal {
    1888         pre-fetch {
    1889             if {![file exists ${configure.universal_sysroot}]} {
    1890                 return -code error "Universal SDK is not installed (are we running on 10.3? did you forget to install it?) and building with +universal will very likely fail"
    1891             }
    1892         }
    1893 
    1894         eval configure.args-append ${configure.universal_args}
    1895         eval configure.cflags-append ${configure.universal_cflags}
    1896         eval configure.cppflags-append ${configure.universal_cppflags}
    1897         eval configure.cxxflags-append ${configure.universal_cxxflags}
    1898         eval configure.ldflags-append ${configure.universal_ldflags}
    1899     }
     1880    # Declare default universal variant (all the magic happens in portconfigure now)
     1881    variant universal {}
    19001882}
    19011883
     
    21332115}
    21342116
    2135 # check for a binary in the path
    2136 # returns an error code if it cannot be found
    2137 proc binaryInPath {binary} {
    2138     global env
    2139     foreach dir [split $env(PATH) :] {
    2140         if {[file executable [file join $dir $binary]]} {
    2141             return [file join $dir $binary]
    2142         }
    2143     }
    2144 
    2145     return -code error [format [msgcat::mc "Failed to locate '%s' in path: '%s'"] $binary $env(PATH)];
    2146 }
    2147 
    2148 # find a binary either in a path defined at MacPorts' configuration time
    2149 # or in the PATH environment variable through binaryInPath (fallback)
    2150 proc findBinary {prog {autoconf_hint ""}} {
    2151     if {${autoconf_hint} != "" && [file executable ${autoconf_hint}]} {
    2152         return ${autoconf_hint}
    2153     } else {
    2154         if {[catch {set cmd_path [binaryInPath ${prog}]} result] == 0} {
    2155             return ${cmd_path}
    2156         } else {
    2157             return -code error "${result} or at its MacPorts configuration time location, did you move it?"
    2158         }
    2159     }
    2160 }
    2161 
    21622117# Set the UI prefix to something standard (so it can be grepped for in output)
    21632118proc set_ui_prefix {} {
     
    23812336    global euid macportsuser
    23822337
    2383     if { [getuid] == 0 && [geteuid] == [name_to_uid "$macportsuser"] } {
    2384     # if started with sudo but have dropped the privileges
    2385         seteuid $euid
    2386         ui_debug "euid changed to: [geteuid]"
    2387         chown  ${path} ${macportsuser}
    2388         ui_debug "chowned $path to $macportsuser"
    2389         seteuid [name_to_uid "$macportsuser"]
    2390         ui_debug "euid changed to: [geteuid]"
    2391     } elseif { [getuid] == 0 } {
    2392     # if started with sudo but have elevated back to root already
    2393         chown  ${path} ${macportsuser}
     2338    if { [getuid] == 0 } {
     2339        if {[geteuid] != 0} {
     2340            # if started with sudo but have dropped the privileges
     2341            seteuid $euid
     2342            ui_debug "euid changed to: [geteuid]"
     2343            chown  ${path} ${macportsuser}
     2344            ui_debug "chowned $path to $macportsuser"
     2345            seteuid [name_to_uid "$macportsuser"]
     2346            ui_debug "euid changed to: [geteuid]"
     2347        } else {
     2348            # if started with sudo but have elevated back to root already
     2349            chown  ${path} ${macportsuser}
     2350        }
    23942351    }
    23952352}
     
    24022359    global euid egid macportsuser
    24032360
    2404     if { [getuid] == 0 && [geteuid] == [name_to_uid "$macportsuser"] } {
     2361    if { [getuid] == 0 && [geteuid] != 0 } {
    24052362    # if started with sudo but have dropped the privileges
    24062363        ui_debug "Can't run $action on this port without elevated privileges. Escalating privileges back to root."
     
    24082365        seteuid $euid
    24092366        ui_debug "euid changed to: [geteuid]. egid changed to: [getegid]."
    2410     }
    2411 
    2412     if { [getuid] != 0 } {
    2413         return -code error "MacPorts requires root privileges for this action";
     2367    } elseif { [getuid] != 0 } {
     2368        return -code error "MacPorts requires root privileges for this action"
    24142369    }
    24152370}
     
    24222377    if { [geteuid] == 0 } {
    24232378        if { [catch {
    2424                 ui_debug "changing euid/egid - current euid: $euid - current egid: $egid"
    2425 
    2426                 #seteuid [name_to_uid [file attributes $workpath -owner]]
    2427                 #setegid [name_to_gid [file attributes $workpath -group]]
    2428 
    2429                 setegid [uname_to_gid "$macportsuser"]
    2430                 seteuid [name_to_uid "$macportsuser"]
    2431                 ui_debug "egid changed to: [getegid]"
    2432                 ui_debug "euid changed to: [geteuid]"
     2379                if {[name_to_uid "$macportsuser"] != 0} {
     2380                    ui_debug "changing euid/egid - current euid: $euid - current egid: $egid"
     2381
     2382                    #seteuid [name_to_uid [file attributes $workpath -owner]]
     2383                    #setegid [name_to_gid [file attributes $workpath -group]]
     2384
     2385                    setegid [uname_to_gid "$macportsuser"]
     2386                    seteuid [name_to_uid "$macportsuser"]
     2387                    ui_debug "egid changed to: [getegid]"
     2388                    ui_debug "euid changed to: [geteuid]"
     2389                }
    24332390            }]
    24342391        } {
  • branches/gsoc09-logging/base/src/registry1.0/portimage.tcl

    r52218 r53509  
    287287                }
    288288        } elseif { [file type $srcfile] == "link" } {
    289                 file copy -force $srcfile $dstfile
     289                file copy -force -- $srcfile $dstfile
    290290        } else {
    291291                # Try a hard link first and if that fails, a symlink
     
    346346                        if {[file exists $file]} {
    347347                                ui_warn "File $file already exists.  Moving to: $bakfile."
    348                                 file rename -force $file $bakfile
     348                                file rename -force -- $file $bakfile
    349349                        }
    350350                       
  • branches/gsoc09-logging/base/src/registry1.0/receipt_flat.tcl

    r51138 r53509  
    7575    # regex match case
    7676    if {$portversion == 0} {
    77         set x [glob -nocomplain [file join ${macports::registry.path} receipts ${portname}-*]]
     77        set x [glob -nocomplain -directory [file join ${macports::registry.path} receipts] -- ${portname}-*]
    7878        if {[string length $x]} {
    7979            set matchfile [lindex $x 0]
     
    137137                        # xxx: If we're in image mode, we really should have had the
    138138                        # version given to us.  How should we handle this?
    139                         set x [glob -nocomplain [file join ${receipt_path} *]]
     139                        set x [glob -nocomplain -directory ${receipt_path} *]
    140140                        if { [string length $x] } {
    141141                                set v [lindex [file split [lindex $x 0]] end]
     
    181181                set convertedDirPath [file join ${macports::registry.path} receipts_converted]
    182182                file mkdir $convertedDirPath
    183                 file rename $receipt_file $convertedDirPath
     183                file rename -- $receipt_file $convertedDirPath
    184184        } elseif {[string match "# Version: *" $receipt_contents]} {
    185185                # This is new format
     
    330330
    331331        if { [file exists ${receipt_file}] } {
    332                 file delete -force "${receipt_file}"
     332                file delete -force -- "${receipt_file}"
    333333        } elseif { [file exists ${receipt_file}.bz2] } {
    334                 file delete -force "${receipt_file}.bz2"
    335         }
    336 
    337         file rename -force "${receipt_file}.tmp" "${receipt_file}"
     334                file delete -force -- "${receipt_file}.bz2"
     335        }
     336
     337        file rename -force -- "${receipt_file}.tmp" "${receipt_file}"
    338338
    339339        if { [file exists ${receipt_file}] && [file exists ${registry::autoconf::bzip2_path}] && ![info exists registry.nobzip] } {
     
    424424                # remove port receipt directory
    425425                ui_debug "deleting directory: ${receipt_path}"
    426                 file delete -force ${receipt_path}
     426                file delete -force -- ${receipt_path}
    427427                # remove port receipt parent directory (if empty)
    428428                set receipt_dir [file join ${macports::registry.path} receipts ${name}]
     
    431431                        if { [llength [readdir ${receipt_dir}]] == 0 } {
    432432                                ui_debug "deleting directory: ${receipt_dir}"
    433                                 file delete -force ${receipt_dir}
     433                                file delete -force -- ${receipt_dir}
    434434                        } else {
    435435                                ui_debug "${receipt_dir} is not empty"
     
    849849
    850850    # don't both checking for presence, file delete doesn't error if file doesn't exist
    851     file delete ${map_file} ${map_file}.bz2
    852 
    853     file rename ${map_file}.tmp ${map_file}
     851    file delete -- ${map_file} ${map_file}.bz2
     852
     853    file rename -- ${map_file}.tmp ${map_file}
    854854
    855855        if { [file exists ${map_file}] && [file exists ${registry::autoconf::bzip2_path}] && ![info exists registry.nobzip] } {
  • branches/gsoc09-logging/base/src/registry2.0/portimage.tcl

    • Property svn:eol-style set to native
    • Property svn:keywords set to Id
  • branches/gsoc09-logging/base/src/registry2.0/portuninstall.tcl

    • Property svn:eol-style set to native
    • Property svn:keywords set to Id
  • branches/gsoc09-logging/base/src/registry2.0/registry_util.tcl

    • Property svn:eol-style set to native
    • Property svn:keywords set to Id
  • branches/gsoc09-logging/base/src/tclobjc1.0/MPMethodSignatureExtensions.h

    • Property svn:eol-style set to native
  • branches/gsoc09-logging/base/src/tclobjc1.0/MPMethodSignatureExtensions.m

    • Property svn:eol-style set to native
  • branches/gsoc09-logging/base/src/tclobjc1.0/Makefile.in

    • Property svn:eol-style set to native
    r40056 r53509  
    1111
    1212clean::
    13         rm -f *.d
     13        rm -f *.o
    1414
    1515distclean::
  • branches/gsoc09-logging/base/src/tclobjc1.0/objc_encoding.h

    • Property svn:eol-style set to native
  • branches/gsoc09-logging/base/src/tclobjc1.0/objc_encoding.m

    • Property svn:eol-style set to native
  • branches/gsoc09-logging/base/src/tclobjc1.0/tclobjc.h

    • Property svn:eol-style set to native
  • branches/gsoc09-logging/base/src/tclobjc1.0/tclobjc.m

    • Property svn:eol-style set to native
  • branches/gsoc09-logging/base/src/tclobjc1.0/tclobjc_types.h

    • Property svn:eol-style set to native
  • branches/gsoc09-logging/base/src/tclobjc1.0/tclobjc_types.m

    • Property svn:eol-style set to native
  • branches/gsoc09-logging/base/src/thread2.6.diff

    • Property svn:keywords deleted
  • branches/gsoc09-logging/base/src/upgrade_sources_conf_default.tcl

    • Property svn:eol-style set to native
Note: See TracChangeset for help on using the changeset viewer.