mirror of
https://github.com/beard7n/bsdports.git
synced 2026-04-17 22:11:19 +02:00
create bsd12 branch
This commit is contained in:
74
Mk/Scripts/actual-package-depends.sh
Normal file
74
Mk/Scripts/actual-package-depends.sh
Normal file
@@ -0,0 +1,74 @@
|
||||
#!/bin/sh
|
||||
# MAINTAINER: portmgr@FeeeBSD.org
|
||||
# $FreeBSD: head/Mk/Scripts/actual-package-depends.sh 471274 2018-06-01 16:20:54Z mat $
|
||||
|
||||
[ -n "${DEBUG_MK_SCRIPTS}" -o -n "${DEBUG_MK_SCRIPTS_ACTUAL_PACKAGE_DEPENDS}" ] && set -x
|
||||
|
||||
if [ -z "${PKG_BIN}" ]; then
|
||||
echo "PKG_BIN required in environment." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
resolv_symlink() {
|
||||
local file tgt
|
||||
file=${1}
|
||||
if [ ! -L ${file} ] ; then
|
||||
echo ${file}
|
||||
return
|
||||
fi
|
||||
|
||||
tgt=$(readlink ${file})
|
||||
case $tgt in
|
||||
/*)
|
||||
echo $tgt
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
file=${file%/*}/${tgt}
|
||||
absolute_path ${file}
|
||||
}
|
||||
|
||||
absolute_path() {
|
||||
local file myifs target
|
||||
file=$1
|
||||
|
||||
myifs=${IFS}
|
||||
IFS='/'
|
||||
set -- ${file}
|
||||
IFS=${myifs}
|
||||
for el; do
|
||||
case $el in
|
||||
.) continue ;;
|
||||
'') continue ;;
|
||||
..) target=${target%/*} ;;
|
||||
*) target="${target}/${el}" ;;
|
||||
esac
|
||||
done
|
||||
echo ${target}
|
||||
}
|
||||
|
||||
find_dep() {
|
||||
pattern=$1
|
||||
case ${pattern} in
|
||||
*\>*|*\<*|*=*)
|
||||
${PKG_BIN} info -Eg "${pattern}" 2>/dev/null ||
|
||||
echo "actual-package-depends: dependency on ${pattern} not registered" >&2
|
||||
return
|
||||
;;
|
||||
/*)
|
||||
searchfile=$pattern
|
||||
;;
|
||||
*)
|
||||
searchfile=$(/usr/bin/which ${pattern} 2>/dev/null)
|
||||
;;
|
||||
esac
|
||||
if [ -n "${searchfile}" ]; then
|
||||
${PKG_BIN} which -q ${searchfile} || ${PKG_BIN} which -q "$(resolv_symlink ${searchfile} 2>/dev/null)" ||
|
||||
echo "actual-package-depends: dependency on ${searchfile} not registered (normal if it belongs to base)" >&2
|
||||
fi
|
||||
}
|
||||
|
||||
for lookup; do
|
||||
${PKG_BIN} query "\"%n\": {origin: \"%o\", version: \"%v\"}" "$(find_dep ${lookup})" || :
|
||||
done
|
||||
91
Mk/Scripts/cargo-crates.awk
Normal file
91
Mk/Scripts/cargo-crates.awk
Normal file
@@ -0,0 +1,91 @@
|
||||
# MAINTAINER: ports@FreeBSD.org
|
||||
# $FreeBSD: head/Mk/Scripts/cargo-crates.awk 446198 2017-07-19 14:00:16Z tobik $
|
||||
|
||||
BEGIN {
|
||||
gh_tuple_len = 0
|
||||
crates_len = 0
|
||||
package_name = "<unknown>"
|
||||
}
|
||||
|
||||
/^"checksum .* .* \(registry\+.*\)" = ".*"/ {
|
||||
# $2: crate
|
||||
# $3: version
|
||||
# $4: url
|
||||
# $6: checksum
|
||||
crates[crates_len++] = sprintf("%s-%s", $2, $3)
|
||||
}
|
||||
|
||||
/^name = ".*"/ {
|
||||
package_name = $3
|
||||
gsub("[^a-zA-Z_]", "", package_name)
|
||||
}
|
||||
|
||||
function split_url(s) {
|
||||
# scheme:[//[user[:password]@]host[:port]][/path][?query][#fragment]
|
||||
split(s, url_scheme, "://")
|
||||
url["scheme"] = url_scheme[1]
|
||||
|
||||
split(url_scheme[2], url_fragment, "#")
|
||||
url["fragment"] = url_fragment[2]
|
||||
|
||||
split(url_fragment[1], url_query, "?")
|
||||
url["query"] = url_query[2]
|
||||
|
||||
split(url_query[1], url_authority, "/")
|
||||
url["path"] = substr(url_query[1], length(url_authority[1]) + 1)
|
||||
|
||||
split(url_authority[1], url_auth, "@")
|
||||
|
||||
if (length(url_auth) == 2) {
|
||||
split(url_auth[1], url_user, ":")
|
||||
url["user"] = url_user[1]
|
||||
url["password"] = url_user[2]
|
||||
split(url_auth[2], url_host, ":")
|
||||
} else {
|
||||
url["user"] = ""
|
||||
url["password"] = ""
|
||||
split(url_auth[1], url_host, ":")
|
||||
}
|
||||
url["host"] = url_host[1]
|
||||
url["port"] = url_host[2]
|
||||
}
|
||||
|
||||
/^source = "git\+(https|http|git):\/\/github.com\/.*#.*"/ {
|
||||
split_url(substr($3, 1, length($3) - 1))
|
||||
|
||||
split(url["path"], path, "/")
|
||||
account = path[2]
|
||||
project = path[3]
|
||||
gsub("\.git$", "", project)
|
||||
|
||||
if (match(url["query"], "^tag=")) {
|
||||
split(url["query"], tag_, "=")
|
||||
tag = tag_[2]
|
||||
} else {
|
||||
tag = url["fragment"]
|
||||
}
|
||||
gh_tuple[gh_tuple_len++] = sprintf(\
|
||||
"%s:%s:%s:%s", account, project, tag, package_name)
|
||||
}
|
||||
|
||||
function print_array(start, arr, arrlen) {
|
||||
end = " \\\n"
|
||||
for (i = 0; i < arrlen; i++) {
|
||||
if (i == arrlen - 1) {
|
||||
end = "\n"
|
||||
}
|
||||
printf "%s\t%s%s", start, arr[i], end
|
||||
start = "\t"
|
||||
}
|
||||
}
|
||||
|
||||
END {
|
||||
if (gh_tuple_len > 0 && ENVIRON["USE_GITHUB"] == "") {
|
||||
printf "USE_GITHUB=\tnodefault\n"
|
||||
}
|
||||
print_array("GH_TUPLE=", gh_tuple, gh_tuple_len)
|
||||
print_array("CARGO_CRATES=", crates, crates_len)
|
||||
if (gh_tuple_len > 0) {
|
||||
printf "CARGO_USE_GITHUB=\tyes\n"
|
||||
}
|
||||
}
|
||||
111
Mk/Scripts/check-desktop-entries.sh
Normal file
111
Mk/Scripts/check-desktop-entries.sh
Normal file
@@ -0,0 +1,111 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD: head/Mk/Scripts/check-desktop-entries.sh 460160 2018-01-28 08:25:06Z mat $
|
||||
#
|
||||
# MAINTAINER: portmgr@FreeBSD.org
|
||||
|
||||
set -e
|
||||
|
||||
. "${dp_SCRIPTSDIR}/functions.sh"
|
||||
|
||||
validate_env dp_CURDIR dp_ECHO_CMD dp_ECHO_MSG dp_EXPR dp_GREP dp_PKGNAME \
|
||||
dp_SED dp_TR dp_MAKE
|
||||
|
||||
[ -n "${DEBUG_MK_SCRIPTS}" ] || [ -n "${DEBUG_MK_SCRIPTS_CHECK_DESKTOP_ENTRIES}" ] && set -x
|
||||
|
||||
set -u
|
||||
|
||||
# http://standards.freedesktop.org/menu-spec/menu-spec-latest.html
|
||||
DESKTOP_CATEGORIES_MAIN='AudioVideo Audio Video Development Education Game
|
||||
Graphics Network Office Science Settings System Utility'
|
||||
DESKTOP_CATEGORIES_ADDITIONAL='Building Debugger IDE GUIDesigner Profiling
|
||||
RevisionControl Translation Calendar ContactManagement Database Dictionary
|
||||
Chart Email Finance FlowChart PDA ProjectManagement Presentation Spreadsheet
|
||||
WordProcessor 2DGraphics VectorGraphics RasterGraphics 3DGraphics Scanning OCR
|
||||
Photography Publishing Viewer TextTools DesktopSettings HardwareSettings
|
||||
Printing PackageManager Dialup InstantMessaging Chat IRCClient Feed
|
||||
FileTransfer HamRadio News P2P RemoteAccess Telephony TelephonyTools
|
||||
VideoConference WebBrowser WebDevelopment Midi Mixer Sequencer Tuner TV
|
||||
AudioVideoEditing Player Recorder DiscBurning ActionGame AdventureGame
|
||||
ArcadeGame BoardGame BlocksGame CardGame KidsGame LogicGame RolePlaying Shooter
|
||||
Simulation SportsGame StrategyGame Art Construction Music Languages
|
||||
ArtificialIntelligence Astronomy Biology Chemistry ComputerScience
|
||||
DataVisualization Economy Electricity Geography Geology Geoscience History
|
||||
Humanities ImageProcessing Literature Maps Math NumericalAnalysis
|
||||
MedicalSoftware Physics Robotics Spirituality Sports ParallelComputing
|
||||
Amusement Archiving Compression Electronics Emulator Engineering FileTools
|
||||
FileManager TerminalEmulator Filesystem Monitor Security Accessibility
|
||||
Calculator Clock TextEditor Documentation Adult Core KDE GNOME MATE XFCE GTK Qt
|
||||
Motif Java ConsoleOnly'
|
||||
DESKTOP_CATEGORIES_RESERVED='Screensaver TrayIcon Applet Shell'
|
||||
|
||||
VALID_DESKTOP_CATEGORIES="${dp_VALID_DESKTOP_CATEGORIES} ${DESKTOP_CATEGORIES_MAIN} ${DESKTOP_CATEGORIES_ADDITIONAL} ${DESKTOP_CATEGORIES_RESERVED}"
|
||||
|
||||
if [ "$(${dp_EXPR} $# % 6)" -ne 0 ]; then
|
||||
${dp_ECHO_MSG} "${dp_PKGNAME}: Makefile error: the DESKTOP_ENTRIES list must contain one or more groups of 6 elements"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
num=0
|
||||
|
||||
while [ $# -ge 6 ]; do
|
||||
num=$(${dp_EXPR} ${num} + 1)
|
||||
entry="#${num}"
|
||||
|
||||
Name="${1}"
|
||||
#Comment="${2}" # Not Used
|
||||
Icon="${3}"
|
||||
Exec="${4}"
|
||||
Categories="${5}"
|
||||
StartupNotify="${6}"
|
||||
|
||||
shift 6
|
||||
|
||||
if [ -n "${Exec}" ]; then
|
||||
entry="${entry} (${Exec})"
|
||||
elif [ -n "${Name}" ]; then
|
||||
entry="${entry} (${Name})"
|
||||
fi
|
||||
|
||||
if [ -z "${Name}" ]; then
|
||||
${dp_ECHO_MSG} "${dp_PKGNAME}: Makefile error: in desktop entry ${entry}: field 1 (Name) is empty"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ${dp_EXPR} '(' "${Icon}" : '.*\.xpm$' ')' '|' '(' "${Icon}" : '.*\.png$' ')' '|' '(' "${Icon}" : '.*\.svg$' ')' > /dev/null; then
|
||||
if ! echo "${Icon}" | ${dp_GREP} -qe '^/' ; then
|
||||
${dp_ECHO_MSG} "${dp_PKGNAME}: Makefile warning: in desktop entry ${entry}: field 3 (Icon) should be either absolute path or icon name without extension if installed icons follow Icon Theme Specification"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "${Exec}" ]; then
|
||||
${dp_ECHO_MSG} "${dp_PKGNAME}: Makefile error: in desktop entry ${entry}: field 4 (Exec) is empty"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -n "${Categories}" ]; then
|
||||
for c in $(${dp_ECHO_CMD} "${Categories}" | ${dp_TR} ';' ' '); do
|
||||
if ! ${dp_ECHO_CMD} "${VALID_DESKTOP_CATEGORIES}" | ${dp_GREP} -wq "${c}"; then
|
||||
${dp_ECHO_CMD} "${dp_PKGNAME}: Makefile warning: in desktop entry ${entry}: category ${c} is not a valid desktop category"
|
||||
fi
|
||||
done
|
||||
|
||||
if ! ${dp_ECHO_CMD} "${Categories}" | ${dp_GREP} -Eq "$(${dp_ECHO_CMD} "${DESKTOP_CATEGORIES_MAIN}" | ${dp_SED} -E 's,[[:blank:]]+,\|,g')"; then
|
||||
${dp_ECHO_CMD} "${dp_PKGNAME}: Makefile warning: in desktop entry ${entry}: field 5 (Categories) must contain at least one main desktop category (make -VDESKTOP_CATEGORIES_MAIN)"
|
||||
fi
|
||||
|
||||
if ! ${dp_EXPR} "${Categories}" : '.*;$' > /dev/null; then
|
||||
${dp_ECHO_MSG} "${dp_PKGNAME}: Makefile error: in desktop entry ${entry}: field 5 (Categories) does not end with a semicolon"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
if [ -z "$(cd "${dp_CURDIR}" && ${dp_MAKE} desktop-categories)" ]; then
|
||||
${dp_ECHO_MSG} "${dp_PKGNAME}: Makefile error: in desktop entry ${entry}: field 5 (Categories) is empty and could not be deduced from the CATEGORIES variable"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${StartupNotify}" != "true" ] && [ "${StartupNotify}" != "false" ] && [ -n "${StartupNotify}" ]; then
|
||||
${dp_ECHO_MSG} "${dp_PKGNAME}: Makefile error: in desktop entry ${entry}: field 6 (StartupNotify) is not \"true\", \"false\" or \"\"(empty)"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
286
Mk/Scripts/check-stagedir.sh
Normal file
286
Mk/Scripts/check-stagedir.sh
Normal file
@@ -0,0 +1,286 @@
|
||||
#!/bin/sh
|
||||
# ports/Mk/Scripts/check-stagedir.sh - called from ports/Mk/bsd.stage.mk
|
||||
# $FreeBSD: head/Mk/Scripts/check-stagedir.sh 505130 2019-06-26 01:07:41Z bdrewery $
|
||||
#
|
||||
# MAINTAINER: portmgr@FreeBSD.org
|
||||
#
|
||||
# This script serves 2 purposes:
|
||||
# 1. Generate a plist
|
||||
# 2. Test a plist for issues:
|
||||
# a. Files in STAGEDIR that are missing from plist
|
||||
# b. Files in plist missing from STAGEDIR
|
||||
# c. Files in plist which are owned by dependencies/MTREEs
|
||||
|
||||
set -e
|
||||
|
||||
. ${SCRIPTSDIR}/functions.sh
|
||||
|
||||
# lists an mtree file's contents, prefixed to dir.
|
||||
listmtree() { # mtreefile prefix
|
||||
{
|
||||
echo '#mtree'
|
||||
sed 's/nochange$//;' $1
|
||||
} | tar -tf- | sed "s,^,$2/,;s,^$2/\.$,$2,;s,^$,/,"
|
||||
}
|
||||
|
||||
### PRODUCE MTREE FILE
|
||||
parse_mtree() {
|
||||
{
|
||||
listmtree /etc/mtree/BSD.root.dist ""
|
||||
listmtree /etc/mtree/BSD.usr.dist /usr
|
||||
listmtree /etc/mtree/BSD.var.dist /var
|
||||
|
||||
# Use MTREE_FILE if specified and it doesn't already
|
||||
# match LOCALBASE
|
||||
if [ -n "${MTREE_FILE}" ]; then
|
||||
if [ "${PREFIX}" != "${LOCALBASE}" -o "${MTREE_FILE}" \
|
||||
!= "${PORTSDIR}/Templates/BSD.local.dist" ]; then
|
||||
listmtree "${MTREE_FILE}" "${PREFIX}"
|
||||
fi
|
||||
fi
|
||||
listmtree "${PORTSDIR}/Templates/BSD.local.dist" "${LOCALBASE}"
|
||||
|
||||
unset MTREE_FILE
|
||||
|
||||
# Add LOCALBASE
|
||||
a=${LOCALBASE}
|
||||
while :; do
|
||||
echo ${a}
|
||||
a=${a%/*}
|
||||
[ -z "${a}" ] && break
|
||||
done
|
||||
|
||||
# Add in PREFIX if this port wants it
|
||||
if [ ${NO_PREFIX_RMDIR} -eq 0 ]; then
|
||||
a=${PREFIX}
|
||||
while :; do
|
||||
echo ${a}
|
||||
a=${a%/*}
|
||||
[ -z "${a}" ] && break
|
||||
done
|
||||
fi
|
||||
} >${WRKDIR}/.mtree
|
||||
}
|
||||
|
||||
# Sort a directory list by the order of the dfs-sorted file (from find -d -s)
|
||||
sort_dfs() {
|
||||
while read -r dir; do
|
||||
grep "^[0-9]* ${dir}$" ${WRKDIR}/.staged-dirs-dfs-sorted
|
||||
done | sort -n | cut -d ' ' -f2-
|
||||
}
|
||||
|
||||
# Prepare sed(1) regex for PLIST_SUB_SED/PORTEXAMPLES/OPTIONS/...
|
||||
setup_plist_seds() {
|
||||
### HANDLE PORTDOCS/PORTEXAMPLES
|
||||
sed_portdocsexamples="/%%DOCSDIR%%/s!^!%%PORTDOCS%%!g; /%%EXAMPLESDIR%%/s!^!%%PORTEXAMPLES%%!g;"
|
||||
if [ ${makeplist} -eq 0 ]; then
|
||||
# echo "=====> Using OPTIONS: ${PORT_OPTIONS}" | /usr/bin/fmt -w 79 | \
|
||||
# sed -e '2,$s/^/ /'
|
||||
# Handle magical PORT* features
|
||||
for option in DOCS EXAMPLES; do
|
||||
want_option=0
|
||||
case " ${PORT_OPTIONS} " in
|
||||
*\ ${option}\ *) want_option=1 ;;
|
||||
esac
|
||||
[ ${want_option} -eq 0 ] && \
|
||||
sed_portdocsexamples="${sed_portdocsexamples} /^%%PORT${option}%%/d;"
|
||||
done
|
||||
unset PORT_OPTIONS
|
||||
fi
|
||||
|
||||
sed_plist_sub=$(mktemp -t sed_plist_sub)
|
||||
# We only exit 0 or exit 1
|
||||
trap "rm -f ${sed_plist_sub}" EXIT 1
|
||||
echo "${PLIST_SUB_SED}" | /bin/sh ${SCRIPTSDIR}/plist_sub_sed_sort.sh ${sed_plist_sub}
|
||||
unset PLIST_SUB_SED
|
||||
# Used for generate_plist
|
||||
sed_files_gen="${sed_portdocsexamples} /^share\/licenses/d; \
|
||||
\#${LOCALBASE}/lib/debug#d;"
|
||||
sed_dirs_gen="s,^,@dir ,; \
|
||||
${sed_portdocsexamples} \
|
||||
/^@dir share\/licenses/d;"
|
||||
|
||||
# These prevent ignoring DOCS/EXAMPLES dirs with sed_portdocsexamples
|
||||
sed_files="/^share\/licenses/d; \
|
||||
\#${LOCALBASE}/lib/debug#d;"
|
||||
sed_dirs="s,^,@dir ,; \
|
||||
/^@dir share\/licenses/d;"
|
||||
|
||||
}
|
||||
|
||||
# Generate plist from staged files
|
||||
generate_plist() {
|
||||
: >${WRKDIR}/.staged-plist
|
||||
|
||||
### HANDLE FILES
|
||||
find ${STAGEDIR} -type f -o -type l | sort | \
|
||||
sed -e "s,${STAGEDIR},," >${WRKDIR}/.staged-files
|
||||
comm -13 ${WRKDIR}/.plist-files ${WRKDIR}/.staged-files | \
|
||||
sed -e "s!^${PREFIX}/!!g;" -f "${sed_plist_sub}" -e "${sed_files_gen}" \
|
||||
>>${WRKDIR}/.staged-plist || :
|
||||
|
||||
### HANDLE DIRS
|
||||
cat ${WRKDIR}/.plist-dirs-unsorted ${WRKDIR}/.mtree \
|
||||
| sort -u >${WRKDIR}/.traced-dirs
|
||||
find ${STAGEDIR} -type d | sed -e "s,^${STAGEDIR},,;/^$/d" | sort \
|
||||
>${WRKDIR}/.staged-dirrms-sorted
|
||||
find -s -d ${STAGEDIR}${PREFIX} -type d -empty | sed -e "s,^${STAGEDIR},,;\,^${PREFIX}$,d;/^$/d" \
|
||||
>${WRKDIR}/.staged-dirs-dfs
|
||||
find -s -d ${STAGEDIR} -type d ! -path "${STAGEDIR}${PREFIX}/*" | sed -e "s,^${STAGEDIR},,;\,^${PREFIX}$,d;/^$/d" \
|
||||
>>${WRKDIR}/.staged-dirs-dfs
|
||||
sort ${WRKDIR}/.staged-dirs-dfs >${WRKDIR}/.staged-dirs-sorted
|
||||
awk '{print FNR, $0}' ${WRKDIR}/.staged-dirs-dfs \
|
||||
>${WRKDIR}/.staged-dirs-dfs-sorted
|
||||
# Find all staged dirs and then sort them by depth-first (find -d -s)
|
||||
comm -13 ${WRKDIR}/.traced-dirs ${WRKDIR}/.staged-dirs-sorted \
|
||||
| sort_dfs | sed -e "s!^${PREFIX}/!!g;" -f "${sed_plist_sub}" -e "${sed_dirs_gen}" \
|
||||
>>${WRKDIR}/.staged-plist || :
|
||||
}
|
||||
|
||||
# Check for files in STAGEDIR missing from plist
|
||||
check_orphans_from_plist() {
|
||||
local ret=0
|
||||
|
||||
echo "===> Checking for items in STAGEDIR missing from pkg-plist"
|
||||
# Handle whitelisting
|
||||
while read -r path; do
|
||||
case "${path}" in
|
||||
*.bak) ;;
|
||||
*.orig) ;;
|
||||
*/.DS_Store) ;;
|
||||
*/.cvsignore) ;;
|
||||
*/.git/*|'@dir '*/.git) ;;
|
||||
*/.gitattributes|*/.gitignore|*/.gitmodules) ;;
|
||||
*/.svn/*|'@dir '*/.svn) ;;
|
||||
*/.svnignore) ;;
|
||||
*/CVS/*|'@dir '*/CVS) ;;
|
||||
*/info/dir|info/dir|info/*/dir|share/info/*/dir) ;;
|
||||
share/fonts/*/fonts.dir) ;;
|
||||
share/fonts/*/fonts.scale) ;;
|
||||
share/applications/mimeinfo.cache) ;;
|
||||
share/mime/XMLnamespaces) ;;
|
||||
share/mime/aliases) ;;
|
||||
share/mime/generic-icons) ;;
|
||||
share/mime/globs) ;;
|
||||
share/mime/globs2) ;;
|
||||
share/mime/icons) ;;
|
||||
share/mime/magic) ;;
|
||||
share/mime/mime.cache) ;;
|
||||
share/mime/subclasses) ;;
|
||||
share/mime/treemagic) ;;
|
||||
share/mime/types) ;;
|
||||
share/mime/version) ;;
|
||||
'@dir etc/gconf/gconf.xml.defaults');;
|
||||
*)
|
||||
# An orphan was found, return non-zero status
|
||||
ret=1
|
||||
echo "Error: Orphaned: ${path}" >&2
|
||||
;;
|
||||
esac
|
||||
done < ${WRKDIR}/.staged-plist
|
||||
return ${ret}
|
||||
}
|
||||
|
||||
# Check for items in plist not in STAGEDIR (pkg lstat(2) errors)
|
||||
check_missing_plist_items() {
|
||||
local ret=0
|
||||
echo "===> Checking for items in pkg-plist which are not in STAGEDIR"
|
||||
: >${WRKDIR}/.invalid-plist-missing
|
||||
comm -23 ${WRKDIR}/.plist-files-no-comments ${WRKDIR}/.staged-files | \
|
||||
sed -e "s!^${PREFIX}/!!g;" -f "${sed_plist_sub}" -e "${sed_files}" \
|
||||
>>${WRKDIR}/.invalid-plist-missing || :
|
||||
|
||||
# Look for directories, then sort them by DFS. Must create the dirs
|
||||
# so find -ds can be used to sort them.
|
||||
rm -rf ${WRKDIR}/.missing-dirs > /dev/null 2>&1 || :
|
||||
mkdir ${WRKDIR}/.missing-dirs
|
||||
comm -23 ${WRKDIR}/.plist-dirs-sorted-no-comments \
|
||||
${WRKDIR}/.staged-dirrms-sorted > ${WRKDIR}/.missing-plist-dirs
|
||||
# Creates the dirs in WRKDIR/.missing-dirs and ensure spaces are
|
||||
# quoted.
|
||||
sed -e "s,^,${WRKDIR}/.missing-dirs," \
|
||||
-e 's,^\(.*\)$,"\1",' \
|
||||
${WRKDIR}/.missing-plist-dirs | xargs mkdir -p
|
||||
find -d -s ${WRKDIR}/.missing-dirs | \
|
||||
sed -e "s,^${WRKDIR}/.missing-dirs,," | \
|
||||
while read -r dir; do \
|
||||
grep -x "${dir}" ${WRKDIR}/.missing-plist-dirs || :; done | \
|
||||
sed -e "s!^${PREFIX}/!!g;" -f "${sed_plist_sub}" -e "${sed_dirs}" \
|
||||
>>${WRKDIR}/.invalid-plist-missing || :
|
||||
rm -rf ${WRKDIR}/.missing-dirs
|
||||
if [ -s "${WRKDIR}/.invalid-plist-missing" ]; then
|
||||
ret=1
|
||||
while read -r line; do
|
||||
echo "Error: Missing: ${line}" >&2
|
||||
done < ${WRKDIR}/.invalid-plist-missing
|
||||
fi
|
||||
return ${ret}
|
||||
}
|
||||
|
||||
# obtain operating mode from command line
|
||||
ret=0
|
||||
makeplist=0
|
||||
case "$1" in
|
||||
checkplist) ;;
|
||||
makeplist) makeplist=1 ;;
|
||||
*) echo >&2 "Usage: $0 {checkplist|makeplist}" ; exit 1 ;;
|
||||
esac
|
||||
|
||||
# validate environment
|
||||
validate_env STAGEDIR PREFIX LOCALBASE WRKDIR WRKSRC MTREE_FILE \
|
||||
TMPPLIST PLIST_SUB_SED SCRIPTSDIR PORT_OPTIONS NO_PREFIX_RMDIR
|
||||
|
||||
[ -n "${DEBUG_MK_SCRIPTS}" -o -n "${DEBUG_MK_SCRIPTS_CHECK_STAGEDIR}" ] && set -x
|
||||
|
||||
set -u
|
||||
|
||||
if [ $makeplist = 0 ] ; then
|
||||
echo "===> Parsing plist"
|
||||
parse_plist "${PREFIX}" 1 < ${TMPPLIST} \
|
||||
3>${WRKDIR}/.plist-dirs-unsorted \
|
||||
>${WRKDIR}/.plist-files-unsorted
|
||||
unset TMPPLIST
|
||||
# Create the -no-comments files and trim out @comment from the plists.
|
||||
# This is used for various tests later.
|
||||
sed -e '/^@comment/d' ${WRKDIR}/.plist-dirs-unsorted \
|
||||
>${WRKDIR}/.plist-dirs-unsorted-no-comments
|
||||
sed -i '' -e 's/^@comment //' ${WRKDIR}/.plist-dirs-unsorted
|
||||
sed -e '/^@comment/d' ${WRKDIR}/.plist-files-unsorted | sort \
|
||||
>${WRKDIR}/.plist-files-no-comments
|
||||
sed -e 's/^@comment //' ${WRKDIR}/.plist-files-unsorted | sort \
|
||||
>${WRKDIR}/.plist-files
|
||||
else
|
||||
# generate plist - pretend the plist had been empty
|
||||
: >${WRKDIR}/.plist-dirs-unsorted
|
||||
: >${WRKDIR}/.plist-files
|
||||
echo '/you/have/to/check/what/makeplist/gives/you'
|
||||
fi
|
||||
|
||||
parse_mtree
|
||||
|
||||
setup_plist_seds
|
||||
generate_plist
|
||||
|
||||
# If just making plist, show results and exit successfully.
|
||||
if [ ${makeplist} -eq 1 ]; then
|
||||
cat ${WRKDIR}/.staged-plist
|
||||
exit 0
|
||||
fi
|
||||
|
||||
check_orphans_from_plist || ret=1
|
||||
|
||||
# Prepare plist-dirs for directory checks
|
||||
sort -u ${WRKDIR}/.plist-dirs-unsorted-no-comments \
|
||||
>${WRKDIR}/.plist-dirs-sorted-no-comments
|
||||
|
||||
check_missing_plist_items || ret=1
|
||||
|
||||
if [ ${ret} -ne 0 ]; then
|
||||
echo "===> Error: Plist issues found." >&2
|
||||
if [ "${PREFIX}" != "${LOCALBASE}" ]; then
|
||||
echo "===> Warning: Test was done with PREFIX != LOCALBASE"
|
||||
echo "===> Warning: The port may not be properly installing into PREFIX"
|
||||
fi
|
||||
fi
|
||||
|
||||
exit ${ret}
|
||||
34
Mk/Scripts/check-vulnerable.sh
Normal file
34
Mk/Scripts/check-vulnerable.sh
Normal file
@@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD: head/Mk/Scripts/check-vulnerable.sh 502793 2019-05-27 13:02:05Z bapt $
|
||||
#
|
||||
# MAINTAINER: portmgr@FreeBSD.org
|
||||
|
||||
set -e
|
||||
|
||||
. "${dp_SCRIPTSDIR}/functions.sh"
|
||||
|
||||
validate_env dp_ECHO_MSG dp_PKG_BIN dp_PORTNAME dp_PKGNAME
|
||||
|
||||
[ -n "${DEBUG_MK_SCRIPTS}" -o -n "${DEBUG_MK_SCRIPTS_CHECK_VULNERABLE}" ] && set -x
|
||||
|
||||
set -u
|
||||
|
||||
# If the package is pkg, disable these checks, it fails while
|
||||
# upgrading when pkg is not there.
|
||||
# FIXME: check is this is still true
|
||||
if [ "${dp_PORTNAME}" = "pkg" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ ! -x "${dp_PKG_BIN}" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! vlist=$(${dp_PKG_BIN} audit "${dp_PKGNAME}"); then
|
||||
${dp_ECHO_MSG} "===> ${dp_PKGNAME} has known vulnerabilities:"
|
||||
${dp_ECHO_MSG} "$vlist"
|
||||
${dp_ECHO_MSG} "=> Please update your ports tree and try again."
|
||||
${dp_ECHO_MSG} "=> Note: Vulnerable ports are marked as such even if there is no update available."
|
||||
${dp_ECHO_MSG} "=> If you wish to ignore this vulnerability rebuild with 'make DISABLE_VULNERABILITIES=yes'"
|
||||
exit 1
|
||||
fi
|
||||
176
Mk/Scripts/check_leftovers.sh
Normal file
176
Mk/Scripts/check_leftovers.sh
Normal file
@@ -0,0 +1,176 @@
|
||||
#! /bin/sh
|
||||
# $FreeBSD: head/Mk/Scripts/check_leftovers.sh 495190 2019-03-09 18:38:18Z bdrewery $
|
||||
#
|
||||
# MAINTAINER: portmgr@FreeBSD.org
|
||||
#
|
||||
# This script is used by poudriere and tinderbox(soon) as the source-of-truth for
|
||||
# what should be considered a leftover and what is whitelisted.
|
||||
#
|
||||
# !!!! This script's input/output format must remain backwards-compatible.
|
||||
# !!!! If you want to change it, create a new script and have the calling
|
||||
# !!!! scripts use the new one if available.
|
||||
#
|
||||
# Usage: env PORTSDIR=... check_leftovers.sh category/port
|
||||
# stdin:
|
||||
# - missing-file
|
||||
# + new-file
|
||||
# M modified-file reason...
|
||||
#
|
||||
# stdout:
|
||||
# same -/+/M format, but with files substituted, without approved
|
||||
# whitelisted files, and hides any directories already in plist.
|
||||
#
|
||||
# The PLIST_SUB feature can be disabled by setting PLIST_SUB_SED=
|
||||
# in environment.
|
||||
|
||||
[ -n "${DEBUG_MK_SCRIPTS}" -o -n "${DEBUG_MK_SCRIPTS_CHECK_LEFTOVERS}" ] && set -x
|
||||
|
||||
origin="$1"
|
||||
[ $# -eq 1 ] || { echo "Must supply ORIGIN as parameter" >&2; exit 1; }
|
||||
[ -n "${PORTSDIR}" ] || { echo "PORTSDIR must be set" >&2; exit 1; }
|
||||
|
||||
portdir="${PORTSDIR}/${origin}"
|
||||
|
||||
# PREFIX/LOCALBASE may be set in env or want default from port.
|
||||
if [ -n "${PREFIX}" ]; then
|
||||
PORT_FLAGS="${PORT_FLAGS} PREFIX=${PREFIX}"
|
||||
else
|
||||
PREFIX=$(make -C ${portdir} -VPREFIX)
|
||||
fi
|
||||
if [ -n "${LOCALBASE}" ]; then
|
||||
PORT_FLAGS="${PORT_FLAGS} LOCALBASE=${LOCALBASE}"
|
||||
else
|
||||
LOCALBASE=$(make -C ${portdir} -VLOCALBASE)
|
||||
fi
|
||||
if [ -z "${CCACHE_DIR}" ]; then
|
||||
CCACHE_DIR=$(make -C ${portdir} -VCCACHE_DIR)
|
||||
fi
|
||||
if [ -z "${UID_FILES}" ]; then
|
||||
UID_FILES=$(make -C ${portdir} -VUID_FILES)
|
||||
fi
|
||||
homedirs=$(awk -F: -v users="$(make -C ${portdir} -V USERS|sed -e 's, ,|,g;/^$/d;s,^,^(,;s,$,)$,')" 'users && $1 ~ users {print $9}' ${UID_FILES}|sort -u|sed -e "s|/usr/local|${PREFIX}|"|tr "\n" " ")
|
||||
plistsub_sed=$(mktemp -t plistsub_sed)
|
||||
trap "rm -f ${plistsub_sed}" EXIT 1
|
||||
make -C ${portdir} -VPLIST_SUB_SED | /bin/sh ${PORTSDIR}/Mk/Scripts/plist_sub_sed_sort.sh ${plistsub_sed}
|
||||
tmpplist=$(make -C ${portdir} -VTMPPLIST)
|
||||
|
||||
while read -r modtype path extra; do
|
||||
# Ignore everything from these files/directories
|
||||
case "${path}" in
|
||||
${CCACHE_DIR:-/nonexistent}/*|\
|
||||
/compat/linux/proc/*|\
|
||||
/dev/*|\
|
||||
/etc/make.conf.bak|\
|
||||
/proc/*|\
|
||||
/tmp/*|\
|
||||
/var/db/pkg/*|\
|
||||
/var/db/ports/*|\
|
||||
/var/log/*|\
|
||||
/var/mail/*|\
|
||||
/var/run/*|\
|
||||
/var/tmp/*) continue ;;
|
||||
# fc-cache - skip for now
|
||||
/var/db/fontconfig/*) continue ;;
|
||||
esac
|
||||
|
||||
ignore_path=0
|
||||
sub_path=$(echo "$path" | sed -e "s|^${PREFIX}/||" -f "${plistsub_sed}")
|
||||
orig_sub_path="${sub_path}"
|
||||
# If this is a directory, use @dir in output
|
||||
is_dir=0
|
||||
if [ -d "${path}" ]; then
|
||||
is_dir=1
|
||||
sub_path="@dir ${sub_path}"
|
||||
fi
|
||||
|
||||
# Handle PORTDOCS/PORTEXAMPLES/etc
|
||||
case "${orig_sub_path}" in
|
||||
%%DOCSDIR%%*) sub_path="%%PORTDOCS%%${sub_path}" ;;
|
||||
%%EXAMPLESDIR%%*) sub_path="%%PORTEXAMPLES%%${sub_path}" ;;
|
||||
esac
|
||||
|
||||
case $modtype in
|
||||
+)
|
||||
if [ ${is_dir} -eq 1 ]; then
|
||||
# home directory of users created
|
||||
case " ${homedirs} " in
|
||||
*\ ${path}\ *) continue ;;
|
||||
*\ ${path}/*\ *) continue ;;
|
||||
esac
|
||||
# Don't show dirs already in plist (due to parents)
|
||||
grep -qE \
|
||||
"^@(unexec rmdir \"?(%D/|${PREFIX})?${path#${PREFIX}/}[ \"]|dir(rm|rmtry)? ${path#${PREFIX}/}\$)" \
|
||||
${tmpplist} && continue
|
||||
fi
|
||||
|
||||
# Check absolute paths
|
||||
case "${path}" in
|
||||
# Leave qmail's queue dir alone to not cause lost mail
|
||||
# during upgrades, just as /var/mail is left alone.
|
||||
/var/qmail/queue/*|/var/qmail/queue) continue ;;
|
||||
esac
|
||||
|
||||
# Check relative/plist paths
|
||||
case "${sub_path}" in
|
||||
# gconftool-2 --makefile-uninstall-rule is unpredictable
|
||||
etc/gconf/gconf.xml.defaults/%gconf-tree*.xml) ;;
|
||||
*) echo "+ ${sub_path}" ;;
|
||||
esac
|
||||
;;
|
||||
-)
|
||||
# Skip removal of PREFIX and PREFIX/info from
|
||||
# bsd.port.mk for now.
|
||||
# Skip if it is PREFIX and non-LOCALBASE. See misc/kdehier4
|
||||
# or mail/qmail for examples
|
||||
[ "${path}" = "${PREFIX}" -a "${LOCALBASE}" != "${PREFIX}" ] &&
|
||||
ignore_path=1
|
||||
|
||||
# The removal of info may be a bug; it's part of BSD.local.dist.
|
||||
# See ports/74691
|
||||
|
||||
[ "${sub_path}" = "info" -a "${LOCALBASE}" != "${PREFIX}" ] &&
|
||||
ignore_path=1
|
||||
|
||||
[ $ignore_path -eq 0 ] && echo "- ${sub_path}"
|
||||
;;
|
||||
M)
|
||||
# Check relative/plist paths
|
||||
case "${sub_path}" in
|
||||
# gconftool-2 --makefile-uninstall-rule is unpredictable
|
||||
etc/gconf/gconf.xml.defaults/%gconf-tree*.xml) ;;
|
||||
# This is a cache file for gio modules could be modified
|
||||
# for any gio modules
|
||||
lib/gio/modules/giomodule.cache) ;;
|
||||
# removal of info files leaves entry uneasy to cleanup
|
||||
# in info/dir
|
||||
info/dir) ;;
|
||||
*/info/dir) ;;
|
||||
# The is pear database cache
|
||||
%%PEARDIR%%/.depdb|%%PEARDIR%%/.filemap) ;;
|
||||
#ls-R files from texmf are often regenerated
|
||||
*/ls-R) ;;
|
||||
# Octave packages database, blank lines can be inserted
|
||||
# between pre-install and post-deinstall
|
||||
share/octave/octave_packages) ;;
|
||||
# xmlcatmgr is constantly updating catalog.ports ignore
|
||||
# modification to that file
|
||||
share/xml/catalog.ports) ;;
|
||||
# Ignore ghc's doc index
|
||||
share/doc/ghc-%%GHC_VERSION%%/*) ;;
|
||||
# Ignore ghc's package conf
|
||||
lib/ghc-%%GHC_VERSION%%/package.conf.d/*) ;;
|
||||
# Ignore common system config files
|
||||
/etc/group|\
|
||||
/etc/make.conf|\
|
||||
/etc/master.passwd|\
|
||||
/etc/passwd|\
|
||||
/etc/pwd.db|\
|
||||
/etc/shells|\
|
||||
/etc/spwd.db) ;;
|
||||
*) echo "M ${sub_path#@dir } ${extra}" ;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
exit 0
|
||||
93
Mk/Scripts/checksum.sh
Normal file
93
Mk/Scripts/checksum.sh
Normal file
@@ -0,0 +1,93 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD: head/Mk/Scripts/checksum.sh 471267 2018-06-01 16:20:33Z mat $
|
||||
#
|
||||
# MAINTAINER: portmgr@FreeBSD.org
|
||||
|
||||
set -e
|
||||
|
||||
. "${dp_SCRIPTSDIR}/functions.sh"
|
||||
|
||||
validate_env dp_CHECKSUM_ALGORITHMS dp_CURDIR dp_DISTDIR dp_DISTINFO_FILE \
|
||||
dp_DIST_SUBDIR dp_ECHO_MSG dp_FETCH_REGET dp_MAKE dp_MAKEFLAGS \
|
||||
dp_DISABLE_SIZE dp_NO_CHECKSUM
|
||||
|
||||
[ -n "${DEBUG_MK_SCRIPTS}" -o -n "${DEBUG_MK_SCRIPTS_CHECKSUM}" ] && set -x
|
||||
|
||||
set -u
|
||||
|
||||
check_checksum_algorithms
|
||||
|
||||
if [ -f "${dp_DISTINFO_FILE}" ]; then
|
||||
cd "${dp_DISTDIR}"
|
||||
OK=
|
||||
refetchlist=
|
||||
for file in "${@}"; do
|
||||
ignored="true"
|
||||
for alg in ${dp_CHECKSUM_ALGORITHMS}; do
|
||||
ignore="false"
|
||||
eval "alg_executable=\$dp_${alg}"
|
||||
|
||||
if [ "$alg_executable" != "NO" ]; then
|
||||
MKSUM=$($alg_executable < "${file}")
|
||||
CKSUM=$(distinfo_data "${alg}" "${file}")
|
||||
else
|
||||
ignore="true"
|
||||
fi
|
||||
|
||||
if [ $ignore = "false" -a -z "$CKSUM" ]; then
|
||||
${dp_ECHO_MSG} "=> No $alg checksum recorded for $file."
|
||||
ignore="true"
|
||||
fi
|
||||
|
||||
if [ $ignore != "false" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
match="false"
|
||||
for chksum in $CKSUM; do
|
||||
if [ "$chksum" = "$MKSUM" ]; then
|
||||
match="true"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ $match = "true" ]; then
|
||||
${dp_ECHO_MSG} "=> $alg Checksum OK for $file."
|
||||
ignored="false"
|
||||
else
|
||||
${dp_ECHO_MSG} "=> $alg Checksum mismatch for $file."
|
||||
refetchlist="$refetchlist $file "
|
||||
OK="${OK:-retry}"
|
||||
[ "${OK}" = "retry" -a "${dp_FETCH_REGET}" -gt 0 ] && rm -f "${file}"
|
||||
ignored="false"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $ignored = "true" ]; then
|
||||
${dp_ECHO_MSG} "=> No suitable checksum found for $file."
|
||||
OK=false
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "${OK:=true}" = "retry" ] && [ "${dp_FETCH_REGET}" -gt 0 ]; then
|
||||
${dp_ECHO_MSG} "===> Refetch for ${dp_FETCH_REGET} more times files: $refetchlist"
|
||||
if ${dp_MAKE} -C "${dp_CURDIR}" ${dp_MAKEFLAGS} FORCE_FETCH_LIST="$refetchlist" FETCH_REGET="$((dp_FETCH_REGET - 1))" fetch; then
|
||||
if ${dp_MAKE} -C "${dp_CURDIR}" ${dp_MAKEFLAGS} FETCH_REGET="$((dp_FETCH_REGET - 1))" checksum ; then
|
||||
OK="true"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$OK" != "true" -a "${dp_FETCH_REGET}" -eq 0 ]; then
|
||||
${dp_ECHO_MSG} "===> Giving up on fetching files: $refetchlist"
|
||||
${dp_ECHO_MSG} "Make sure the Makefile and distinfo file (${dp_DISTINFO_FILE})"
|
||||
${dp_ECHO_MSG} "are up to date. If you are absolutely sure you want to override this"
|
||||
${dp_ECHO_MSG} "check, type \"make NO_CHECKSUM=yes [other args]\"."
|
||||
exit 1
|
||||
fi
|
||||
if [ "$OK" != "true" ]; then
|
||||
exit 1
|
||||
fi
|
||||
elif [ -n "${*}" ]; then
|
||||
${dp_ECHO_MSG} "=> No checksum file (${dp_DISTINFO_FILE})."
|
||||
exit 1
|
||||
fi
|
||||
168
Mk/Scripts/create-manifest.sh
Normal file
168
Mk/Scripts/create-manifest.sh
Normal file
@@ -0,0 +1,168 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD: head/Mk/Scripts/create-manifest.sh 503385 2019-06-03 12:57:44Z mat $
|
||||
#
|
||||
# MAINTAINER: portmgr@FreeBSD.org
|
||||
|
||||
set -e
|
||||
|
||||
. "${dp_SCRIPTSDIR}/functions.sh"
|
||||
|
||||
validate_env dp_ACTUAL_PACKAGE_DEPENDS dp_CATEGORIES dp_COMMENT \
|
||||
dp_COMPLETE_OPTIONS_LIST dp_DEPRECATED dp_DESCR dp_EXPIRATION_DATE \
|
||||
dp_GROUPS dp_LICENSE dp_LICENSE_COMB dp_MAINTAINER dp_METADIR \
|
||||
dp_NO_ARCH dp_PKGBASE dp_PKGDEINSTALL dp_PKGINSTALL dp_PKGMESSAGES \
|
||||
dp_PKGORIGIN dp_PKGPOSTDEINSTALL dp_PKGPOSTINSTALL dp_PKGPOSTUPGRADE \
|
||||
dp_PKGPREDEINSTALL dp_PKGPREINSTALL dp_PKGPREUPGRADE dp_PKGUPGRADE \
|
||||
dp_PKGVERSION dp_PKG_BIN dp_PKG_IGNORE_DEPENDS dp_PKG_NOTES \
|
||||
dp_PORT_OPTIONS dp_PREFIX dp_USERS dp_WWW
|
||||
|
||||
[ -n "${DEBUG_MK_SCRIPTS}" -o -n "${DEBUG_MK_SCRIPTS_CREATE_MANIFEST}" ] && set -x
|
||||
|
||||
set -u
|
||||
|
||||
listcontains() {
|
||||
local str lst elt
|
||||
str=$1
|
||||
lst=$2
|
||||
|
||||
for elt in ${lst} ; do
|
||||
if [ ${elt} = ${str} ]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
mkdir -p ${dp_METADIR}
|
||||
|
||||
# Save stdout and redirect it to the manifest file.
|
||||
exec 3>&1 >${dp_METADIR}/+MANIFEST
|
||||
|
||||
# First, all the required bits
|
||||
cat <<EOT
|
||||
name: "${dp_PKGBASE}"
|
||||
version: "${dp_PKGVERSION}"
|
||||
origin: ${dp_PKGORIGIN}
|
||||
comment: <<EOD
|
||||
${dp_COMMENT}
|
||||
EOD
|
||||
maintainer: ${dp_MAINTAINER}
|
||||
prefix: ${dp_PREFIX}
|
||||
categories: [ ${dp_CATEGORIES} ]
|
||||
licenselogic: ${dp_LICENSE_COMB:-single}
|
||||
EOT
|
||||
|
||||
# Then, the optional bits
|
||||
[ -z "${dp_WWW}" ] || echo "www: ${dp_WWW}"
|
||||
[ -z "${dp_LICENSE}" ] || echo "licenses: [ ${dp_LICENSE} ]"
|
||||
[ -z "${dp_USERS}" ] || echo "users: [ ${dp_USERS} ]"
|
||||
[ -z "${dp_GROUPS}" ] || echo "groups: [ ${dp_GROUPS} ]"
|
||||
[ -n "${dp_NO_ARCH}" ] && echo "arch : $(${dp_PKG_BIN} config abi | tr '[:upper:]' '[:lower:]' | cut -d: -f1,2):*"
|
||||
[ -n "${dp_NO_ARCH}" ] && echo "abi : $(${dp_PKG_BIN} config abi | cut -d: -f1,2):*"
|
||||
|
||||
# Then the key/values sections
|
||||
echo "deps: { "
|
||||
eval ${dp_ACTUAL_PACKAGE_DEPENDS} | grep -v -E ${dp_PKG_IGNORE_DEPENDS} | sort -u
|
||||
echo "}"
|
||||
|
||||
echo "options: {"
|
||||
for opt in ${dp_COMPLETE_OPTIONS_LIST}; do
|
||||
if listcontains ${opt} "${dp_PORT_OPTIONS}"; then
|
||||
echo " ${opt}: on,"
|
||||
else
|
||||
echo " ${opt}: off,"
|
||||
fi
|
||||
done
|
||||
echo "}"
|
||||
|
||||
if [ -n "${dp_PKG_NOTES}" ]; then
|
||||
echo "annotations: {"
|
||||
for note in ${dp_PKG_NOTES}; do
|
||||
echo " ${note}: <<EOD"
|
||||
eval "echo \"\${dp_PKG_NOTE_${note}}\""
|
||||
echo "EOD"
|
||||
done
|
||||
echo "}"
|
||||
fi
|
||||
|
||||
# Copy the pkg-descr file
|
||||
cp ${dp_DESCR} ${dp_METADIR}/+DESC
|
||||
|
||||
# Concatenate all the scripts
|
||||
output_files=
|
||||
for stage in INSTALL DEINSTALL UPGRADE; do
|
||||
for prepost in '' PRE POST; do
|
||||
output=${dp_METADIR}/+${prepost:+${prepost}_}${stage}
|
||||
[ -f "${output}" ] && output_files="${output_files:+${output_files} }${output}"
|
||||
done
|
||||
done
|
||||
[ -n "${output_files}" ] && rm -f ${output_files}
|
||||
|
||||
for stage in INSTALL DEINSTALL UPGRADE; do
|
||||
for prepost in '' PRE POST; do
|
||||
eval files="\${dp_PKG${prepost}${stage}}"
|
||||
output=${dp_METADIR}/+${prepost:+${prepost}_}${stage}
|
||||
for input in ${files}; do
|
||||
[ -f "${input}" ] && cat ${input} >> ${output}
|
||||
done
|
||||
done
|
||||
done
|
||||
|
||||
# *** STARTING NOW, STDOUT is +DISPLAY ***
|
||||
|
||||
exec >${dp_METADIR}/+DISPLAY
|
||||
|
||||
echo '['
|
||||
for message in ${dp_PKGMESSAGES}; do
|
||||
if [ -f "${message}" ]; then
|
||||
#if if starts with [ then it is ucl and we do drop last and first line
|
||||
if head -1 "${message}" | grep -q '^\['; then
|
||||
sed '1d;$d' "${message}"
|
||||
else
|
||||
echo '{message=<<EOD'
|
||||
cat "${message}"
|
||||
printf 'EOD\n},\n'
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Try and keep these messages in sync with check-deprecated
|
||||
if [ ${dp_MAINTAINER} = "ports@FreeBSD.org" ]; then
|
||||
cat <<-EOT
|
||||
{ message=<<EOD
|
||||
===> NOTICE:
|
||||
|
||||
The ${dp_PKGBASE} port currently does not have a maintainer. As a result, it is
|
||||
more likely to have unresolved issues, not be up-to-date, or even be removed in
|
||||
the future. To volunteer to maintain this port, please create an issue at:
|
||||
|
||||
https://bugs.freebsd.org/bugzilla
|
||||
|
||||
More information about port maintainership is available at:
|
||||
|
||||
https://www.freebsd.org/doc/en/articles/contributing/ports-contributing.html#maintain-port
|
||||
EOD
|
||||
},
|
||||
EOT
|
||||
fi
|
||||
|
||||
if [ -n "${dp_DEPRECATED}" ]; then
|
||||
cat <<-EOT
|
||||
{ message=<<EOD
|
||||
===> NOTICE:
|
||||
|
||||
This port is deprecated; you may wish to reconsider installing it:
|
||||
|
||||
${dp_DEPRECATED}.
|
||||
|
||||
EOT
|
||||
|
||||
if [ -n "${dp_EXPIRATION_DATE}" ]; then
|
||||
cat <<-EOT
|
||||
It is scheduled to be removed on or after ${dp_EXPIRATION_DATE}.
|
||||
|
||||
EOT
|
||||
fi
|
||||
printf 'EOD\n},\n'
|
||||
fi
|
||||
echo ']'
|
||||
132
Mk/Scripts/depends-list.sh
Normal file
132
Mk/Scripts/depends-list.sh
Normal file
@@ -0,0 +1,132 @@
|
||||
#!/bin/sh
|
||||
# MAINTAINER: portmgr@FreeBSD.org
|
||||
# $FreeBSD: head/Mk/Scripts/depends-list.sh 471988 2018-06-08 09:26:20Z mat $
|
||||
|
||||
set -e
|
||||
|
||||
. ${dp_SCRIPTSDIR}/functions.sh
|
||||
|
||||
flavors=0
|
||||
recursive=0
|
||||
missing=0
|
||||
requires_wrkdir=0
|
||||
while getopts "fmrw" FLAG; do
|
||||
case "${FLAG}" in
|
||||
f)
|
||||
flavors=1
|
||||
;;
|
||||
m)
|
||||
missing=1
|
||||
recursive=1
|
||||
;;
|
||||
r)
|
||||
recursive=1
|
||||
;;
|
||||
w)
|
||||
# Only list dependencies that have a WRKDIR. Used for
|
||||
# 'make clean-depends'.
|
||||
# Without -r recurse when WRKDIR exists; with -r
|
||||
# always recurse.
|
||||
requires_wrkdir=1
|
||||
;;
|
||||
*)
|
||||
echo "Unknown flag" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND-1))
|
||||
|
||||
validate_env PORTSDIR dp_PKGNAME
|
||||
if [ ${recursive} -eq 1 -o ${requires_wrkdir} -eq 1 ]; then
|
||||
validate_env dp_MAKE
|
||||
# Cache command executions to avoid looking them up again in every
|
||||
# sub-make.
|
||||
MAKE="${dp_MAKE}" export_ports_env >/dev/null
|
||||
fi
|
||||
|
||||
[ -n "${DEBUG_MK_SCRIPTS}" -o -n "${DEBUG_MK_SCRIPTS_DEPENDS_LIST}" ] && set -x
|
||||
|
||||
set -u
|
||||
|
||||
if [ ${missing} -eq 1 ]; then
|
||||
existing=$(${dp_PKG_INFO} -aoq|paste -d ' ' -s -)
|
||||
fi
|
||||
|
||||
check_dep() {
|
||||
local _dep wrkdir show_dep
|
||||
|
||||
for _dep ; do
|
||||
unset FLAVOR
|
||||
myifs=${IFS}
|
||||
IFS=:
|
||||
set -- ${_dep}
|
||||
IFS=${myifs}
|
||||
|
||||
case "${2}" in
|
||||
/*) d=${2} ;;
|
||||
*) d=${PORTSDIR}/${2} ;;
|
||||
esac
|
||||
|
||||
case "${d}" in
|
||||
*@*/*) ;; # Ignore @ in the path which would not be a flavor
|
||||
*@*)
|
||||
export FLAVOR=${d##*@}
|
||||
d=${d%@*}
|
||||
;;
|
||||
esac
|
||||
if [ ${flavors} -eq 1 -a -n "${FLAVOR:-}" ]; then
|
||||
port_display="${d}@${FLAVOR}"
|
||||
else
|
||||
port_display="${d}"
|
||||
fi
|
||||
|
||||
case " ${checked} " in
|
||||
*\ ${d}\ *) continue ;; # Already checked
|
||||
esac
|
||||
checked="${checked} ${d}"
|
||||
# Check if the dependency actually exists or skip otherwise.
|
||||
if [ ! -d "${d}" ]; then
|
||||
echo "${dp_PKGNAME}: \"${port_display}\" non-existent -- dependency list incomplete" >&2
|
||||
continue
|
||||
fi
|
||||
|
||||
# If only looking for missing, show if missing
|
||||
if [ ${missing} -eq 1 ]; then
|
||||
case " ${existing} " in
|
||||
*\ ${d#${PORTSDIR}/}\ *) continue ;; # We have it, nothing to see
|
||||
esac
|
||||
fi
|
||||
|
||||
# Grab any needed vars from the port.
|
||||
|
||||
if [ ${requires_wrkdir} -eq 1 ]; then
|
||||
# shellcheck disable=SC2046
|
||||
# We want word splitting here.
|
||||
set -- $(${dp_MAKE} -C ${d} -VWRKDIR -V_UNIFIED_DEPENDS)
|
||||
wrkdir="$1"
|
||||
shift
|
||||
elif [ ${recursive} -eq 1 ]; then
|
||||
# shellcheck disable=SC2046
|
||||
# We want word splitting here.
|
||||
set -- $(${dp_MAKE} -C ${d} -V_UNIFIED_DEPENDS)
|
||||
fi
|
||||
|
||||
# If a WRKDIR is required to show the dependency, check for it.
|
||||
show_dep=1
|
||||
if [ ${requires_wrkdir} -eq 1 ] && ! [ -d "${wrkdir}" ]; then
|
||||
show_dep=0
|
||||
fi
|
||||
[ ${show_dep} -eq 1 ] && echo "${port_display}"
|
||||
if [ ${recursive} -eq 1 -o ${requires_wrkdir} -eq 1 -a ${show_dep} -eq 1 ]; then
|
||||
# shellcheck disable=SC2068
|
||||
# Do not add quotes, we want to split the string here.
|
||||
check_dep $@
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
checked=
|
||||
# shellcheck disable=SC2068
|
||||
# Do not add quotes, we want to split the string here.
|
||||
check_dep $@
|
||||
89
Mk/Scripts/desktop-categories.sh
Normal file
89
Mk/Scripts/desktop-categories.sh
Normal file
@@ -0,0 +1,89 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD: head/Mk/Scripts/desktop-categories.sh 460160 2018-01-28 08:25:06Z mat $
|
||||
#
|
||||
# MAINTAINER: portmgr@FreeBSD.org
|
||||
|
||||
set -e
|
||||
|
||||
. "${dp_SCRIPTSDIR}/functions.sh"
|
||||
|
||||
validate_env dp_CATEGORIES dp_SORT dp_TR dp_ECHO_CMD
|
||||
|
||||
[ -n "${DEBUG_MK_SCRIPTS}" ] || [ -n "${DEBUG_MK_SCRIPTS_DESKTOP_CATEGORIES}" ] && set -x
|
||||
|
||||
set -u
|
||||
|
||||
categories=""
|
||||
for native_category in ${dp_CATEGORIES}; do
|
||||
c=""
|
||||
case ${native_category} in
|
||||
accessibility) c="Utility Accessibility" ;;
|
||||
archivers) c="Utility Archiving" ;;
|
||||
astro) c="Education Science Astronomy" ;;
|
||||
audio) c="AudioVideo Audio" ;;
|
||||
benchmarks) c="System" ;;
|
||||
biology) c="Education Science Biology" ;;
|
||||
cad) c="Graphics Engineering" ;;
|
||||
comms) c="Utility" ;;
|
||||
converters) c="Utility" ;;
|
||||
databases) c="Office Database" ;;
|
||||
deskutils) c="Utility" ;;
|
||||
devel) c="Development" ;;
|
||||
dns) c="Network" ;;
|
||||
elisp) c="Development" ;;
|
||||
editors) c="Utility" ;;
|
||||
emulators) c="System Emulator" ;;
|
||||
finance) c="Office Finance" ;;
|
||||
ftp) c="Network FileTransfer" ;;
|
||||
games) c="Game" ;;
|
||||
geography) c="Education Science Geography" ;;
|
||||
gnome) c="GNOME GTK" ;;
|
||||
graphics) c="Graphics" ;;
|
||||
hamradio) c="HamRadio" ;;
|
||||
haskell) c="Development" ;;
|
||||
irc) c="Network IRCClient" ;;
|
||||
java) c="Development Java" ;;
|
||||
kde) c="KDE Qt" ;;
|
||||
lang) c="Development" ;;
|
||||
lisp) c="Development" ;;
|
||||
mail) c="Office Email" ;;
|
||||
mate) c="MATE GTK" ;;
|
||||
math) c="Education Science Math" ;;
|
||||
mbone) c="Network AudioVideo" ;;
|
||||
multimedia) c="AudioVideo" ;;
|
||||
net) c="Network" ;;
|
||||
net-im) c="Network InstantMessaging" ;;
|
||||
net-mgmt) c="Network" ;;
|
||||
net-p2p) c="Network P2P" ;;
|
||||
news) c="Network News" ;;
|
||||
palm) c="Office PDA" ;;
|
||||
parallel) c="ParallelComputing" ;;
|
||||
pear) c="Development WebDevelopment" ;;
|
||||
perl5) c="Development" ;;
|
||||
python) c="Development" ;;
|
||||
ruby) c="Development" ;;
|
||||
rubygems) c="Development" ;;
|
||||
scheme) c="Development" ;;
|
||||
science) c="Science Education" ;;
|
||||
security) c="System Security" ;;
|
||||
shells) c="System Shell" ;;
|
||||
sysutils) c="System" ;;
|
||||
tcl*|tk*) c="Development" ;;
|
||||
textproc) c="Utility TextTools" ;;
|
||||
www) c="Network" ;;
|
||||
x11-clocks) c="Utility Clock" ;;
|
||||
x11-fm) c="System FileManager" ;;
|
||||
xfce) c="GTK XFCE" ;;
|
||||
zope) c="Development WebDevelopment" ;;
|
||||
esac
|
||||
if [ -n "${c}" ]; then
|
||||
categories="${categories} ${c}"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "${categories}" ]; then
|
||||
for c in ${categories}; do
|
||||
${dp_ECHO_CMD} "${c}"
|
||||
done | ${dp_SORT} -u | ${dp_TR} '\n' ';'
|
||||
${dp_ECHO_CMD}
|
||||
fi
|
||||
50
Mk/Scripts/dialog4ports.sh
Normal file
50
Mk/Scripts/dialog4ports.sh
Normal file
@@ -0,0 +1,50 @@
|
||||
#! /bin/sh
|
||||
# $FreeBSD: head/Mk/Scripts/dialog4ports.sh 415573 2016-05-20 19:01:59Z mat $
|
||||
# Maintainer: portmgr@FreeBSD.org
|
||||
set -e
|
||||
|
||||
[ -n "${DEBUG_MK_SCRIPTS}" -o -n "${DEBUG_MK_SCRIPTS_DIALOG4PORTS}" ] && set -x
|
||||
|
||||
if [ -z "${DIALOG4PORTS}" -o -z "${PORTSDIR}" -o -z "${MAKE}" ]; then
|
||||
echo "DIALOG4PORTS, MAKE and PORTSDIR required in environment." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
: ${DIALOGPORT:=system/dialog4ports}
|
||||
: ${DIALOGNAME:=dialog4ports}
|
||||
|
||||
OPTIONSFILE="$1"
|
||||
|
||||
if ! [ -e $DIALOG4PORTS ]; then
|
||||
# If INSTALL_AS_USER is set then just build and use the WRKDIR version
|
||||
# Also do this if PREFIX!=LOCALBASE to avoid missing file or double
|
||||
# installs
|
||||
if [ -n "${INSTALL_AS_USER}" -o "${PREFIX}" != "${LOCALBASE}" ]; then
|
||||
if ! [ -d "${PORTSDIR}/${DIALOGPORT}" ]; then
|
||||
echo "===> Skipping 'config' as ${DIALOGPORT} is not checked out" >&2
|
||||
exit 1
|
||||
fi
|
||||
DIALOG4PORTS=$(${MAKE} -C ${PORTSDIR}/${DIALOGPORT} -V DIALOG4PORTS)
|
||||
if ! [ -e "${DIALOG4PORTS}" ]; then
|
||||
echo "===> Building ${DIALOGNAME} as it is required for the config dialog"
|
||||
${MAKE} -C ${PORTSDIR}/${DIALOGPORT} -D NO_DIALOG clean build
|
||||
fi
|
||||
else
|
||||
# Build+install through su-install as normal
|
||||
echo "===> Building/installing ${DIALOGNAME} as it is required for the config dialog"
|
||||
${MAKE} -C ${PORTSDIR}/${DIALOGPORT} -D NO_DIALOG clean install
|
||||
# Need to clean again as it can't run twice in 1 call above
|
||||
${MAKE} -C ${PORTSDIR}/${DIALOGPORT} -D NO_DIALOG clean
|
||||
fi
|
||||
fi
|
||||
|
||||
# Backwards compat with older version which used stdout [<= 0.1.1] (or stderr [0.1.2]).
|
||||
# Clear environment of PKGNAME or the dialog will show on older versions
|
||||
# that do not understand -v.
|
||||
if ! env -u PKGNAME ${DIALOG4PORTS} -v > /dev/null 2>&1; then
|
||||
exec $DIALOG4PORTS > $OPTIONSFILE 2>&1
|
||||
fi
|
||||
|
||||
# Newer versions use stderr to work around a jail issue
|
||||
# http://lists.freebsd.org/pipermail/freebsd-ports/2013-March/082383.html
|
||||
exec $DIALOG4PORTS 2> $OPTIONSFILE
|
||||
197
Mk/Scripts/do-depends.sh
Normal file
197
Mk/Scripts/do-depends.sh
Normal file
@@ -0,0 +1,197 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD: head/Mk/Scripts/do-depends.sh 455690 2017-12-07 01:51:00Z bdrewery $
|
||||
#
|
||||
# MAINTAINER: portmgr@FreeBSD.org
|
||||
|
||||
set -e
|
||||
|
||||
. ${dp_SCRIPTSDIR}/functions.sh
|
||||
|
||||
validate_env dp_RAWDEPENDS dp_DEPTYPE dp_DEPENDS_TARGET dp_DEPENDS_PRECLEAN \
|
||||
dp_DEPENDS_CLEAN dp_DEPENDS_ARGS dp_USE_PACKAGE_DEPENDS \
|
||||
dp_USE_PACKAGE_DEPENDS_ONLY dp_PKG_ADD dp_PKG_INFO dp_WRKDIR \
|
||||
dp_PKGNAME dp_STRICT_DEPENDS dp_LOCALBASE dp_LIB_DIRS dp_SH \
|
||||
dp_SCRIPTSDIR PORTSDIR dp_MAKE dp_MAKEFLAGS
|
||||
|
||||
[ -n "${DEBUG_MK_SCRIPTS}" -o -n "${DEBUG_MK_SCRIPTS_DO_DEPENDS}" ] && set -x
|
||||
|
||||
set -u
|
||||
|
||||
install_depends()
|
||||
{
|
||||
origin=$1
|
||||
target=$2
|
||||
depends_args=$3
|
||||
if [ -z "${dp_USE_PACKAGE_DEPENDS}" -a -z "${dp_USE_PACKAGE_DEPENDS_ONLY}" ]; then
|
||||
MAKEFLAGS="${dp_MAKEFLAGS}" ${dp_MAKE} -C ${origin} -DINSTALLS_DEPENDS ${target} ${depends_args}
|
||||
return 0
|
||||
fi
|
||||
|
||||
port_var_fetch "${origin}" "${depends_args}" \
|
||||
PKGFILE pkgfile \
|
||||
PKGBASE pkgbase
|
||||
|
||||
if [ -r "${pkgfile}" -a "${target}" = "${dp_DEPENDS_TARGET}" ]; then
|
||||
echo "===> Installing existing package ${pkgfile}"
|
||||
if [ "${pkgbase}" = "pkg" ]; then
|
||||
[ -d ${dp_WRKDIR} ] || mkdir -p ${dp_WRKDIR}
|
||||
tar xf ${pkgfile} -C ${dp_WRKDIR} -s ",/.*/,,g" "*/pkg"
|
||||
${dp_WRKDIR}/pkg add ${pkgfile}
|
||||
rm -f ${dp_WRKDIR}/pkg
|
||||
else
|
||||
${dp_PKG_ADD} -A ${pkgfile}
|
||||
fi
|
||||
elif [ -n "${dp_USE_PACKAGE_DEPENDS_ONLY}" -a "${target}" = "${dp_DEPENDS_TARGET}" ]; then
|
||||
echo "===> ${dp_PKGNAME} depends on package: ${pkgfile} - not found" >&2
|
||||
echo "===> USE_PACKAGE_DEPENDS_ONLY set - not building missing dependency from source" >&2
|
||||
exit 1
|
||||
else
|
||||
MAKEFLAGS="${dp_MAKEFLAGS}" ${dp_MAKE} -C ${origin} -DINSTALLS_DEPENDS ${target} ${depends_args}
|
||||
fi
|
||||
}
|
||||
|
||||
find_package()
|
||||
{
|
||||
if ${dp_PKG_INFO} "$1" >/dev/null 2>&1; then
|
||||
echo "===> ${dp_PKGNAME} depends on package: $1 - found"
|
||||
return 0
|
||||
fi
|
||||
echo "===> ${dp_PKGNAME} depends on package: $1 - not found"
|
||||
return 1
|
||||
}
|
||||
|
||||
find_file()
|
||||
{
|
||||
if [ -e "$1" ]; then
|
||||
echo "===> ${dp_PKGNAME} depends on file: $1 - found"
|
||||
return 0
|
||||
fi
|
||||
echo "===> ${dp_PKGNAME} depends on file: $1 - not found"
|
||||
return 1
|
||||
}
|
||||
|
||||
find_file_path()
|
||||
{
|
||||
if which -s $1 ; then
|
||||
echo "===> ${dp_PKGNAME} depends on executable: $1 - found"
|
||||
return 0
|
||||
fi
|
||||
echo "===> ${dp_PKGNAME} depends on executable: $1 - not found"
|
||||
return 1
|
||||
}
|
||||
|
||||
find_lib()
|
||||
{
|
||||
echo -n "===> ${dp_PKGNAME} depends on shared library: $1"
|
||||
libfile=$(env -i PATH="${PATH}" LIB_DIRS="${dp_LIB_DIRS}" LOCALBASE="${dp_LOCALBASE}" ${dp_SH} ${dp_SCRIPTSDIR}/find-lib.sh $1)
|
||||
if [ -z "${libfile}" ]; then
|
||||
echo " - not found"
|
||||
return 1
|
||||
fi
|
||||
echo " - found (${libfile})"
|
||||
}
|
||||
|
||||
anynotfound=0
|
||||
err=0
|
||||
for _line in ${dp_RAWDEPENDS} ; do
|
||||
# ensure we never leak flavors
|
||||
unset FLAVOR
|
||||
myifs=${IFS}
|
||||
IFS=:
|
||||
set -- ${_line}
|
||||
IFS=${myifs}
|
||||
if [ $# -lt 2 -o $# -gt 3 ]; then
|
||||
echo "Error: bad dependency syntax in ${dp_DEPTYPE}" >&2
|
||||
echo "expecting: pattern:origin[@flavour][:target]" >&2
|
||||
echo "got: ${_line}" >&2
|
||||
err=1
|
||||
continue
|
||||
fi
|
||||
pattern=$1
|
||||
origin=$2
|
||||
last=${3:-}
|
||||
|
||||
if [ -z "${pattern}" ]; then
|
||||
echo "Error: there is an empty port dependency in ${dp_DEPTYPE}" >&2
|
||||
err=1
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ -z "${origin}" ]; then
|
||||
echo "Error: a dependency has an empty origin in ${dp_DEPTYPE}" >&2
|
||||
err=1
|
||||
continue
|
||||
fi
|
||||
|
||||
case "${origin}" in
|
||||
/*) ;;
|
||||
*) origin="${PORTSDIR}/${origin}" ;;
|
||||
esac
|
||||
case "${origin}" in
|
||||
*@*/*) ;; # Ignore @ in the path which would not be a flavor
|
||||
*@*)
|
||||
export FLAVOR="${origin##*@}"
|
||||
origin=${origin%@*}
|
||||
;;
|
||||
esac
|
||||
|
||||
depends_args="${dp_DEPENDS_ARGS}"
|
||||
target=${dp_DEPENDS_TARGET}
|
||||
if [ -n "${last}" ]; then
|
||||
target=${last}
|
||||
if [ -n "${dp_DEPENDS_PRECLEAN}" ]; then
|
||||
target="clean ${target}"
|
||||
depends_args="${depends_args:+${depends_args} }NOCLEANDEPENDS=yes"
|
||||
fi
|
||||
if [ -n "${dp_DEPENDS_CLEAN}" ]; then
|
||||
target="${target} clean"
|
||||
depends_args="${depends_args:+${depends_args} }NOCLEANDEPENDS=yes"
|
||||
fi
|
||||
fi
|
||||
|
||||
case ${dp_DEPTYPE} in
|
||||
LIB_DEPENDS)
|
||||
case ${pattern} in
|
||||
lib*.so*) fct=find_lib ;;
|
||||
*)
|
||||
echo "Error: pattern ${pattern} in LIB_DEPENDS is not valid"
|
||||
err=1
|
||||
continue
|
||||
;;
|
||||
esac ;;
|
||||
*)
|
||||
case ${pattern} in
|
||||
*\>*|*\<*|*=*) fct=find_package ;;
|
||||
/nonexistent) fct=false ;;
|
||||
/*) fct=find_file ;;
|
||||
*) fct=find_file_path ;;
|
||||
esac ;;
|
||||
esac
|
||||
if ${fct} "${pattern}" ; then
|
||||
continue
|
||||
fi
|
||||
[ ${pattern} = "/nonexistent" ] || anynotfound=1
|
||||
|
||||
if [ ! -f "${origin}/Makefile" ]; then
|
||||
echo "Error a dependency refers to a non existing origin: ${origin} in ${dp_DEPTYPE}" >&2
|
||||
err=1
|
||||
continue
|
||||
fi
|
||||
|
||||
# Now actually install the dependencies
|
||||
install_depends "${origin}" "${target}" "${depends_args}"
|
||||
# Recheck if the installed dependency validates the pattern except for /nonexistent
|
||||
[ "${fct}" = "false" ] || ${fct} "${pattern}"
|
||||
echo "===> Returning to build of ${dp_PKGNAME}"
|
||||
done
|
||||
|
||||
if [ $err -eq 1 ]; then
|
||||
echo "Errors with dependencies."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -n "${dp_STRICT_DEPENDS}" -a ${anynotfound} -eq 1 ]; then \
|
||||
echo "===> dp_STRICT_DEPENDS set - Not installing missing dependencies."
|
||||
echo " This means a dependency is wrong since it was not satisfied in the ${dp_DEPTYPE} phase."
|
||||
exit 1
|
||||
fi
|
||||
176
Mk/Scripts/do-fetch.sh
Normal file
176
Mk/Scripts/do-fetch.sh
Normal file
@@ -0,0 +1,176 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD: head/Mk/Scripts/do-fetch.sh 462544 2018-02-21 21:26:46Z bdrewery $
|
||||
#
|
||||
# MAINTAINER: portmgr@FreeBSD.org
|
||||
|
||||
set -e
|
||||
|
||||
. "${dp_SCRIPTSDIR}/functions.sh"
|
||||
|
||||
validate_env dp_DEVELOPER dp_DISABLE_SIZE dp_DISTDIR dp_DISTINFO_FILE \
|
||||
dp_DIST_SUBDIR dp_ECHO_MSG dp_FETCH_AFTER_ARGS dp_FETCH_BEFORE_ARGS \
|
||||
dp_FETCH_CMD dp_FETCH_ENV dp_FORCE_FETCH_ALL dp_FORCE_FETCH_LIST \
|
||||
dp_MASTER_SITE_BACKUP dp_MASTER_SITE_OVERRIDE dp_MASTER_SORT_AWK \
|
||||
dp_NO_CHECKSUM dp_RANDOMIZE_SITES dp_SITE_FLAVOR dp_TARGET
|
||||
|
||||
[ -n "${DEBUG_MK_SCRIPTS}" -o -n "${DEBUG_MK_SCRIPTS_DO_FETCH}" ] && set -x
|
||||
|
||||
set -u
|
||||
|
||||
case ${dp_TARGET} in
|
||||
do-fetch|makesum)
|
||||
if [ ! -d "${dp_DISTDIR}" ]; then
|
||||
mkdir -p "${dp_DISTDIR}"
|
||||
fi
|
||||
cd "${dp_DISTDIR}"
|
||||
;;
|
||||
esac
|
||||
|
||||
for _file in "${@}"; do
|
||||
file=${_file%%:*}
|
||||
|
||||
# If this files has groups
|
||||
if [ "$_file" = "$file" ]; then
|
||||
select=DEFAULT
|
||||
else
|
||||
select=$(echo "${_file##*:}" | sed -e 's/,/ /g')
|
||||
fi
|
||||
|
||||
filebasename=${file##*/}
|
||||
if [ -n "${dp_FORCE_FETCH_ALL}" ]; then
|
||||
force_fetch=true
|
||||
else
|
||||
force_fetch=false
|
||||
for afile in ${dp_FORCE_FETCH_LIST}; do
|
||||
afile=${afile##*/}
|
||||
if [ "x$afile" = "x$filebasename" ]; then
|
||||
force_fetch=true
|
||||
fi
|
||||
done
|
||||
fi
|
||||
if [ -f "${file}" -a "$force_fetch" != "true" ]; then
|
||||
continue
|
||||
fi
|
||||
full_file="${dp_DIST_SUBDIR:+${dp_DIST_SUBDIR}/}${file}"
|
||||
if [ -L "$file" ]; then
|
||||
${dp_ECHO_MSG} "=> ${dp_DISTDIR}/$file is a broken symlink."
|
||||
${dp_ECHO_MSG} "=> Perhaps a filesystem (most likely a CD) isn't mounted?"
|
||||
${dp_ECHO_MSG} "=> Please correct this problem and try again."
|
||||
exit 1
|
||||
fi
|
||||
if [ -f "${dp_DISTINFO_FILE}" -a -z "${dp_NO_CHECKSUM}" ]; then
|
||||
_sha256sum=$(distinfo_data SHA256 "${full_file}")
|
||||
if [ -z "$_sha256sum" ]; then
|
||||
${dp_ECHO_MSG} "=> ${dp_DIST_SUBDIR:+$dp_DIST_SUBDIR/}$file is not in ${dp_DISTINFO_FILE}."
|
||||
${dp_ECHO_MSG} "=> Either ${dp_DISTINFO_FILE} is out of date, or"
|
||||
${dp_ECHO_MSG} "=> ${dp_DIST_SUBDIR:+$dp_DIST_SUBDIR/}$file is spelled incorrectly."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
case ${dp_TARGET} in
|
||||
do-fetch|makesum)
|
||||
${dp_ECHO_MSG} "=> $file doesn't seem to exist in ${dp_DISTDIR}."
|
||||
if [ ! -w "${dp_DISTDIR}" ]; then
|
||||
${dp_ECHO_MSG} "=> ${dp_DISTDIR} is not writable by you; cannot fetch."
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
__MASTER_SITES_TMP=
|
||||
for group in $select; do
|
||||
# Disable nounset for this, it may come up empty, but
|
||||
# we don't want to fail with a strange error here.
|
||||
set +u
|
||||
eval ___MASTER_SITES_TMP="\${_${dp_SITE_FLAVOR}_SITES_${group}}"
|
||||
set -u
|
||||
if [ -n "${___MASTER_SITES_TMP}" ] ; then
|
||||
__MASTER_SITES_TMP="${__MASTER_SITES_TMP} ${___MASTER_SITES_TMP}"
|
||||
else
|
||||
case ${dp_TARGET} in
|
||||
do-fetch|makesum)
|
||||
if [ -n "${dp_DEVELOPER}" ]; then
|
||||
${dp_ECHO_MSG} "===> /!\\ Error /!\\"
|
||||
else
|
||||
${dp_ECHO_MSG} "===> /!\\ Warning /!\\"
|
||||
fi
|
||||
${dp_ECHO_MSG} " The :${group} group used for $file is missing"
|
||||
${dp_ECHO_MSG} " from ${dp_SITE_FLAVOR}_SITES. Check for typos, or errors."
|
||||
if [ -n "${dp_DEVELOPER}" ]; then
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
fi
|
||||
done
|
||||
___MASTER_SITES_TMP=
|
||||
SORTED_MASTER_SITES_CMD_TMP="echo ${dp_MASTER_SITE_OVERRIDE} $(echo -n "${__MASTER_SITES_TMP}" | awk "${dp_MASTER_SORT_AWK}") ${dp_MASTER_SITE_BACKUP}"
|
||||
case ${dp_TARGET} in
|
||||
fetch-list)
|
||||
echo -n "mkdir -p ${dp_DISTDIR} && "
|
||||
echo -n "cd ${dp_DISTDIR} && { "
|
||||
;;
|
||||
esac
|
||||
sites_remaining=0
|
||||
if [ -n "${dp_RANDOMIZE_SITES}" ]; then
|
||||
sites="$(${SORTED_MASTER_SITES_CMD_TMP} | ${dp_RANDOMIZE_SITES})"
|
||||
else
|
||||
sites="$(${SORTED_MASTER_SITES_CMD_TMP})"
|
||||
fi
|
||||
for site in ${sites}; do
|
||||
sites_remaining=$((sites_remaining + 1))
|
||||
done
|
||||
for site in ${sites}; do
|
||||
sites_remaining=$((sites_remaining - 1))
|
||||
CKSIZE=$(distinfo_data SIZE "${full_file}")
|
||||
# There is a lot of escaping, but the " needs to survive echo/eval.
|
||||
case ${file} in
|
||||
*/*)
|
||||
mkdir -p "${file%/*}"
|
||||
args="-o ${file} ${site}${file}"
|
||||
;;
|
||||
*)
|
||||
args="${site}${file}"
|
||||
;;
|
||||
esac
|
||||
_fetch_cmd="${dp_FETCH_CMD} ${dp_FETCH_BEFORE_ARGS}"
|
||||
if [ -z "${dp_DISABLE_SIZE}" -a -n "${CKSIZE}" ]; then
|
||||
_fetch_cmd="${_fetch_cmd} -S ${CKSIZE}"
|
||||
fi
|
||||
_fetch_cmd="${_fetch_cmd} ${args} ${dp_FETCH_AFTER_ARGS}"
|
||||
case ${dp_TARGET} in
|
||||
do-fetch|makesum)
|
||||
${dp_ECHO_MSG} "=> Attempting to fetch ${site}${file}"
|
||||
if env -S "${dp_FETCH_ENV}" ${_fetch_cmd}; then
|
||||
actual_size=$(stat -f %z "${file}")
|
||||
if [ -n "${dp_DISABLE_SIZE}" ] || [ -z "${CKSIZE}" ] || [ "${actual_size}" -eq "${CKSIZE}" ]; then
|
||||
continue 2
|
||||
else
|
||||
${dp_ECHO_MSG} "=> Fetched file size mismatch (expected ${CKSIZE}, actual ${actual_size})"
|
||||
if [ ${sites_remaining} -gt 0 ]; then
|
||||
${dp_ECHO_MSG} "=> Trying next site"
|
||||
rm -f "${file}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
fetch-list)
|
||||
echo -n "env $(escape "${_fetch_cmd}") || "
|
||||
;;
|
||||
fetch-url-list-int)
|
||||
echo ${args}
|
||||
;;
|
||||
esac
|
||||
done
|
||||
case ${dp_TARGET} in
|
||||
do-fetch|makesum)
|
||||
${dp_ECHO_MSG} "=> Couldn't fetch it - please try to retrieve this"
|
||||
${dp_ECHO_MSG} "=> port manually into ${dp_DISTDIR} and try again."
|
||||
exit 1
|
||||
;;
|
||||
fetch-list)
|
||||
echo "echo \"${file}\" not fetched; }"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
126
Mk/Scripts/do-patch.sh
Normal file
126
Mk/Scripts/do-patch.sh
Normal file
@@ -0,0 +1,126 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD: head/Mk/Scripts/do-patch.sh 459915 2018-01-25 09:12:21Z mat $
|
||||
#
|
||||
# MAINTAINER: portmgr@FreeBSD.org
|
||||
|
||||
set -e
|
||||
|
||||
. "${dp_SCRIPTSDIR}/functions.sh"
|
||||
|
||||
validate_env dp_BZCAT dp_CAT dp_DISTDIR dp_ECHO_MSG dp_EXTRA_PATCHES \
|
||||
dp_EXTRA_PATCH_TREE dp_GZCAT dp_OPSYS dp_PATCH dp_PATCHDIR \
|
||||
dp_PATCHFILES dp_PATCH_ARGS dp_PATCH_DEBUG_TMP dp_PATCH_DIST_ARGS \
|
||||
dp_PATCH_SILENT dp_PATCH_WRKSRC dp_PKGNAME dp_PKGORIGIN \
|
||||
dp_UNZIP_NATIVE_CMD dp_XZCAT
|
||||
|
||||
[ -n "${DEBUG_MK_SCRIPTS}" -o -n "${DEBUG_MK_SCRIPTS_DO_PATCH}" ] && set -x
|
||||
|
||||
set -u
|
||||
|
||||
apply_one_patch() {
|
||||
local file="$1"
|
||||
local msg="$2"
|
||||
shift 2
|
||||
local patch_strip=""
|
||||
|
||||
case ${file} in
|
||||
*:-p[0-9])
|
||||
patch_strip=${file##*:}
|
||||
file=${file%:-p[0-9]}
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -n "${msg}" ]; then
|
||||
${dp_ECHO_MSG} "===> ${msg} ${file}${patch_strip:+ with ${patch_strip}}"
|
||||
fi
|
||||
|
||||
case "${file}" in
|
||||
*.Z|*.gz)
|
||||
${dp_GZCAT} "${file}"
|
||||
;;
|
||||
*.bz2)
|
||||
${dp_BZCAT} "${file}"
|
||||
;;
|
||||
*.xz)
|
||||
${dp_XZCAT} "${file}"
|
||||
;;
|
||||
*.zip)
|
||||
${dp_UNZIP_NATIVE_CMD} -p "${file}"
|
||||
;;
|
||||
*)
|
||||
${dp_CAT} "${file}"
|
||||
;;
|
||||
esac | do_patch "$@" ${patch_strip}
|
||||
}
|
||||
|
||||
do_patch() {
|
||||
"${dp_PATCH}" -d "${dp_PATCH_WRKSRC}" "$@"
|
||||
}
|
||||
|
||||
patch_from_directory() {
|
||||
local dir="$1"
|
||||
local msg="$2"
|
||||
|
||||
if [ -d "${dir}" ]; then
|
||||
cd "${dir}"
|
||||
|
||||
if [ "$(echo patch-*)" != "patch-*" ]; then
|
||||
|
||||
${dp_ECHO_MSG} "===> Applying ${msg} patches for ${dp_PKGNAME}"
|
||||
|
||||
PATCHES_APPLIED=""
|
||||
|
||||
for i in patch-*; do
|
||||
case ${i} in
|
||||
*.orig|*.rej|*~|*,v)
|
||||
${dp_ECHO_MSG} "===> Ignoring patchfile ${i}"
|
||||
;;
|
||||
*)
|
||||
if [ -n "${dp_PATCH_DEBUG_TMP}" ]; then
|
||||
${dp_ECHO_MSG} "===> Applying ${msg} patch ${i}"
|
||||
fi
|
||||
if do_patch ${dp_PATCH_ARGS} < ${i}; then
|
||||
PATCHES_APPLIED="${PATCHES_APPLIED} ${i}"
|
||||
else
|
||||
${dp_ECHO_MSG} "=> ${msg} patch ${i} failed to apply cleanly."
|
||||
if [ -n "${PATCHES_APPLIED}" -a "${dp_PATCH_SILENT}" != "yes" ]; then
|
||||
${dp_ECHO_MSG} "=> Patch(es) ${PATCHES_APPLIED} applied cleanly."
|
||||
fi
|
||||
false
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
if [ -n "${dp_PATCHFILES}" ]; then
|
||||
${dp_ECHO_MSG} "===> Applying distribution patches for ${dp_PKGNAME}"
|
||||
cd "${dp_DISTDIR}"
|
||||
for i in ${dp_PATCHFILES}; do
|
||||
apply_one_patch "${i}" \
|
||||
"${dp_PATCH_DEBUG_TMP:+ Applying distribution patch}" \
|
||||
${dp_PATCH_DIST_ARGS}
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -n "${dp_EXTRA_PATCHES}" ]; then
|
||||
for i in ${dp_EXTRA_PATCHES}; do
|
||||
if [ -d "${i}" ]; then
|
||||
patch_from_directory "${i}" \
|
||||
"extra patch"
|
||||
else
|
||||
apply_one_patch "${i}" \
|
||||
"Applying extra patch" \
|
||||
${dp_PATCH_ARGS}
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
patch_from_directory "${dp_PATCHDIR}" "${dp_OPSYS}"
|
||||
|
||||
if [ -n "${dp_EXTRA_PATCH_TREE}" ]; then
|
||||
patch_from_directory "${dp_EXTRA_PATCH_TREE}/${dp_PKGORIGIN}" "local"
|
||||
fi
|
||||
|
||||
212
Mk/Scripts/do-users-groups.sh
Normal file
212
Mk/Scripts/do-users-groups.sh
Normal file
@@ -0,0 +1,212 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD: head/Mk/Scripts/do-users-groups.sh 459356 2018-01-18 15:42:15Z mat $
|
||||
#
|
||||
# MAINTAINER: portmgr@FreeBSD.org
|
||||
|
||||
set -e
|
||||
|
||||
. "${dp_SCRIPTSDIR}/functions.sh"
|
||||
|
||||
validate_env dp_ECHO_MSG dp_GID_FILES dp_GID_OFFSET dp_GROUPS_BLACKLIST \
|
||||
dp_INSTALL dp_OPSYS dp_OSVERSION dp_PREFIX dp_PW dp_SCRIPTSDIR \
|
||||
dp_UG_DEINSTALL dp_UG_INSTALL dp_UID_FILES dp_UID_OFFSET \
|
||||
dp_USERS_BLACKLIST
|
||||
|
||||
[ -n "${DEBUG_MK_SCRIPTS}" -o -n "${DEBUG_MK_SCRIPTS_DO_USERS_GROUPS}" ] && set -x
|
||||
|
||||
set -u
|
||||
|
||||
USERS=$1
|
||||
GROUPS=$2
|
||||
|
||||
error() {
|
||||
${dp_ECHO_MSG} "${1}"
|
||||
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Lines from GID and UID files both contain *. As we do not need any pathname
|
||||
# expansion, disable globbing.
|
||||
set -f
|
||||
|
||||
rm -f "${dp_UG_INSTALL}" "${dp_UG_DEINSTALL}" || :
|
||||
|
||||
if [ "${dp_OPSYS}" = FreeBSD ] ; then
|
||||
cat >> "${dp_UG_INSTALL}" <<-eot
|
||||
if [ -n "\${PKG_ROOTDIR}" ] && [ "\${PKG_ROOTDIR}" != "/" ]; then
|
||||
PW="${dp_PW} -R \${PKG_ROOTDIR}"
|
||||
else
|
||||
PW=${dp_PW}
|
||||
fi
|
||||
eot
|
||||
else
|
||||
echo "PW=${dp_PW}" >> "${dp_UG_INSTALL}"
|
||||
fi
|
||||
|
||||
# Both scripts need to start the same, so
|
||||
cp -f "${dp_UG_INSTALL}" "${dp_UG_DEINSTALL}"
|
||||
|
||||
if [ -n "${GROUPS}" ]; then
|
||||
for file in ${dp_GID_FILES}; do
|
||||
if [ ! -f "${file}" ]; then
|
||||
error "** ${file} doesn't exist. Exiting."
|
||||
fi
|
||||
done
|
||||
${dp_ECHO_MSG} "===> Creating groups."
|
||||
echo "echo \"===> Creating groups.\"" >> "${dp_UG_INSTALL}"
|
||||
for group in ${GROUPS}; do
|
||||
# _bgpd:*:130:
|
||||
if ! grep -q "^${group}:" ${dp_GID_FILES}; then \
|
||||
error "** Cannot find any information about group \`${group}' in ${dp_GID_FILES}."
|
||||
fi
|
||||
while read -r line; do
|
||||
# Do not change IFS for more than one command, if we
|
||||
# changed IFS around the while read, it would mess up
|
||||
# the string splitting in the heredoc command.
|
||||
o_IFS=${IFS}
|
||||
IFS=":"
|
||||
set -- ${line}
|
||||
IFS=${o_IFS}
|
||||
group=$1
|
||||
gid=$3
|
||||
if [ -z "${gid}" ]; then
|
||||
error "Group line for group ${group} has no gid"
|
||||
fi
|
||||
gid=$((gid+dp_GID_OFFSET))
|
||||
cat >> "${dp_UG_INSTALL}" <<-eot2
|
||||
if ! \${PW} groupshow $group >/dev/null 2>&1; then
|
||||
echo "Creating group '$group' with gid '$gid'."
|
||||
\${PW} groupadd $group -g $gid
|
||||
else
|
||||
echo "Using existing group '$group'."
|
||||
fi
|
||||
eot2
|
||||
done <<-eot
|
||||
$(grep -h "^${group}:" ${dp_GID_FILES} | head -n 1)
|
||||
eot
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -n "${USERS}" ]; then
|
||||
for file in ${dp_UID_FILES}; do
|
||||
if [ ! -f "${file}" ]; then
|
||||
error "** ${file} doesn't exist. Exiting."
|
||||
fi
|
||||
done
|
||||
|
||||
${dp_ECHO_MSG} "===> Creating users"
|
||||
echo "echo \"===> Creating users\"" >> "${dp_UG_INSTALL}"
|
||||
|
||||
for user in ${USERS}; do
|
||||
# _bgpd:*:130:130:BGP Daemon:/var/empty:/sbin/nologin
|
||||
if ! grep -q "^${user}:" ${dp_UID_FILES} ; then
|
||||
error "** Cannot find any information about user \`${user}' in ${dp_UID_FILES}."
|
||||
fi
|
||||
while read -r line; do
|
||||
# Do not change IFS for more than one command, if we
|
||||
# changed IFS around the while read, it would mess up
|
||||
# the string splitting in the heredoc command.
|
||||
o_IFS=${IFS}
|
||||
IFS=":"
|
||||
set -- ${line}
|
||||
IFS=${o_IFS}
|
||||
login=$1
|
||||
uid=$3
|
||||
gid=$4
|
||||
class=$5
|
||||
gecos=$8
|
||||
homedir=$9
|
||||
shell=${10}
|
||||
if [ -z "$uid" ] || [ -z "$gid" ] || [ -z "$homedir" ] || [ -z "$shell" ]; then
|
||||
error "User line for ${user} is invalid"
|
||||
fi
|
||||
uid=$((uid+dp_UID_OFFSET))
|
||||
gid=$((gid+dp_GID_OFFSET))
|
||||
if [ -n "$class" ]; then
|
||||
class="-L $class"
|
||||
fi
|
||||
homedir=$(echo "$homedir" | sed "s|^/usr/local|${dp_PREFIX}|")
|
||||
cat >> "${dp_UG_INSTALL}" <<-eot2
|
||||
if ! \${PW} usershow $login >/dev/null 2>&1; then
|
||||
echo "Creating user '$login' with uid '$uid'."
|
||||
\${PW} useradd $login -u $uid -g $gid $class -c "$gecos" -d $homedir -s $shell
|
||||
else
|
||||
echo "Using existing user '$login'."
|
||||
fi
|
||||
eot2
|
||||
case $homedir in
|
||||
/|/nonexistent|/var/empty)
|
||||
;;
|
||||
*)
|
||||
group=$(awk -F: -v gid=${gid} '$1 !~ /^#/ && $3 == gid { print $1 }' ${dp_GID_FILES})
|
||||
echo "${dp_INSTALL} -d -g $group -o $login $homedir" >> "${dp_UG_INSTALL}"
|
||||
;;
|
||||
esac
|
||||
done <<-eot
|
||||
$(grep -h "^${user}:" ${dp_UID_FILES} | head -n 1)
|
||||
eot
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -n "${GROUPS}" ]; then
|
||||
for group in ${GROUPS}; do
|
||||
# mail:*:6:postfix,clamav
|
||||
while read -r line; do
|
||||
# Do not change IFS for more than one command, if we
|
||||
# changed IFS around the while read, it would mess up
|
||||
# the string splitting in the heredoc command.
|
||||
o_IFS=${IFS}
|
||||
IFS=":"
|
||||
# As some lines do not have a fourth argument, provide
|
||||
# one so $4 always exists.
|
||||
set -- ${line} ""
|
||||
IFS=${o_IFS}
|
||||
group=$1
|
||||
gid=$3
|
||||
members=$4
|
||||
gid=$((gid+dp_GID_OFFSET))
|
||||
o_IFS=${IFS}
|
||||
IFS=","
|
||||
set -- ${members}
|
||||
IFS=${o_IFS}
|
||||
for login in "$@"; do
|
||||
for user in ${USERS}; do
|
||||
if [ -n "${user}" ] && [ "${user}" = "${login}" ]; then
|
||||
cat >> "${dp_UG_INSTALL}" <<-eot2
|
||||
if ! \${PW} groupshow ${group} | grep -qw ${login}; then
|
||||
echo "Adding user '${login}' to group '${group}'."
|
||||
\${PW} groupmod ${group} -m ${login}
|
||||
fi
|
||||
eot2
|
||||
fi
|
||||
done
|
||||
done
|
||||
done <<-eot
|
||||
$(grep -h "^${group}:" ${dp_GID_FILES} | head -n 1)
|
||||
eot
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -n "${USERS}" ]; then
|
||||
for user in ${USERS}; do
|
||||
if ! echo "${dp_USERS_BLACKLIST}" | grep -qw "${user}"; then
|
||||
cat >> "${dp_UG_DEINSTALL}" <<-eot
|
||||
if \${PW} usershow ${user} >/dev/null 2>&1; then
|
||||
echo "==> You should manually remove the \"${user}\" user. "
|
||||
fi
|
||||
eot
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -n "${GROUPS}" ]; then
|
||||
for group in ${GROUPS}; do
|
||||
if ! echo "${dp_GROUPS_BLACKLIST}" | grep -qw "${group}"; then
|
||||
cat >> "${dp_UG_DEINSTALL}" <<-eot
|
||||
if \${PW} groupshow ${group} >/dev/null 2>&1; then
|
||||
echo "==> You should manually remove the \"${group}\" group "
|
||||
fi
|
||||
eot
|
||||
fi
|
||||
done
|
||||
fi
|
||||
33
Mk/Scripts/find-lib.sh
Normal file
33
Mk/Scripts/find-lib.sh
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/bin/sh
|
||||
# MAINTAINER: portmgr@FreeBSD.org
|
||||
# $FreeBSD: head/Mk/Scripts/find-lib.sh 481327 2018-10-06 08:19:19Z antoine $
|
||||
|
||||
[ -n "${DEBUG_MK_SCRIPTS}" -o -n "${DEBUG_MK_SCRIPTS_FIND_LIB}" ] && set -x
|
||||
|
||||
if [ -z "${LIB_DIRS}" -o -z "${LOCALBASE}" ]; then
|
||||
echo "LIB_DIRS, LOCALBASE required in environment." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -f /usr/share/misc/magic.mime -o -f /usr/share/misc/magic.mime.mgc ]; then
|
||||
echo >&2
|
||||
echo "Either /usr/share/misc/magic.mime or /usr/share/misc/magic.mime.mgc exist and must be removed." >&2
|
||||
echo "These are legacy files from an older release and may safely be deleted." >&2
|
||||
echo "Please see UPDATING 20150213 for more details." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $# -ne 1 ]; then
|
||||
echo "$0: no argument provided." >&2
|
||||
fi
|
||||
|
||||
lib=$1
|
||||
dirs="${LIB_DIRS} $(cat ${LOCALBASE}/libdata/ldconfig/* 2>/dev/null || :)"
|
||||
|
||||
for libdir in ${dirs} ; do
|
||||
test -f ${libdir}/${lib} || continue
|
||||
libfile=${libdir}/${lib}
|
||||
[ "$(/usr/bin/file -b -L --mime-type ${libfile})" = "application/x-sharedlib" ] || continue
|
||||
echo $libfile
|
||||
break
|
||||
done
|
||||
276
Mk/Scripts/functions.sh
Normal file
276
Mk/Scripts/functions.sh
Normal file
@@ -0,0 +1,276 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD: head/Mk/Scripts/functions.sh 505522 2019-06-30 23:02:44Z bdrewery $
|
||||
# This file for common functions used for port scripts.
|
||||
#
|
||||
# MAINTAINER: portmgr@FreeBSD.org
|
||||
|
||||
# Strip (owner,group,perm) from keywords
|
||||
_strip_perms() {
|
||||
sed -Ee 's/^@\([^)]*\)[[:space:]]+//' \
|
||||
-e 's/^(@[[:alpha:]]+)\([^)]*\)[[:space:]]+/\1 /'
|
||||
}
|
||||
|
||||
# Expand TMPPLIST to absolute paths, splitting files and dirs into separate
|
||||
# descriptors.
|
||||
# Input:
|
||||
# fd:0 - plist to parse
|
||||
# Required params:
|
||||
# PREFIX
|
||||
# parse_comments: Whether to parse and include commented files.
|
||||
# Output:
|
||||
# fd:1 - list of files
|
||||
# fd:2 - stderr
|
||||
# fd:3 - list of directories
|
||||
parse_plist() {
|
||||
local cwd cwd_save commented_cwd comment line newcwd parse_comments \
|
||||
PREFIX
|
||||
|
||||
PREFIX="${1}"
|
||||
parse_comments="${2:-1}"
|
||||
|
||||
cwd=${PREFIX}
|
||||
cwd_save=
|
||||
commented_cwd=
|
||||
_strip_perms | while read -r line; do
|
||||
# Handle deactivated OPTIONS. Treat "@comment file" as being in
|
||||
# the plist so it does not show up as an orphan. PLIST_SUB uses
|
||||
# a @comment to deactive files. XXX: It would be better to
|
||||
# make all ports use @ignore instead of @comment.
|
||||
if [ ${parse_comments} -eq 1 -a -z "${line%%@comment *}" ]; then
|
||||
line="${line##*@comment }"
|
||||
# Strip (owner,group,perm) from keywords
|
||||
# Need to do this again after stripping away @comment.
|
||||
line="$(printf %s "$line" | _strip_perms)"
|
||||
# Remove @comment so it can be parsed as a file,
|
||||
# but later prepend it again to create a list of
|
||||
# all files commented and uncommented.
|
||||
comment="@comment "
|
||||
# Only consider comment @cwd for commented lines
|
||||
if [ -n "${commented_cwd}" ]; then
|
||||
[ -z "${cwd_save}" ] && cwd_save=${cwd}
|
||||
cwd=${commented_cwd}
|
||||
fi
|
||||
else
|
||||
comment=
|
||||
# On first uncommented line, forget about commented
|
||||
# @cwd
|
||||
if [ -n "${cwd_save}" ]; then
|
||||
cwd=${cwd_save}
|
||||
cwd_save=
|
||||
commented_cwd=
|
||||
fi
|
||||
fi
|
||||
|
||||
case $line in
|
||||
@dir*|'@unexec rmdir'*|'@unexec /bin/rmdir'*)
|
||||
line="$(printf %s "$line" \
|
||||
| sed -Ee 's/\|\|.*//;s|[[:space:]]+[0-9]*[[:space:]]*>[&]?[[:space:]]*[^[:space:]]+||g' \
|
||||
-e "/^@unexec[[:space:]]+(\/bin\/)?rmdir( -p)?/s|([^%])%D([^%])|\1${cwd}\2|g" \
|
||||
-e '/^@unexec[[:space:]]+(\/bin\/)?rmdir( -p)?/s|"(.*)"[[:space:]]*|\1|g' \
|
||||
-e 's/@unexec[[:space:]]+(\/bin\/)?rmdir( -p)?[[:space:]]+//' \
|
||||
-e 's/@dir(rm|rmtry)?[[:space:]]+//' \
|
||||
-e 's/[[:space:]]+$//')"
|
||||
case "$line" in
|
||||
/*) echo >&3 "${comment}${line%/}" ;;
|
||||
*) echo >&3 "${comment}${cwd}/${line%/}" ;;
|
||||
esac
|
||||
;;
|
||||
# Handle [file] Keywords
|
||||
@info\ *|@shell\ *|@xmlcatmgr\ *)
|
||||
set -- $line
|
||||
shift
|
||||
case "$*" in
|
||||
/*) echo "${comment}$*" ;;
|
||||
*) echo "${comment}${cwd}/$*" ;;
|
||||
esac
|
||||
;;
|
||||
@sample\ *)
|
||||
set -- $line
|
||||
shift
|
||||
sample_file=$1
|
||||
target_file=${1%.sample}
|
||||
if [ $# -eq 2 ]; then
|
||||
target_file=$2
|
||||
fi
|
||||
case "${sample_file}" in
|
||||
/*) ;;
|
||||
*) sample_file=${cwd}/${sample_file} ;;
|
||||
esac
|
||||
case "${target_file}" in
|
||||
/*) ;;
|
||||
*) target_file=${cwd}/${target_file} ;;
|
||||
esac
|
||||
# Ignore the actual file if it is in stagedir
|
||||
echo "@comment ${target_file}"
|
||||
echo "${comment}${sample_file}"
|
||||
;;
|
||||
# Handle [dir] Keywords
|
||||
@fc\ *|@fcfontsdir\ *|@fontsdir\ *)
|
||||
set -- $line
|
||||
shift
|
||||
case "$*" in
|
||||
/*)
|
||||
echo >&3 "${comment}$*"
|
||||
;;
|
||||
*)
|
||||
echo >&3 "${comment}${cwd}/$*"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
# order matters here - we must check @cwd first because
|
||||
# otherwise the @cwd* would also match it first, shadowing the
|
||||
# @cwd) line.
|
||||
@cwd|@cd)
|
||||
# Don't actually reset cwd for commented @cwd
|
||||
if [ -n "${comment}" ]; then
|
||||
commented_cwd=${PREFIX}
|
||||
else
|
||||
cwd=${PREFIX}
|
||||
fi
|
||||
;;
|
||||
@cwd*|@cd*)
|
||||
set -- $line
|
||||
newcwd=$2
|
||||
# Don't set cwd=/ as it causes // in plist and
|
||||
# won't match later.
|
||||
[ "${newcwd}" = "/" ] && newcwd=
|
||||
# Don't actually reset cwd for commented @cwd
|
||||
if [ -n "${comment}" ]; then
|
||||
commented_cwd=${newcwd}
|
||||
else
|
||||
cwd=${newcwd}
|
||||
fi
|
||||
unset newcwd
|
||||
;;
|
||||
@*) ;;
|
||||
/*) echo "${comment}${line}" ;;
|
||||
*) echo "${comment}${cwd}/${line}" ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
validate_env() {
|
||||
local envfault
|
||||
for i ; do
|
||||
if ! (eval ": \${${i}?}" ) >/dev/null; then
|
||||
envfault="${envfault}${envfault:+" "}${i}"
|
||||
fi
|
||||
done
|
||||
if [ -n "${envfault}" ]; then
|
||||
echo "Environment variable ${envfault} undefined. Aborting." \
|
||||
| fmt >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
export_ports_env() {
|
||||
local export_vars make_cmd make_env var value uses
|
||||
|
||||
if [ -n "${HAVE_PORTS_ENV:-}" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
validate_env MAKE PORTSDIR
|
||||
|
||||
uses="python compiler:features objc"
|
||||
|
||||
make_env="\
|
||||
_PORTS_ENV_CHECK=1 \
|
||||
PACKAGE_BUILDING=1 \
|
||||
GNU_CONFIGURE=1 \
|
||||
USE_JAVA=1 \
|
||||
USE_LINUX=1 \
|
||||
"
|
||||
|
||||
make_cmd="${make_env}"
|
||||
|
||||
export_vars="$(${MAKE} -f ${PORTSDIR}/Mk/bsd.port.mk \
|
||||
-V PORTS_ENV_VARS ${make_env} USES="${uses}")"
|
||||
|
||||
for var in ${export_vars}; do
|
||||
make_cmd="${make_cmd}${make_cmd:+ }-V ${var}=\${${var}:Q}"
|
||||
done
|
||||
|
||||
# Bring in all the vars, but not empty ones.
|
||||
eval "$(${MAKE} -f ${PORTSDIR}/Mk/bsd.port.mk ${make_cmd} \
|
||||
USES="${uses}" | grep -v '=$' | sed -e 's,\\ $,,')"
|
||||
for var in ${export_vars}; do
|
||||
# Export and display non-empty ones. This is not redundant
|
||||
# with above since we're looping on all vars here; do not
|
||||
# export a var we didn't eval in.
|
||||
value="$(eval echo \$${var})"
|
||||
|
||||
if [ -n "${value}" ]; then
|
||||
# shellcheck disable=SC2163
|
||||
# We want to export the variable which name is in var.
|
||||
export ${var}
|
||||
echo "export ${var}=\"${value}\""
|
||||
fi
|
||||
done
|
||||
export HAVE_PORTS_ENV=1
|
||||
echo "export HAVE_PORTS_ENV=1"
|
||||
}
|
||||
|
||||
distinfo_data() {
|
||||
local alg file
|
||||
|
||||
alg=$1
|
||||
file=$2
|
||||
|
||||
if [ \( -n "${dp_DISABLE_SIZE}" -a -n "${dp_NO_CHECKSUM}" \) -o ! -f "${dp_DISTINFO_FILE}" ]; then
|
||||
exit
|
||||
fi
|
||||
awk -v alg="$alg" -v file="${file}" \
|
||||
'$1 == alg && $2 == "(" file ")" {print $4}' "${dp_DISTINFO_FILE}"
|
||||
}
|
||||
|
||||
check_checksum_algorithms() {
|
||||
for alg in ${dp_CHECKSUM_ALGORITHMS}; do
|
||||
eval "alg_executable=\$dp_$alg"
|
||||
if [ -z "$alg_executable" ]; then
|
||||
${dp_ECHO_MSG} "Checksum algorithm $alg: Couldn't find the executable."
|
||||
${dp_ECHO_MSG} "Set $alg=/path/to/$alg in /etc/make.conf and try again."
|
||||
exit 1
|
||||
elif [ ! -x "$alg_executable" ]; then
|
||||
${dp_ECHO_MSG} "Checksum algorithm $alg: $alg_executable is not executable."
|
||||
${dp_ECHO_MSG} "Fix modes, or change $alg=$alg_executable in /etc/make.conf and try again."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
escape() {
|
||||
echo "$1" | sed -e 's/[&;()!#]/\\&/g'
|
||||
}
|
||||
unescape() {
|
||||
echo "$1" | sed -e 's/\\//g'
|
||||
}
|
||||
|
||||
# Fetch vars from the Makefile and set them locally.
|
||||
# port_var_fetch ports-mgmt/pkg "" PKGNAME pkgname PKGBASE pkgbase ...
|
||||
# the 2nd variable is for passing any wanted make arguments, such as
|
||||
# DEPENDS_ARGS.
|
||||
port_var_fetch() {
|
||||
local origin="$1"
|
||||
local make_args="$2"
|
||||
local _makeflags _vars
|
||||
local _portvar _var _line
|
||||
|
||||
_makeflags=
|
||||
_vars=
|
||||
shift 2
|
||||
while [ $# -ge 2 ]; do
|
||||
_portvar="$1"
|
||||
_var="$2"
|
||||
_makeflags="${_makeflags}${_makeflags:+ }-V${_portvar}"
|
||||
_vars="${_vars}${_vars:+ }${_var}"
|
||||
shift 2
|
||||
done
|
||||
set -- ${_vars}
|
||||
while read -r _line; do
|
||||
setvar "$1" "${_line}"
|
||||
shift
|
||||
done <<-EOF
|
||||
$(${dp_MAKE} -C "${origin}" ${make_args} ${_makeflags} || echo)
|
||||
EOF
|
||||
}
|
||||
46
Mk/Scripts/generate-symbols.sh
Normal file
46
Mk/Scripts/generate-symbols.sh
Normal file
@@ -0,0 +1,46 @@
|
||||
#! /bin/sh
|
||||
# $FreeBSD: head/Mk/Scripts/generate-symbols.sh 505131 2019-06-26 01:19:00Z bdrewery $
|
||||
# Maintainer: portmgr@FreeBSD.org
|
||||
#
|
||||
# This script will find all ELF files in STAGEDIR and then strip and move
|
||||
# the symbols to LOCALBASE/lib/debug/<original path>.
|
||||
# For example:
|
||||
# /var/qmail/bin/qmaild -> /usr/local/lib/debug/var/qmail/bin/qmaild.debug
|
||||
# /usr/local/bin/ssh -> /usr/local/lib/debug/usr/local/bin/ssh
|
||||
LIB_DIR_PREFIX="${LOCALBASE}/lib/debug"
|
||||
|
||||
msg() {
|
||||
echo "====> $*"
|
||||
}
|
||||
|
||||
msg "Finding symbols"
|
||||
|
||||
# Find all ELF files
|
||||
ELF_FILES=$(mktemp -t elf_files)
|
||||
find ${STAGEDIR} -type f \
|
||||
-exec /usr/bin/readelf -S {} + 2>/dev/null | awk ' \
|
||||
/File:/ {sub(/File: /, "", $0); file=$0}
|
||||
/[[:space:]]\.debug_info[[:space:]]*PROGBITS/ {print file}' \
|
||||
> ${ELF_FILES}
|
||||
|
||||
# Create all of the /usr/local/lib/* dirs
|
||||
lib_dir="${STAGEDIR}${LIB_DIR_PREFIX}"
|
||||
sed -e "s,^${STAGEDIR}/,${lib_dir}/," -e 's,/[^/]*$,,' \
|
||||
${ELF_FILES} | sort -u | xargs mkdir -p
|
||||
|
||||
while read -r staged_elf_file; do
|
||||
elf_file_name="${staged_elf_file##*/}"
|
||||
lib_dir_dest="${lib_dir}/${staged_elf_file#${STAGEDIR}/}"
|
||||
# Strip off filename
|
||||
lib_dir_dest="${lib_dir_dest%/*}"
|
||||
# Save symbols to f.debug
|
||||
debug_file_name="${lib_dir_dest}/${elf_file_name}.debug"
|
||||
objcopy --only-keep-debug "${staged_elf_file}" "${debug_file_name}"
|
||||
# Strip and add a reference to f.debug for finding the symbols.
|
||||
objcopy --strip-debug --strip-unneeded \
|
||||
--add-gnu-debuglink="${debug_file_name}" "${staged_elf_file}"
|
||||
msg "Saved symbols for ${staged_elf_file}"
|
||||
echo "${debug_file_name#${STAGEDIR}}" >&3
|
||||
done < ${ELF_FILES} 3>> ${TMPPLIST}
|
||||
|
||||
rm -f ${ELF_FILES}
|
||||
66
Mk/Scripts/install-desktop-entries.sh
Normal file
66
Mk/Scripts/install-desktop-entries.sh
Normal file
@@ -0,0 +1,66 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD: head/Mk/Scripts/install-desktop-entries.sh 460160 2018-01-28 08:25:06Z mat $
|
||||
#
|
||||
# MAINTAINER: portmgr@FreeBSD.org
|
||||
|
||||
set -e
|
||||
|
||||
. "${dp_SCRIPTSDIR}/functions.sh"
|
||||
|
||||
validate_env dp_SED dp_ECHO_CMD dp_STAGEDIR dp_DESKTOPDIR
|
||||
|
||||
[ -n "${DEBUG_MK_SCRIPTS}" ] || [ -n "${DEBUG_MK_SCRIPTS_INSTALL_DESKTOP_ENTRIES}" ] && set -x
|
||||
|
||||
set -u
|
||||
|
||||
while [ $# -ge 6 ]; do
|
||||
|
||||
Name="${1}"
|
||||
Comment="${2}"
|
||||
Icon="${3}"
|
||||
Exec="${4}"
|
||||
Categories="${5}"
|
||||
StartupNotify="${6}"
|
||||
|
||||
shift 6
|
||||
|
||||
filename="$(${dp_ECHO_CMD} "${Exec}" | ${dp_SED} -e 's,^/,,g;s,[/ ],_,g;s,[^_[:alnum:]],,g').desktop"
|
||||
|
||||
pathname="${dp_STAGEDIR}${dp_DESKTOPDIR}/${filename}"
|
||||
|
||||
${dp_ECHO_CMD} "${dp_DESKTOPDIR}/${filename}" >> "${dp_TMPPLIST}"
|
||||
|
||||
{
|
||||
${dp_ECHO_CMD} "[Desktop Entry]"
|
||||
${dp_ECHO_CMD} "Type=Application"
|
||||
${dp_ECHO_CMD} "Version=1.0"
|
||||
${dp_ECHO_CMD} "Name=${Name}"
|
||||
} > "${pathname}"
|
||||
|
||||
if [ -n "${Comment}" ]; then
|
||||
comment="${Comment}"
|
||||
else
|
||||
comment="$(cd "${dp_CURDIR}" && ${dp_MAKE} -VCOMMENT)"
|
||||
fi
|
||||
|
||||
${dp_ECHO_CMD} "GenericName=${comment}" >> "${pathname}"
|
||||
${dp_ECHO_CMD} "Comment=${comment}" >> "${pathname}"
|
||||
|
||||
if [ -n "${Icon}" ]; then
|
||||
${dp_ECHO_CMD} "Icon=${Icon}" >> "${pathname}"
|
||||
fi
|
||||
|
||||
${dp_ECHO_CMD} "Exec=${Exec}" >> "${pathname}"
|
||||
|
||||
if [ -n "${Categories}" ]; then
|
||||
categories="${Categories}"
|
||||
else
|
||||
categories="$(cd "${dp_CURDIR}" && ${dp_MAKE} desktop-categories)"
|
||||
fi
|
||||
|
||||
${dp_ECHO_CMD} "Categories=${categories}" >> "${pathname}"
|
||||
|
||||
if [ -n "${StartupNotify}" ]; then
|
||||
${dp_ECHO_CMD} "StartupNotify=${StartupNotify}" >> "${pathname}"
|
||||
fi
|
||||
done
|
||||
53
Mk/Scripts/makesum.sh
Normal file
53
Mk/Scripts/makesum.sh
Normal file
@@ -0,0 +1,53 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD: head/Mk/Scripts/makesum.sh 415842 2016-05-25 15:58:31Z mat $
|
||||
#
|
||||
# MAINTAINER: portmgr@FreeBSD.org
|
||||
|
||||
set -e
|
||||
|
||||
. "${dp_SCRIPTSDIR}/functions.sh"
|
||||
|
||||
validate_env dp_CHECKSUM_ALGORITHMS dp_CKSUMFILES dp_DISTDIR dp_DISTINFO_FILE \
|
||||
dp_ECHO_MSG
|
||||
|
||||
[ -n "${DEBUG_MK_SCRIPTS}" -o -n "${DEBUG_MK_SCRIPTS_MAKESUM}" ] && set -x
|
||||
|
||||
set -u
|
||||
|
||||
DISTINFO_OLD=$(mktemp -t makesum-old)
|
||||
DISTINFO_NEW=$(mktemp -t makesum-new)
|
||||
|
||||
trap 'rm -f ${DISTINFO_OLD} ${DISTINFO_NEW}' EXIT INT TERM
|
||||
|
||||
check_checksum_algorithms
|
||||
|
||||
cd "${dp_DISTDIR}"
|
||||
|
||||
# Running `make makesum` a twice should not change the timestamp generated from
|
||||
# the first run.
|
||||
# So, we extract the content of the distinfo file minus the TIMESTAMP, if it
|
||||
# contains a TIMESTAMP.
|
||||
if [ -f "${dp_DISTINFO_FILE}" ] && grep -q "^TIMESTAMP " ${dp_DISTINFO_FILE}; then
|
||||
grep -v "^TIMESTAMP " ${dp_DISTINFO_FILE} > ${DISTINFO_OLD}
|
||||
fi
|
||||
|
||||
for file in ${dp_CKSUMFILES}; do
|
||||
for alg in ${dp_CHECKSUM_ALGORITHMS}; do
|
||||
eval "alg_executable=\$dp_$alg"
|
||||
|
||||
if [ "$alg_executable" != "NO" ]; then
|
||||
$alg_executable "$file" >> "${DISTINFO_NEW}"
|
||||
fi
|
||||
done
|
||||
echo "SIZE ($file) = $(stat -f %z "$file")" >> "${DISTINFO_NEW}"
|
||||
done
|
||||
|
||||
# Now, we generate the distinfo file in two cases:
|
||||
# - If the saved file is empty, it means there was no TIMESTAMP in it, so we
|
||||
# need to add one.
|
||||
# - If the old and new distinfo content minus the TIMESTAMP differ, it means
|
||||
# something was updated or changed, it is time to generate a new timestamp.
|
||||
if [ ! -s ${DISTINFO_OLD} ] || ! cmp -s ${DISTINFO_OLD} ${DISTINFO_NEW}; then
|
||||
echo "TIMESTAMP = $(date '+%s')" > ${dp_DISTINFO_FILE}
|
||||
cat ${DISTINFO_NEW} >> ${dp_DISTINFO_FILE}
|
||||
fi
|
||||
17
Mk/Scripts/plist_sub_sed_sort.sh
Normal file
17
Mk/Scripts/plist_sub_sed_sort.sh
Normal file
@@ -0,0 +1,17 @@
|
||||
#! /bin/sh
|
||||
# $FreeBSD: head/Mk/Scripts/plist_sub_sed_sort.sh 475361 2018-07-26 11:09:46Z mat $
|
||||
#
|
||||
# MAINTAINER: portmgr@FreeBSD.org
|
||||
#
|
||||
# PLIST_SUB_SED helper to sort by longest value first.
|
||||
|
||||
awk '{
|
||||
while (match($0, /s![^!]*![^!]*!g;/)) {
|
||||
sedp=substr($0, RSTART, RLENGTH)
|
||||
$0=substr($0, RSTART+RLENGTH)
|
||||
split(sedp, a, "!")
|
||||
# Convert \. to . for sorting.
|
||||
gsub(/\\./, ".", a[2])
|
||||
print length(a[2]), sedp
|
||||
}
|
||||
}' | sort -rn | awk '{$1=""; print $0}' > $1
|
||||
13
Mk/Scripts/ports_env.sh
Normal file
13
Mk/Scripts/ports_env.sh
Normal file
@@ -0,0 +1,13 @@
|
||||
#! /bin/sh
|
||||
|
||||
# MAINTAINER: portmgr@FreeBSD.org
|
||||
# $FreeBSD: head/Mk/Scripts/ports_env.sh 399171 2015-10-13 00:03:10Z bdrewery $
|
||||
|
||||
if [ -z "${SCRIPTSDIR}" ]; then
|
||||
echo "Must set SCRIPTSDIR" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
. ${SCRIPTSDIR}/functions.sh
|
||||
|
||||
export_ports_env
|
||||
1008
Mk/Scripts/qa.sh
Normal file
1008
Mk/Scripts/qa.sh
Normal file
File diff suppressed because it is too large
Load Diff
95
Mk/Scripts/security-check.awk
Normal file
95
Mk/Scripts/security-check.awk
Normal file
@@ -0,0 +1,95 @@
|
||||
BEGIN {
|
||||
file = "";
|
||||
split("", stupid_binaries);
|
||||
split("", network_binaries);
|
||||
split("", setuid_binaries);
|
||||
split("", writable_files);
|
||||
split("", startup_scripts);
|
||||
header_printed = 0;
|
||||
}
|
||||
FILENAME ~ /\.flattened$/ {
|
||||
if ($0 ~ /(^|\/)etc\/rc\.d\//)
|
||||
startup_scripts[$0] = 1;
|
||||
}
|
||||
FILENAME ~ /\.readelf$/ {
|
||||
if (match($0, /^File:/)) {
|
||||
file = substr($0, 7);
|
||||
next;
|
||||
}
|
||||
if (file == "")
|
||||
next;
|
||||
if ($5 ~ /^(gets|mktemp|tempnam|tmpnam)$/ ||
|
||||
($5 ~ /^(strcpy|strcat|sprintf)$/ && audit != ""))
|
||||
stupid_binaries[file] = stupid_binaries[file] " " $5;
|
||||
if ($5 ~ /^(accept|recvfrom)$/)
|
||||
network_binaries[file] = 1;
|
||||
}
|
||||
FILENAME ~ /\.setuid$/ { setuid_binaries[$0] = 1; }
|
||||
FILENAME ~ /\.writable$/ { writable_files[$0] = 1; }
|
||||
function print_header() {
|
||||
if (header_printed)
|
||||
return;
|
||||
if (audit != "")
|
||||
print "===> SECURITY REPORT (PARANOID MODE): ";
|
||||
else
|
||||
print "===> SECURITY REPORT: ";
|
||||
header_printed = 1;
|
||||
}
|
||||
function note_for_the_stupid(file) { return (file in stupid_binaries) ? (" (USES POSSIBLY INSECURE FUNCTIONS:" stupid_binaries[file] ")") : ""; }
|
||||
END {
|
||||
note_printed = 0;
|
||||
for (file in setuid_binaries) {
|
||||
if (!note_printed) {
|
||||
print_header();
|
||||
print " This port has installed the following binaries which execute with";
|
||||
print " increased privileges.";
|
||||
note_printed = 1;
|
||||
}
|
||||
print file note_for_the_stupid(file);
|
||||
}
|
||||
if (note_printed)
|
||||
print "";
|
||||
note_printed = 0;
|
||||
for (file in network_binaries) {
|
||||
if (!note_printed) {
|
||||
print_header();
|
||||
print " This port has installed the following files which may act as network";
|
||||
print " servers and may therefore pose a remote security risk to the system.";
|
||||
note_printed = 1;
|
||||
}
|
||||
print file note_for_the_stupid(file);
|
||||
}
|
||||
if (note_printed) {
|
||||
print "";
|
||||
note_printed = 0;
|
||||
for (file in startup_scripts) {
|
||||
if (!note_printed) {
|
||||
print_header();
|
||||
print " This port has installed the following startup scripts which may cause";
|
||||
print " these network services to be started at boot time.";
|
||||
note_printed = 1;
|
||||
}
|
||||
print file;
|
||||
}
|
||||
if (note_printed)
|
||||
print "";
|
||||
}
|
||||
note_printed = 0;
|
||||
for (file in writable_files) {
|
||||
if (!note_printed) {
|
||||
print_header();
|
||||
print " This port has installed the following world-writable files/directories.";
|
||||
note_printed = 1;
|
||||
}
|
||||
print file;
|
||||
}
|
||||
if (note_printed)
|
||||
print "";
|
||||
if (header_printed) {
|
||||
print " If there are vulnerabilities in these programs there may be a security";
|
||||
print " risk to the system. FreeBSD makes no guarantee about the security of";
|
||||
print " ports included in the Ports Collection. Please type 'make deinstall'";
|
||||
print " to deinstall the port if this is a concern.";
|
||||
}
|
||||
exit header_printed;
|
||||
}
|
||||
296
Mk/Scripts/smart_makepatch.sh
Normal file
296
Mk/Scripts/smart_makepatch.sh
Normal file
@@ -0,0 +1,296 @@
|
||||
#!/bin/sh
|
||||
# MAINTAINER: portmgr@FreeBSD.org
|
||||
# $FreeBSD: head/Mk/Scripts/smart_makepatch.sh 502102 2019-05-20 13:04:03Z mat $
|
||||
|
||||
# This script regenerates patches. It conserves existing comments and
|
||||
# file names, even if the file name does not meet any current or
|
||||
# previous convention. It will keep multiple patches in the same file
|
||||
# rather than splitting them into individual files.
|
||||
#
|
||||
# If a generated patch was not present before, it will create a file
|
||||
# name where forward slashes are replaced with an underscore and
|
||||
# underscores are appended by another underscore.
|
||||
#
|
||||
# Limitations:
|
||||
# 1) If a file is modified by multiple patches, it will be regenerated
|
||||
# as a single patch. That means if two multi-patch files modified
|
||||
# the same source file, when regenerated, the source file's patch
|
||||
# will only appear in one of patch file.
|
||||
# 2) It's possible that trailing garbage at the end of a patch in a
|
||||
# multipatch file might corrupt the comment (or be interpreted as
|
||||
# a comment) of the following patch. (garbage in, garbage out)
|
||||
#
|
||||
# Reminder
|
||||
# Don't forget to disable post-patch targets before regenerating patches
|
||||
# if those targets modify source files (e.g. with sed). You may also
|
||||
# want to disable EXTRA_PATCHES as well if that is being used.
|
||||
|
||||
[ -n "${DEBUG_MK_SCRIPTS}" -o -n "${DEBUG_MK_SCRIPTS_SMART_MAKEPATCH}" ] && set -x
|
||||
|
||||
if [ -z "${PATCHDIR}" -o -z "${PATCH_WRKSRC}" -o -z "${WRKDIR}" ]; then
|
||||
echo "WRKDIR, PATCHDIR, and PATCH_WRKSRC required in environment." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
WORKAREA=${WRKDIR}/.makepatch-tmp
|
||||
PATCHMAP=${WORKAREA}/pregen.map
|
||||
COMMENTS=${WORKAREA}/comments
|
||||
REGENNED=${WORKAREA}/regenerated
|
||||
DESTDIR=${WORKAREA}/staged
|
||||
SAVEDIR=${WORKAREA}/archived-patches
|
||||
|
||||
case "${STRIP_COMPONENTS}" in
|
||||
[123456789]) ;;
|
||||
1[0123456789]) ;;
|
||||
*) STRIP_COMPONENTS=0
|
||||
esac
|
||||
|
||||
strip_path() {
|
||||
local raw_name=$1
|
||||
if [ "${STRIP_COMPONENTS}" = "0" ]; then
|
||||
echo ${raw_name}
|
||||
else
|
||||
echo ${raw_name} | awk -v sc=${STRIP_COMPONENTS} -F "/" \
|
||||
'{ for (x = sc + 1; x <= NF; x++) {
|
||||
slash = (x>sc+1) ? "/" : "";
|
||||
printf ("%s%s", slash, $x);
|
||||
}}'
|
||||
fi
|
||||
}
|
||||
|
||||
std_patch_filename() {
|
||||
local sans_cwd
|
||||
local raw_name
|
||||
sans_cwd=$(echo $1 | sed 's|^\.\/||')
|
||||
raw_name=$(strip_path ${sans_cwd})
|
||||
echo "patch-$(echo ${raw_name} | sed -e 's|_|&&|g; s|/|_|g')"
|
||||
}
|
||||
|
||||
patchdir_files_list() {
|
||||
if [ -d "${PATCHDIR}" ]; then
|
||||
(cd ${PATCHDIR} && \
|
||||
find ./* -type f -name "patch-*" -maxdepth 0 \
|
||||
2>/dev/null | sed -e 's,^\./,,; /\.orig$/d'
|
||||
)
|
||||
fi;
|
||||
}
|
||||
|
||||
valid_name() {
|
||||
local current_patch_name=$1
|
||||
local result=$3
|
||||
local first_target
|
||||
local testres
|
||||
local lps
|
||||
first_target=$(echo $2 | sed 's|^\.\/||')
|
||||
for lps in __ - + ; do
|
||||
testres=patch-$(echo ${first_target} | sed -e "s|/|${lps}|g")
|
||||
if [ "${testres}" = "${current_patch_name}" ]; then
|
||||
result=${testres}
|
||||
break
|
||||
fi
|
||||
done
|
||||
echo ${result}
|
||||
}
|
||||
|
||||
map_existing_patches() {
|
||||
mkdir -p ${WORKAREA}
|
||||
: > ${PATCHMAP}
|
||||
local target
|
||||
local future_name
|
||||
local std_target
|
||||
local P
|
||||
local t
|
||||
for P in ${old_patch_list}; do
|
||||
target=$(cd ${PATCHDIR} && \
|
||||
grep "^+++ " ${P} | awk '{print $2}'
|
||||
)
|
||||
# For single patches, we honor previous separators, but use
|
||||
# a standard patch name if the current patch name does not
|
||||
# conform. However, if two or more patches are contained in
|
||||
# single file, then we do *NOT* rename the file
|
||||
future_name=
|
||||
for t in ${target}; do
|
||||
if [ -n "${future_name}" ]; then
|
||||
future_name=${P}
|
||||
break;
|
||||
fi
|
||||
std_target=$(std_patch_filename ${t})
|
||||
future_name=$(valid_name ${P} ${t} ${std_target})
|
||||
done
|
||||
for t in ${target}; do
|
||||
std_target=$(std_patch_filename ${t})
|
||||
echo "${future_name} ${std_target}" >> ${PATCHMAP}
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
extract_comment_from_patch() {
|
||||
local existing_patch=${PATCHDIR}/$1
|
||||
local contains
|
||||
local rawname
|
||||
local fname
|
||||
local num
|
||||
contains=$(grep "^+++ " ${existing_patch} | awk '{x++; print x}')
|
||||
for num in ${contains}; do
|
||||
rawname=$(grep "^+++ " ${existing_patch} | \
|
||||
awk -v num=${num} '{x++; if (x==num) print $2}')
|
||||
fname=$(std_patch_filename $rawname)
|
||||
awk -v num=${num} '
|
||||
BEGIN { done=0; x=0; hunk=0; looking=(num==1) }
|
||||
{
|
||||
if (!done) {
|
||||
if ($1 == "@@") {
|
||||
split ($2,a,",");
|
||||
split ($3,b,",");
|
||||
hca = a[2];
|
||||
hcb = a[3];
|
||||
hunk = 1;
|
||||
} else if (hunk) {
|
||||
first=substr($1,1,1);
|
||||
if (first == "-") { hca-- }
|
||||
else if (first == "+") { hcb-- }
|
||||
else {hca--; hcb--}
|
||||
if (hca == 0 && hcb == 0) {hunk = 0}
|
||||
}
|
||||
if ($1 == "---") {
|
||||
x++;
|
||||
if (x == num) { done = 1 }
|
||||
if (x + 1 == num) { looking = 1 }
|
||||
} else if (!hunk && looking) {
|
||||
if ($1!="diff" && $1!="index" && $1!="+++") {
|
||||
print $0
|
||||
}
|
||||
}
|
||||
}
|
||||
}' ${existing_patch} > ${COMMENTS}/${fname}
|
||||
done
|
||||
}
|
||||
|
||||
extract_comments() {
|
||||
mkdir -p ${COMMENTS}
|
||||
rm -f ${COMMENTS}/*
|
||||
local P
|
||||
for P in ${old_patch_list}; do
|
||||
extract_comment_from_patch ${P}
|
||||
done
|
||||
}
|
||||
|
||||
regenerate_patches() {
|
||||
mkdir -p ${REGENNED}
|
||||
rm -f ${REGENNED}/*
|
||||
[ ! -d "${PATCH_WRKSRC}" ] && return
|
||||
|
||||
local F
|
||||
local NEW
|
||||
local OUT
|
||||
local ORIG
|
||||
local new_list
|
||||
new_list=$(cd "${PATCH_WRKSRC}" && \
|
||||
find -s ./* -type f -name '*.orig' 2>/dev/null)
|
||||
(cd "${PATCH_WRKSRC}" && for F in ${new_list}; do
|
||||
ORIG=${F#./}
|
||||
NEW=${ORIG%.orig}
|
||||
cmp -s ${ORIG} ${NEW} && continue
|
||||
OUT=${REGENNED}/$(std_patch_filename ${NEW})
|
||||
TZ=UTC diff -udp ${ORIG} ${NEW} | sed \
|
||||
-e '/^---/s|\.[0-9]* +0000$| UTC|' \
|
||||
-e '/^+++/s|\([[:blank:]][-0-9:.+]*\)*$||' \
|
||||
> ${OUT} || true
|
||||
done)
|
||||
}
|
||||
|
||||
get_patch_name() {
|
||||
awk -v name=$1 '
|
||||
{ if ($2 == name)
|
||||
{
|
||||
if (!done) { print $1 };
|
||||
done = 1;
|
||||
}
|
||||
}
|
||||
END { if (!done) print name }' ${PATCHMAP}
|
||||
}
|
||||
|
||||
stage_patches() {
|
||||
mkdir -p ${DESTDIR}
|
||||
rm -f ${DESTDIR}/*
|
||||
local P
|
||||
local name
|
||||
local patch_list
|
||||
patch_list=$(cd ${REGENNED} && find ./* -name "patch-*" 2>/dev/null)
|
||||
for P in ${patch_list}; do
|
||||
P=${P#./}
|
||||
name=$(get_patch_name ${P})
|
||||
[ -e ${COMMENTS}/${P} ] && cat ${COMMENTS}/${P} \
|
||||
>> ${DESTDIR}/${name}
|
||||
if [ "${P}" = "${name}" ]; then
|
||||
echo "Generated ${P}"
|
||||
else
|
||||
echo "Generated ${P} >> ${name} (legacy)"
|
||||
fi
|
||||
cat ${REGENNED}/${P} >> ${DESTDIR}/${name}
|
||||
done
|
||||
}
|
||||
|
||||
compare_common_patches() {
|
||||
[ -z "${old_patch_list}" ] && return
|
||||
local archive_patch_list
|
||||
local P
|
||||
local ppatch
|
||||
local ppatch_stripped
|
||||
local cpatch
|
||||
local cpatch_stripped
|
||||
for P in ${old_patch_list}; do
|
||||
if [ -e ${DESTDIR}/${P} ]; then
|
||||
ppatch=${PATCHDIR}/${P}
|
||||
cpatch=${DESTDIR}/${P}
|
||||
ppatch_stripped=$(mktemp -t portpatch)
|
||||
cpatch_stripped=$(mktemp -t portpatch)
|
||||
sed -E -e '/^--- .+ UTC$/d; s/^(@@ [^@]* @@).*/\1/' \
|
||||
${ppatch} > ${ppatch_stripped}
|
||||
sed -E -e '/^--- .+ UTC$/d; s/^(@@ [^@]* @@).*/\1/' \
|
||||
${cpatch} > ${cpatch_stripped}
|
||||
# Don't replace patches with only metadata changes
|
||||
if ! cmp -s ${ppatch_stripped} ${cpatch_stripped}; then
|
||||
archive_patch_list="${archive_patch_list} ${P}"
|
||||
else
|
||||
echo "${P} only contains metadata changes; not replacing"
|
||||
rm ${cpatch}
|
||||
fi
|
||||
rm ${ppatch_stripped}
|
||||
rm ${cpatch_stripped}
|
||||
fi
|
||||
done
|
||||
old_patch_list=${archive_patch_list}
|
||||
}
|
||||
|
||||
conserve_old_patches() {
|
||||
mkdir -p ${SAVEDIR}
|
||||
rm -f ${SAVEDIR}/*
|
||||
[ -z "${old_patch_list}" ] && return
|
||||
|
||||
local P
|
||||
for P in ${old_patch_list}; do
|
||||
mv ${PATCHDIR}/${P} ${SAVEDIR}/${P}
|
||||
done
|
||||
echo "The previous patches have been placed here:"
|
||||
echo ${SAVEDIR}
|
||||
}
|
||||
|
||||
install_regenerated_patches() {
|
||||
local testdir
|
||||
testdir=$(find ${DESTDIR} -empty)
|
||||
if [ -z "${testdir}" ]; then
|
||||
mkdir -p ${PATCHDIR}
|
||||
find ${DESTDIR} -type f -exec mv {} ${PATCHDIR}/ \;
|
||||
fi
|
||||
}
|
||||
|
||||
old_patch_list=$(patchdir_files_list)
|
||||
|
||||
map_existing_patches
|
||||
extract_comments
|
||||
regenerate_patches
|
||||
stage_patches
|
||||
compare_common_patches
|
||||
conserve_old_patches
|
||||
install_regenerated_patches
|
||||
Reference in New Issue
Block a user