Solved After building/installing world and kernel from src how should I proceed with shared libs ?

I went the adventurous path, and decided to install both kernel and userland from src.
Following /usr/src/UPDATING, I succeeded building a environment from src, but at footnote 6, I got confused.
Basically, in what order should I remove old-libs ?
Should I first build my pkgs from ports through poudriere, install them, and then issue: make delete-old-libs or first delete old libs, and then build and install port pkgs ?

I think once in the environment, it should be safe to delete old libs first, and then rebuild and update the pkgs.
 
I have a backup already, and I am going to try out to delete old-libs.
Well, if it is needed or not, I do not know, but I wonder why it is suggested by the UPDATING file...
Since libs do not tend to take large space away, I think.
 
Should I first build my pkgs from ports through poudriere, install them, and then issue: make delete-old-libs or first delete old libs, and then build and install port pkgs ?
Really only relevant when doing a major version upgrade. Rebuild and reinstall the ports first, then delete-old-libs. When you delete-old-libs your currently installed ports/packages will stop working because the (base OS) libraries they need are gone. So you need to reinstall those before you remove the old library versions.
 
I see.
I thought every program once reads its shared library, and then stores a copy in memory, but I was wrong, I guess.
 
Whatever is running will likely keep running, yes. But restarting applications (or after rebooting the host) would try to load library versions that don't exist anymore (after you delete-old-libs). Anything started new (like perhaps shells/bash) will fail. Common pitfall when doing major version upgrades remotely, after the reboot their shell refuses to work, so they can't login anymore. Because the shell (shells/bash for example) they have installed was linked to the 'old' libc version, which they removed during the upgrade procedure (the third freebsd-update install when using freebsd-update(8) does something similar to delete-old-libs).

Fixable[*], if you know what you're doing, but does require console access. And many often don't have remote KVM or IPMI access. So they would need to go on-site to fix it.

[*] After an upgrade from 13 to 14 for example you could install misc/compat13x as a quickfix. To fix pkg(8) you could use pkg bootstrap -f (forces the bootstrap of pkg(7)) or use pkg-static. Assuming the repository it uses has the correct packages for the new version.
 
Not all base libraries are required by all ports/pkgs installed.
Base libraries that are not at all required by any non-base components can be sanely deleted.

Below is the script (removed really unneeded old remnants and fixed some typos in comments) to generate script to rebuild any ports depending upon to-be-deleted base libraries when base OpenSSL /usr/lib/ossl-modules/fips.so was obsoleted.

sh:
#!/bin/sh

#Posted Feb.25,2015 to FreeBSD-current ML by Mark Millard
#Modified by Tomoaki AOKI to generate upgrading script for pkg_replace.

# Define files to (temporarily) generate.
OLDLIB="base_ossl-fips"
CHECKPREFIX1="/usr/lib/ossl-modules/fips"
CHECKFORRE1="${CHECKPREFIX1}[^ ]*\.so"
# CHECKPREFIX2="/lib/libnv"
# CHECKFORRE2="${CHECKPREFIX2}[^ ]*\.so\.0"
# CHECKPREFIX3="/usr/lib32/libcrypto"
# CHECKFORRE3="${CHECKPREFIX3}[^ ]*\.so\.111"
# CHECKPREFIX4="/usr/lib32/libssl"
# CHECKFORRE4="${CHECKPREFIX4}[^ ]*\.so\.111"
DETECTED="/tmp/${OLDLIB}deps0"
NeedUpdate="/tmp/${OLDLIB}deps"
ActualScript="/tmp/rebuild_${OLDLIB}_deps.sh"

# Define pre processing procedure if needed (optional).
PreUpdate="CurDir=\`pwd\`"

# Define port updating program of your choice.
UpdateProgram="pkg_replace -l /usr/ports/${OLDLIB}_deps-\`date \"+%Y%m%d%H%M%S\"\`.log -c -m 'WITH+=NVIDIA,NVIDIA_GL DISABLE_VULNERABILITIES=yes' -v -W -w -b -f"

