diff options
author | Bryan Drewery <bdrewery@FreeBSD.org> | 2022-06-18 05:54:11 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-18 05:54:11 +0300 |
commit | 0c5f990cc3377cb1e23c9e5be1b06f5b60ab1c90 (patch) | |
tree | 12fc95c07b7349cbddff64f6b0f727ef041bd6e1 /src | |
parent | 72657130236a208bc2c4f8d78261f9551ae8e758 (diff) | |
parent | 7fba0f4ab967640ddcf18a41d14daad9a4284744 (diff) |
Merge branch 'master' into 0mp/fixes-in-manuals
Diffstat (limited to 'src')
-rw-r--r-- | src/man/poudriere-jail.8 | 4 | ||||
-rw-r--r-- | src/man/poudriere-options.8 | 12 | ||||
-rw-r--r-- | src/man/poudriere-pkgclean.8 | 26 | ||||
-rw-r--r-- | src/man/poudriere.8 | 10 | ||||
-rwxr-xr-x | src/share/poudriere/common.sh | 125 | ||||
-rw-r--r-- | src/share/poudriere/image.sh | 4 | ||||
-rw-r--r-- | src/share/poudriere/image_zfs.sh | 49 | ||||
-rw-r--r-- | src/share/poudriere/include/pkg.sh | 16 | ||||
-rwxr-xr-x | src/share/poudriere/options.sh | 25 | ||||
-rwxr-xr-x | src/share/poudriere/pkgclean.sh | 150 |
10 files changed, 308 insertions, 113 deletions
diff --git a/src/man/poudriere-jail.8 b/src/man/poudriere-jail.8 index 67b15e62..792a4c4d 100644 --- a/src/man/poudriere-jail.8 +++ b/src/man/poudriere-jail.8 @@ -421,10 +421,10 @@ that is based on .It Sy Example 2\&: No Checking If a Jail Already Exists .Pp The following command returns success if a poudriere jail called -.Dq 112i386 +.Dq 130i386 already exists. .Bd -literal -offset 2n -.Li # Ic poudriere jail -l -n -q | grep --quiet '^112i386$' +.Li # Ic poudriere jail -l -n -q | grep --quiet '^130i386$' .Ed .El .Sh SEE ALSO diff --git a/src/man/poudriere-options.8 b/src/man/poudriere-options.8 index a88883fd..4c5c0a63 100644 --- a/src/man/poudriere-options.8 +++ b/src/man/poudriere-options.8 @@ -28,7 +28,7 @@ .\" .\" Note: The date here should be updated whenever a non-trivial .\" change is made to the manual page. -.Dd April 26, 2021 +.Dd May 28, 2022 .Dt POUDRIERE-OPTIONS 8 .Os .Sh NAME @@ -74,6 +74,16 @@ and shell-style comments are allowed. If given, configure the options only for the given jail. .It Fl n Do not be recursive +.It Fl o Ar port_dbdirname +Use the specified directory name to write the options to. +This name will expand to +.Pa $POUDRIERE_ETC/$port_dbdirname . +This can be used to write options to a different directory than +.Fl jpz +specify. +The +.Fl jpz +flags will be used for the make.conf, poudriere.conf, and ports dir. .It Fl p Ar portstree Run the configuration inside the given ports tree. .Pq Default: Dq Li default diff --git a/src/man/poudriere-pkgclean.8 b/src/man/poudriere-pkgclean.8 index 1f9e4397..25791df2 100644 --- a/src/man/poudriere-pkgclean.8 +++ b/src/man/poudriere-pkgclean.8 @@ -28,7 +28,7 @@ .\" .\" Note: The date here should be updated whenever a non-trivial .\" change is made to the manual page. -.Dd April 29, 2022 +.Dd June 6, 2022 .Dt POUDRIERE-PKGCLEAN 8 .Os .Sh NAME @@ -44,6 +44,18 @@ .Op Ar origin2 Op Ar ... .Sh DESCRIPTION This command is used to delete all packages not specified to build. +By default packages +.Em not listed +will be deleted; +Listed packages, and their dependencies, will be kept. +.Pp +If +.Fl C +is specified then packages listed on the command line will be deleted +rather than kept. +Their orphaned dependencies will not be deleted. +A second run with a full list of wanted packages is needed to +cleanup orphaned dependencies. .Pp Either a subcommand or a list of port origins must be supplied. .Sh SUBCOMMANDS @@ -63,6 +75,12 @@ arguments may be specified at once. .El .Sh OPTIONS .Bl -tag -width "-f conffile" +.It Fl C +Delete the listed packages rather than keep them. +This can be used to delete specific packages that need to be rebuilt +while keeping them in the port list file. +.Fl r +can be specified to delete reverse dependencies as well. .It Fl J Ar number This argument specifies how many .Ar number @@ -86,6 +104,12 @@ Specifies which ports .Ar tree to use. .Pq Default: Dq Li default +.It Fl r +When +.Fl C +is specified then all reverse dependencies will be deleted as well. +This can be used to later force rebuild anything depending on the listed +packages. .It Fl R Also clean restricted packages. .It Fl v diff --git a/src/man/poudriere.8 b/src/man/poudriere.8 index dff13904..0eb146a2 100644 --- a/src/man/poudriere.8 +++ b/src/man/poudriere.8 @@ -153,7 +153,7 @@ for bulk build packages. First you have to create a jail, which will hold all the building infrastructure needs. .Pp -.Dl "poudriere jail -c -v 8.2-RELEASE -a amd64 -j 82amd64" +.Dl "poudriere jail -c -v 13.1-RELEASE -a amd64 -j 131amd64" .Pp A jail will take approximately 3GB of space. .Pp @@ -163,7 +163,7 @@ regardless of what version you are running. amd64 users can choose i386 arch like in this example: .Pp -.Dl "poudriere jail -c -v 8.1-RELEASE -a i386 -j 81i386" +.Dl "poudriere jail -c -v 13.0-RELEASE -a i386 -j 130i386" .Pp This command will fetch and install a minimal jail, small (~400MB) so you can create a lot of them. @@ -193,15 +193,15 @@ Any line starting with the hash sign will be treated as a comment. Now you can launch the bulk build. At minimum the jail and list of packages to build must be specified. .Pp -.Dl "poudriere bulk -f ~/pkglist -j 81i386" +.Dl "poudriere bulk -f ~/pkglist -j 130i386" .Pp .Bq Find your packages .Pp Once the bulk build is over, you can meet your shiny new packages here: .Pp -.Dl Pa /usr/local/poudriere/data/packages/81i386 +.Dl Pa /usr/local/poudriere/data/packages/130i386 .Pp -with 81i386 as the name of the jail. +with 130i386 as the name of the jail. .Ss Test a single port This second example show how to use .Nm diff --git a/src/share/poudriere/common.sh b/src/share/poudriere/common.sh index af13d175..84c35c18 100755 --- a/src/share/poudriere/common.sh +++ b/src/share/poudriere/common.sh @@ -150,7 +150,7 @@ _msg_n() { fi case "${COLOR_ARROW-}${1}" in *$'\033'"["*) - printf "${COLOR_ARROW}${elapsed}${DRY_MODE-}${arrow:+${COLOR_ARROW}${arrow} }${COLOR_RESET}%s${COLOR_RESET}${NL}" "$*" + printf "${COLOR_ARROW-}${elapsed}${DRY_MODE-}${arrow:+${COLOR_ARROW-}${arrow} }${COLOR_RESET}%s${COLOR_RESET}${NL}" "$*" ;; *) printf "${elapsed}${DRY_MODE-}${arrow:+${arrow} }%s${NL}" "$*" @@ -1010,17 +1010,17 @@ buildlog_stop() { local originspec=$2 local build_failed="$3" local log - local buildtime + local now elapsed buildtime _log_path log - buildtime=$( \ - stat -f '%N %B' ${log}/logs/${pkgname}.log | awk -v now=$(clock -epoch) \ - -f ${AWKPREFIX}/siginfo_buildtime.awk | - awk -F'!' '{print $2}' \ - ) echo "build of ${originspec} | ${pkgname} ended at $(date)" - echo "build time: ${buildtime}" + if [ -n "${TIME_START_JOB:-}" ]; then + now=$(clock -monotonic) + elapsed=$((now - TIME_START_JOB)) + calculate_duration buildtime "${elapsed}" + echo "build time: ${buildtime}" + fi if [ ${build_failed} -gt 0 ]; then echo "!!! build failure encountered !!!" fi @@ -1280,10 +1280,17 @@ sig_handler() { } exit_handler() { + exit_status="$?" + set +u case "${SHFLAGS}" in *x*) ;; *) local -; set +x ;; esac + # Don't spam errors with 'set +e; exit >0'. + case "$-" in + *e*) ;; + *) ERROR_VERBOSE=0 ;; + esac # Ignore errors while cleaning up set +e ERRORS_ARE_FATAL=0 @@ -1321,6 +1328,16 @@ exit_handler() { cd "${MASTER_DATADIR}" fi fi + + case "${exit_status}" in + 0|${EX_USAGE}) + : ${ERROR_VERBOSE:=0} ;; + *) : ${ERROR_VERBOSE:=1} ;; + esac + if [ "${ERROR_VERBOSE}" -eq 1 ] && [ "${CRASHED:-0}" -eq 0 ]; then + echo "[ERROR] Unhandled error!" >&2 + fi + if was_a_jail_run; then # Don't use jail for any caching in cleanup SHASH_VAR_PATH="${SHASH_VAR_PATH_DEFAULT}" @@ -1359,6 +1376,9 @@ exit_handler() { if [ -n "${POUDRIERE_TMPDIR-}" ]; then rm -rf "${POUDRIERE_TMPDIR}" >/dev/null 2>&1 || : fi + if [ "${ERROR_VERBOSE}" -eq 1 ]; then + echo "Exiting with status ${exit_status}" >&2 || : + fi } build_url() { @@ -1580,26 +1600,27 @@ siginfo_handler() { EOF for j in ${JOBS}; do # Ignore error here as the zfs dataset may not be cloned yet. - _bget status ${j} status || : + _bget status ${j} status || status= # Skip builders not started yet if [ -z "${status}" ]; then continue fi + set -f + IFS=: + set -- ${status} + unset IFS + set +f + phase="${1}" + # Hide idle workers - case "${status}" in - idle:|done:) continue ;; + case "${phase}" in + idle|done) continue ;; esac - phase="${status%%:*}" - status="${status#*:}" - origin="${status%%:*}" - status="${status#*:}" - pkgname="${status%%:*}" - status="${status#*:}" - started="${status%%:*}" - status="${status#*:}" - started_phase="${status%%:*}" - colorize_job_id job_id_color "${j}" + origin="${2-}" + pkgname="${3-}" + started="${4-}" + started_phase="${5-}" if [ -n "${pkgname}" ]; then elapsed=$((now - started)) @@ -1619,6 +1640,7 @@ siginfo_handler() { cpu= mem= fi + colorize_job_id job_id_color "${j}" display_add \ "[" "${job_id_color}" "${j}" "]" \ "${buildtime-}" \ @@ -7671,6 +7693,26 @@ originspec_is_needed_and_not_ignored() { }' "${MASTER_DATADIR}/all_pkgs" } +# Port was listed to be built +originspec_is_listed() { + [ $# -eq 1 ] || eargs originspec_is_listed originspec + local originspec="$1" + + if [ "${ALL}" -eq 1 ]; then + return 0 + fi + + awk -voriginspec="${originspec}" ' + $3 == "listed" && $2 == originspec { + found=1 + exit 0 + } + END { + if (found != 1) + exit 1 + }' "${MASTER_DATADIR}/all_pkgs" +} + get_porttesting() { [ $# -eq 1 ] || eargs get_porttesting pkgname local pkgname="$1" @@ -8298,8 +8340,9 @@ balance_pool() { append_make() { [ $# -eq 3 ] || eargs append_make srcdir src_makeconf dst_makeconf local srcdir="$1" - local src_makeconf=$2 - local dst_makeconf=$3 + local src_makeconf="$2" + local dst_makeconf="$3" + local src_makeconf_real if [ "${src_makeconf}" = "-" ]; then src_makeconf="${srcdir}/make.conf" @@ -8308,13 +8351,18 @@ append_make() { fi [ -f "${src_makeconf}" ] || return 0 - src_makeconf="$(realpath ${src_makeconf} 2>/dev/null)" + src_makeconf_real="$(realpath ${src_makeconf} 2>/dev/null)" # Only append if not already done (-z -p or -j match) - if grep -q "# ${src_makeconf} #" ${dst_makeconf}; then + if grep -q "# ${src_makeconf_real} #" ${dst_makeconf}; then return 0 fi msg "Appending to make.conf: ${src_makeconf}" - echo "#### ${src_makeconf} ####" >> ${dst_makeconf} + echo -n "#### ${src_makeconf_eal} ####" >> "${dst_makeconf}" + if [ "${src_makeconf_real}" != "${src_makeconf}" ]; then + echo " ${src_makeconf}" + else + echo + fi >> "${dst_makeconf}" cat "${src_makeconf}" >> ${dst_makeconf} } @@ -8322,18 +8370,18 @@ read_packages_from_params() { if [ $# -eq 0 -o -z "$1" ]; then [ -n "${LISTPKGS}" -o ${ALL} -eq 1 ] || - err 1 "No packages specified" + err ${EX_USAGE} "No packages specified" if [ ${ALL} -eq 0 ]; then for listpkg_name in ${LISTPKGS}; do [ -r "${listpkg_name}" ] || - err 1 "No such list of packages: ${listpkg_name}" + err ${EX_USAGE} "No such list of packages: ${listpkg_name}" done fi else [ ${ALL} -eq 0 ] || - err 1 "command line arguments and -a cannot be used at the same time" + err ${EX_USAGE} "command line arguments and -a cannot be used at the same time" [ -z "${LISTPKGS}" ] || - err 1 "command line arguments and list of ports cannot be used at the same time" + err ${EX_USAGE} "command line arguments and list of ports cannot be used at the same time" LISTPORTS="$@" fi } @@ -8359,6 +8407,7 @@ sign_pkg() { local sigtype="$1" local pkgfile="$2" + msg "Signing pkg bootstrap with method: ${sigtype}" if [ "${sigtype}" = "fingerprint" ]; then unlink "${pkgfile}.sig" sha256 -q "${pkgfile}" | ${SIGNING_COMMAND} > "${pkgfile}.sig" @@ -8393,15 +8442,20 @@ build_repo() { fi mkdir -p ${MASTERMNT}/tmp/packages if [ -n "${PKG_REPO_SIGNING_KEY}" ]; then + msg "Signing repository with key: ${PKG_REPO_SIGNING_KEY}" install -m 0400 ${PKG_REPO_SIGNING_KEY} \ ${MASTERMNT}/tmp/repo.key injail ${PKG_BIN} repo \ ${pkg_repo_list_files} \ -o /tmp/packages \ ${PKG_META} \ - /packages /tmp/repo.key + /packages /tmp/repo.key || + err "$?" "Failed to sign pkg repository" unlink ${MASTERMNT}/tmp/repo.key elif [ "${PKG_REPO_FROM_HOST:-no}" = "yes" ]; then + if [ -n "${SIGNING_COMMAND-}" ]; then + msg "Signing repository with command: ${SIGNING_COMMAND}" + fi # Sometimes building repo from host is needed if # using SSH with DNSSEC as older hosts don't support # it. @@ -8409,12 +8463,17 @@ build_repo() { ${pkg_repo_list_files} \ -o ${MASTERMNT}/tmp/packages ${PKG_META_MASTERMNT} \ ${MASTERMNT}/packages \ - ${SIGNING_COMMAND:+signing_command: ${SIGNING_COMMAND}} + ${SIGNING_COMMAND:+signing_command: ${SIGNING_COMMAND}} || + err "$?" "Failed to sign pkg repository" else + if [ -n "${SIGNING_COMMAND-}" ]; then + msg "Signing repository with command: ${SIGNING_COMMAND}" + fi JNETNAME="n" injail ${PKG_BIN} repo \ ${pkg_repo_list_files} \ -o /tmp/packages ${PKG_META} /packages \ - ${SIGNING_COMMAND:+signing_command: ${SIGNING_COMMAND}} + ${SIGNING_COMMAND:+signing_command: ${SIGNING_COMMAND}} || + err "$?" "Failed to sign pkg repository" fi cp ${MASTERMNT}/tmp/packages/* ${PACKAGES}/ diff --git a/src/share/poudriere/image.sh b/src/share/poudriere/image.sh index bfa5b0da..95d2f18c 100644 --- a/src/share/poudriere/image.sh +++ b/src/share/poudriere/image.sh @@ -395,7 +395,7 @@ post_getopts : ${SWAPSIZE:=0} : ${PTNAME:=default} : ${ZFS_SEND_FLAGS:=-Rec} -: ${ZFS_POOL_NAME:=${IMAGENAME}root} +: ${ZFS_POOL_NAME:=zroot} : ${ZFS_BEROOT_NAME:=ROOT} : ${ZFS_BOOTFS_NAME:=default} @@ -406,6 +406,8 @@ MEDIAREMAINDER=${MEDIATYPE#*+} SUBMEDIATYPE=${MEDIAREMAINDER%%+*} MEDIAREMAINDER=${MEDIAREMAINDER#*+} +TMP_ZFS_POOL_NAME="${ZFS_POOL_NAME}.$(jot -r 1 1000000000)" + if [ "${MEDIATYPE}" = "none" ]; then err 1 "Missing -t option" fi diff --git a/src/share/poudriere/image_zfs.sh b/src/share/poudriere/image_zfs.sh index d788f088..7b2271e7 100644 --- a/src/share/poudriere/image_zfs.sh +++ b/src/share/poudriere/image_zfs.sh @@ -41,8 +41,8 @@ zfs_check() [ -n "${IMAGESIZE}" ] || err 1 "Please specify the imagesize" [ -n "${ZFS_POOL_NAME}" ] || err 1 "Please specify a pool name" - zpool list -Ho name ${ZFS_POOL_NAME} >/dev/null 2>&1 && \ - err 1 "Target pool name already exists" + zpool list -Ho name ${TMP_ZFS_POOL_NAME} >/dev/null 2>&1 && \ + err 1 "Temporary pool name already exists" case "${IMAGENAME}" in ''|*[!A-Za-z0-9]*) err 1 "Name can only contain alphanumeric characters" @@ -62,6 +62,7 @@ zfs_prepare() truncate -s ${IMAGESIZE} ${WRKDIR}/raw.img md=$(/sbin/mdconfig ${WRKDIR}/raw.img) zroot=${ZFS_POOL_NAME} + tmpzroot=${TMP_ZFS_POOL_NAME} msg "Creating temporary ZFS pool" zpool create \ @@ -70,27 +71,28 @@ zfs_prepare() -O checksum=sha512 \ -O compression=on \ -O atime=off \ + -t ${tmpzroot} \ -R ${WRKDIR}/world ${zroot} /dev/${md} || exit if [ -n "${ORIGIN_IMAGE}" ]; then msg "Importing previous ZFS Datasets" - zfs recv -F ${zroot} < "${ORIGIN_IMAGE}" + zfs recv -F ${tmpzroot} < "${ORIGIN_IMAGE}" else msg "Creating ZFS Datasets" - zfs create -o mountpoint=none ${zroot}/${ZFS_BEROOT_NAME} - zfs create -o mountpoint=/ ${zroot}/${ZFS_BEROOT_NAME}/${ZFS_BOOTFS_NAME} - zfs create -o mountpoint=/tmp -o exec=on -o setuid=off ${zroot}/tmp - zfs create -o mountpoint=/usr -o canmount=off ${zroot}/usr - zfs create ${zroot}/usr/home - zfs create -o setuid=off ${zroot}/usr/ports - zfs create ${zroot}/usr/src - zfs create ${zroot}/usr/obj - zfs create -o mountpoint=/var -o canmount=off ${zroot}/var - zfs create -o exec=off -o setuid=off ${zroot}/var/audit - zfs create -o exec=off -o setuid=off ${zroot}/var/crash - zfs create -o exec=off -o setuid=off ${zroot}/var/log - zfs create -o atime=on ${zroot}/var/mail - zfs create -o setuid=off ${zroot}/var/tmp + zfs create -o mountpoint=none ${tmpzroot}/${ZFS_BEROOT_NAME} + zfs create -o mountpoint=/ ${tmpzroot}/${ZFS_BEROOT_NAME}/${ZFS_BOOTFS_NAME} + zfs create -o mountpoint=/tmp -o exec=on -o setuid=off ${tmpzroot}/tmp + zfs create -o mountpoint=/usr -o canmount=off ${tmpzroot}/usr + zfs create ${tmpzroot}/usr/home + zfs create -o setuid=off ${tmpzroot}/usr/ports + zfs create ${tmpzroot}/usr/src + zfs create ${tmpzroot}/usr/obj + zfs create -o mountpoint=/var -o canmount=off ${tmpzroot}/var + zfs create -o exec=off -o setuid=off ${tmpzroot}/var/audit + zfs create -o exec=off -o setuid=off ${tmpzroot}/var/crash + zfs create -o exec=off -o setuid=off ${tmpzroot}/var/log + zfs create -o atime=on ${tmpzroot}/var/mail + zfs create -o setuid=off ${tmpzroot}/var/tmp chmod 1777 ${WRKDIR}/world/tmp ${WRKDIR}/world/var/tmp fi } @@ -115,11 +117,12 @@ zfs_generate() : ${SNAPSHOT_NAME:=$IMAGENAME} FINALIMAGE=${IMAGENAME}.img zroot="${ZFS_POOL_NAME}" - zpool set bootfs=${zroot}/${ZFS_BEROOT_NAME}/${ZFS_BOOTFS_NAME} ${zroot} - zpool set autoexpand=on ${zroot} - zfs set canmount=noauto ${zroot}/${ZFS_BEROOT_NAME}/${ZFS_BOOTFS_NAME} + tmpzroot="${TMP_ZFS_POOL_NAME}" + zpool set bootfs=${tmpzroot}/${ZFS_BEROOT_NAME}/${ZFS_BOOTFS_NAME} ${tmpzroot} + zpool set autoexpand=on ${tmpzroot} + zfs set canmount=noauto ${tmpzroot}/${ZFS_BEROOT_NAME}/${ZFS_BOOTFS_NAME} - SNAPSPEC="${zroot}@${SNAPSHOT_NAME}" + SNAPSPEC="${tmpzroot}@${SNAPSHOT_NAME}" msg "Creating snapshot(s) for image generation" zfs snapshot -r "$SNAPSPEC" @@ -137,7 +140,7 @@ zfs_generate() esac case "${MEDIAREMAINDER}" in *be*) - BESNAPSPEC="${zroot}/${ZFS_BEROOT_NAME}/${ZFS_BOOTFS_NAME}@${SNAPSHOT_NAME}" + BESNAPSPEC="${tmpzroot}/${ZFS_BEROOT_NAME}/${ZFS_BOOTFS_NAME}@${SNAPSHOT_NAME}" _zfs_writereplicationstream "${BESNAPSPEC}" "${IMAGENAME}.be.zfs" ;; esac @@ -145,7 +148,7 @@ zfs_generate() esac ## When generating a disk image, we need to export the pool first. - zpool export ${zroot} + zpool export ${tmpzroot} zroot= /sbin/mdconfig -d -u ${md#md} md= diff --git a/src/share/poudriere/include/pkg.sh b/src/share/poudriere/include/pkg.sh index 995d89fc..f9beeea3 100644 --- a/src/share/poudriere/include/pkg.sh +++ b/src/share/poudriere/include/pkg.sh @@ -27,7 +27,7 @@ pkg_get_origin() { [ $# -lt 2 ] && eargs pkg_get_origin var_return pkg [origin] local var_return="$1" local pkg="$2" - local _origin=$3 + local _origin="${3-}" local SHASH_VAR_PATH SHASH_VAR_PREFIX= get_pkg_cache_dir SHASH_VAR_PATH "${pkg}" @@ -150,15 +150,15 @@ pkg_get_dep_origin_pkgnames() { while [ $# -ne 0 ]; do origin="$1" pkgname="$2" - compiled_dep_origins="${compiled_dep_origins}${compiled_dep_origins:+ }${origin}" - compiled_dep_pkgnames="${compiled_dep_pkgnames}${compiled_dep_pkgnames:+ }${pkgname}" + compiled_dep_origins="${compiled_dep_origins:+${compiled_dep_origins} }${origin}" + compiled_dep_pkgnames="${compiled_dep_pkgnames:+${compiled_dep_pkgnames} }${pkgname}" shift 2 done if [ -n "${var_return_origins}" ]; then - setvar "${var_return_origins}" "${compiled_dep_origins}" + setvar "${var_return_origins}" "${compiled_dep_origins-}" fi if [ -n "${var_return_pkgnames}" ]; then - setvar "${var_return_pkgnames}" "${compiled_dep_pkgnames}" + setvar "${var_return_pkgnames}" "${compiled_dep_pkgnames-}" fi } @@ -177,14 +177,14 @@ pkg_get_options() { off|false) key="-${key}" ;; on|true) key="+${key}" ;; esac - _compiled_options="${_compiled_options}${_compiled_options:+ }${key}" + _compiled_options="${_compiled_options:+${_compiled_options} }${key}" done <<-EOF $(injail ${PKG_BIN} query -F "/packages/All/${pkg##*/}" '%Ok %Ov' | sort) EOF - shash_set 'pkg' 'options2' "${_compiled_options}" + shash_set 'pkg' 'options2' "${_compiled_options-}" fi if [ -n "${var_return}" ]; then - setvar "${var_return}" "${_compiled_options}" + setvar "${var_return}" "${_compiled_options-}" fi } diff --git a/src/share/poudriere/options.sh b/src/share/poudriere/options.sh index e325cde8..78bc63b7 100755 --- a/src/share/poudriere/options.sh +++ b/src/share/poudriere/options.sh @@ -42,6 +42,7 @@ Options: -c -- Use 'make config' target -C -- Use 'make config-conditional' target (default) -j name -- Run on the given jail + -o name -- Specify name of options directory to write to -p tree -- Specify on which ports tree the configuration will be done -n -- Do not configure/show/remove options of dependencies -r -- Remove port options instead of configuring them @@ -58,10 +59,11 @@ PTNAME_TMP="" DO_RECURSE=y COMMAND=config-conditional RECURSE_COMMAND=config-recursive +OFLAG=0 [ $# -eq 0 ] && usage -while getopts "a:cCj:f:p:nrsz:" FLAG; do +while getopts "a:cCj:f:o:p:nrsz:" FLAG; do case "${FLAG}" in a) ARCH=${OPTARG} @@ -86,6 +88,10 @@ while getopts "a:cCj:f:p:nrsz:" FLAG; do OPTARG="${SAVED_PWD}/${OPTARG}" LISTPKGS="${LISTPKGS:+${LISTPKGS} }${OPTARG}" ;; + o) + PORT_DBDIRNAME="${OPTARG}" + OFLAG=1 + ;; p) porttree_exists ${OPTARG} || err 2 "No such ports tree: ${OPTARG}" @@ -132,11 +138,14 @@ command -v dialog4ports >/dev/null 2>&1 || err 1 "You must have ports-mgmt/dialo read_packages_from_params "$@" OLD_PORT_DBDIR=${POUDRIERED}/${JAILNAME}${JAILNAME:+-}${SETNAME}${SETNAME:+-}options -PORT_DBDIR=${POUDRIERED}/${JAILNAME}${JAILNAME:+-}${PTNAME_TMP}${PTNAME_TMP:+-}${SETNAME}${SETNAME:+-}options +: ${PORT_DBDIRNAME:="${JAILNAME}${JAILNAME:+-}${PTNAME_TMP}${PTNAME_TMP:+-}${SETNAME}${SETNAME:+-}options"} +PORT_DBDIR="${POUDRIERED}/${PORT_DBDIRNAME}" -if [ -d "${OLD_PORT_DBDIR}" ] && [ ! -d "${PORT_DBDIR}" ]; then +if [ "${OFLAG}" -eq 0 ] && + [ -d "${OLD_PORT_DBDIR}" ] && [ ! -d "${PORT_DBDIR}" ]; then msg_warn "You already have options configured without '-p ${PTNAME_TMP}' that will no longer be used." msg_warn "Drop the '-p ${PTNAME_TMP}' option to avoid this problem." + msg_warn "Alternatively use '-o dirname' to write to a different directory than -jpz specify." if [ -t 0 ]; then confirm_if_tty "Are you sure you want to continue?" || exit 0 else @@ -144,8 +153,9 @@ if [ -d "${OLD_PORT_DBDIR}" ] && [ ! -d "${PORT_DBDIR}" ]; then fi fi -mkdir -p ${PORT_DBDIR} -msg "Working on options directory ${PORT_DBDIR}" +mkdir -p "${PORT_DBDIR}" +msg "Working on options directory: ${PORT_DBDIR}" +msg "Using ports from: ${PORTSDIR}" __MAKE_CONF=$(mktemp -t poudriere-make.conf) export __MAKE_CONF @@ -163,6 +173,11 @@ for originspec in $(listed_ports show_moved); do make PORT_DBDIR=${PORT_DBDIR} \ -C ${PORTSDIR}/${origin} \ ${COMMAND} + case "${COMMAND}" in + showconfig|config-conditional) + msg "Re-run 'poudriere options' with the -c flag to modify the options." + ;; + esac if [ -n "${DO_RECURSE}" ]; then env ${flavor:+FLAVOR=${flavor}} \ diff --git a/src/share/poudriere/pkgclean.sh b/src/share/poudriere/pkgclean.sh index 62ef7a30..4f3ec505 100755 --- a/src/share/poudriere/pkgclean.sh +++ b/src/share/poudriere/pkgclean.sh @@ -37,6 +37,7 @@ Parameters: [ports...] -- List of ports to keep on the command line Options: + -C -- Delete packages listed on command line rather than keep -j jail -- Which jail to use for packages -J n -- Run n jobs in parallel (Defaults to the number of CPUs times 1.25) @@ -45,6 +46,7 @@ Options: -N -- Do not build the package repository when clean completed -O overlays -- Specify extra ports trees to overlay -p tree -- Which ports tree to use for packages + -r -- With -C delete reverse dependencies too -R -- Clean RESTRICTED packages after building -v -- Be verbose; show more information. Use twice to enable debug output @@ -60,10 +62,12 @@ DRY_RUN=0 DO_ALL=0 BUILD_REPO=1 OVERLAYS="" +CLEAN_LISTED=0 +CLEAN_RDEPS=0 [ $# -eq 0 ] && usage -while getopts "Aaj:J:f:nNO:p:Rvyz:" FLAG; do +while getopts "AaCj:J:f:nNO:p:rRvyz:" FLAG; do case "${FLAG}" in A) DO_ALL=1 @@ -71,6 +75,9 @@ while getopts "Aaj:J:f:nNO:p:Rvyz:" FLAG; do a) ALL=1 ;; + C) + CLEAN_LISTED=1 + ;; j) jail_exists ${OPTARG} || err 1 "No such jail: ${OPTARG}" JAILNAME=${OPTARG} @@ -101,6 +108,9 @@ while getopts "Aaj:J:f:nNO:p:Rvyz:" FLAG; do err 2 "No such ports tree: ${OPTARG}" PTNAME=${OPTARG} ;; + r) + CLEAN_RDEPS=1 + ;; R) NO_RESTRICTED=1 ;; @@ -127,6 +137,13 @@ post_getopts [ -z "${JAILNAME}" ] && \ err 1 "Don't know on which jail to run please specify -j" +if [ "${CLEAN_LISTED}" -eq 1 -a -n "${LISTPKGS}" ]; then + err ${EX_USAGE} "-C and -f should not be used together" +fi +if [ "${CLEAN_LISTED}" -eq 0 -a "${CLEAN_RDEPS}" -eq 1 ]; then + err ${EX_USAGE} "-r only works with -C" +fi + MASTERNAME=${JAILNAME}-${PTNAME}${SETNAME:+-${SETNAME}} _mastermnt MASTERMNT @@ -158,8 +175,16 @@ PKG_EXT='*' package_dir_exists_and_has_packages || maybe_run_queued "${saved_argv}" msg "Gathering all expected packages" +if [ "${CLEAN_LISTED}" -eq 0 ]; then + msg_warn "Will delete anything not listed. To delete listed use -C." +else + msg_warn "Will delete anything listed. To keep listed do not use -C." +fi jail_start "${JAILNAME}" "${PTNAME}" "${SETNAME}" prepare_ports +if ! ensure_pkg_installed; then + err 1 "pkg must be built before this command can be used" +fi msg "Looking for unneeded packages" bset status "pkgclean:" @@ -176,40 +201,97 @@ pkgclean_cleanup() { BADFILES_LIST=$(mktemp -t poudriere_pkgclean) FOUND_ORIGINS=$(mktemp -t poudriere_pkgclean) +should_delete() { + [ $# -eq 1 ] || eargs should_delete pkgfile + local pkgfile="$1" + local pkgname origin ret + + pkgname="${pkgfile##*/}" + pkgname="${pkgname%.*}" + ret=0 + + if ! pkg_get_origin origin "${pkgfile}"; then + msg_verbose "Found corrupt package: ${pkgfile}" + return 0 # delete + fi + if [ "${CLEAN_LISTED}" -eq 0 ]; then + should_delete_unlisted "${pkgfile}" "${origin}" "${pkgname}" || + ret="$?" + elif [ "${CLEAN_LISTED}" -eq 1 ]; then + should_delete_listed "${pkgfile}" "${origin}" "${pkgname}" || + ret="$?" + else + echo "${pkgfile} ${origin}" >> "${FOUND_ORIGINS}" + fi + return "${ret}" +} + +# Handle NO -C +should_delete_unlisted() { + [ $# -eq 3 ] || eargs should_delete_unlisted pkgfile origin pkgname + local pkgfile="$1" + local origin="$2" + local pkgname="$3" + local forbidden + + if shash_remove pkgname-forbidden "${pkgname}" forbidden; then + msg_verbose "Found forbidden package (${COLOR_PORT}${origin}${COLOR_RESET}) (${forbidden}): ${pkgfile}" + return 0 # delete + elif ! pkgbase_is_needed "${pkgname}"; then + msg_verbose "Found unwanted package (${COLOR_PORT}${origin}${COLOR_RESET}): ${pkgfile}" + return 0 # delete + fi + return 1 # keep +} + +# Handle -C and -r +should_delete_listed() { + [ $# -eq 3 ] || eargs should_delete_listed pkgfile origin pkgname + local pkgfile="$1" + local origin="$2" + local pkgname="$3" + local dep_origin compiled_deps + + if originspec_is_listed "${origin}"; then + msg_verbose "Found specified package (${COLOR_PORT}${origin}${COLOR_RESET}): ${pkgfile}" + return 0 # delete + elif ! pkg_get_dep_origin_pkgnames compiled_deps '' "${pkgfile}"; then + msg_verbose "Found corrupt package (${COLOR_PORT}${origin}${COLOR_RESET}) (deps): ${pkgfile}" + return 0 # delete + fi + if [ "${CLEAN_RDEPS}" -eq 1 ]; then + for dep_origin in ${compiled_deps}; do + if originspec_is_listed "${dep_origin}"; then + msg_verbose "Found specified package (${COLOR_PORT}${dep_origin}${COLOR_RESET}) rdep: ${pkgfile}" + return 0 # delete + fi + done + fi + return 1 # keep +} + for file in ${PACKAGES}/All/*; do case ${file} in - *.${PKG_EXT}) - pkgname="${file##*/}" - pkgname="${pkgname%.*}" - if ! pkg_get_origin origin "${file}"; then - msg_verbose "Found corrupt package: ${file}" - echo "${file}" >> ${BADFILES_LIST} - elif shash_remove pkgname-forbidden "${pkgname}" \ - forbidden; then - msg_verbose "Found forbidden package (${forbidden}): ${file}" - echo "${file}" >> ${BADFILES_LIST} - elif ! pkgbase_is_needed "${pkgname}"; then - msg_verbose "Found unwanted package: ${file}" - echo "${file}" >> ${BADFILES_LIST} - else - echo "${file} ${origin}" >> ${FOUND_ORIGINS} - fi - ;; - *.txz) - if [ -L "${file}" ]; then - # Ignore txz symlinks as they otherwise - # cuase spam and confusion. If we delete - # a package it points to then it will be - # removed later by - # delete_stale_symlinks_and_empty_dirs(). - continue - fi - # FALLTHROUGH - ;& - *) - msg_verbose "Found incorrect format file: ${file}" - echo "${file}" >> ${BADFILES_LIST} - ;; + *.${PKG_EXT}) + if should_delete "${file}"; then + echo "${file}" >> "${BADFILES_LIST}" + fi + ;; + *.txz) + if [ -L "${file}" ]; then + # Ignore txz symlinks as they otherwise + # cause spam and confusion. If we delete + # a package it points to then it will be + # removed later by + # delete_stale_symlinks_and_empty_dirs(). + continue + fi + # FALLTHROUGH + ;& + *) + msg_verbose "Found incorrect format file: ${file}" + echo "${file}" >> ${BADFILES_LIST} + ;; esac done @@ -220,7 +302,7 @@ pkg_compare() { ensure_pkg_installed || err 1 \ - "ports-mgmt/pkg is missing. First build it with bulk, then rerun pkgclean" + "ports-mgmt/pkg is missing. First build it with bulk, then re-run pkgclean" injail ${PKG_VERSION} -t "${oldversion}" "${newversion}" } |