Check-in [30a0468a6d]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:MFT: Quote filenames
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | 3.0.x
Files: files | file ages | folders
SHA1: 30a0468a6d0eeaf22c135b483fc729fc60aa20bc
User & Date: bdrewery 2013-06-23 12:03:32
Context
2013-06-23
12:03
MFT: parallel_exec: Fix to not disable 'set -e' in child cmd due to || This set -e juggling is to keep this function portable to other scripts that may or may not be running set -e. This fixes compute_deps() finding invalid port origins and not properly stopping before the build starts, which can lead to infinite loops check-in: 0960f3ab3b user: bdrewery tags: 3.0.x
12:03
MFT: Quote filenames check-in: 30a0468a6d user: bdrewery tags: 3.0.x
2013-06-08
12:09
MFT: make.conf: Fix appending MASTERNAME-make.conf twice Reported by: kwm Ticket: [674c0b93bf2] check-in: ccde6da1a3 user: bdrewery tags: 3.0.x
Changes

Changes to src/share/poudriere/common.sh.

   991    991   	local ret=0
   992    992   	local depfile
   993    993   	[ ! -d ${POUDRIERE_DATA}/packages/${MASTERNAME}/All ] && return $ret
   994    994   	dirempty ${POUDRIERE_DATA}/packages/${MASTERNAME}/All && return $ret
   995    995   	for pkg in ${POUDRIERE_DATA}/packages/${MASTERNAME}/All/*.${PKG_EXT}; do
   996    996   		# Check for non-empty directory with no packages in it
   997    997   		[ "${pkg}" = "${POUDRIERE_DATA}/packages/${MASTERNAME}/All/*.${PKG_EXT}" ] && break
   998         -		depfile=$(deps_file ${pkg})
          998  +		depfile="$(deps_file "${pkg}")"
   999    999   		while read dep; do
  1000   1000   			if [ ! -e "${POUDRIERE_DATA}/packages/${MASTERNAME}/All/${dep}.${PKG_EXT}" ]; then
  1001   1001   				ret=1
  1002   1002   				msg_debug "${pkg} needs missing ${POUDRIERE_DATA}/packages/${MASTERNAME}/All/${dep}.${PKG_EXT}"
  1003   1003   				msg "Deleting ${pkg##*/}: missing dependency: ${dep}"
  1004         -				delete_pkg ${pkg}
         1004  +				delete_pkg "${pkg}"
  1005   1005   				break
  1006   1006   			fi
  1007   1007   		done < "${depfile}"
  1008   1008   	done
  1009   1009   
  1010   1010   	return $ret
  1011   1011   }
