clr-distro-factory icon indicating copy to clipboard operation
clr-distro-factory copied to clipboard

Support creating debuginfo for clr_debug_fuse

Open gtkramer opened this issue 5 years ago • 0 comments

This should be done in a separate pipeline running on an agent different than the build agent. Do not want debuginfo generation to be in the critical path of the build because it is optional for non-developers who are just running or hosting applications.

Start with the script from https://github.com/clearlinux/clr-debug-info in scripts/clr_debug_prepare along with the following code, replacing/removing undefined variables as necessary:

RAW=${DEBUGINFODIR}.raw

refresh_clr-debug-info() {
	local "${@}"
	TYPE=projects
	PROJ=clr-debug-info
	if [[ -d "${BUILDDIR}/${TYPE}/${PROJ}" ]] ; then
        	sudo rm -rf "${BUILDDIR}/${TYPE}/${PROJ}/"
        fi
        git clone "${GITHOST}:${TYPE}/${PROJ}" "${BUILDDIR}/${TYPE}/${PROJ}"
        
	PROJDIR=${REPO_BASE_DIR}/${PROJ}
        pushd ${PROJDIR}

        # clr-debug-info HEAD moves forward at will, but releases are tagged 
        # with one, two , or three didgets if it ever reaches release 100.
        TAG=$(git tag -l | grep -E "^[0-9]{1,3}$" | sort -n | tail -1)
        git checkout ${TAG}     || error "git special checkout failed"

        autoreconf -fiv
        if [[ $? -ne 0 ]]; then
                error "autoreconf -fiv failed"
        fi
        ${PROJDIR}/configure --prefix=${BUILDDIR}/usr
        if [[ $? -ne 0 ]]; then
                error "${PROJDIR}/configure ... failed"
        fi
        make
        sudo make install
        if [[ $? -ne 0 ]]; then
                error "make install failed"
        fi

        popd
}


create_debug() {
	local "${@}"
	log "Creating debug info for ${VER} in $0"
	#Begin debug data creation ----------------------
	set +x
	mkdir -p ${RAW}/done
	pushd ${RAW}
	DCNT=0
	for i in ${RELEASEDIR}/${VER}/clear/x86_64/debug/*.rpm ; do
        	base=`basename $i`;
        	if [[ ! -e ${RAW}/done/$base ]] ; then
			echo "Extracting ${base} ..."
			# Extract to a temporary staging dir first
			TMP="$(mktemp -d)"
			sudo rpm2cpio "${i}" | ( cd "${TMP}"; sudo cpio -idu || : )
			# Packages are now shipping debuginfo under
			# /usr/share/debug/ instead of /usr/{lib,src}/debug/.
			# Move back to /usr/{lib,src}/debug for compatibility.
			sudo mkdir -p "${TMP}"/usr/lib/debug
			sudo mkdir -p "${TMP}"/usr/src
			sudo find "${TMP}"/usr/share/debug/ -mindepth 1 -maxdepth 1 -type d -regextype awk -regex '.*/(.build-id|boot|lib|sbin|usr)$' | xargs -r -I '{}' sudo mv -v '{}' "${TMP}"/usr/lib/debug/
			sudo find "${TMP}"/usr/share/debug/ -mindepth 1 -maxdepth 1 -type d -name 'src' | xargs -r -I '{}' sudo mv -v '{}' "${TMP}"/usr/src/debug
			sudo rm -rf "${TMP}"/usr/share
			# Then copy only changed content into debuginfo.raw.
			# Symlinks are copied verbatim, since new ones are
			# needed whenever build IDs change, and some of the
			# symlinks are expected to be broken (so we can't use
			# the -L option) ...
			sudo rsync --info=stats2 -i -rlc "${TMP}"/ "${RAW}"/
			sudo rm -rf "${TMP}"
                	touch ${RAW}/done/$base
        	fi
	done
	popd
	set -x

	time nice sudo -E bash -x ${BUILDDIR}/usr/bin/clr_debug_prepare /home/releases/debuginfo.raw /home/releases/debuginfo || error "Unable to run clr_debug_prepare"

	#Validate files updated
	if [[ $(find ${RAW}/ -type f -atime 0 -amin -6 |wc -l) -eq 0 ]] ; then 
		log "ERROR: No new files in ${RAW}, debug is not working correctly!"
	fi
	
	if [[ $(find ${DEBUGINFODIR}/ -type f -atime 0 -amin -6 |wc -l) -eq 0 ]] ; then 
		log "ERROR: No new files in ${DEBUGINFODIR}, debug is not working correctly!"
	fi
	
	log "Finished creating debug info in $0"
}


main () {
	local "${@}"

	refresh_clr-debug-info ${@} 

        create_debug ${@}
}

main ${@}

gtkramer avatar Dec 18 '19 19:12 gtkramer