From owner-svn-src-user@FreeBSD.ORG Sun Aug 15 06:10:09 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 198E810656F2; Sun, 15 Aug 2010 06:10:09 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E3B6F8FC08; Sun, 15 Aug 2010 06:10:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o7F6A8Fg049806; Sun, 15 Aug 2010 06:10:08 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7F6A8KN049804; Sun, 15 Aug 2010 06:10:08 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201008150610.o7F6A8KN049804@svn.freebsd.org> From: Doug Barton Date: Sun, 15 Aug 2010 06:10:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211322 - user/dougb/portmaster X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Aug 2010 06:10:09 -0000 Author: dougb Date: Sun Aug 15 06:10:08 2010 New Revision: 211322 URL: http://svn.freebsd.org/changeset/base/211322 Log: Improve the regexp for parse_index() by specifying the PORTSDIR path, and not using globals. In the initialization code when using --index* set the path for the ports tree in the INDEX file with a special version of $pd, PM_IPD. We only need to set this to something other than /usr/ports if $pd is not already set, and/or it's set to something other than /usr/ports. In addition to improving the efficiency of parse_index() this has the pleasant side effect of (slightly) improving support for non-standard PORTSDIR. For -F, at the end of the run break out of the loop if the number of extant fetches is 0. This doesn't happen often, but there is a race that can cause it. Printing the message that we're waiting for zero fetches is silly; but the real problem is sleep'ing for no reason. Modified: user/dougb/portmaster/portmaster Modified: user/dougb/portmaster/portmaster ============================================================================== --- user/dougb/portmaster/portmaster Sat Aug 14 22:49:07 2010 (r211321) +++ user/dougb/portmaster/portmaster Sun Aug 15 06:10:08 2010 (r211322) @@ -570,16 +570,20 @@ if [ "$$" -eq "$PM_PARENT_PID" ]; then PM_INDEX_PORTS=`pkg_version -Ivl\< $PM_INDEX | cut -f1 -d\<` export PM_INDEX_PORTS - fi - if [ -z "$pd" ]; then - if [ -n "$PM_INDEX_ONLY" ]; then - pd=`head -1 $PM_INDEX | cut -f 2 -d\|` - pd=${pd%/*} - pd=${pd%/*} + if [ -z "$pd" -o "$pd" != /usr/ports ]; then + PM_IPD=`head -1 $PM_INDEX | cut -f 2 -d\|` + PM_IPD=${PM_IPD%/*} + PM_IPD=${PM_IPD%/*} + + [ -n "$PM_INDEX_ONLY" ] && pd=$PM_IPD + else + PM_IPD=$pd fi - [ -z "$pd" ] && fail 'The value of PORTSDIR cannot be empty' + export PM_IPD fi + + [ -z "$pd" ] && fail 'The value of PORTSDIR cannot be empty' if [ -z "$pdb" ]; then if [ -z "$PKG_DBDIR" ]; then [ -d /var/db/pkg ] && pdb=/var/db/pkg @@ -1006,7 +1010,7 @@ init_packages_var () { parse_index () { local line - line=`grep -m1 .*\|.*/${1}\|.* $PM_INDEX` || return 1 + line=`grep -m1 "|${PM_IPD}/${1}|" $PM_INDEX` || return 1 case "$2" in name) echo ${line%%|*} ;; @@ -2046,6 +2050,7 @@ check_fetch_only () { while `ls ${TMPDIR}/f-${PM_PARENT_PID}-fetchlog-* >/dev/null 2>&1`; do nf=`ps -ax | grep [f]etch | wc -l` nf=${nf##* } + [ "$nf" -eq 0 ] && break # Not often, but it happens fetches=fetches ; [ "$nf" -eq 1 ] && fetches=fetch echo "===>>> Waiting for ${nf##* } distfile $fetches to finish" sleep $sleep From owner-svn-src-user@FreeBSD.ORG Sun Aug 15 11:38:38 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9630F106566C; Sun, 15 Aug 2010 11:38:38 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 859BB8FC19; Sun, 15 Aug 2010 11:38:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o7FBccwo059260; Sun, 15 Aug 2010 11:38:38 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7FBccbo059258; Sun, 15 Aug 2010 11:38:38 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201008151138.o7FBccbo059258@svn.freebsd.org> From: Adrian Chadd Date: Sun, 15 Aug 2010 11:38:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211329 - user/adrian/if_ath_devel/sys/dev/ath/ath_hal/ar5212 X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Aug 2010 11:38:38 -0000 Author: adrian Date: Sun Aug 15 11:38:38 2010 New Revision: 211329 URL: http://svn.freebsd.org/changeset/base/211329 Log: Revert some mis-committed indenting. This brings ath_devel's ar5212 back in line with -head. Modified: user/adrian/if_ath_devel/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c Modified: user/adrian/if_ath_devel/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c ============================================================================== --- user/adrian/if_ath_devel/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c Sun Aug 15 11:32:05 2010 (r211328) +++ user/adrian/if_ath_devel/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c Sun Aug 15 11:38:38 2010 (r211329) @@ -567,13 +567,13 @@ ar5212SetDecompMask(struct ath_hal *ah, { struct ath_hal_5212 *ahp = AH5212(ah); - if (keyidx >= HAL_DECOMP_MASK_SIZE) - return HAL_EINVAL; - OS_REG_WRITE(ah, AR_DCM_A, keyidx); - OS_REG_WRITE(ah, AR_DCM_D, en ? AR_DCM_D_EN : 0); - ahp->ah_decompMask[keyidx] = en; + if (keyidx >= HAL_DECOMP_MASK_SIZE) + return HAL_EINVAL; + OS_REG_WRITE(ah, AR_DCM_A, keyidx); + OS_REG_WRITE(ah, AR_DCM_D, en ? AR_DCM_D_EN : 0); + ahp->ah_decompMask[keyidx] = en; - return AH_TRUE; + return AH_TRUE; } /* Setup coverage class */ @@ -646,7 +646,7 @@ ar5212Use32KHzclock(struct ath_hal *ah, struct ath_hal_5212 *ahp = AH5212(ah); return ath_hal_eepromGetFlag(ah, AR_EEP_32KHZCRYSTAL) && (ahp->ah_enable32kHzClock == USE_32KHZ || - ahp->ah_enable32kHzClock == AUTO_32KHZ); + ahp->ah_enable32kHzClock == AUTO_32KHZ); } else return AH_FALSE; } @@ -675,16 +675,16 @@ ar5212SetupClock(struct ath_hal *ah, HAL if (IS_2413(ah) || IS_5413(ah) || IS_2417(ah)) { OS_REG_WRITE(ah, AR_PHY_SLEEP_CTR_LIMIT, 0x26); - OS_REG_WRITE(ah, AR_PHY_SLEEP_SCAL, 0x0d); - OS_REG_WRITE(ah, AR_PHY_M_SLEEP, 0x07); - OS_REG_WRITE(ah, AR_PHY_REFCLKDLY, 0x3f); + OS_REG_WRITE(ah, AR_PHY_SLEEP_SCAL, 0x0d); + OS_REG_WRITE(ah, AR_PHY_M_SLEEP, 0x07); + OS_REG_WRITE(ah, AR_PHY_REFCLKDLY, 0x3f); /* # Set sleep clock rate to 32 KHz. */ OS_REG_RMW_FIELD(ah, AR_PCICFG, AR_PCICFG_SCLK_RATE_IND, 0x2); } else { OS_REG_WRITE(ah, AR_PHY_SLEEP_CTR_LIMIT, 0x0a); - OS_REG_WRITE(ah, AR_PHY_SLEEP_SCAL, 0x0c); - OS_REG_WRITE(ah, AR_PHY_M_SLEEP, 0x03); - OS_REG_WRITE(ah, AR_PHY_REFCLKDLY, 0x20); + OS_REG_WRITE(ah, AR_PHY_SLEEP_SCAL, 0x0c); + OS_REG_WRITE(ah, AR_PHY_M_SLEEP, 0x03); + OS_REG_WRITE(ah, AR_PHY_REFCLKDLY, 0x20); OS_REG_RMW_FIELD(ah, AR_PCICFG, AR_PCICFG_SCLK_RATE_IND, 0x3); } } else { @@ -702,8 +702,8 @@ ar5212SetupClock(struct ath_hal *ah, HAL OS_REG_WRITE(ah, AR_PHY_SLEEP_SCAL, 0x32); else OS_REG_WRITE(ah, AR_PHY_SLEEP_SCAL, 0x0e); - OS_REG_WRITE(ah, AR_PHY_M_SLEEP, 0x0c); - OS_REG_WRITE(ah, AR_PHY_REFCLKDLY, 0xff); + OS_REG_WRITE(ah, AR_PHY_M_SLEEP, 0x0c); + OS_REG_WRITE(ah, AR_PHY_REFCLKDLY, 0xff); OS_REG_WRITE(ah, AR_PHY_REFCLKPD, IS_RAD5112_ANY(ah) || IS_5413(ah) || IS_2417(ah) ? 0x14 : 0x18); OS_REG_RMW_FIELD(ah, AR_USEC, AR_USEC_USEC32, @@ -731,9 +731,9 @@ ar5212RestoreClock(struct ath_hal *ah, H */ OS_REG_WRITE(ah, AR_PHY_SLEEP_CTR_CONTROL, 0x1f); OS_REG_WRITE(ah, AR_PHY_SLEEP_CTR_LIMIT, 0x7f); - OS_REG_WRITE(ah, AR_PHY_SLEEP_SCAL, 0x0e); - OS_REG_WRITE(ah, AR_PHY_M_SLEEP, 0x0c); - OS_REG_WRITE(ah, AR_PHY_REFCLKDLY, 0xff); + OS_REG_WRITE(ah, AR_PHY_SLEEP_SCAL, 0x0e); + OS_REG_WRITE(ah, AR_PHY_M_SLEEP, 0x0c); + OS_REG_WRITE(ah, AR_PHY_REFCLKDLY, 0xff); OS_REG_WRITE(ah, AR_PHY_REFCLKPD, IS_RAD5112_ANY(ah) || IS_5413(ah) ? 0x14 : 0x18); } @@ -1106,4 +1106,3 @@ ar5212WaitNFCalComplete(struct ath_hal * } return AH_FALSE; } - From owner-svn-src-user@FreeBSD.ORG Sun Aug 15 11:44:08 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D42F51065694; Sun, 15 Aug 2010 11:44:08 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C44398FC0C; Sun, 15 Aug 2010 11:44:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o7FBi8mL059446; Sun, 15 Aug 2010 11:44:08 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7FBi85c059444; Sun, 15 Aug 2010 11:44:08 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201008151144.o7FBi85c059444@svn.freebsd.org> From: Adrian Chadd Date: Sun, 15 Aug 2010 11:44:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211331 - user/adrian/if_ath_devel/sys/dev/ath/ath_hal/ar5416 X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Aug 2010 11:44:08 -0000 Author: adrian Date: Sun Aug 15 11:44:08 2010 New Revision: 211331 URL: http://svn.freebsd.org/changeset/base/211331 Log: Fix indenting/whitespace to make consistent with -head. Modified: user/adrian/if_ath_devel/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c Modified: user/adrian/if_ath_devel/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c ============================================================================== --- user/adrian/if_ath_devel/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c Sun Aug 15 11:40:53 2010 (r211330) +++ user/adrian/if_ath_devel/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c Sun Aug 15 11:44:08 2010 (r211331) @@ -229,9 +229,9 @@ ar5416InitCal(struct ath_hal *ah, const */ if (! ar5212WaitNFCalComplete(ah, 10000)) { HALDEBUG(ah, HAL_DEBUG_ANY, "%s: initial NF calibration did " - "not complete in time; noisy environment?\n", __func__); + "not complete in time; noisy environment?\n", __func__); return AH_FALSE; - } + } /* Initialize list pointers */ cal->cal_list = cal->cal_last = cal->cal_curr = AH_NULL; From owner-svn-src-user@FreeBSD.ORG Sun Aug 15 14:11:59 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4B5C0106566B; Sun, 15 Aug 2010 14:11:59 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3B0188FC1C; Sun, 15 Aug 2010 14:11:59 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o7FEBxGU062498; Sun, 15 Aug 2010 14:11:59 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7FEBxBW062496; Sun, 15 Aug 2010 14:11:59 GMT (envelope-from des@svn.freebsd.org) Message-Id: <201008151411.o7FEBxBW062496@svn.freebsd.org> From: Dag-Erling Smorgrav Date: Sun, 15 Aug 2010 14:11:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211334 - user/des/phybs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Aug 2010 14:11:59 -0000 Author: des Date: Sun Aug 15 14:11:58 2010 New Revision: 211334 URL: http://svn.freebsd.org/changeset/base/211334 Log: Instead of a hardcoding the block size, ask the device; default to 512 bytes for regular files. Adjust all other default values accordingly. Modified: user/des/phybs/phybs.c Modified: user/des/phybs/phybs.c ============================================================================== --- user/des/phybs/phybs.c Sun Aug 15 13:25:18 2010 (r211333) +++ user/des/phybs/phybs.c Sun Aug 15 14:11:58 2010 (r211334) @@ -27,7 +27,10 @@ * $FreeBSD$ */ +#include +#include #include +#include #include #include @@ -38,14 +41,15 @@ #include #include -#define BSIZE 512 +static const char *device; -static unsigned int minsize = 1024; -static unsigned int maxsize = 8192; -static unsigned int total = (128 * 1024 * 1024); +static unsigned int bsize; +static unsigned int minsize; +static unsigned int maxsize; +static unsigned int total; -static int opt_r = 0; -static int opt_w = 1; +static int opt_r; +static int opt_w; static int tty = 0; static char progress[] = " [----------------]" @@ -112,7 +116,7 @@ usage(void) } static unsigned int -poweroftwo(char opt, const char *valstr, unsigned int min, unsigned int max) +poweroftwo(char opt, const char *valstr) { uint64_t val; @@ -124,7 +128,7 @@ poweroftwo(char opt, const char *valstr, fprintf(stderr, "-%c: not a power of two\n", opt); usage(); } - if (val < min || (max != 0 && val > max) || val > UINT_MAX) { + if (val == 0 || val > UINT_MAX) { fprintf(stderr, "-%c: out of range\n", opt); usage(); } @@ -134,22 +138,25 @@ poweroftwo(char opt, const char *valstr, int main(int argc, char *argv[]) { - char *device; + struct stat st; int fd, opt; tty = isatty(STDOUT_FILENO); - while ((opt = getopt(argc, argv, "h:l:rw")) != -1) + while ((opt = getopt(argc, argv, "h:l:rt:w")) != -1) switch (opt) { case 'h': - maxsize = poweroftwo(opt, optarg, minsize, 0); + maxsize = poweroftwo(opt, optarg); break; case 'l': - minsize = poweroftwo(opt, optarg, BSIZE, maxsize); + minsize = poweroftwo(opt, optarg); break; case 'r': opt_r = 1; break; + case 't': + total = poweroftwo(opt, optarg); + break; case 'w': opt_w = 1; break; @@ -160,24 +167,51 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; - if (!opt_r && !opt_w) - opt_r = opt_w = 1; - if (argc != 1) usage(); device = argv[0]; + if (!opt_r && !opt_w) + errx(1, "must specify -r and / or -w"); + if ((fd = open(device, opt_w ? O_RDWR : O_RDONLY)) == -1) err(1, "open(%s)", device); + + if (fstat(fd, &st) != 0) + err(1, "stat(%s)", device); + bsize = 512; + if (S_ISCHR(st.st_mode) && ioctl(fd, DIOCGSECTORSIZE, &bsize) == -1) + err(1, "ioctl(%s, DIOCGSECTORSIZE)", device); + + if (minsize == 0) + minsize = bsize * 2; + if (minsize % bsize != 0) + errx(1, "minsize (%u) is not a multiple of block size (%u)", + minsize, bsize); + + if (maxsize == 0) + maxsize = minsize * 8; + if (maxsize % minsize != 0) + errx(1, "maxsize (%u) is not a multiple of minsize (%u)", + maxsize, minsize); + + if (total == 0) + total = 128 * 1024 * 1024; + if (total % maxsize != 0) + errx(1, "total (%u) is not a multiple of maxsize (%u)", + total, maxsize); + printf("%8s%8s%8s%8s%12s%8s%8s\n", "count", "size", "offset", "step", "msec", "tps", "kBps"); + for (size_t size = minsize; size <= maxsize; size *= 2) { printf("\n"); scan(fd, size, 0, size * 4, total / size); - for (off_t offset = BSIZE; offset < (off_t)size; offset *= 2) + for (off_t offset = bsize; offset < (off_t)size; offset *= 2) scan(fd, size, offset, size * 4, total / size); } + close(fd); exit(0); } From owner-svn-src-user@FreeBSD.ORG Mon Aug 16 04:22:29 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 819111065696; Mon, 16 Aug 2010 04:22:29 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 723F48FC0A; Mon, 16 Aug 2010 04:22:29 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o7G4MTQe084795; Mon, 16 Aug 2010 04:22:29 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7G4MT8l084793; Mon, 16 Aug 2010 04:22:29 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201008160422.o7G4MT8l084793@svn.freebsd.org> From: Doug Barton Date: Mon, 16 Aug 2010 04:22:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211389 - user/dougb/portmaster X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Aug 2010 04:22:29 -0000 Author: dougb Date: Mon Aug 16 04:22:29 2010 New Revision: 211389 URL: http://svn.freebsd.org/changeset/base/211389 Log: Dramatic (9-10 times) speedup in iport_from_origin() by making an intelligent guess about what director{y|ies] to search in based on the origin directory name. This algorithm only misses on 2 out of my 489 currently installed ports which means we're almost always looking in either exactly the right directory the first time, or at worst (such as the py-* ports) a dramatically smaller subset. Modified: user/dougb/portmaster/portmaster Modified: user/dougb/portmaster/portmaster ============================================================================== --- user/dougb/portmaster/portmaster Sun Aug 15 23:58:21 2010 (r211388) +++ user/dougb/portmaster/portmaster Mon Aug 16 04:22:29 2010 (r211389) @@ -625,10 +625,14 @@ unset var newopts #=============== Begin functions relevant to --features and main =============== iport_from_origin () { - local dir + local sn dir + + sn=${1#*/} ; sn=${sn%-*} ; sn=${sn%%[0-9]*} - if ! dir=`grep -l "@comment ORIGIN:${1}$" $pdb/*/+CONTENTS 2>/dev/null`; then - dir=`pkg_info -q -O $1` || return 1 + if ! dir=`grep -l "@comment ORIGIN:${1}$" $pdb/${sn}*/+CONTENTS 2>/dev/null`; then + if ! dir=`grep -l "@comment ORIGIN:${1}$" $pdb/*/+CONTENTS 2>/dev/null`; then + dir=`pkg_info -q -O $1` || return 1 + fi fi # It should not happen that more than one port meets this From owner-svn-src-user@FreeBSD.ORG Sat Aug 21 04:04:47 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2231A1065675; Sat, 21 Aug 2010 04:04:47 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1117C8FC1F; Sat, 21 Aug 2010 04:04:47 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o7L44kSU056024; Sat, 21 Aug 2010 04:04:46 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7L44kEG056022; Sat, 21 Aug 2010 04:04:46 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201008210404.o7L44kEG056022@svn.freebsd.org> From: Doug Barton Date: Sat, 21 Aug 2010 04:04:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211535 - user/dougb/portmaster X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Aug 2010 04:04:47 -0000 Author: dougb Date: Sat Aug 21 04:04:46 2010 New Revision: 211535 URL: http://svn.freebsd.org/changeset/base/211535 Log: Roto-rooter some old code in check_for_updates() and check_restart_and_udf(): 1. Add a new function, check_force_multi() which is called from check_for from several places now. It checks whether or not -f is in use, and if not whether the port in question is part of multiport(). 2. Cut some of the stale code in check_for: a. Since the only time check_for is called in a list context is when using -L, rely on that instead of its own variable. b. There is no need to specify the udf file on its own anymore, so eliminate that here (and everywhere else). c. It is not necessary to check URB* related stuff in check_for, all of the callers handle this already. 3. check_pkg_version() does not need to be its own function anymore, so bring that code back in line. 4. Call the new check_force_multi() from all the places that need it. This is new to the --index case (a bug fix), and modified/streamlined when the ports directory is being checked whether $iport and $port_ver are the same or not. 5. If there is no $origin directory but +IGNOREME exists make the result consistent with the MOVED case by adding some white space after the warning message and adding the port to CUR_DEPS so it won't warn again. 6. At the end when no update is available don't create CUR_DEPS if -L 7. In check_restart_and_udf() make the code consistent with other functions that check flags, and just derive the udf file from $iport. 8. In update_port() print more relevant messages on what is going to be done based on whether we are doing an update, or (re-)install. 9. In dependency_check() pass the arg to already_done (really old bug). 10. Correct some spurious whitespace in the code. Modified: user/dougb/portmaster/portmaster Modified: user/dougb/portmaster/portmaster ============================================================================== --- user/dougb/portmaster/portmaster Fri Aug 20 23:51:34 2010 (r211534) +++ user/dougb/portmaster/portmaster Sat Aug 21 04:04:46 2010 (r211535) @@ -1087,7 +1087,7 @@ if [ -n "$CLEAN_PACKAGES" ]; then origin=${origin#@comment ORIGIN:} if [ -z "$PM_INDEX" ]; then - if [ -d "$pd/$origin" ]; then + if [ -d "$pd/$origin" ]; then pm_cd $pd/$origin && port_ver=`pm_make -V PKGNAME` [ -n "$port_ver" ] || fail "Is $pd/$origin/Makefile missing?" else @@ -1391,47 +1391,35 @@ check_state () { return 0 } -check_pkg_version () { - local iport port_ver udf - - iport=$1 ; port_ver=$2 ; udf=$3 - - case `pkg_version -t $iport $port_ver` in - \<) return 1 ;; - =) return ;; - \>) if [ -n "$PM_VERBOSE" ]; then - echo " ===>>> Port version $port_ver does not" - echo " ===>>> seem newer than installed $iport" - fi - if [ -n "$PM_FORCE" ]; then - check_restart_and_udf $udf $iport || return 1 - elif [ -n "$URB_YES" ]; then - case "$MASTER_RB_LIST" in *" $iport "*) - if ! check_restart_and_udf $udf $iport; then - return 1 - else - URB_DONE_LIST="${URB_DONE_LIST}${upg_port}:" - fi ;; - esac - fi ;; - esac +# Takes $iport and $origin as arguments +# +check_force_multi () { + if [ -n "$PM_FORCE" ]; then + check_restart_and_udf $1 || return 1 + elif [ -n "$PM_MULTI_PORTS" ]; then + case "$PM_MULTI_PORTS" in + *:${1}:*) return 1 ;; + *:${2}:*) return 1 ;; + esac + fi } check_for_updates () { # Global: num_updates - local list_only nf iport origin port_ver skip udf do_update + local nf iport origin port_ver do_update skip - [ "$1" = 'list' ] && { list_only=list_only; nf=nonfatal; shift; } + [ "$1" = 'list' ] && { nf=nonfatal; shift; } - iport=$1 - - origin=${2:-`origin_from_pdb $iport`} || return 0 + iport=$1 ; origin=${2:-`origin_from_pdb $iport`} || return 0 if [ -n "$PM_INDEX" ]; then case "$PM_INDEX_PORTS" in *${iport}*) port_ver=`parse_index $origin name` ; do_update=upd_idx ;; esac + [ -z "$do_update" -a -z "$LIST_PLUS" ] && { + check_force_multi $iport $origin || do_update=upd_fm_idx; } + [ -n "$PM_INDEX_FIRST" ] || skip=index_skip fi @@ -1440,6 +1428,8 @@ check_for_updates () { if [ -e "$pdb/$iport/+IGNOREME" ]; then echo " ===>>> Warning: Unable to cd to $pd/$origin" echo " ===>>> Continuing due to $pdb/$iport/+IGNOREME" + echo '' + CUR_DEPS="${CUR_DEPS}${iport}:${origin}:" return 0 else fail "Cannot cd to port directory: $pd/$origin" @@ -1464,42 +1454,43 @@ check_for_updates () { fi if [ -z "$do_update" -a -n "$port_ver" ]; then - udf="$pdb/$iport/PM_UPGRADE_DONE_FLAG" if [ "$iport" = "$port_ver" ]; then - if [ -n "$PM_FORCE" ]; then - check_restart_and_udf $udf $iport || do_update=do_update_force - elif [ -n "$URB_YES" ]; then - case "$MASTER_RB_LIST" in *" $iport "*) - if ! check_restart_and_udf $udf $iport; then - do_update=do_update_urb - else - URB_DONE_LIST="${URB_DONE_LIST}${upg_port}:" - fi ;; - esac - elif [ -n "$PM_MULTI_PORTS" ]; then - case "$PM_MULTI_PORTS" in - *:${iport}:*) do_update=do_update_mi ;; - *:${origin}:*) do_update=do_update_mo ;; - esac - elif [ -n "$LIST_PLUS" ]; then - [ -z "$PM_INDEX_ONLY" ] && check_state + if [ -n "$LIST_PLUS" ]; then + check_state return 0 elif [ -n "$LIST" ]; then return 0 + else + check_force_multi $iport $origin || do_update=upd_fm_eq + unset port_ver fi else - check_pkg_version $iport $port_ver $udf || do_update=do_update_check + case `pkg_version -t $iport $port_ver` in + \<) do_update=upd_lt ;; + =) ;; # Can be reached if same version with different options + \>) if [ -n "$PM_VERBOSE" ]; then + echo " ===>>> Port version $port_ver does not" + echo " ===>>> seem newer than installed $iport" + fi ;; + *) fail "pkg_version -t $iport $port_ver gave an unexpected result" + esac + + [ -z "$do_update" ] && { + check_force_multi $iport $origin || do_update=upd_fm_ne; } fi fi - [ -z "$do_update" ] && { CUR_DEPS="${CUR_DEPS}${iport}:${origin}:" ; return 0; } + if [ -z "$do_update" ]; then + [ -z "$LIST_PLUS" ] && CUR_DEPS="${CUR_DEPS}${iport}:${origin}:" + return 0 + fi - if [ -n "$list_only" ]; then + if [ -n "$LIST_PLUS" ]; then if [ -z "$moved_npd" ]; then echo " ===>>> New version available: $port_ver" [ -e "$pdb/$iport/+IGNOREME" ] && echo " ===>>> +IGNOREME file is present for $1" - [ -z "$PM_INDEX_ONLY" ] && { pm_cd_pd $origin ; check_state; } + [ -z "$PM_INDEX_ONLY" ] && { pm_cd_pd $origin ; check_state; } num_updates=$(( $num_updates + 1 )) else unset moved_npd @@ -1990,14 +1981,13 @@ already_done () { check_restart_and_udf () { # RESTART will usually be empty, and we don't want # to go out to the disk if we don't have to. - if [ -z "$RESTART" ]; then - return 1 - elif [ ! -e "$1" ]; then + [ -z "$RESTART" ] && return 1 + + if [ ! -e "$pdb/${1}/PM_UPGRADE_DONE_FLAG" ]; then return 1 else - already_done $2 ; echo '' + already_done $1 ; echo '' fi - return 0 } check_interactive () { @@ -2120,10 +2110,16 @@ update_build_l () { } update_port () { - local update_to deps + local deps - [ -n "$2" ] && update_to=" to $2" - echo "===>>> Launching child to update ${1#$pd/}${update_to}" + if [ -n "$2" ]; then + echo "===>>> Launching child to update $1 to $2" + else + case "$1" in + */*) echo "===>>> Launching child to install ${1#$pd/}" ;; + *) echo "===>>> Launching child to reinstall $1" ;; + esac + fi dep_of_deps=$(( $dep_of_deps + 1 )) @@ -2280,7 +2276,7 @@ dependency_check () { clean_build_only_list fi - local d_port origin iport udf + local d_port origin iport # Do not export, for THIS parent process only [ -n "$PM_FIRST_PASS" ] && doing_dep_check=doing_dep_check @@ -2332,9 +2328,8 @@ dependency_check () { check_exclude ${iport:-$origin} || continue - udf="$pdb/$iport/PM_UPGRADE_DONE_FLAG" if [ -n "$PM_FORCE" -a -n "$iport" ]; then - if ! check_restart_and_udf $udf $iport; then + if ! check_restart_and_udf $iport; then echo "===>>> Forcing update for $pd/$origin" update_port $iport else @@ -2343,11 +2338,11 @@ dependency_check () { continue elif [ -n "$URB_YES" -a -n "$iport" ]; then case "$URB_DONE_LIST" in - *:${iport}:*) already_done ; continue ;; esac + *:${iport}:*) already_done $iport ; continue ;; esac case "$MASTER_RB_LIST" in *" $iport "*) check_interactive $iport || continue - if ! check_restart_and_udf $udf $iport; then + if ! check_restart_and_udf $iport; then update_port $iport else CUR_DEPS="${CUR_DEPS}${iport}:${origin}:" @@ -2803,8 +2798,7 @@ if ! : ; then PM_DEPTH= if [ -n "$PM_FORCE" ]; then - udf="$pdb/$iport/PM_UPGRADE_DONE_FLAG" - if ! check_restart_and_udf $udf $iport; then + if ! check_restart_and_udf $iport; then echo "===>>> Forcing update for $iport" update_port $iport else