................................................................................
  1839   1839   		tr '\n' ' ' | sed -e "s,[[:graph:]]*/usr/ports/,,g" \
  1840   1840   		-e "s,:[[:graph:]]*,,g" | \
  1841   1841   		sort -u || err 1 "Makefile broken: $1"
  1842   1842   }
  1843   1843   
  1844   1844   deps_file() {
  1845   1845   	[ $# -ne 1 ] && eargs pkg
  1846         -	local pkg=$1
  1847         -	local depfile=$(pkg_cache_dir ${pkg})/deps
         1846  +	local pkg="$1"
         1847  +	local depfile="$(pkg_cache_dir "${pkg}")/deps"
  1848   1848   
  1849   1849   	if [ ! -f "${depfile}" ]; then
  1850   1850   		if [ "${PKG_EXT}" = "tbz" ]; then
  1851   1851   			injail tar -qxf "/packages/All/${pkg##*/}" -O +CONTENTS | awk '$1 == "@pkgdep" { print $2 }' > "${depfile}"
  1852   1852   		else
  1853   1853   			injail /poudriere/pkg-static info -qdF "/packages/All/${pkg##*/}" > "${depfile}"
  1854   1854   		fi
................................................................................
  1855   1855   	fi
  1856   1856   
  1857   1857   	echo ${depfile}
  1858   1858   }
  1859   1859   
  1860   1860   pkg_get_origin() {
  1861   1861   	[ $# -lt 1 ] && eargs pkg
  1862         -	local pkg=$1
  1863         -	local originfile=$(pkg_cache_dir ${pkg})/origin
         1862  +	local pkg="$1"
         1863  +	local originfile="$(pkg_cache_dir "${pkg}")/origin"
  1864   1864   	local origin=$2
  1865   1865   
  1866   1866   	if [ ! -f "${originfile}" ]; then
  1867   1867   		if [ -z "${origin}" ]; then
  1868   1868   			if [ "${PKG_EXT}" = "tbz" ]; then
  1869   1869   				origin=$(injail tar -qxf "/packages/All/${pkg##*/}" -O +CONTENTS | \
  1870   1870   					awk -F: '$1 == "@comment ORIGIN" { print $2 }')
................................................................................
  1878   1878   		read origin < "${originfile}"
  1879   1879   	fi
  1880   1880   	echo ${origin}
  1881   1881   }
  1882   1882   
  1883   1883   pkg_get_dep_origin() {
  1884   1884   	[ $# -ne 1 ] && eargs pkg
  1885         -	local pkg=$1
  1886         -	local dep_origin_file=$(pkg_cache_dir ${pkg})/dep_origin
         1885  +	local pkg="$1"
         1886  +	local dep_origin_file="$(pkg_cache_dir "${pkg}")/dep_origin"
  1887   1887   	local compiled_dep_origins
  1888   1888   
  1889   1889   	if [ ! -f "${dep_origin_file}" ]; then
  1890   1890   		if [ "${PKG_EXT}" = "tbz" ]; then
  1891   1891   			compiled_dep_origins=$(injail tar -qxf "/packages/All/${pkg##*/}" -O +CONTENTS | \
  1892   1892   				awk -F: '$1 == "@comment DEPORIGIN" {print $2}' | tr '\n' ' ')
  1893   1893   		else
................................................................................
  1900   1900   	fi
  1901   1901   
  1902   1902   	cat "${dep_origin_file}"
  1903   1903   }
  1904   1904   
  1905   1905   pkg_get_options() {
  1906   1906   	[ $# -ne 1 ] && eargs pkg
  1907         -	local pkg=$1
  1908         -	local optionsfile=$(pkg_cache_dir ${pkg})/options
         1907  +	local pkg="$1"
         1908  +	local optionsfile="$(pkg_cache_dir "${pkg}")/options"
  1909   1909   	local compiled_options
  1910   1910   
  1911   1911   	if [ ! -f "${optionsfile}" ]; then
  1912   1912   		if [ "${PKG_EXT}" = "tbz" ]; then
  1913   1913   			compiled_options=$(injail tar -qxf "/packages/All/${pkg##*/}" -O +CONTENTS | \
  1914   1914   				awk -F: '$1 == "@comment OPTIONS" {print $2}' | tr ' ' '\n' | \
  1915   1915   				sed -n 's/^\+\(.*\)/\1/p' | sort | tr '\n' ' ')
................................................................................
  1925   1925   	cat "${optionsfile}"
  1926   1926   }
  1927   1927   
  1928   1928   pkg_cache_data() {
  1929   1929   	[ $# -ne 2 ] && eargs pkg origin
  1930   1930   	# Ignore errors in here
  1931   1931   	set +e
  1932         -	local pkg=$1
         1932  +	local pkg="$1"
  1933   1933   	local origin=$2
  1934         -	local cachedir=$(pkg_cache_dir ${pkg})
  1935         -	local originfile=${cachedir}/origin
         1934  +	local cachedir="$(pkg_cache_dir "${pkg}")"
         1935  +	local originfile="${cachedir}/origin"
  1936   1936   	local mnt=$(my_path)
  1937   1937   
  1938   1938   	if [ ${PKGNG} -eq 1 -a ! -x ${mnt}/poudriere/pkg-static ]; then
  1939   1939   		injail tar xf /packages/Latest/pkg.txz -C / \
  1940   1940   			-s ",/.*/,poudriere/,g" "*/pkg-static"
  1941   1941   	fi
  1942         -	mkdir -p $(pkg_cache_dir ${pkg})
  1943         -	pkg_get_options ${pkg} > /dev/null
  1944         -	pkg_get_origin ${pkg} ${origin} > /dev/null
  1945         -	pkg_get_dep_origin ${pkg} > /dev/null
  1946         -	deps_file ${pkg} > /dev/null
         1942  +	mkdir -p "$(pkg_cache_dir "${pkg}")"
         1943  +	pkg_get_options "${pkg}" > /dev/null
         1944  +	pkg_get_origin "${pkg}" ${origin} > /dev/null
         1945  +	pkg_get_dep_origin "${pkg}" > /dev/null
         1946  +	deps_file "${pkg}" > /dev/null
  1947   1947   	set -e
  1948   1948   }
  1949   1949   
  1950   1950   pkg_to_pkgname() {
  1951   1951   	[ $# -ne 1 ] && eargs pkg
  1952   1952   	local pkg=$1
  1953   1953   	local pkg_file=${pkg##*/}
................................................................................
  1959   1959   	echo ${POUDRIERE_DATA}/cache/${MASTERNAME}
  1960   1960   }
  1961   1961   
  1962   1962   # Return the cache dir for the given pkg
  1963   1963   # @param string pkg $PKGDIR/All/PKGNAME.PKG_EXT
  1964   1964   pkg_cache_dir() {
  1965   1965   	[ $# -ne 1 ] && eargs pkg
  1966         -	local pkg=$1
  1967         -	local pkg_file=${pkg##*/}
         1966  +	local pkg="$1"
         1967  +	local pkg_file="${pkg##*/}"
  1968   1968   
  1969   1969   	echo $(cache_dir)/${pkg_file}
  1970   1970   }
  1971   1971   
  1972   1972   clear_pkg_cache() {
  1973   1973   	[ $# -ne 1 ] && eargs pkg
  1974         -	local pkg=$1
         1974  +	local pkg="$1"
  1975   1975   
  1976         -	rm -fr $(pkg_cache_dir ${pkg})
         1976  +	rm -fr "$(pkg_cache_dir "${pkg}")"
  1977   1977   }
  1978   1978   
  1979   1979   delete_pkg() {
  1980   1980   	[ $# -ne 1 ] && eargs pkg
  1981         -	local pkg=$1
         1981  +	local pkg="$1"
  1982   1982   
  1983   1983   	# Delete the package and the depsfile since this package is being deleted,
  1984   1984   	# which will force it to be recreated
  1985   1985   	rm -f "${pkg}"
  1986         -	clear_pkg_cache ${pkg}
         1986  +	clear_pkg_cache "${pkg}"
  1987   1987   }
  1988   1988   
  1989   1989   # Deleted cached information for stale packages (manually removed)
  1990   1990   delete_stale_pkg_cache() {
  1991   1991   	local pkgname
  1992   1992   	local cachedir=$(cache_dir)
  1993   1993   	[ ! -d ${cachedir} ] && return 0
  1994   1994   	dirempty ${cachedir} && return 0
  1995   1995   	for pkg in ${cachedir}/*.${PKG_EXT}; do
  1996         -		pkg_file=${pkg##*/}
         1996  +		pkg_file="${pkg##*/}"
  1997   1997   		# If this package no longer exists in the PKGDIR, delete the cache.
  1998   1998   		[ ! -e "${POUDRIERE_DATA}/packages/${MASTERNAME}/All/${pkg_file}" ] &&
  1999         -			clear_pkg_cache ${pkg}
         1999  +			clear_pkg_cache "${pkg}"
  2000   2000   	done
  2001   2001   
  2002   2002   	return 0
  2003   2003   }
  2004   2004   
  2005   2005   delete_old_pkg() {
  2006   2006   	local pkg="$1"
  2007   2007   	local mnt=$(my_path)
  2008   2008   	local o v v2 compiled_options current_options current_deps compiled_deps
  2009   2009   	if [ "${pkg##*/}" = "repo.txz" ]; then
  2010   2010   		msg "Removing invalid pkg repo file: ${pkg}"
  2011         -		rm -f ${pkg}
         2011  +		rm -f "${pkg}"
  2012   2012   		return 0
  2013   2013   	fi
  2014   2014   
  2015         -	mkdir -p $(pkg_cache_dir ${pkg})
         2015  +	mkdir -p "$(pkg_cache_dir "${pkg}")"
  2016   2016   
  2017         -	o=$(pkg_get_origin ${pkg})
  2018         -	v=${pkg##*-}
         2017  +	o=$(pkg_get_origin "${pkg}")
         2018  +	v="${pkg##*-}"
  2019   2019   	v=${v%.*}
  2020   2020   	if [ ! -d "${mnt}/usr/ports/${o}" ]; then
  2021   2021   		msg "${o} does not exist anymore. Deleting stale ${pkg##*/}"
  2022         -		delete_pkg ${pkg}
         2022  +		delete_pkg "${pkg}"
  2023   2023   		return 0
  2024   2024   	fi
  2025   2025   	v2=$(cache_get_pkgname ${o})
  2026   2026   	v2=${v2##*-}
  2027   2027   	if [ "$v" != "$v2" ]; then
  2028   2028   		msg "Deleting old version: ${pkg##*/}"
  2029         -		delete_pkg ${pkg}
         2029  +		delete_pkg "${pkg}"
  2030   2030   		return 0
  2031   2031   	fi
  2032   2032   
  2033   2033   	# Detect ports that have new dependencies that the existing packages
  2034   2034   	# do not have and delete them.
  2035   2035   	if [ "${CHECK_CHANGED_DEPS:-yes}" != "no" ]; then
  2036   2036   		current_deps=$(injail make -C /usr/ports/${o} run-depends-list | \
  2037   2037   			sed 's,/usr/ports/,,g' | tr '\n' ' ')
  2038         -		compiled_deps=$(pkg_get_dep_origin ${pkg})
         2038  +		compiled_deps=$(pkg_get_dep_origin "${pkg}")
  2039   2039   		for d in ${current_deps}; do
  2040   2040   			case " $compiled_deps " in
  2041   2041   			*\ $d\ *) ;;
  2042   2042   			*)
  2043   2043   				msg "Deleting ${pkg##*/}: new dependency: ${d}"
  2044         -				delete_pkg ${pkg}
         2044  +				delete_pkg "${pkg}"
  2045   2045   				return 0
  2046   2046   				;;
  2047   2047   			esac
  2048   2048   		done
  2049   2049   	fi
  2050   2050   
  2051   2051   	# Check if the compiled options match the current options from make.conf and /var/db/options
  2052   2052   	if [ "${CHECK_CHANGED_OPTIONS:-verbose}" != "no" ]; then
  2053   2053   		current_options=$(injail make -C /usr/ports/${o} pretty-print-config | \
  2054   2054   			tr ' ' '\n' | sed -n 's/^\+\(.*\)/\1/p' | sort | tr '\n' ' ')
  2055         -		compiled_options=$(pkg_get_options ${pkg})
         2055  +		compiled_options=$(pkg_get_options "${pkg}")
  2056   2056   
  2057   2057   		if [ "${compiled_options}" != "${current_options}" ]; then
  2058   2058   			msg "Options changed, deleting: ${pkg##*/}"
  2059   2059   			if [ "${CHECK_CHANGED_OPTIONS}" = "verbose" ]; then
  2060   2060   				msg "Pkg: ${compiled_options}"
  2061   2061   				msg "New: ${current_options}"
  2062   2062   			fi
  2063         -			delete_pkg ${pkg}
         2063  +			delete_pkg "${pkg}"
  2064   2064   			return 0
  2065   2065   		fi
  2066   2066   	fi
  2067   2067   }
  2068   2068   
  2069   2069   delete_old_pkgs() {
  2070   2070   	[ ! -d ${POUDRIERE_DATA}/packages/${MASTERNAME}/All ] && return 0
................................................................................
  2345   2345   	bset status "sanity:"
  2346   2346   
  2347   2347   	if [ ${CLEAN_LISTED:-0} -eq 1 ]; then
  2348   2348   		listed_ports | while read port; do
  2349   2349   			pkg="${POUDRIERE_DATA}/packages/${MASTERNAME}/All/$(cache_get_pkgname ${port}).${PKG_EXT}"
  2350   2350   			if [ -f "${pkg}" ]; then
  2351   2351   				msg "Deleting existing package: ${pkg##*/}"
  2352         -				delete_pkg ${pkg}
         2352  +				delete_pkg "${pkg}"
  2353   2353   			fi
  2354   2354   		done
  2355   2355   	fi
  2356   2356   
  2357   2357   	# If the build dir already exists, it is being resumed and any
  2358   2358   	# packages already built/failed/skipped/ignored should not
  2359   2359   	# be rebuilt