From bea3ba0b4ef11916dd060e0df7be1da5292c5b16 Mon Sep 17 00:00:00 2001 From: will_niutao Date: Wed, 10 May 2023 17:55:36 +0800 Subject: [PATCH 01/11] feat(gen-pkg-bb): add script to generate yocto bb file Signed-off-by: will_niutao --- gen-pkg-bb.sh | 327 +++++++++++++++++++++++++ get-license.py | 578 +++++++++++++++++++++++++++++++++++++++++++++ get-package-xml.py | 1 + 3 files changed, 906 insertions(+) create mode 100755 gen-pkg-bb.sh create mode 100644 get-license.py diff --git a/gen-pkg-bb.sh b/gen-pkg-bb.sh new file mode 100755 index 0000000..d85651e --- /dev/null +++ b/gen-pkg-bb.sh @@ -0,0 +1,327 @@ +#!/bin/bash + +. base.sh + +GEN_ONE=$1 + +ROS_PKG_SRC=${OUTPUT}/ros-pkg-src.list +ROS_PACKAGE_FIX=${ROOT}/package_fix +ROS_PKG_REMAP=${ROOT}/spec_fix/pkg.remap + +prepare() +{ + if [ "${ROS_SRC_BASE}" = "" ] + then + error_log "Please give the source repo path of ros" + exit 1 + fi + + if [ ! -d ${ROS_SRC_BASE} ] + then + error_log "Please give the source repo path of ros" + exit 1 + fi + + if [ ! -f ${ROS_PKG_SRC} -o ! -f ${ROS_PKG_LIST} ] + then + error_log "Can not find ${ROS_PKG_SRC}, you can use get-repo-src.sh to create it" + exit 1 + fi + + if [ "$GEN_ONE" == "" ] + then + rm -rf ${ROS_BB_BASE} + fi + mkdir -p ${ROS_BB_BASE} +} + +spec_fix() +{ + pkg=$1 + deps_suffix=$2 + require_type=$3 + key_word=$4 + require_file=$5 + + spec_fix_file=${ROOT}/spec_fix/$pkg.${deps_suffix} + + [ ! -f ${spec_fix_file} ] && return + + if [ -f ${require_file} ] + then + for dep in `grep "^\-" ${spec_fix_file} | sed -e "s#^\-##g"` + do + sed -i "/^$require_type: *$dep\$/d" $require_file + done + fi + + grep -q "^\+" $spec_fix_file + [ $? -ne 0 ] && return + + grep "^\+" $spec_fix_file | sed -e "s#^\+#$require_type: #g" >> ${require_file} +} + +rename_requires() +{ + require_file=$1 + + while read deb_pkg rpm_pkg + do + sed -i "s#Requires: ${deb_pkg}\$#Requires: ${rpm_pkg}#g" $require_file + done <${ROS_PKG_REMAP} +} + +replace_key_word() +{ + key_word=$1 + input_file=$2 + replace_file=$3 + + if [ ! -f ${input_file} ] + then + sed -i "/${key_word}/d" $replace_file + return + fi + + desc_wc=`cat ${input_file} | wc -l` + if [ "$desc_wc" = "1" ] + then + desc=`cat ${input_file}` + sed -i "s#${key_word}#$desc#g" $replace_file + else + desc=`cat ${input_file} | sed ":a;N;s/\n/ROS_DESC_CRLF/g;ta"` + sed -i "s^${key_word}^$desc^g" $replace_file + sed -i ":a;N;s/ROS_DESC_CRLF/\n/g;ta" $replace_file + fi +} + +gen_requires() +{ + pkg=$1 + deps_suffix=$2 + require_type=$3 + key_word=$4 + spec=$5 + + debug_log "gen ${deps_suffix}" + + package_xml_deps=${ROS_DEPS_BASE}/$pkg-${deps_suffix} + require_file=${OUTPUT}/.tempRequires + + rm -f ${require_file} + + [ -f ${package_xml_deps} ] && cp ${package_xml_deps} ${require_file} + spec_fix $pkg $deps_suffix $require_type $key_word $require_file + + if [ ! -f ${require_file} ] + then + sed -i "/${key_word}/d" $spec + return + fi + + rename_requires $require_file + + replace_key_word ${key_word} ${require_file} $spec +} + +modify_spec() +{ + pkg=$1 + spec=$2 + pkg_dir_name=$3 + base_version=$4 + release_version=$5 + + info_log "gen spec for $pkg" + + debug_log "gen version" + + csrc=`find $pkg_dir_name -name "*.c" | grep -v /test/ | wc -l` + cppsrc=`find $pkg_dir_name -name "*.cpp" | grep -v /test/ | wc -l` + no_debug=`grep -P "^${pkg}\$" ${ROOT}/spec_fix/no-debuginfo` + + if [ "$csrc" == "0" -a "$cppsrc" == "0" ] || [ "$no_debug" != "" ] + then + sed -i "s#ROS_PACKAGE_NO_DEBUGINFO#%global debug_package %{nil}#g" $spec + else + sed -i '/ROS_PACKAGE_NO_DEBUGINFO/d' $spec + fi + + + sed -i "s#ROS_PACKAGE_NAME#$pkg#g" $spec + sed -i "s#ROS_PACKAGE_VERSION#$base_version#g" $spec + sed -i "s#ROS_PACKAGE_RELEASE#$release_version#g" $spec + + + debug_log "gen license" + + debug_log "gen url" + if [ "$url" = "" ] + then + sed -i '/ROS_PACKAGE_URL/d' $spec + else + sed -i "s#ROS_PACKAGE_URL#$url#g" $spec + fi + + gen_requires $pkg Requires Requires ROS_PACKAGE_REQUIRES $spec + gen_requires $pkg BuildRequires BuildRequires ROS_PACKAGE_BUILDREQUIRES $spec + gen_requires $pkg test-BuildRequires BuildRequires ROS_TEST_BUILDREQUIRES $spec + replace_key_word ROS_PROVIDES_FIX ${ROOT}/spec_fix/$pkg.Provides $spec + + if [ "$pkg" == "ament-cmake-core" -o "$pkg" == "ament-package" -o "$pkg" == "ros-workspace" ] + then + sed -i '/ROS_ALL_FIX_REQUIRES/d' $spec + else + sed -i "s#ROS_ALL_FIX_REQUIRES##g" $spec + fi + + debug_log "gen changelog" + #changetime=`date +"%a %b %d %Y"` + changetime="Thu May 04 2023" + changelog="$changetime $maintainer - $base_version-$release_version" + sed -i "s#ROS_PACKAGE_CHANGELOG#$changelog#g" $spec + + debug_log "gen spec ok" +} + +spec_type_fix() +{ + pkg=$1 + + spec_type=`grep "$pkg " ${ROOT}/spec_fix/spec-type-fix | cut -d' ' -f2` + if [ "$spec_type" == "" ] + then + return + fi + + + spec_tplt=${spec_type}-ubuntu.spec + + cp ${ROOT}/template/${spec_tplt} $pkg.spec +} + +package_fix() +{ + pkg=$1 + pkg_repo=$2 + + if [ -d ${ROS_PACKAGE_FIX}/$pkg ] + then + find ${ROS_PACKAGE_FIX}/$pkg -type f | grep -v "\.fix" | xargs -i cp {} $pkg_repo/ + replace_key_word ROS_SOURCE_FIX ${ROS_PACKAGE_FIX}/$pkg/source.fix $spec + replace_key_word ROS_PREP_FIX ${ROS_PACKAGE_FIX}/$pkg/prep.fix $spec + else + sed -i '/ROS_SOURCE_FIX/d' $spec + sed -i '/ROS_PREP_FIX/d' $spec + fi +} + +get_description() +{ + pkg=$1 + desc_wc=`cat ${ROS_DEPS_BASE}/$pkg-PackageXml-description | wc -l` + if [ "$desc_wc" = "1" ] + then + desc=`cat ${ROS_DEPS_BASE}/$pkg-PackageXml-description` + echo "$desc" + else + echo "ROS $pkg package" + fi +} + license_wc=`grep license: ${ROS_DEPS_BASE}/$pkg-PackageXml | awk -F"license:" '{print $2}' | wc -l` + if [ "$license_wc" = "1" ] + then + license=`grep license: ${ROS_DEPS_BASE}/$pkg-PackageXml | awk -F"license:" '{print $2}'` + sed -i "s#ROS_PACKAGE_LICENSE#$license#g" $spec + else + license=`grep license: ${ROS_DEPS_BASE}/$pkg-PackageXml | awk -F"license:" '{print $2}' | sed ":a;N;s/\n/ and /g;ta"` + sed -i "s#ROS_PACKAGE_LICENSE#$license#g" $spec + fi + +main() +{ + prepare + + info_log "Start to analyse ros-pkg." + + for repo in `cat ${ROS_PKG_LIST} | awk '{print $2}' | sort | uniq` + do + [ "$GEN_ONE" == "" ] && info_log "start to gen $repo" + + mkdir -p ${ROS_BB_BASE}/${repo}/ + cd ${ROS_BB_BASE}/${repo}/ + + grep -P "\t$repo\t" ${ROS_PKG_SRC} >${OUTPUT}/.repo_pkgs + grep -P "\t$repo/" ${ROS_PKG_SRC} >>${OUTPUT}/.repo_pkgs + + while read pkg path version + do + if [ "$GEN_ONE" != "" -a "$pkg" != "$GEN_ONE" ] + then + continue + fi + + if [ "$pkg" = "" -o "$path" = "" -o "$version" = "" ] + then + error_log "Wrong package $pkg" + exit 1 + fi + + base_version=`echo $version | awk -F"-" '{print $1}'` + release_version=`echo $version | awk -F"-" '{print $2}'` + + pkg_dir_name=`cd ${ROS_SRC_BASE}/${repo} && ls ros-${ROS_DISTRO}-${pkg}_*.orig.tar.gz | sed -e "s#.orig.tar.gz##g" | sed -e "s#_#-#g"` + if [ -f ${ROS_SRC_BASE}/${repo}/${pkg_dir_name}/CMakeLists.txt ] + then + ROS_BUILD_TYPE="ament_cmake" + else + ROS_BUILD_TYPE="ament_python" + fi + + #bbfile=${pkg}_${base_version}-${release_version}.bb + bbfile=${pkg}.bb + + echo "# Generated by ros-porting-tools -- DO NOT EDIT" > $bbfile + echo "# Copyright Huawei Technologies Co., Ltd." >> $bbfile + echo "" >> $bbfile + + echo "# repository name" >> $bbfile + echo "ROS_CN = \"${repo}\"" + + bpn=`grep "name:" ${ROS_DEPS_BASE}/$pkg-PackageXml | cut -d':' -f2` + echo "# package name in package.xml" >> $bbfile + echo "ROS_BPN = \"${bpn}\"" >> $bbfile + + echo "# software tarball name" >> $bbfile + echo "ROS_SPN = \"${pkg}\"" >> $bbfile + + echo "PV = \"${base_version}\"" >> $bbfile + echo "" >> $bbfile + + echo "inherit ros-distro-${ROS_DISTRO}" >> $bbfile + echo "" >> $bbfile + + echo "DESCRIPTION = \"`get_description $pkg`\"" >> $bbfile + + maintainer=`grep maintainer: ${ROS_DEPS_BASE}/$pkg-PackageXml | awk -F"maintainer:" '{print $2}'` + echo "AUTHOR = \"${maintainer}\"" >> $bbfile + + url=`grep url: ${ROS_DEPS_BASE}/$pkg-PackageXml | awk -F"url:" '{print $2}' | sed -n '1p'` + echo "HOMEPAGE = \"${url}\"" >> $bbfile + + echo "LICENSE = \"`python3 ${ROOT}/get-license.py $`\"" >> $bbfile + + pkg_dir_name=${ROS_SRC_BASE}/${repo}/$pkg_dir_name + + spec_type_fix $pkg + + modify_spec $pkg $pkg.spec $pkg_dir_name $base_version $release_version + + package_fix $pkg ${ROS_BB_BASE}/${repo} + done < ${OUTPUT}/.repo_pkgs + done + + info_log "Gen ros-pkg-src.list done, you can find it in ${ROS_PKG_SRC}" +} + +main $* diff --git a/get-license.py b/get-license.py new file mode 100644 index 0000000..09a2b7c --- /dev/null +++ b/get-license.py @@ -0,0 +1,578 @@ +#!/usr/bin/python3 + +# Copyright 2017 Open Source Robotics Foundation, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from datetime import datetime +import errno +import os +import random +import re +import string +import sys +import time + +def get_license(lic): + """ + Temporary import the license modification from catkin_pkg validation. + + Once all active ROS packages are updated to have more reasonble license + values, this whole function can be dropped and the value should be the + same as what package.xml says. + """ + def is_valid_spdx_identifier(lic): + """ + Checks if the license is already one of valid SPDX Identifiers from + https://spdx.org/licenses/ + + The list was created with: + cat doc/spdx-3.10-2020-08-03.csv | cut -f 2 | grep -v ^Identifier$ \ + | sed 's/^/"/g; s/$/",/g' | xargs --delimiter='\n' + """ + + return lic in ["0BSD", + "AAL", + "Abstyles", + "Adobe-2006", + "Adobe-Glyph", + "ADSL", + "AFL-1.1", + "AFL-1.2", + "AFL-2.0", + "AFL-2.1", + "AFL-3.0", + "Afmparse", + "AGPL-1.0-only", + "AGPL-1.0-or-later", + "AGPL-3.0-only", + "AGPL-3.0-or-later", + "Aladdin", + "AMDPLPA", + "AML", + "AMPAS", + "ANTLR-PD", + "Apache-1.0", + "Apache-1.1", + "Apache-2.0", + "APAFML", + "APL-1.0", + "APSL-1.0", + "APSL-1.1", + "APSL-1.2", + "APSL-2.0", + "Artistic-1.0", + "Artistic-1.0-cl8", + "Artistic-1.0-Perl", + "Artistic-2.0", + "Bahyph", + "Barr", + "Beerware", + "BitTorrent-1.0", + "BitTorrent-1.1", + "blessing", + "BlueOak-1.0.0", + "Borceux", + "BSD-1-Clause", + "BSD-2-Clause", + "BSD-2-Clause-Patent", + "BSD-2-Clause-Views", + "BSD-3-Clause", + "BSD-3-Clause-Attribution", + "BSD-3-Clause-Clear", + "BSD-3-Clause-LBNL", + "BSD-3-Clause-No-Nuclear-License", + "BSD-3-Clause-No-Nuclear-License-2014", + "BSD-3-Clause-No-Nuclear-Warranty", + "BSD-3-Clause-Open-MPI", + "BSD-4-Clause", + "BSD-4-Clause-UC", + "BSD-Protection", + "BSD-Source-Code", + "BSL-1.0", + "bzip2-1.0.5", + "bzip2-1.0.6", + "CAL-1.0", + "CAL-1.0-Combined-Work-Exception", + "Caldera", + "CATOSL-1.1", + "CC-BY-1.0", + "CC-BY-2.0", + "CC-BY-2.5", + "CC-BY-3.0", + "CC-BY-3.0-AT", + "CC-BY-4.0", + "CC-BY-NC-1.0", + "CC-BY-NC-2.0", + "CC-BY-NC-2.5", + "CC-BY-NC-3.0", + "CC-BY-NC-4.0", + "CC-BY-NC-ND-1.0", + "CC-BY-NC-ND-2.0", + "CC-BY-NC-ND-2.5", + "CC-BY-NC-ND-3.0", + "CC-BY-NC-ND-3.0-IGO", + "CC-BY-NC-ND-4.0", + "CC-BY-NC-SA-1.0", + "CC-BY-NC-SA-2.0", + "CC-BY-NC-SA-2.5", + "CC-BY-NC-SA-3.0", + "CC-BY-NC-SA-4.0", + "CC-BY-ND-1.0", + "CC-BY-ND-2.0", + "CC-BY-ND-2.5", + "CC-BY-ND-3.0", + "CC-BY-ND-4.0", + "CC-BY-SA-1.0", + "CC-BY-SA-2.0", + "CC-BY-SA-2.5", + "CC-BY-SA-3.0", + "CC-BY-SA-3.0-AT", + "CC-BY-SA-4.0", + "CC-PDDC", + "CC0-1.0", + "CDDL-1.0", + "CDDL-1.1", + "CDLA-Permissive-1.0", + "CDLA-Sharing-1.0", + "CECILL-1.0", + "CECILL-1.1", + "CECILL-2.0", + "CECILL-2.1", + "CECILL-B", + "CECILL-C", + "CERN-OHL-1.1", + "CERN-OHL-1.2", + "CERN-OHL-P-2.0", + "CERN-OHL-S-2.0", + "CERN-OHL-W-2.0", + "ClArtistic", + "CNRI-Jython", + "CNRI-Python", + "CNRI-Python-GPL-Compatible", + "Condor-1.1", + "copyleft-next-0.3.0", + "copyleft-next-0.3.1", + "CPAL-1.0", + "CPL-1.0", + "CPOL-1.02", + "Crossword", + "CrystalStacker", + "CUA-OPL-1.0", + "Cube", + "curl", + "D-FSL-1.0", + "diffmark", + "DOC", + "Dotseqn", + "DSDP", + "dvipdfm", + "ECL-1.0", + "ECL-2.0", + "EFL-1.0", + "EFL-2.0", + "eGenix", + "Entessa", + "EPICS", + "EPL-1.0", + "EPL-2.0", + "ErlPL-1.1", + "etalab-2.0", + "EUDatagrid", + "EUPL-1.0", + "EUPL-1.1", + "EUPL-1.2", + "Eurosym", + "Fair", + "Frameworx-1.0", + "FreeImage", + "FSFAP", + "FSFUL", + "FSFULLR", + "FTL", + "GFDL-1.1-invariants-only", + "GFDL-1.1-invariants-or-later", + "GFDL-1.1-no-invariants-only", + "GFDL-1.1-no-invariants-or-later", + "GFDL-1.1-only", + "GFDL-1.1-or-later", + "GFDL-1.2-invariants-only", + "GFDL-1.2-invariants-or-later", + "GFDL-1.2-no-invariants-only", + "GFDL-1.2-no-invariants-or-later", + "GFDL-1.2-only", + "GFDL-1.2-or-later", + "GFDL-1.3-invariants-only", + "GFDL-1.3-invariants-or-later", + "GFDL-1.3-no-invariants-only", + "GFDL-1.3-no-invariants-or-later", + "GFDL-1.3-only", + "GFDL-1.3-or-later", + "Giftware", + "GL2PS", + "Glide", + "Glulxe", + "GLWTPL", + "gnuplot", + "GPL-1.0-only", + "GPL-1.0-or-later", + "GPL-2.0-only", + "GPL-2.0-or-later", + "GPL-3.0-only", + "GPL-3.0-or-later", + "gSOAP-1.3b", + "HaskellReport", + "Hippocratic-2.1", + "HPND", + "HPND-sell-variant", + "IBM-pibs", + "ICU", + "IJG", + "ImageMagick", + "iMatix", + "Imlib2", + "Info-ZIP", + "Intel", + "Intel-ACPI", + "Interbase-1.0", + "IPA", + "IPL-1.0", + "ISC", + "JasPer-2.0", + "JPNIC", + "JSON", + "LAL-1.2", + "LAL-1.3", + "Latex2e", + "Leptonica", + "LGPL-2.0-only", + "LGPL-2.0-or-later", + "LGPL-2.1-only", + "LGPL-2.1-or-later", + "LGPL-3.0-only", + "LGPL-3.0-or-later", + "LGPLLR", + "Libpng", + "libpng-2.0", + "libselinux-1.0", + "libtiff", + "LiLiQ-P-1.1", + "LiLiQ-R-1.1", + "LiLiQ-Rplus-1.1", + "Linux-OpenIB", + "LPL-1.0", + "LPL-1.02", + "LPPL-1.0", + "LPPL-1.1", + "LPPL-1.2", + "LPPL-1.3a", + "LPPL-1.3c", + "MakeIndex", + "MirOS", + "MIT", + "MIT-0", + "MIT-advertising", + "MIT-CMU", + "MIT-enna", + "MIT-feh", + "MITNFA", + "Motosoto", + "mpich2", + "MPL-1.0", + "MPL-1.1", + "MPL-2.0", + "MPL-2.0-no-copyleft-exception", + "MS-PL", + "MS-RL", + "MTLL", + "MulanPSL-1.0", + "MulanPSL-2.0", + "Multics", + "Mup", + "NASA-1.3", + "Naumen", + "NBPL-1.0", + "NCGL-UK-2.0", + "NCSA", + "Net-SNMP", + "NetCDF", + "Newsletr", + "NGPL", + "NIST-PD", + "NIST-PD-fallback", + "NLOD-1.0", + "NLPL", + "Nokia", + "NOSL", + "Noweb", + "NPL-1.0", + "NPL-1.1", + "NPOSL-3.0", + "NRL", + "NTP", + "NTP-0", + "O-UDA-1.0", + "OCCT-PL", + "OCLC-2.0", + "ODbL-1.0", + "ODC-By-1.0", + "OFL-1.0", + "OFL-1.0-no-RFN", + "OFL-1.0-RFN", + "OFL-1.1", + "OFL-1.1-no-RFN", + "OFL-1.1-RFN", + "OGC-1.0", + "OGL-Canada-2.0", + "OGL-UK-1.0", + "OGL-UK-2.0", + "OGL-UK-3.0", + "OGTSL", + "OLDAP-1.1", + "OLDAP-1.2", + "OLDAP-1.3", + "OLDAP-1.4", + "OLDAP-2.0", + "OLDAP-2.0.1", + "OLDAP-2.1", + "OLDAP-2.2", + "OLDAP-2.2.1", + "OLDAP-2.2.2", + "OLDAP-2.3", + "OLDAP-2.4", + "OLDAP-2.5", + "OLDAP-2.6", + "OLDAP-2.7", + "OLDAP-2.8", + "OML", + "OpenSSL", + "OPL-1.0", + "OSET-PL-2.1", + "OSL-1.0", + "OSL-1.1", + "OSL-2.0", + "OSL-2.1", + "OSL-3.0", + "Parity-6.0.0", + "Parity-7.0.0", + "PDDL-1.0", + "PHP-3.0", + "PHP-3.01", + "Plexus", + "PolyForm-Noncommercial-1.0.0", + "PolyForm-Small-Business-1.0.0", + "PostgreSQL", + "PSF-2.0", + "psfrag", + "psutils", + "Python-2.0", + "Qhull", + "QPL-1.0", + "Rdisc", + "RHeCos-1.1", + "RPL-1.1", + "RPL-1.5", + "RPSL-1.0", + "RSA-MD", + "RSCPL", + "Ruby", + "SAX-PD", + "Saxpath", + "SCEA", + "Sendmail", + "Sendmail-8.23", + "SGI-B-1.0", + "SGI-B-1.1", + "SGI-B-2.0", + "SHL-0.5", + "SHL-0.51", + "SimPL-2.0", + "SISSL", + "SISSL-1.2", + "Sleepycat", + "SMLNJ", + "SMPPL", + "SNIA", + "Spencer-86", + "Spencer-94", + "Spencer-99", + "SPL-1.0", + "SSH-OpenSSH", + "SSH-short", + "SSPL-1.0", + "SugarCRM-1.1.3", + "SWL", + "TAPR-OHL-1.0", + "TCL", + "TCP-wrappers", + "TMate", + "TORQUE-1.1", + "TOSL", + "TU-Berlin-1.0", + "TU-Berlin-2.0", + "UCL-1.0", + "Unicode-DFS-2015", + "Unicode-DFS-2016", + "Unicode-TOU", + "Unlicense", + "UPL-1.0", + "Vim", + "VOSTROM", + "VSL-1.0", + "W3C", + "W3C-19980720", + "W3C-20150513", + "Watcom-1.0", + "Wsuipa", + "WTFPL", + "X11", + "Xerox", + "XFree86-1.1", + "xinetd", + "Xnet", + "xpp", + "XSkat", + "YPL-1.0", + "YPL-1.1", + "Zed", + "Zend-2.0", + "Zimbra-1.3", + "Zimbra-1.4", + "Zlib", + "zlib-acknowledgement", + "ZPL-1.1", + "ZPL-2.0", + "ZPL-2.1"] + + def map_license_to_spdx(lic): + """ + Map some commonly used license values to one of valid SPDX Identifiers + from https://spdx.org/licenses/ + + This is mapping only whatever value is listed in package.xml without + any knowledge about the actual license used in the source files - it + can map only the clear unambiguous cases (while triggering an warning) + The rest needs to be fixed in package.xml, so it will trigger an error + + This is similar to what e.g. Openembedded is doing in: + http://git.openembedded.org/openembedded-core/tree/meta/conf/licenses.conf + """ + return { + 'Apache License Version 2.0': 'Apache-2.0', + 'Apachi 2': 'Apache-2.0', + 'Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)': 'Apache-2.0', # noqa: E501 + 'Apache v2': 'Apache-2.0', + 'Apache v2.0': 'Apache-2.0', + 'Apache2.0': 'Apache-2.0', + 'APACHE2.0': 'Apache-2.0', + 'Apache2': 'Apache-2.0', + 'Apache License, Version 2.0': 'Apache-2.0', + 'Apache 2': 'Apache-2.0', + 'Apache 2.0': 'Apache-2.0', + 'Apache License 2.0': 'Apache-2.0', + 'LGPL v2': 'LGPL-2.0-only', + 'LGPL v2.1 or later': 'LGPL-2.1-or-later', + 'LGPL v2.1': 'LGPL-2.1-only', + 'LGPL-2.1': 'LGPL-2.1-only', + 'LGPLv2.1': 'LGPL-2.1-only', + 'GNU Lesser Public License 2.1': 'LGPL-2.1-only', + 'LGPL3': 'LGPL-3.0-only', + 'LGPLv3': 'LGPL-3.0-only', + 'GPL-2.0': 'GPL-2.0-only', + 'GPLv2': 'GPL-2.0-only', + 'GNU General Public License v2.0': 'GPL-2.0-only', + 'GNU GPL v3.0': 'GPL-3.0-only', + 'GPL v3': 'GPL-3.0-only', + 'GPLv3': 'GPL-3.0-only', + 'ECL2.0': 'EPL-2.0', + 'Eclipse Public License 2.0': 'EPL-2.0', + 'Mozilla Public License Version 1.1': 'MPL-1.1', + 'Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License': 'CC-BY-NC-ND-4.0', # noqa: E501 + 'CreativeCommons-Attribution-NonCommercial-NoDerivatives-4.0': 'CC-BY-NC-ND-4.0', # noqa: E501 + 'CreativeCommons-Attribution-NonCommercial-ShareAlike-4.0-International': 'CC-BY-NC-SA-4.0', # noqa: E501 + 'CC BY-NC-SA 4.0': 'CC-BY-NC-SA-4.0', + 'CreativeCommons-by-nc-4.0': 'CC-BY-NC-4.0', + 'CreativeCommons-by-nc-sa-2.0': 'CC-BY-NC-SA-2.0', + 'Creative Commons BY-NC-ND 3.0': 'CC-BY-NC-ND-3.0', + 'BSD 3-clause Clear License': 'BSD-2-Clause', + 'BSD 3-clause. See license attached': 'BSD-2-Clause', + 'BSD 2-Clause License': 'BSD-2-Clause', + 'BSD2': 'BSD-2-Clause', + 'BSD-3': 'BSD-3-Clause', + 'BSD 3-Clause': 'BSD-3-Clause', + 'Boost Software License 1.0': 'BSL-1.0', + 'Boost': 'BSL-1.0', + 'Boost Software License, Version 1.0': 'BSL-1.0', + 'Boost Software License': 'BSL-1.0', + 'BSL1.0': 'BSL-1.0', + 'MIT License': 'MIT', + 'zlib License': 'Zlib', + 'zlib': 'Zlib' + }.get(lic, None) + + def map_license_to_more_common_format(lic): + """ + These aren't SPDX Identifiers, but lets unify them to use at least + similar format. + """ + return { + "Check author's website": 'Check-authors-website', + 'proprietary': 'Proprietary', + 'Public Domain': 'PD', + 'Public domain': 'PD', + 'TODO': 'TODO-CATKIN-PACKAGE-LICENSE' + }.get(lic, None) + + def map_license_to_ampersand_separated_list(lic): + """ + Check if the license tag contains multiple license values. + + Show warning about using multiple license tags when the + value is one of the listed. + """ + return { + 'LGPLv2.1, modified BSD': 'LGPL-2.1-only & modified BSD', + 'Lesser GPL and Apache License': 'Lesser GPL & Apache License', + 'BSD,GPL because of list.h; other files released under BSD,GPL': 'BSD & GPL because of list.h & other files released under BSD & GPL', # noqa: E501 + 'GPL because of list.h; other files released under BSD': 'GPL because of list.h & other files released under BSD', # noqa: E501 + 'BSD, some icons are licensed under the GNU Lesser General Public License (LGPL) or Creative Commons Attribution-Noncommercial 3.0 License': 'BSD & some icons are licensed under LGPL or CC-BY-NC-3.0', # noqa: E501 + 'BSD,LGPL,LGPL (amcl)': 'BSD & LGPL & LGPL (amcl)', + 'BSD, GPL': 'BSD & GPL', + 'BSD, Apache 2.0': 'BSD & Apache-2.0', + 'BSD, LGPL': 'BSD & LGPL', + 'BSD,LGPL,Apache 2.0': 'BSD & LGPL & Apache-2.0' + }.get(lic, None) + + def translate_license(lic): + conversion_table = {ord(' '): '-', ord('/'): '-', ord(':'): '-', + ord('+'): '-', ord('('): '-', ord(')'): '-'} + multi_hyphen_re = re.compile('-{2,}') + return multi_hyphen_re.sub('-', lic.translate(conversion_table)) + + if is_valid_spdx_identifier(lic): + return lic + common = map_license_to_more_common_format(lic) + if common: + lic = common + multiple = map_license_to_ampersand_separated_list(lic) + if multiple: + lic = multiple + spdx = map_license_to_spdx(lic) + if spdx: + lic = spdx + return translate_license(lic) + +if __name__ == '__main__': + lic=get_license(sys.argv[1]) + + print(lic) diff --git a/get-package-xml.py b/get-package-xml.py index 1dac8ff..59f47df 100644 --- a/get-package-xml.py +++ b/get-package-xml.py @@ -44,6 +44,7 @@ def get_depend(depend_name, org_depend_file_name): f.close() +get_depend("name", sys.argv[1]) get_depend("depend", sys.argv[1]) get_depend("build_depend", sys.argv[1]) get_depend("build_export_depend", sys.argv[1]) -- Gitee From 9a9949f7cc24f8d51b97b4b3df513c42cbd5d559 Mon Sep 17 00:00:00 2001 From: will_niutao Date: Wed, 10 May 2023 19:17:39 +0800 Subject: [PATCH 02/11] gen license for bb file Signed-off-by: will_niutao --- gen-pkg-bb.sh | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/gen-pkg-bb.sh b/gen-pkg-bb.sh index d85651e..2273ce0 100755 --- a/gen-pkg-bb.sh +++ b/gen-pkg-bb.sh @@ -219,7 +219,8 @@ package_fix() get_description() { pkg=$1 - desc_wc=`cat ${ROS_DEPS_BASE}/$pkg-PackageXml-description | wc -l` + + desc_wc=`cat ${ROS_DEPS_BASE}/$pkg-PackageXml-description | wc -l` if [ "$desc_wc" = "1" ] then desc=`cat ${ROS_DEPS_BASE}/$pkg-PackageXml-description` @@ -228,16 +229,29 @@ get_description() echo "ROS $pkg package" fi } + +gen_license() +{ + pkg=$1 + bbfile=$2 + license_wc=`grep license: ${ROS_DEPS_BASE}/$pkg-PackageXml | awk -F"license:" '{print $2}' | wc -l` if [ "$license_wc" = "1" ] then license=`grep license: ${ROS_DEPS_BASE}/$pkg-PackageXml | awk -F"license:" '{print $2}'` - sed -i "s#ROS_PACKAGE_LICENSE#$license#g" $spec else license=`grep license: ${ROS_DEPS_BASE}/$pkg-PackageXml | awk -F"license:" '{print $2}' | sed ":a;N;s/\n/ and /g;ta"` - sed -i "s#ROS_PACKAGE_LICENSE#$license#g" $spec + error_log $pkg $license + exit 1 fi + lic=`python3 ${ROOT}/get-license.py "$license"` + + [ "$lic" == "" ] && error_log "can not get license for package $pkg, origin license is \"$license\"" && exit 1 + + echo "LICENSE = \"$lic\"" >> $bbfile +} + main() { prepare @@ -309,7 +323,6 @@ main() url=`grep url: ${ROS_DEPS_BASE}/$pkg-PackageXml | awk -F"url:" '{print $2}' | sed -n '1p'` echo "HOMEPAGE = \"${url}\"" >> $bbfile - echo "LICENSE = \"`python3 ${ROOT}/get-license.py $`\"" >> $bbfile pkg_dir_name=${ROS_SRC_BASE}/${repo}/$pkg_dir_name -- Gitee From a1d1858539f17b5164f0f3ca670f2633403d36fe Mon Sep 17 00:00:00 2001 From: will_niutao Date: Wed, 10 May 2023 21:13:20 +0800 Subject: [PATCH 03/11] fix: add run_depend to Requires Signed-off-by: will_niutao --- get-package-xml.py | 1 + get-pkg-deps.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/get-package-xml.py b/get-package-xml.py index 59f47df..45e7d78 100644 --- a/get-package-xml.py +++ b/get-package-xml.py @@ -52,6 +52,7 @@ get_depend("exec_depend", sys.argv[1]) get_depend("test_depend", sys.argv[1]) get_depend("buildtool_depend", sys.argv[1]) get_depend("buildtool_export_depend", sys.argv[1]) +get_depend("run_depend", sys.argv[1]) get_depend("license", sys.argv[1]) get_depend("url", sys.argv[1]) get_depend("maintainer", sys.argv[1]) diff --git a/get-pkg-deps.sh b/get-pkg-deps.sh index e9a9f41..b31017f 100755 --- a/get-pkg-deps.sh +++ b/get-pkg-deps.sh @@ -127,6 +127,7 @@ main() gen_depend $pkg $path build_depend build gen_depend $pkg $path build_export_depend exec gen_depend $pkg $path exec_depend exec + gen_depend $pkg $path run_depend exec gen_depend $pkg $path test_depend test gen_depend $pkg $path buildtool_depend build gen_depend $pkg $path buildtool_export_depend exec -- Gitee From 09947a84f068a36a593c0d4dd8c732e452183b7b Mon Sep 17 00:00:00 2001 From: will_niutao Date: Wed, 10 May 2023 22:52:11 +0800 Subject: [PATCH 04/11] feat: create XxDepends in get-pkg-deps.sh Signed-off-by: will_niutao --- gen-pkg-bb.sh | 101 ++++++++++++++++++++++-------------------------- get-pkg-deps.sh | 32 +++++++++++++++ 2 files changed, 79 insertions(+), 54 deletions(-) diff --git a/gen-pkg-bb.sh b/gen-pkg-bb.sh index 2273ce0..beb7f07 100755 --- a/gen-pkg-bb.sh +++ b/gen-pkg-bb.sh @@ -95,6 +95,11 @@ replace_key_word() fi } + depend=`grep -P "^${depend_name}:" ${ROS_DEPS_BASE}/$pkg-PackageXml | awk -F"${depend_name}:" '{print $2}'` + if [ "$depend" = "" ] + then + return 0 + fi gen_requires() { pkg=$1 @@ -134,39 +139,10 @@ modify_spec() info_log "gen spec for $pkg" - debug_log "gen version" - - csrc=`find $pkg_dir_name -name "*.c" | grep -v /test/ | wc -l` - cppsrc=`find $pkg_dir_name -name "*.cpp" | grep -v /test/ | wc -l` - no_debug=`grep -P "^${pkg}\$" ${ROOT}/spec_fix/no-debuginfo` - - if [ "$csrc" == "0" -a "$cppsrc" == "0" ] || [ "$no_debug" != "" ] - then - sed -i "s#ROS_PACKAGE_NO_DEBUGINFO#%global debug_package %{nil}#g" $spec - else - sed -i '/ROS_PACKAGE_NO_DEBUGINFO/d' $spec - fi - - - sed -i "s#ROS_PACKAGE_NAME#$pkg#g" $spec - sed -i "s#ROS_PACKAGE_VERSION#$base_version#g" $spec - sed -i "s#ROS_PACKAGE_RELEASE#$release_version#g" $spec - - - debug_log "gen license" - - debug_log "gen url" - if [ "$url" = "" ] - then - sed -i '/ROS_PACKAGE_URL/d' $spec - else - sed -i "s#ROS_PACKAGE_URL#$url#g" $spec - fi gen_requires $pkg Requires Requires ROS_PACKAGE_REQUIRES $spec gen_requires $pkg BuildRequires BuildRequires ROS_PACKAGE_BUILDREQUIRES $spec gen_requires $pkg test-BuildRequires BuildRequires ROS_TEST_BUILDREQUIRES $spec - replace_key_word ROS_PROVIDES_FIX ${ROOT}/spec_fix/$pkg.Provides $spec if [ "$pkg" == "ament-cmake-core" -o "$pkg" == "ament-package" -o "$pkg" == "ros-workspace" ] then @@ -175,29 +151,6 @@ modify_spec() sed -i "s#ROS_ALL_FIX_REQUIRES##g" $spec fi - debug_log "gen changelog" - #changetime=`date +"%a %b %d %Y"` - changetime="Thu May 04 2023" - changelog="$changetime $maintainer - $base_version-$release_version" - sed -i "s#ROS_PACKAGE_CHANGELOG#$changelog#g" $spec - - debug_log "gen spec ok" -} - -spec_type_fix() -{ - pkg=$1 - - spec_type=`grep "$pkg " ${ROOT}/spec_fix/spec-type-fix | cut -d' ' -f2` - if [ "$spec_type" == "" ] - then - return - fi - - - spec_tplt=${spec_type}-ubuntu.spec - - cp ${ROOT}/template/${spec_tplt} $pkg.spec } package_fix() @@ -249,7 +202,37 @@ gen_license() [ "$lic" == "" ] && error_log "can not get license for package $pkg, origin license is \"$license\"" && exit 1 + lic_org=`grep "license" ${ROS_SRC_BASE}/${repo}/${pkg_dir_name}/package.xml` + lic_line=`grep -n "license" ${ROS_SRC_BASE}/${repo}/${pkg_dir_name}/package.xml | cut -d':' -f1` + lic_md5=`echo "$lic_org" | md5sum | cut -d' ' -f1` + echo "LICENSE = \"$lic\"" >> $bbfile + echo "LIC_FILES_CHKSUM = \"file://package.xml;beginline=${lic_line};endline=${lic_line};md5=${lic_md5}\"" >> $bbfile +} + +gen_src_url() +{ + pkg=$1 + bbfile=$2 + + echo "SRC_URI = \" \\" >> $bbfile + echo " file://\${OPENEULER_LOCAL_NAME}/ros-\${ROS_DISTRO}-\${ROS_SPN}_\${PV}.orig.tar.gz \\" >> $bbfile + if [ ! -d ${ROS_PACKAGE_FIX}/${pkg} ] + then + return + fi + + for i in `cd ${ROS_PACKAGE_FIX}/${pkg} && ls | grep -v "\.fix"` + do + echo " file://${i} \\" >> $bbfile + done + + echo "\"" >> $bbfile + echo "" >> $bbfile +} + +gen_build_depends() +{ } main() @@ -322,12 +305,22 @@ main() url=`grep url: ${ROS_DEPS_BASE}/$pkg-PackageXml | awk -F"url:" '{print $2}' | sed -n '1p'` echo "HOMEPAGE = \"${url}\"" >> $bbfile + echo "" >> $bbfile + + echo "" >> $bbfile + echo "" >> $bbfile + echo "" >> $bbfile + echo "" >> $bbfile + echo "" >> $bbfile + echo "" >> $bbfile + echo "" >> $bbfile + echo "" >> $bbfile + echo "" >> $bbfile + echo "" >> $bbfile pkg_dir_name=${ROS_SRC_BASE}/${repo}/$pkg_dir_name - spec_type_fix $pkg - modify_spec $pkg $pkg.spec $pkg_dir_name $base_version $release_version package_fix $pkg ${ROS_BB_BASE}/${repo} diff --git a/get-pkg-deps.sh b/get-pkg-deps.sh index b31017f..ef72044 100755 --- a/get-pkg-deps.sh +++ b/get-pkg-deps.sh @@ -60,6 +60,38 @@ gen_depend() return 0 fi + case $depend_name in + "depend") + echo "$depend" >> ${ROS_DEPS_BASE}/$pkg-BuildDepends + echo "$depend" >> ${ROS_DEPS_BASE}/$pkg-ExecDepends + ;; + "build_depend") + echo "$depend" >> ${ROS_DEPS_BASE}/$pkg-BuildDepends + ;; + "build_export_depend") + echo "$depend" >> ${ROS_DEPS_BASE}/$pkg-BuildExportDepends + echo "$depend" >> ${ROS_DEPS_BASE}/$pkg-ExecDepends + ;; + "exec_depend") + echo "$depend" >> ${ROS_DEPS_BASE}/$pkg-ExecDepends + ;; + "run_depend") + echo "$depend" >> ${ROS_DEPS_BASE}/$pkg-ExecDepends + ;; + "test_depend") + echo "$depend" >> ${ROS_DEPS_BASE}/$pkg-TestDepends + ;; + "buildtool_depend") + echo "$depend" >> ${ROS_DEPS_BASE}/$pkg-BuildToolDepends + ;; + "buildtool_export_depend") + echo "$depend" >> ${ROS_DEPS_BASE}/$pkg-BuildToolExportDepends + ;; + "*") + error_log "Wrong dep_name $dep_name" + ;; + esac + for i in $depend do match_ros_pkg=`echo $i | sed "s#_#-#g"` -- Gitee From 6a84692d203820ff465d52e042a70582c992871c Mon Sep 17 00:00:00 2001 From: will_niutao Date: Thu, 11 May 2023 09:21:23 +0800 Subject: [PATCH 05/11] fix: fix compile error Signed-off-by: will_niutao --- .../moveit-hybrid-planning-remove-test.patch | 36 ++++++++++++++++ package_fix/moveit-hybrid-planning/source.fix | 4 ++ ...ndustrial-motion-planner-remove-test.patch | 41 +++++++++++++++++++ .../pilz-industrial-motion-planner/source.fix | 4 ++ 4 files changed, 85 insertions(+) create mode 100644 package_fix/moveit-hybrid-planning/moveit-hybrid-planning-remove-test.patch create mode 100644 package_fix/moveit-hybrid-planning/source.fix create mode 100644 package_fix/pilz-industrial-motion-planner/pilz-industrial-motion-planner-remove-test.patch create mode 100644 package_fix/pilz-industrial-motion-planner/source.fix diff --git a/package_fix/moveit-hybrid-planning/moveit-hybrid-planning-remove-test.patch b/package_fix/moveit-hybrid-planning/moveit-hybrid-planning-remove-test.patch new file mode 100644 index 0000000..c3c20a9 --- /dev/null +++ b/package_fix/moveit-hybrid-planning/moveit-hybrid-planning-remove-test.patch @@ -0,0 +1,36 @@ +diff -Naur ros-humble-moveit-hybrid-planning-2.5.4_org/CMakeLists.txt ros-humble-moveit-hybrid-planning-2.5.4/CMakeLists.txt +--- ros-humble-moveit-hybrid-planning-2.5.4_org/CMakeLists.txt 2023-05-10 19:55:50.851945574 +0800 ++++ ros-humble-moveit-hybrid-planning-2.5.4/CMakeLists.txt 2023-05-11 08:53:03.827303767 +0800 +@@ -62,7 +62,7 @@ + add_subdirectory(hybrid_planning_manager) + add_subdirectory(global_planner) + add_subdirectory(local_planner) +-add_subdirectory(test) ++#add_subdirectory(test) + + rclcpp_components_register_nodes(moveit_hybrid_planning_manager "moveit::hybrid_planning::HybridPlanningManager") + rclcpp_components_register_nodes(moveit_global_planner_component "moveit::hybrid_planning::GlobalPlannerComponent") +@@ -75,16 +75,16 @@ + RUNTIME DESTINATION bin + INCLUDES DESTINATION include) + +-install(TARGETS cancel_action hybrid_planning_demo_node +- ARCHIVE DESTINATION lib +- LIBRARY DESTINATION lib +- RUNTIME DESTINATION lib/${PROJECT_NAME} +- INCLUDES DESTINATION include) ++#install(TARGETS cancel_action hybrid_planning_demo_node ++# ARCHIVE DESTINATION lib ++# LIBRARY DESTINATION lib ++# RUNTIME DESTINATION lib/${PROJECT_NAME} ++# INCLUDES DESTINATION include) + + install(DIRECTORY ${THIS_PACKAGE_INCLUDE_DIRS} DESTINATION include) + +-install(DIRECTORY test/launch DESTINATION share/${PROJECT_NAME}) +-install(DIRECTORY test/config DESTINATION share/${PROJECT_NAME}) ++#install(DIRECTORY test/launch DESTINATION share/${PROJECT_NAME}) ++#install(DIRECTORY test/config DESTINATION share/${PROJECT_NAME}) + + pluginlib_export_plugin_description_file(moveit_hybrid_planning single_plan_execution_plugin.xml) + pluginlib_export_plugin_description_file(moveit_hybrid_planning moveit_planning_pipeline_plugin.xml) diff --git a/package_fix/moveit-hybrid-planning/source.fix b/package_fix/moveit-hybrid-planning/source.fix new file mode 100644 index 0000000..6f43d2c --- /dev/null +++ b/package_fix/moveit-hybrid-planning/source.fix @@ -0,0 +1,4 @@ + +# cancel_action and hybrid_planning_demo_node are compiling takes too long, +# so remove them from package +Patch0: moveit-hybrid-planning-remove-test.patch diff --git a/package_fix/pilz-industrial-motion-planner/pilz-industrial-motion-planner-remove-test.patch b/package_fix/pilz-industrial-motion-planner/pilz-industrial-motion-planner-remove-test.patch new file mode 100644 index 0000000..3965882 --- /dev/null +++ b/package_fix/pilz-industrial-motion-planner/pilz-industrial-motion-planner-remove-test.patch @@ -0,0 +1,41 @@ +diff -Naur ros-humble-pilz-industrial-motion-planner-2.5.4_org/CMakeLists.txt ros-humble-pilz-industrial-motion-planner-2.5.4/CMakeLists.txt +--- ros-humble-pilz-industrial-motion-planner-2.5.4_org/CMakeLists.txt 2023-05-11 09:16:18.329010364 +0800 ++++ ros-humble-pilz-industrial-motion-planner-2.5.4/CMakeLists.txt 2023-05-11 09:17:20.321388212 +0800 +@@ -195,21 +195,21 @@ + ament_export_targets(${PROJECT_NAME}Targets HAS_LIBRARY_TARGET) + ament_export_dependencies(${THIS_PACKAGE_INCLUDE_DEPENDS} orocos_kdl_vendor) + +-if(BUILD_TESTING) +- # Include Tests +- add_subdirectory(test) +- +- find_package(ament_lint_auto REQUIRED) +- +- # These don't pass yet, disable them for now +- set(ament_cmake_copyright_FOUND TRUE) +- set(ament_cmake_cpplint_FOUND TRUE) +- set(ament_cmake_flake8_FOUND TRUE) +- set(ament_cmake_uncrustify_FOUND TRUE) +- set(ament_cmake_lint_cmake_FOUND TRUE) +- +- # Run all lint tests in package.xml except those listed above +- ament_lint_auto_find_test_dependencies() +-endif() ++#if(BUILD_TESTING) ++# # Include Tests ++# add_subdirectory(test) ++# ++# find_package(ament_lint_auto REQUIRED) ++# ++# # These don't pass yet, disable them for now ++# set(ament_cmake_copyright_FOUND TRUE) ++# set(ament_cmake_cpplint_FOUND TRUE) ++# set(ament_cmake_flake8_FOUND TRUE) ++# set(ament_cmake_uncrustify_FOUND TRUE) ++# set(ament_cmake_lint_cmake_FOUND TRUE) ++# ++# # Run all lint tests in package.xml except those listed above ++# ament_lint_auto_find_test_dependencies() ++#endif() + + ament_package() diff --git a/package_fix/pilz-industrial-motion-planner/source.fix b/package_fix/pilz-industrial-motion-planner/source.fix new file mode 100644 index 0000000..618b9a4 --- /dev/null +++ b/package_fix/pilz-industrial-motion-planner/source.fix @@ -0,0 +1,4 @@ + +# The unittest are compiling takes too long, +# so remove them from package +Patch0: pilz-industrial-motion-planner-remove-test.patch -- Gitee From d2469966b026f78d809723720eea849a96320257 Mon Sep 17 00:00:00 2001 From: will_niutao Date: Thu, 11 May 2023 10:26:55 +0800 Subject: [PATCH 06/11] fix: rename package name libglew-dev to glew-devel Signed-off-by: will_niutao --- spec_fix/pkg.remap | 1 + 1 file changed, 1 insertion(+) diff --git a/spec_fix/pkg.remap b/spec_fix/pkg.remap index 59d9681..1c081aa 100644 --- a/spec_fix/pkg.remap +++ b/spec_fix/pkg.remap @@ -106,3 +106,4 @@ libbluetooth-dev bluez-devel libjsoncpp-dev jsoncpp-devel python3-pil python3-pillow libomp-dev libomp-devel +libglew-dev glew-devel -- Gitee From 6fe8dc26ec0e59decded6b6044edea4297054a51 Mon Sep 17 00:00:00 2001 From: will_niutao Date: Thu, 11 May 2023 11:09:15 +0800 Subject: [PATCH 07/11] feat: complete gen-pkg-bb.sh Signed-off-by: will_niutao --- gen-pkg-bb.sh | 286 ++++++++++++++++++++++-------------------------- get-pkg-deps.sh | 82 +++++++------- 2 files changed, 171 insertions(+), 197 deletions(-) diff --git a/gen-pkg-bb.sh b/gen-pkg-bb.sh index beb7f07..9c82416 100755 --- a/gen-pkg-bb.sh +++ b/gen-pkg-bb.sh @@ -35,30 +35,77 @@ prepare() mkdir -p ${ROS_BB_BASE} } -spec_fix() +gen_description() { pkg=$1 - deps_suffix=$2 - require_type=$3 - key_word=$4 - require_file=$5 + bbfile=$2 + + desc_wc=`cat ${ROS_DEPS_BASE}/$pkg-PackageXml-description | wc -l` + if [ "$desc_wc" = "1" ] + then + desc=`cat ${ROS_DEPS_BASE}/$pkg-PackageXml-description` + else + desc="ROS $pkg package" + fi - spec_fix_file=${ROOT}/spec_fix/$pkg.${deps_suffix} + echo "DESCRIPTION = \"$desc\"" >> $bbfile +} - [ ! -f ${spec_fix_file} ] && return +gen_license() +{ + pkg=$1 + pkg_dir=$2 + bbfile=$3 - if [ -f ${require_file} ] + license_wc=`grep license: ${ROS_DEPS_BASE}/$pkg-PackageXml | awk -F"license:" '{print $2}' | wc -l` + if [ "$license_wc" = "1" ] + then + license=`grep license: ${ROS_DEPS_BASE}/$pkg-PackageXml | awk -F"license:" '{print $2}'` + else + license=`grep license: ${ROS_DEPS_BASE}/$pkg-PackageXml | awk -F"license:" '{print $2}' | sed ":a;N;s/\n/ and /g;ta"` + error_log $pkg $license + exit 1 + fi + + lic=`python3 ${ROOT}/get-license.py "$license"` + + [ "$lic" == "" ] && error_log "can not get license for package $pkg, origin license is \"$license\"" && exit 1 + + lic_org=`grep "license" ${pkg_dir}/package.xml` + lic_line=`grep -n "license" ${pkg_dir}/package.xml | cut -d':' -f1` + lic_md5=`echo "$lic_org" | md5sum | cut -d' ' -f1` + + echo "LICENSE = \"$lic\"" >> $bbfile + echo "LIC_FILES_CHKSUM = \"file://package.xml;beginline=${lic_line};endline=${lic_line};md5=${lic_md5}\"" >> $bbfile +} + +gen_src_url() +{ + pkg=$1 + bbfile=$2 + + echo "SRC_URI = \" \\" >> $bbfile + echo " file://\${OPENEULER_LOCAL_NAME}/ros-\${ROS_DISTRO}-\${ROS_SPN}_\${PV}.orig.tar.gz \\" >> $bbfile + if [ ! -d ${ROS_PACKAGE_FIX}/${pkg} ] then - for dep in `grep "^\-" ${spec_fix_file} | sed -e "s#^\-##g"` + return + fi + + for tarball in `cd ${ROS_PACKAGE_FIX}/${pkg} && ls | grep -v "\.fix"` | grep -v "\.patch"` + do + echo " file://${tarball} \\" >> $bbfile + done + + if [ -f ${ROS_PACKAGE_FIX}/${pkg}/source.fix ] + then + for patch in `grep "^Patch.*: " ${ROS_PACKAGE_FIX}/${pkg}/source.fix | cut -d':' -f2` do - sed -i "/^$require_type: *$dep\$/d" $require_file + echo " file://${patch} \\" >> $bbfile done fi - grep -q "^\+" $spec_fix_file - [ $? -ne 0 ] && return - - grep "^\+" $spec_fix_file | sed -e "s#^\+#$require_type: #g" >> ${require_file} + echo "\"" >> $bbfile + echo "" >> $bbfile } rename_requires() @@ -67,172 +114,116 @@ rename_requires() while read deb_pkg rpm_pkg do - sed -i "s#Requires: ${deb_pkg}\$#Requires: ${rpm_pkg}#g" $require_file + sed -i "s#^${deb_pkg}\$#${rpm_pkg}#g" $require_file done <${ROS_PKG_REMAP} } -replace_key_word() +spec_fix() { - key_word=$1 - input_file=$2 - replace_file=$3 + pkg=$1 + spec_fix_type=$2 + require_file=$3 - if [ ! -f ${input_file} ] + spec_fix_file=${ROOT}/spec_fix/$pkg.${spec_fix_type} + + [ ! -f ${spec_fix_file} ] && return + + if [ -f ${require_file} ] then - sed -i "/${key_word}/d" $replace_file - return + for dep in `grep "^\-" ${spec_fix_file} | sed -e "s#^\-##g"` + do + sed -i "/^$dep\$/d" $require_file + done fi - desc_wc=`cat ${input_file} | wc -l` - if [ "$desc_wc" = "1" ] - then - desc=`cat ${input_file}` - sed -i "s#${key_word}#$desc#g" $replace_file - else - desc=`cat ${input_file} | sed ":a;N;s/\n/ROS_DESC_CRLF/g;ta"` - sed -i "s^${key_word}^$desc^g" $replace_file - sed -i ":a;N;s/ROS_DESC_CRLF/\n/g;ta" $replace_file - fi + grep -q "^\+" $spec_fix_file + [ $? -ne 0 ] && return + + grep "^\+" $spec_fix_file | sed -e "s#^\+##g" >> ${require_file} } - depend=`grep -P "^${depend_name}:" ${ROS_DEPS_BASE}/$pkg-PackageXml | awk -F"${depend_name}:" '{print $2}'` - if [ "$depend" = "" ] - then - return 0 - fi -gen_requires() + +gen_each_depend() { pkg=$1 - deps_suffix=$2 - require_type=$3 - key_word=$4 - spec=$5 + depend_name=$2 + deps_suffix=$3 + spec_fix_type=$4 + bbfile=$5 - debug_log "gen ${deps_suffix}" + debug_log "gen ${depend_name}" package_xml_deps=${ROS_DEPS_BASE}/$pkg-${deps_suffix} - require_file=${OUTPUT}/.tempRequires + require_file=${OUTPUT}/.tempDepends rm -f ${require_file} [ -f ${package_xml_deps} ] && cp ${package_xml_deps} ${require_file} - spec_fix $pkg $deps_suffix $require_type $key_word $require_file + spec_fix $pkg $spec_fix_type $require_file if [ ! -f ${require_file} ] then - sed -i "/${key_word}/d" $spec + echo "$depend_name = \"" >> $bbfile + echo "\"" >> $bbfile + echo "" >> $bbfile return fi rename_requires $require_file - replace_key_word ${key_word} ${require_file} $spec -} + echo "$depend_name = \" \\" >> $bbfile -modify_spec() -{ - pkg=$1 - spec=$2 - pkg_dir_name=$3 - base_version=$4 - release_version=$5 - - info_log "gen spec for $pkg" - - - gen_requires $pkg Requires Requires ROS_PACKAGE_REQUIRES $spec - gen_requires $pkg BuildRequires BuildRequires ROS_PACKAGE_BUILDREQUIRES $spec - gen_requires $pkg test-BuildRequires BuildRequires ROS_TEST_BUILDREQUIRES $spec - - if [ "$pkg" == "ament-cmake-core" -o "$pkg" == "ament-package" -o "$pkg" == "ros-workspace" ] + if [ "$pkg" != "ament-cmake-core" -a "$pkg" != "ament-package" -a "$pkg" != "ros-workspace" ] then - sed -i '/ROS_ALL_FIX_REQUIRES/d' $spec - else - sed -i "s#ROS_ALL_FIX_REQUIRES##g" $spec + if [ "$depend_name" == "ROS_BUILD_DEPENDS" -o "$depend_name" == "ROS_EXEC_DEPENDS" ] + then + echo "ros-workspace" >> $require_file + fi fi -} - -package_fix() -{ - pkg=$1 - pkg_repo=$2 - - if [ -d ${ROS_PACKAGE_FIX}/$pkg ] + if [ "$depend_name" == "ROS_BUILDTOOL_DEPENDS" -o "$depend_name" == "ROS_BUILDTOOL_EXPORT_DEPENDS" ] then - find ${ROS_PACKAGE_FIX}/$pkg -type f | grep -v "\.fix" | xargs -i cp {} $pkg_repo/ - replace_key_word ROS_SOURCE_FIX ${ROS_PACKAGE_FIX}/$pkg/source.fix $spec - replace_key_word ROS_PREP_FIX ${ROS_PACKAGE_FIX}/$pkg/prep.fix $spec + cat $require_file | sed -e "s#$#-native \\#g" -e "s#^# #g" >> $bbfile else - sed -i '/ROS_SOURCE_FIX/d' $spec - sed -i '/ROS_PREP_FIX/d' $spec + cat $require_file | sed -e "s#^# #g" >> $bbfile fi -} -get_description() -{ - pkg=$1 - - desc_wc=`cat ${ROS_DEPS_BASE}/$pkg-PackageXml-description | wc -l` - if [ "$desc_wc" = "1" ] - then - desc=`cat ${ROS_DEPS_BASE}/$pkg-PackageXml-description` - echo "$desc" - else - echo "ROS $pkg package" - fi + echo "\"" >> $bbfile + echo "" >> $bbfile } -gen_license() +gen_depends() { pkg=$1 bbfile=$2 - license_wc=`grep license: ${ROS_DEPS_BASE}/$pkg-PackageXml | awk -F"license:" '{print $2}' | wc -l` - if [ "$license_wc" = "1" ] - then - license=`grep license: ${ROS_DEPS_BASE}/$pkg-PackageXml | awk -F"license:" '{print $2}'` - else - license=`grep license: ${ROS_DEPS_BASE}/$pkg-PackageXml | awk -F"license:" '{print $2}' | sed ":a;N;s/\n/ and /g;ta"` - error_log $pkg $license - exit 1 - fi - - lic=`python3 ${ROOT}/get-license.py "$license"` - - [ "$lic" == "" ] && error_log "can not get license for package $pkg, origin license is \"$license\"" && exit 1 - - lic_org=`grep "license" ${ROS_SRC_BASE}/${repo}/${pkg_dir_name}/package.xml` - lic_line=`grep -n "license" ${ROS_SRC_BASE}/${repo}/${pkg_dir_name}/package.xml | cut -d':' -f1` - lic_md5=`echo "$lic_org" | md5sum | cut -d' ' -f1` + gen_each_depend $pkg ROS_BUILD_DEPENDS BuildDepends BuildRequires $bbfile + gen_each_depend $pkg ROS_BUILD_EXPORT_DEPENDS BuildExportDepends BuildRequires $bbfile + gen_each_depend $pkg ROS_BUILDTOOL_DEPENDS BuildToolDepends BuildRequires $bbfile + gen_each_depend $pkg ROS_BUILDTOOL_EXPORT_DEPENDS BuildToolExportDepends BuildRequires $bbfile + gen_each_depend $pkg ROS_EXEC_DEPENDS ExecDepends Requires $bbfile + gen_each_depend $pkg ROS_TEST_DEPENDS TestDepends test-BuildRequires $bbfile - echo "LICENSE = \"$lic\"" >> $bbfile - echo "LIC_FILES_CHKSUM = \"file://package.xml;beginline=${lic_line};endline=${lic_line};md5=${lic_md5}\"" >> $bbfile + echo 'DEPENDS = "${ROS_BUILD_DEPENDS} ${ROS_BUILD_EXPORT_DEPENDS}"' >> $bbfile + echo 'DEPENDS += "${ROS_BUILDTOOL_DEPENDS} ${ROS_BUILDTOOL_EXPORT_DEPENDS}"' >> $bbfile + echo 'RDEPENDS:${PN} += "${ROS_EXEC_DEPENDS}"' >> $bbfile + echo "" >> $bbfile } -gen_src_url() +gen_build_type() { - pkg=$1 + pkg_dir=$1 bbfile=$2 - echo "SRC_URI = \" \\" >> $bbfile - echo " file://\${OPENEULER_LOCAL_NAME}/ros-\${ROS_DISTRO}-\${ROS_SPN}_\${PV}.orig.tar.gz \\" >> $bbfile - if [ ! -d ${ROS_PACKAGE_FIX}/${pkg} ] - then - return - fi - - for i in `cd ${ROS_PACKAGE_FIX}/${pkg} && ls | grep -v "\.fix"` - do - echo " file://${i} \\" >> $bbfile - done - - echo "\"" >> $bbfile - echo "" >> $bbfile -} + if [ -f ${pkg_dir}/CMakeLists.txt ] + then + build_type="ament_cmake" + else + build_type="ament_python" + fi -gen_build_depends() -{ + echo "ROS_BUILD_TYPE = \"${build_type}\"" >> $bbfile + echo 'inherit ros_${ROS_BUILD_TYPE}' >> $bbfile } main() @@ -268,12 +259,6 @@ main() release_version=`echo $version | awk -F"-" '{print $2}'` pkg_dir_name=`cd ${ROS_SRC_BASE}/${repo} && ls ros-${ROS_DISTRO}-${pkg}_*.orig.tar.gz | sed -e "s#.orig.tar.gz##g" | sed -e "s#_#-#g"` - if [ -f ${ROS_SRC_BASE}/${repo}/${pkg_dir_name}/CMakeLists.txt ] - then - ROS_BUILD_TYPE="ament_cmake" - else - ROS_BUILD_TYPE="ament_python" - fi #bbfile=${pkg}_${base_version}-${release_version}.bb bbfile=${pkg}.bb @@ -298,7 +283,7 @@ main() echo "inherit ros-distro-${ROS_DISTRO}" >> $bbfile echo "" >> $bbfile - echo "DESCRIPTION = \"`get_description $pkg`\"" >> $bbfile + gen_description $pkg $bbfile maintainer=`grep maintainer: ${ROS_DEPS_BASE}/$pkg-PackageXml | awk -F"maintainer:" '{print $2}'` echo "AUTHOR = \"${maintainer}\"" >> $bbfile @@ -307,27 +292,14 @@ main() echo "HOMEPAGE = \"${url}\"" >> $bbfile echo "" >> $bbfile - echo "" >> $bbfile - echo "" >> $bbfile - echo "" >> $bbfile - echo "" >> $bbfile - echo "" >> $bbfile - echo "" >> $bbfile - echo "" >> $bbfile - echo "" >> $bbfile - echo "" >> $bbfile - echo "" >> $bbfile - - - pkg_dir_name=${ROS_SRC_BASE}/${repo}/$pkg_dir_name - - modify_spec $pkg $pkg.spec $pkg_dir_name $base_version $release_version - - package_fix $pkg ${ROS_BB_BASE}/${repo} + gen_license $pkg ${ROS_SRC_BASE}/${repo}/${pkg_dir_name} $bbfile + gen_src_url $pkg $bbfile + gen_depends $pkg $bbfile + gen_build_type ${ROS_SRC_BASE}/${repo}/${pkg_dir_name} $bbfile done < ${OUTPUT}/.repo_pkgs done - info_log "Gen ros-pkg-src.list done, you can find it in ${ROS_PKG_SRC}" + info_log "Gen bb files done, you can find it in ${ROS_BB_BASE}" } main $* diff --git a/get-pkg-deps.sh b/get-pkg-deps.sh index ef72044..6a9bd0b 100755 --- a/get-pkg-deps.sh +++ b/get-pkg-deps.sh @@ -60,66 +60,68 @@ gen_depend() return 0 fi - case $depend_name in - "depend") - echo "$depend" >> ${ROS_DEPS_BASE}/$pkg-BuildDepends - echo "$depend" >> ${ROS_DEPS_BASE}/$pkg-ExecDepends - ;; - "build_depend") - echo "$depend" >> ${ROS_DEPS_BASE}/$pkg-BuildDepends - ;; - "build_export_depend") - echo "$depend" >> ${ROS_DEPS_BASE}/$pkg-BuildExportDepends - echo "$depend" >> ${ROS_DEPS_BASE}/$pkg-ExecDepends - ;; - "exec_depend") - echo "$depend" >> ${ROS_DEPS_BASE}/$pkg-ExecDepends - ;; - "run_depend") - echo "$depend" >> ${ROS_DEPS_BASE}/$pkg-ExecDepends - ;; - "test_depend") - echo "$depend" >> ${ROS_DEPS_BASE}/$pkg-TestDepends - ;; - "buildtool_depend") - echo "$depend" >> ${ROS_DEPS_BASE}/$pkg-BuildToolDepends - ;; - "buildtool_export_depend") - echo "$depend" >> ${ROS_DEPS_BASE}/$pkg-BuildToolExportDepends - ;; - "*") - error_log "Wrong dep_name $dep_name" - ;; - esac - for i in $depend do match_ros_pkg=`echo $i | sed "s#_#-#g"` grep -Pq "^${match_ros_pkg}\t" ${ROS_PKG_LIST} if [ $? -eq 0 ] then - dep="ros-%{ros_distro}-${match_ros_pkg}" + dep_spec="ros-%{ros_distro}-${match_ros_pkg}" + dep_bb="${match_ros_pkg}" else - dep=$i + dep_spec=$i + dep_bb=$i echo "$i" >>${ROS_DEPS_BASE}/$pkg-ExtDeps fi case $dep_type in "all") - write_dep Requires $dep ${ROS_DEPS_BASE}/$pkg-Requires - write_dep BuildRequires $dep ${ROS_DEPS_BASE}/$pkg-BuildRequires + write_dep Requires $dep_spec ${ROS_DEPS_BASE}/$pkg-Requires + write_dep BuildRequires $dep_spec ${ROS_DEPS_BASE}/$pkg-BuildRequires ;; "exec") - write_dep Requires $dep ${ROS_DEPS_BASE}/$pkg-Requires + write_dep Requires $dep_spec ${ROS_DEPS_BASE}/$pkg-Requires ;; "build") - write_dep BuildRequires $dep ${ROS_DEPS_BASE}/$pkg-BuildRequires + write_dep BuildRequires $dep_spec ${ROS_DEPS_BASE}/$pkg-BuildRequires ;; "test") - write_dep BuildRequires $dep ${ROS_DEPS_BASE}/$pkg-test-BuildRequires + write_dep BuildRequires $dep_spec ${ROS_DEPS_BASE}/$pkg-test-BuildRequires + ;; + "*") + error_log "Wrong dep_type $dep_spec_type" + ;; + esac + + case $dep_bbend_name in + "depend") + echo "$dep_bb" >> ${ROS_DEPS_BASE}/$pkg-BuildDepends + echo "$dep_bb" >> ${ROS_DEPS_BASE}/$pkg-ExecDepends + ;; + "build_depend") + echo "$dep_bb" >> ${ROS_DEPS_BASE}/$pkg-BuildDepends + ;; + "build_export_depend") + echo "$dep_bb" >> ${ROS_DEPS_BASE}/$pkg-BuildExportDepends + echo "$dep_bb" >> ${ROS_DEPS_BASE}/$pkg-ExecDepends + ;; + "exec_depend") + echo "$dep_bb" >> ${ROS_DEPS_BASE}/$pkg-ExecDepends + ;; + "run_depend") + echo "$dep_bb" >> ${ROS_DEPS_BASE}/$pkg-ExecDepends + ;; + "test_depend") + echo "$dep_bb" >> ${ROS_DEPS_BASE}/$pkg-TestDepends + ;; + "buildtool_depend") + echo "$dep_bb" >> ${ROS_DEPS_BASE}/$pkg-BuildToolDepends + ;; + "buildtool_export_depend") + echo "$dep_bb" >> ${ROS_DEPS_BASE}/$pkg-BuildToolExportDepends ;; "*") - error_log "Wrong dep_type $dep_type" + error_log "Wrong dep_name $dep_name" ;; esac done -- Gitee From ea88d1e75d97f03049ab8f821005d54f7dec1dfd Mon Sep 17 00:00:00 2001 From: will_niutao Date: Thu, 11 May 2023 12:02:27 +0800 Subject: [PATCH 08/11] fix compile error Signed-off-by: will_niutao --- spec_fix/moveit-ros-perception.BuildRequires | 2 ++ spec_fix/pkg.remap | 1 + 2 files changed, 3 insertions(+) diff --git a/spec_fix/moveit-ros-perception.BuildRequires b/spec_fix/moveit-ros-perception.BuildRequires index 0468adc..8e7c80a 100644 --- a/spec_fix/moveit-ros-perception.BuildRequires +++ b/spec_fix/moveit-ros-perception.BuildRequires @@ -1 +1,3 @@ +mesa-libGLU-devel +-glut ++freeglut-devel diff --git a/spec_fix/pkg.remap b/spec_fix/pkg.remap index 1c081aa..775c118 100644 --- a/spec_fix/pkg.remap +++ b/spec_fix/pkg.remap @@ -107,3 +107,4 @@ libjsoncpp-dev jsoncpp-devel python3-pil python3-pillow libomp-dev libomp-devel libglew-dev glew-devel +glut freeglut -- Gitee From 7b12823d00c1fdfe1cd9a9f9b6d65dab4c869a11 Mon Sep 17 00:00:00 2001 From: will_niutao Date: Thu, 11 May 2023 12:03:04 +0800 Subject: [PATCH 09/11] fix: fix gen-pkg-bb.sh can not generate DEPENDS error Signed-off-by: will_niutao --- gen-pkg-bb.sh | 50 ++++++++++++++++++++++++++++--------------------- get-pkg-deps.sh | 2 +- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/gen-pkg-bb.sh b/gen-pkg-bb.sh index 9c82416..1ea2253 100755 --- a/gen-pkg-bb.sh +++ b/gen-pkg-bb.sh @@ -57,26 +57,29 @@ gen_license() pkg_dir=$2 bbfile=$3 - license_wc=`grep license: ${ROS_DEPS_BASE}/$pkg-PackageXml | awk -F"license:" '{print $2}' | wc -l` - if [ "$license_wc" = "1" ] - then - license=`grep license: ${ROS_DEPS_BASE}/$pkg-PackageXml | awk -F"license:" '{print $2}'` - else - license=`grep license: ${ROS_DEPS_BASE}/$pkg-PackageXml | awk -F"license:" '{print $2}' | sed ":a;N;s/\n/ and /g;ta"` - error_log $pkg $license - exit 1 - fi - - lic=`python3 ${ROOT}/get-license.py "$license"` + lics="" + grep license: ${ROS_DEPS_BASE}/$pkg-PackageXml | awk -F"license:" '{print $2}' >${OUTPUT}/.tempLicense + while read lic + do + yocto_lic=`python3 ${ROOT}/get-license.py "$lic"` + [ "$yocto_lic" == "" ] && error_log "can not get license for package $pkg, origin license is \"$lic\"" && exit 1 - [ "$lic" == "" ] && error_log "can not get license for package $pkg, origin license is \"$license\"" && exit 1 + if [ "$lics" == "" ] + then + lics="$yocto_lic" + else + lics="$lics & $yocto_lic" + fi + done < ${OUTPUT}/.tempLicense lic_org=`grep "license" ${pkg_dir}/package.xml` - lic_line=`grep -n "license" ${pkg_dir}/package.xml | cut -d':' -f1` + lic_beginline=`grep -n "license" ${pkg_dir}/package.xml | head -1 | cut -d':' -f1` + lic_endline=`grep -n "license" ${pkg_dir}/package.xml | tail -1 | cut -d':' -f1` lic_md5=`echo "$lic_org" | md5sum | cut -d' ' -f1` - echo "LICENSE = \"$lic\"" >> $bbfile - echo "LIC_FILES_CHKSUM = \"file://package.xml;beginline=${lic_line};endline=${lic_line};md5=${lic_md5}\"" >> $bbfile + echo "LICENSE = \"$lics\"" >> $bbfile + echo "LIC_FILES_CHKSUM = \"file://package.xml;beginline=${lic_beginline};endline=${lic_endline};md5=${lic_md5}\"" >> $bbfile + echo "" >> $bbfile } gen_src_url() @@ -88,10 +91,12 @@ gen_src_url() echo " file://\${OPENEULER_LOCAL_NAME}/ros-\${ROS_DISTRO}-\${ROS_SPN}_\${PV}.orig.tar.gz \\" >> $bbfile if [ ! -d ${ROS_PACKAGE_FIX}/${pkg} ] then + echo "\"" >> $bbfile + echo "" >> $bbfile return fi - for tarball in `cd ${ROS_PACKAGE_FIX}/${pkg} && ls | grep -v "\.fix"` | grep -v "\.patch"` + for tarball in `cd ${ROS_PACKAGE_FIX}/${pkg} && ls | grep -v "\.fix" | grep -v "\.patch"` do echo " file://${tarball} \\" >> $bbfile done @@ -163,7 +168,7 @@ gen_each_depend() if [ ! -f ${require_file} ] then - echo "$depend_name = \"" >> $bbfile + echo "$depend_name = \" \\" >> $bbfile echo "\"" >> $bbfile echo "" >> $bbfile return @@ -183,9 +188,9 @@ gen_each_depend() if [ "$depend_name" == "ROS_BUILDTOOL_DEPENDS" -o "$depend_name" == "ROS_BUILDTOOL_EXPORT_DEPENDS" ] then - cat $require_file | sed -e "s#$#-native \\#g" -e "s#^# #g" >> $bbfile + cat $require_file | sed -e 's#$#-native \\#g' -e 's#^# #g' >> $bbfile else - cat $require_file | sed -e "s#^# #g" >> $bbfile + cat $require_file | sed -e 's#$# \\#g' -e 's#^# #g' >> $bbfile fi echo "\"" >> $bbfile @@ -234,7 +239,7 @@ main() for repo in `cat ${ROS_PKG_LIST} | awk '{print $2}' | sort | uniq` do - [ "$GEN_ONE" == "" ] && info_log "start to gen $repo" + [ "$GEN_ONE" == "" ] && info_log "start to generate bbfile for repository $repo" mkdir -p ${ROS_BB_BASE}/${repo}/ cd ${ROS_BB_BASE}/${repo}/ @@ -255,6 +260,8 @@ main() exit 1 fi + info_log "generate bbfile for package $pkg" + base_version=`echo $version | awk -F"-" '{print $1}'` release_version=`echo $version | awk -F"-" '{print $2}'` @@ -268,7 +275,7 @@ main() echo "" >> $bbfile echo "# repository name" >> $bbfile - echo "ROS_CN = \"${repo}\"" + echo "ROS_CN = \"${repo}\"" >> $bbfile bpn=`grep "name:" ${ROS_DEPS_BASE}/$pkg-PackageXml | cut -d':' -f2` echo "# package name in package.xml" >> $bbfile @@ -289,6 +296,7 @@ main() echo "AUTHOR = \"${maintainer}\"" >> $bbfile url=`grep url: ${ROS_DEPS_BASE}/$pkg-PackageXml | awk -F"url:" '{print $2}' | sed -n '1p'` + [ "$url" == "" ] && url="https://wiki.ros.org" echo "HOMEPAGE = \"${url}\"" >> $bbfile echo "" >> $bbfile diff --git a/get-pkg-deps.sh b/get-pkg-deps.sh index 6a9bd0b..8983c29 100755 --- a/get-pkg-deps.sh +++ b/get-pkg-deps.sh @@ -93,7 +93,7 @@ gen_depend() ;; esac - case $dep_bbend_name in + case $depend_name in "depend") echo "$dep_bb" >> ${ROS_DEPS_BASE}/$pkg-BuildDepends echo "$dep_bb" >> ${ROS_DEPS_BASE}/$pkg-ExecDepends -- Gitee From 8b3661410931f82761ce1a94ad5e141ddec14145 Mon Sep 17 00:00:00 2001 From: will_niutao Date: Thu, 11 May 2023 17:35:12 +0800 Subject: [PATCH 10/11] fix: fix error --- gen-pkg-bb.sh | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/gen-pkg-bb.sh b/gen-pkg-bb.sh index 1ea2253..eead0b9 100755 --- a/gen-pkg-bb.sh +++ b/gen-pkg-bb.sh @@ -7,6 +7,10 @@ GEN_ONE=$1 ROS_PKG_SRC=${OUTPUT}/ros-pkg-src.list ROS_PACKAGE_FIX=${ROOT}/package_fix ROS_PKG_REMAP=${ROOT}/spec_fix/pkg.remap +ROS_GENERAGTED_BB_BASE=${ROS_BB_BASE}/recipes-generated +ROS_NATIVE_PKGS=${ROS_GENERAGTED_BB_BASE}/ros-native-pkgs.inc +ROS_NATIVE_PKGS_TMP1=${ROS_BB_BASE}/.ros-native-pkgs.tmp1 +ROS_NATIVE_PKGS_TMP2=${ROS_BB_BASE}/.ros-native-pkgs.tmp2 prepare() { @@ -30,9 +34,13 @@ prepare() if [ "$GEN_ONE" == "" ] then - rm -rf ${ROS_BB_BASE} + rm -rf ${ROS_GENERAGTED_BB_BASE} + rm -f ${ROS_NATIVE_PKGS} + rm -f ${ROS_NATIVE_PKGS_TMP2} fi - mkdir -p ${ROS_BB_BASE} + + rm -f ${ROS_NATIVE_PKGS_TMP1} + mkdir -p ${ROS_GENERAGTED_BB_BASE} } gen_description() @@ -188,6 +196,7 @@ gen_each_depend() if [ "$depend_name" == "ROS_BUILDTOOL_DEPENDS" -o "$depend_name" == "ROS_BUILDTOOL_EXPORT_DEPENDS" ] then + cat $require_file >> ${ROS_NATIVE_PKGS_TMP1} cat $require_file | sed -e 's#$#-native \\#g' -e 's#^# #g' >> $bbfile else cat $require_file | sed -e 's#$# \\#g' -e 's#^# #g' >> $bbfile @@ -231,6 +240,25 @@ gen_build_type() echo 'inherit ros_${ROS_BUILD_TYPE}' >> $bbfile } +gen_native_pkgs() +{ + [ -f ${ROS_NATIVE_PKGS_TMP1} ] && cat ${ROS_NATIVE_PKGS_TMP1} >> ${ROS_NATIVE_PKGS_TMP2} + + if [ -f ${ROS_NATIVE_PKGS_TMP2} ] + then + cat ${ROS_NATIVE_PKGS_TMP2} | sort | uniq >${ROS_NATIVE_PKGS_TMP1} + mv ${ROS_NATIVE_PKGS_TMP1} ${ROS_NATIVE_PKGS_TMP2} + fi + + echo "# Generated by ros-porting-tools -- DO NOT EDIT" > ${ROS_NATIVE_PKGS} + echo "# Copyright Huawei Technologies Co., Ltd." >> ${ROS_NATIVE_PKGS} + echo "" >> ${ROS_NATIVE_PKGS} + + echo "ROS_NATIVE_PKGS = \"\\" >> ${ROS_NATIVE_PKGS} + cat ${ROS_NATIVE_PKGS_TMP2} | sed -e 's#$#-native \\#g' -e 's#^# #g' >> ${ROS_NATIVE_PKGS} + echo "\"" >> ${ROS_NATIVE_PKGS} +} + main() { prepare @@ -241,8 +269,8 @@ main() do [ "$GEN_ONE" == "" ] && info_log "start to generate bbfile for repository $repo" - mkdir -p ${ROS_BB_BASE}/${repo}/ - cd ${ROS_BB_BASE}/${repo}/ + mkdir -p ${ROS_GENERAGTED_BB_BASE}/${repo}/ + cd ${ROS_GENERAGTED_BB_BASE}/${repo}/ grep -P "\t$repo\t" ${ROS_PKG_SRC} >${OUTPUT}/.repo_pkgs grep -P "\t$repo/" ${ROS_PKG_SRC} >>${OUTPUT}/.repo_pkgs @@ -277,7 +305,7 @@ main() echo "# repository name" >> $bbfile echo "ROS_CN = \"${repo}\"" >> $bbfile - bpn=`grep "name:" ${ROS_DEPS_BASE}/$pkg-PackageXml | cut -d':' -f2` + bpn=`grep "name:" ${ROS_DEPS_BASE}/$pkg-PackageXml | cut -d':' -f2 | head -1` echo "# package name in package.xml" >> $bbfile echo "ROS_BPN = \"${bpn}\"" >> $bbfile @@ -288,6 +316,7 @@ main() echo "" >> $bbfile echo "inherit ros-distro-${ROS_DISTRO}" >> $bbfile + echo "inherit ros-native-pkgs" >> $bbfile echo "" >> $bbfile gen_description $pkg $bbfile @@ -307,7 +336,9 @@ main() done < ${OUTPUT}/.repo_pkgs done - info_log "Gen bb files done, you can find it in ${ROS_BB_BASE}" + gen_native_pkgs + + info_log "Gen bb files done, you can find it in ${ROS_GENERAGTED_BB_BASE}" } main $* -- Gitee From a1376fb541a371e55509ef0f2ba5f497f255d4e3 Mon Sep 17 00:00:00 2001 From: will_niutao Date: Thu, 11 May 2023 19:06:26 +0800 Subject: [PATCH 11/11] fix: fix compile error after package upgrade Signed-off-by: will_niutao --- .../pick-ik/pick-ik-fix-Catch2-error.patch | 9 ++++---- .../pick-ik/pick-ik-fix-compile-error.patch | 21 ------------------- package_fix/pick-ik/source.fix | 1 - package_fix/rsl/rsl-fix-Catch2-error.patch | 19 ++++++++--------- 4 files changed, 13 insertions(+), 37 deletions(-) delete mode 100644 package_fix/pick-ik/pick-ik-fix-compile-error.patch diff --git a/package_fix/pick-ik/pick-ik-fix-Catch2-error.patch b/package_fix/pick-ik/pick-ik-fix-Catch2-error.patch index 8943e98..5c7fc64 100644 --- a/package_fix/pick-ik/pick-ik-fix-Catch2-error.patch +++ b/package_fix/pick-ik/pick-ik-fix-Catch2-error.patch @@ -1,11 +1,10 @@ -diff -Naur ros-humble-pick-ik-1.0.0_org/tests/CMakeLists.txt ros-humble-pick-ik-1.0.0/tests/CMakeLists.txt ---- ros-humble-pick-ik-1.0.0_org/tests/CMakeLists.txt 2023-05-08 19:56:51.791390734 +0800 -+++ ros-humble-pick-ik-1.0.0/tests/CMakeLists.txt 2023-05-08 20:01:35.391545184 +0800 +--- ros-humble-pick-ik-1.0.1_org/tests/CMakeLists.txt 2023-05-11 17:43:27.366923785 +0800 ++++ ros-humble-pick-ik-1.0.1/tests/CMakeLists.txt 2023-05-11 17:44:51.517452612 +0800 @@ -1,7 +1,8 @@ -list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) -- - find_package(Catch2 3.1.0 REQUIRED) + find_package(Catch2 3.3.0 REQUIRED) +- +if (NOT Catch2_FOUND) + list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) +endif() diff --git a/package_fix/pick-ik/pick-ik-fix-compile-error.patch b/package_fix/pick-ik/pick-ik-fix-compile-error.patch deleted file mode 100644 index 0b89437..0000000 --- a/package_fix/pick-ik/pick-ik-fix-compile-error.patch +++ /dev/null @@ -1,21 +0,0 @@ -diff -Naur ros-humble-pick-ik-1.0.0_org/src/ik_memetic.cpp ros-humble-pick-ik-1.0.0/src/ik_memetic.cpp ---- ros-humble-pick-ik-1.0.0_org/src/ik_memetic.cpp 2023-05-08 19:56:51.791390734 +0800 -+++ ros-humble-pick-ik-1.0.0/src/ik_memetic.cpp 2023-05-08 20:50:43.986739066 +0800 -@@ -38,7 +38,7 @@ - static_cast(params.population_size - 1)); - } - inverse_gene_size_ = 1.0 / static_cast(initial_guess.size()); --}; -+} - - bool MemeticIk::checkWipeout() { - // Handle wipeouts if no progress is being made. -diff -Naur ros-humble-pick-ik-1.0.0_org/src/pick_ik_plugin.cpp ros-humble-pick-ik-1.0.0/src/pick_ik_plugin.cpp ---- ros-humble-pick-ik-1.0.0_org/src/pick_ik_plugin.cpp 2023-05-08 19:56:51.791390734 +0800 -+++ ros-humble-pick-ik-1.0.0/src/pick_ik_plugin.cpp 2023-05-08 20:50:37.026637108 +0800 -@@ -364,4 +364,4 @@ - - } // namespace pick_ik - --PLUGINLIB_EXPORT_CLASS(pick_ik::PickIKPlugin, kinematics::KinematicsBase); -+PLUGINLIB_EXPORT_CLASS(pick_ik::PickIKPlugin, kinematics::KinematicsBase) diff --git a/package_fix/pick-ik/source.fix b/package_fix/pick-ik/source.fix index 955ad75..e0efca8 100644 --- a/package_fix/pick-ik/source.fix +++ b/package_fix/pick-ik/source.fix @@ -1,3 +1,2 @@ Patch0: pick-ik-fix-Catch2-error.patch -Patch1: pick-ik-fix-compile-error.patch diff --git a/package_fix/rsl/rsl-fix-Catch2-error.patch b/package_fix/rsl/rsl-fix-Catch2-error.patch index ddfc38b..66ff4d6 100644 --- a/package_fix/rsl/rsl-fix-Catch2-error.patch +++ b/package_fix/rsl/rsl-fix-Catch2-error.patch @@ -1,19 +1,18 @@ -diff -Naur ros-humble-rsl-0.2.1_org/tests/CMakeLists.txt ros-humble-rsl-0.2.1/tests/CMakeLists.txt ---- ros-humble-rsl-0.2.1_org/tests/CMakeLists.txt 2023-05-07 11:53:18.215360070 +0800 -+++ ros-humble-rsl-0.2.1/tests/CMakeLists.txt 2023-05-07 11:59:24.986324119 +0800 -@@ -1,7 +1,8 @@ +diff -Naur ros-humble-rsl-0.2.2_org/tests/CMakeLists.txt ros-humble-rsl-0.2.2/tests/CMakeLists.txt +--- ros-humble-rsl-0.2.2_org/tests/CMakeLists.txt 2023-05-11 17:36:22.490110840 +0800 ++++ ros-humble-rsl-0.2.2/tests/CMakeLists.txt 2023-05-11 17:38:07.594806701 +0800 +@@ -1,6 +1,9 @@ -list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) -- --find_package(Catch2 3.2.0 REQUIRED) - find_package(range-v3 REQUIRED) -+find_package(Catch2 3.2.0 REQUIRED) + + find_package(Catch2 3.3.0 REQUIRED) +if (NOT Catch2_FOUND) + list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) +endif() ++ + find_package(range-v3 REQUIRED) add_executable(test-rsl - algorithm.cpp -@@ -19,4 +20,5 @@ +@@ -19,4 +22,5 @@ Catch2::Catch2WithMain range-v3::range-v3 ) -- Gitee