# Define post processing procedure if needed (optional).
PostUpdate="cd \${CurDir} && portsclean -C"

if [ -f ${DETECTED} ] ; then
    rm ${DETECTED}
fi

if [ -f ${NeedUpdate} ] ; then
    rm ${NeedUpdate}
fi

## Replacing single quotes with double quotes for egrep allowed using shell variable.
find /usr/local/*bin* /usr/local/lib* -type f \
| xargs ldd -f '%p %A\n' 2>&1 | grep "^${CHECKFORRE1}" | cut -w -f2 \
| xargs ldd -a | egrep "(^/.*:$| ${CHECKFORRE1} )" \
| grep -B1 " ${CHECKPREFIX1}" | grep "^/.*:$" | sed -e's;:$;;' \
| xargs pkg which -q -o | sort -u > ${DETECTED}
# find /usr/local/*bin* /usr/local/lib* -type f \
# | xargs ldd -f '%p %A\n' 2>&1 | grep "^${CHECKFORRE2}" | cut -w -f2 \
# | xargs ldd -a | egrep "(^/.*:$| ${CHECKFORRE2} )" \
# | grep -B1 " ${CHECKPREFIX2}" | grep "^/.*:$" | sed -e's;:$;;' \
# | xargs pkg which -q -o | sort -u >> ${DETECTED}
# find /usr/local/*bin* /usr/local/lib* -type f \
# | xargs ldd -f '%p %A\n' 2>&1 | grep "^${CHECKFORRE3}" | cut -w -f2 \
# | xargs ldd -a | egrep "(^/.*:$| ${CHECKFORRE3} )" \
# | grep -B1 " ${CHECKPREFIX3}" | grep "^/.*:$" | sed -e's;:$;;' \
# | xargs pkg which -q -o | sort -u >> ${DETECTED}
# find /usr/local/*bin* /usr/local/lib* -type f \
# | xargs ldd -f '%p %A\n' 2>&1 | grep "^${CHECKFORRE4}" | cut -w -f2 \
# | xargs ldd -a | egrep "(^/.*:$| ${CHECKFORRE4} )" \
# | grep -B1 " ${CHECKPREFIX4}" | grep "^/.*:$" | sed -e's;:$;;' \
# | xargs pkg which -q -o | sort -u >> ${DETECTED}

# Remove duplicate.
cat ${DETECTED} | sort | uniq > ${NeedUpdate}

# Generate actual script. if you want other options, other update tool, rewrite as you like.
echo "#!/bin/sh" > ${ActualScript}

echo ${PreUpdate} >> ${ActualScript}

echo -n ${UpdateProgram} >> ${ActualScript}

cat ${NeedUpdate} | while read TARGET
do
    # The line containing only "the" means that no port origin is detected.
    if [ "the" = ${TARGET} ] ; then
        continue
    fi

    echo -n " " >> ${ActualScript}
    echo -n ${TARGET} >> ${ActualScript}
done

echo "" >> ${ActualScript}

echo ${PostUpdate} >> ${ActualScript}

chmod 754 ${ActualScript}

echo "The actual script is generated as ${ActualScript}."
echo "If you don\'t want huge port like libreoffice, chromium etc., manually remove"
echo "them from generated script."
echo "Intentionally kept temporary file ${NeedUpdate} for ease of confirmation."
echo "Note that the line containing only \"the\" means that no port origin is detected"
echo "for any of binaries."

Note that this script (massibly modified from original) supports up to 4 base libraries at once, and commented out for 3 as only 1 library was needed to be checked this time.

And you can check the generated temporary file pointed by variable NeedUpdate (by default, /tmp/${OLDLIB}deps) before running the generated script whether there's anything required rebuilding or not (ignore 'the' here as noted in comments).
 
Back
Top