Skip to content

Commit

Permalink
bulk: implement small_repo
Browse files Browse the repository at this point in the history
Unlike thin repo the small repos also includes the runtime dependencies
and the pkg itself.
  • Loading branch information
bapt committed Nov 4, 2020
1 parent dbd2620 commit 3513c3a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 5 deletions.
14 changes: 12 additions & 2 deletions src/share/poudriere/bulk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ Options:
fatal; don't skip dependent ports on findings.
-m -- minimal repository, only create a repository with the listed
packages, incompatible with -a.
-M -- medium repository, only create a repository with the listed
packages and their runtime dependencies, incompatible with -a.
-N -- Do not build package repository when build completed
-n -- Dry-run. Show what will be done, but do not build
any packages.
Expand Down Expand Up @@ -90,14 +92,15 @@ CLEAN_LISTED=0
DRY_RUN=0
ALL=0
THIN_REPO=0
SMALL_REPO=0
BUILD_REPO=1
INTERACTIVE_MODE=0
OVERLAYS=""
. ${SCRIPTPREFIX}/common.sh

[ $# -eq 0 ] && usage

while getopts "ab:B:CcFf:iIj:J:kmnNO:p:RrSTtvwz:" FLAG; do
while getopts "ab:B:CcFf:iIj:J:kmnMNO:p:RrSTtvwz:" FLAG; do
case "${FLAG}" in
a)
ALL=1
Expand Down Expand Up @@ -146,6 +149,10 @@ while getopts "ab:B:CcFf:iIj:J:kmnNO:p:RrSTtvwz:" FLAG; do
k)
PORTTESTING_FATAL=no
;;
M)
SMALL_REPO=1
THIN_REPO=1
;;
m)
THIN_REPO=1
;;
Expand Down Expand Up @@ -202,8 +209,11 @@ while getopts "ab:B:CcFf:iIj:J:kmnNO:p:RrSTtvwz:" FLAG; do
esac
done

if [ ${ALL} -eq 1 -a ${SMALL_REPO} -eq 1 ]; then
err 1 "incompatible options: both -a and -M are provided"
fi
if [ ${ALL} -eq 1 -a ${THIN_REPO} -eq 1 ]; then
err 1 "incompatible options: bith -a and -m are provided"
err 1 "incompatible options: both -a and -m are provided"
fi
if [ ${ALL} -eq 1 -a ${CLEAN_LISTED} -eq 1 ]; then
CLEAN=1
Expand Down
33 changes: 30 additions & 3 deletions src/share/poudriere/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2595,7 +2595,12 @@ jail_start() {

# May already be set for pkgclean
: ${PACKAGES:=${POUDRIERE_DATA}/packages/${MASTERNAME}}
: ${THIN_PACKAGES:=${POUDRIERE_DATA}/packages/${MASTERNAME}-thin}
if [ ${SMALL_REPO} -eq 1 ]; then
THIN_EXT=-small
else
THIN_EXT=-thin
fi
: ${THIN_PACKAGES:=${POUDRIERE_DATA}/packages/${MASTERNAME}${THIN_EXT}}

mkdir -p ${PACKAGES}/
was_a_bulk_run && stash_packages
Expand Down Expand Up @@ -7702,16 +7707,38 @@ sign_pkg() {
fi
}

add_pkg_to_repo() {
local pkgname=$1
local target=$2
[ -f ${target}/${pkgname}.${PKG_EXT} ] && return
if [ ${SMALL_REPO} -eq 1 ]; then
for dep in $(injail ${PKG_BIN} info -qd -F /packages/All/${pkgname}.${PKG_EXT}); do
add_pkg_to_repo ${dep} ${target}
done
fi
cp ${PACKAGES}/All/${pkgname}.${PKG_EXT} ${target}/
}

build_thin_repo() {
# Try to be as atomic as possible in recreating the new thin repo
mkdir -p ${THIN_PACKAGES}/All.new
while mapfile_read_loop "all_pkgs" \
_pkgname _originspec _rdep _ignore; do
if [ "${_rdep}" = "listed" ] ; then
cp ${PACKAGES}/All/${_pkgname}.${PKG_EXT} \
add_pkg_to_repo ${_pkgname} \
${THIN_PACKAGES}/All.new
fi
done
if [ ${SMALL_REPO} -eq 1 ]; then
cp ${PACKAGES}/All/pkg-*.txz ${THIN_PACKAGES}/All.new
fi
if [ -d "${THIN_PACKAGES}/Latest" ]; then
rm -rf "${THIN_PACKAGES}/Latest"
if [ ${SMALL_REPO} -eq 1 ]; then
mkdir ${THIN_PACKAGES}/Latest
cp -RP ${PACKAGES}/Latest/pkg.${PKG_EXT} ${THIN_PACKAGES}/Latest
fi
fi
if [ -d "${THIN_PACKAGES}/All" ]; then
mv ${THIN_PACKAGES}/All ${THIN_PACKAGES}/All.old
fi
Expand All @@ -7726,7 +7753,6 @@ build_repo() {

if [ ${THIN_REPO} -eq 1 ]; then
msg "Creating thin pkg repository"
build_thin_repo
packages=${THIN_PACKAGES}
else
msg "Creating pkg repository"
Expand All @@ -7737,6 +7763,7 @@ build_repo() {
ensure_pkg_installed force_extract || \
err 1 "Unable to extract pkg."
if [ ${THIN_REPO} -eq 1 ]; then
build_thin_repo
# only overwrite the packages repo with the thin one
# after having extracted pkg because pkg might not
# be on the thin repo
Expand Down

0 comments on commit 3513c3a

Please sign in to comment.