Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- repopulate_cache() {
- # populate the cache with what is needed for do_compile
- ${GO} clean -modcache
- go_do_compile
- }
- update_modules_srcuri() {
- dldir="${GOMODCACHE}/cache/download/"
- find $dldir -name "*.zip" | sort > ${B}/.go-modules
- modsfile="${THISDIR}/${BPN}-go-mods.inc"
- echo "# Autogenerated with 'bitbake -c update_modules ${PN}'\n" > $modsfile
- echo 'SRC_URI += "\' >> $modsfile
- while read -r zip; do
- sha256="$(sha256sum $zip | awk '{ print $1; }')"
- zip=$(realpath --relative-to=$dldir $zip)
- url=$(echo $zip | awk -F '/@v/' '{print $1}')
- url=$(echo $url | sed -e 's/\![a-z]/\U&/g' -e 's/!//g')
- version=$(echo $zip | awk -F '/@v/' '{print $2}')
- version="${version%.zip}"
- echo " gomod://$url;version=$version;sha256sum=$sha256 \\" >> $modsfile
- done < ${B}/.go-modules
- echo '"' >> $modsfile
- }
- update_license_files() {
- licdir="${GOMODCACHE}"
- find $licdir -name LICENSE | sort > ${B}/.go-mod-licenses
- licgen="${THISDIR}/${BPN}-licenses.inc"
- echo "# Autogenerated with 'bitbake -c update_modules ${PN}'\n" > $licgen
- echo 'LIC_FILES_CHKSUM += " \' >> $licgen
- while read -r licfile; do
- echo $licfile
- relpath="$(realpath --relative-to=$licdir $licfile)"
- md5=$(md5sum $licfile | awk '{ print $1; }')
- # these are two lines to prevent bitbake expanding the variable, the must be a better way
- echo -n " file://$" >> $licgen
- echo "{GOMODCACHE}/$relpath;md5=$md5 \\" >> $licgen
- license="$(sed -En "s/^$md5,([^,]+),?/\\1/p" ${THISDIR}/${BPN}-license-md5.csv)"
- if [ "$license" = "" ]; then
- bbwarn "Unknown license: $licfile"
- fi
- if echo "$license" | grep ' '; then
- license="($license)"
- fi
- if [ "$usedlic" = "" ]; then
- usedlic="$license"
- else
- usedlic="$usedlic\n$license"
- fi
- done < ${B}/.go-mod-licenses
- echo '"' >> $licgen
- usedlic="$(echo $usedlic | sort -u | awk '{printf " & %s", $0}')"
- echo >> $licgen
- echo "LICENSE += \"$usedlic\"" >> $licgen
- }
- RECIPE_UPGRADE_EXTRA_TASKS += "do_update_modules"
- addtask do_update_modules after do_configure
- do_update_modules[nostamp] = "1"
- do_update_modules[network] = "1"
- do_update_modules[dirs] = "${GOTMPDIR} ${B}/src/${GO_WORKDIR}"
- do_update_modules() {
- repopulate_cache
- update_modules_srcuri
- update_license_files
- }
Advertisement
Add Comment
Please, Sign In to add comment