Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 468380
Collapse All | Expand All

(-)a/gx86/eclass/eutils.eclass (-55 / +63 lines)
Lines 1458-1468 prune_libtool_files() { Link Here
1458
		local archivefile=${f/%.la/.a}
1458
		local archivefile=${f/%.la/.a}
1459
1459
1460
		[[ ${f} != ${archivefile} ]] || die 'regex sanity check failed'
1460
		[[ ${f} != ${archivefile} ]] || die 'regex sanity check failed'
1461
1462
		local reason pkgconfig_scanned
1461
		local reason pkgconfig_scanned
1462
		local snotlink=$(sed -n -e 's:^shouldnotlink=::p' "${f}")
1463
1464
		if [[ ${snotlink} == yes ]]; then
1463
1465
1464
		# Remove static libs we're not supposed to link against.
1466
			# Remove static libs we're not supposed to link against.
1465
		if grep -q '^shouldnotlink=yes$' "${f}"; then
1466
			if [[ -f ${archivefile} ]]; then
1467
			if [[ -f ${archivefile} ]]; then
1467
				einfo "Removing unnecessary ${archivefile#${D%/}} (static plugin)"
1468
				einfo "Removing unnecessary ${archivefile#${D%/}} (static plugin)"
1468
				queue+=( "${archivefile}" )
1469
				queue+=( "${archivefile}" )
Lines 1474-1535 prune_libtool_files() { Link Here
1474
				reason='module'
1475
				reason='module'
1475
			fi
1476
			fi
1476
1477
1477
		# Remove .la files when:
1478
		elif [[ ${snotlink} == no ]]; then
1478
		# - user explicitly wants us to remove all .la files,
1479
1479
		# - respective static archive doesn't exist,
1480
			# A valid .la file must have a valid 'shouldnotlink='.
1480
		# - they are covered by a .pc file already,
1481
			# That assumption helps us avoid removing random files
1481
		# - they don't provide any new information (no libs & no flags).
1482
			# which match '*.la', see bug #468380.
1482
1483
1483
		elif [[ ${removing_all} ]]; then
1484
			# Remove .la files when:
1484
			reason='requested'
1485
			# - user explicitly wants us to remove all .la files,
1485
		elif [[ ! -f ${archivefile} ]]; then
1486
			# - respective static archive doesn't exist,
1486
			reason='no static archive'
1487
			# - they are covered by a .pc file already,
1487
		elif [[ ! $(sed -nre \
1488
			# - they don't provide any new information (no libs & no flags).
1488
				"s/^(dependency_libs|inherited_linker_flags)='(.*)'$/\2/p" \
1489
1489
				"${f}") ]]; then
1490
			if [[ ${removing_all} ]]; then
1490
			reason='no libs & flags'
1491
				reason='requested'
1491
		else
1492
			elif [[ ! -f ${archivefile} ]]; then
1492
			if [[ ! ${pkgconfig_scanned} ]]; then
1493
				reason='no static archive'
1493
				# Create a list of all .pc-covered libs.
1494
			elif [[ ! $(sed -nre \
1494
				local pc_libs=()
1495
					"s/^(dependency_libs|inherited_linker_flags)='(.*)'$/\2/p" \
1495
				if [[ ! ${removing_all} ]]; then
1496
					"${f}") ]]; then
1496
					local pc
1497
				reason='no libs & flags'
1497
					local tf=${T}/prune-lt-files.pc
1498
			else
1498
					local pkgconf=$(tc-getPKG_CONFIG)
1499
				if [[ ! ${pkgconfig_scanned} ]]; then
1499
1500
					# Create a list of all .pc-covered libs.
1500
					while IFS= read -r -d '' pc; do # for all .pc files
1501
					local pc_libs=()
1501
						local arg libs
1502
					if [[ ! ${removing_all} ]]; then
1502
1503
						local pc
1503
						# Use pkg-config if available (and works),
1504
						local tf=${T}/prune-lt-files.pc
1504
						# fallback to sed.
1505
						local pkgconf=$(tc-getPKG_CONFIG)
1505
						if ${pkgconf} --exists "${pc}" &>/dev/null; then
1506
1506
							sed -e '/^Requires:/d' "${pc}" > "${tf}"
1507
						while IFS= read -r -d '' pc; do # for all .pc files
1507
							libs=$(${pkgconf} --libs "${tf}")
1508
							local arg libs
1508
						else
1509
1509
							libs=$(sed -ne 's/^Libs://p' "${pc}")
1510
							# Use pkg-config if available (and works),
1510
						fi
1511
							# fallback to sed.
1511
1512
							if ${pkgconf} --exists "${pc}" &>/dev/null; then
1512
						for arg in ${libs}; do
1513
								sed -e '/^Requires:/d' "${pc}" > "${tf}"
1513
							if [[ ${arg} == -l* ]]; then
1514
								libs=$(${pkgconf} --libs "${tf}")
1514
								if [[ ${arg} == '*$*' ]]; then
1515
							else
1515
									eqawarn "${FUNCNAME}: variable substitution likely failed in ${pc}"
1516
								libs=$(sed -ne 's/^Libs://p' "${pc}")
1516
									eqawarn "(arg: ${arg})"
1517
							fi
1517
									eqawarn "Most likely, you need to add virtual/pkgconfig to DEPEND."
1518
1519
							for arg in ${libs}; do
1520
								if [[ ${arg} == -l* ]]; then
1521
									if [[ ${arg} == '*$*' ]]; then
1522
										eqawarn "${FUNCNAME}: variable substitution likely failed in ${pc}"
1523
										eqawarn "(arg: ${arg})"
1524
										eqawarn "Most likely, you need to add virtual/pkgconfig to DEPEND."
1525
									fi
1526
1527
									pc_libs+=( lib${arg#-l}.la )
1518
								fi
1528
								fi
1529
							done
1530
						done < <(find "${D}" -type f -name '*.pc' -print0)
1519
1531
1520
								pc_libs+=( lib${arg#-l}.la )
1532
						rm -f "${tf}"
1521
							fi
1533
					fi
1522
						done
1523
					done < <(find "${D}" -type f -name '*.pc' -print0)
1524
1534
1525
					rm -f "${tf}"
1535
					pkgconfig_scanned=1
1526
				fi
1536
				fi # pkgconfig_scanned
1527
1537
1528
				pkgconfig_scanned=1
1538
				has "${f##*/}" "${pc_libs[@]}" && reason='covered by .pc'
1529
			fi
1539
			fi # removal due to .pc
1530
1540
1531
			has "${f##*/}" "${pc_libs[@]}" && reason='covered by .pc'
1541
		fi # shouldnotlink==no
1532
		fi
1533
1542
1534
		if [[ ${reason} ]]; then
1543
		if [[ ${reason} ]]; then
1535
			einfo "Removing unnecessary ${f#${D%/}} (${reason})"
1544
			einfo "Removing unnecessary ${f#${D%/}} (${reason})"
1536
- 

Return to bug 468380