列出构建Yocto映像所需的所有包/文件的SRC_URI

时间:2018-05-15 08:23:14

标签: yocto bitbake

我想列出当我烘焙图像时bitbake将获取的所有文件。

目前,我能够通过执行bitbake core-image-minimal -c fetchall获取烘焙Yocto图像所需的所有文件的SRC_URI,然后解析日志文件。

是否有更简单的方法可以在不需要下载文件的情况下获得相同的结果?

我不确定bitbake是否支持此功能。理想情况下,我正在寻找一个打印出包名称的命令,并列出所有具有相应URL的文件

> bitbake core-image-minimal -c fetchall --print-only

4 个答案:

答案 0 :(得分:5)

通常 bitbake 不提供此类功能。

但我能够创建一个简单的解决方案,创建简单的 .bbclass 文件,该文件在所有食谱中继承,通过将其添加到 local.conf 文件中,请参阅我的步骤是为了存档:

步骤:

  1. 让我们创建一个用于获取和打印 SRC_URI 变量的类 print-src.bbclass 文件(记得将此类文件存储在图层中)这可以在conf / bblayers.conf中找到:

    $ cat print-src.bbclass
    
    python do_print_src () {
    srcuri = d.getVar('SRC_URI', True).split()
    bb.warn("SRC_URI look like: %s" % srcuri)
    }
    
    addtask do_print_src before do_fetch
    
  2. INHERIT + =" print-src" 添加到 conf / local.conf 文件中

  3. 编辑:使用 bitbake --ununly 选项很重要,它允许为指定目标运行任务图的特定任务(使用 - runonly 选项 do_print_src 需要用作 print_src ),

    修改:请注意 - runall = RUNALL - runonly = RUNONLY Yocto Sumo release 2.5一起引入,< / p>

    $ bitbake core-image-minimal --runonly print_src
    Loaded 1236 entries from dependency cache.
    NOTE: Resolving any missing task queue dependencies
    
    Build Configuration:
    BB_VERSION           = "1.37.0"
    BUILD_SYS            = "x86_64-linux"
    NATIVELSBSTRING      = "universal-4.8"
    TARGET_SYS           = "i586-poky-linux"
    MACHINE              = "qemux86"
    DISTRO               = "poky"
    DISTRO_VERSION       = "2.5"
    TUNE_FEATURES        = "m32 i586"
    TARGET_FPU           = ""
    meta                 
    meta-poky            
    meta-yocto-bsp       = "master:13cc30cd7de4841990b600e83e1249c81a5171dd"
    
    Initialising tasks: 100% |##########################################################################################################################################################################| Time: 0:00:00
    NOTE: Executing RunQueue Tasks
    WARNING: ptest-runner-2.2+gitAUTOINC+49956f65bb-r0 do_print_src: SRC_URI look like: ['git://git.yoctoproject.org/ptest-runner2']
    WARNING: grep-3.1-r0 do_print_src: SRC_URI look like: ['http://ftp.gnu.org/gnu/grep/grep-3.1.tar.xz', 'file://0001-Unset-need_charset_alias-when-building-for-musl.patch']
    ...
    ... 
    NOTE: Tasks Summary: Attempted 201 tasks of which 0 didn't need to be rerun and all succeeded.
    
    Summary: There were 202 WARNING messages shown.
    

    请参阅示例警告输出日志行:

    警告: ptest-runner-2.2 + gitAUTOINC + 49956f65bb -r0 do_print_src:SRC_URI如下所示:[&#39; git://git.yoctoproject.org/ptest-runner2' ]

答案 1 :(得分:1)

我需要这样的东西,并且在此之前就已经完成了。

我可以通过执行以下命令生成一个凌乱的URI列表:

bitbake -g zlib && cat recipe-depends.dot | \
grep -v -e '-native' | grep -v digraph | \
grep -v -e '-image' | awk '{print $1}' | \
sort | uniq | xargs -I {} -t bitbake -e {} | grep SRC_URI=

这将为您提供配方中使用的所有URI和文件以及一些注释。

不是一个完美的解决方案,但我会看看我是否可以改进它。

答案 2 :(得分:1)

我打了poky来创建NA中包含该包的有效提取网址的awk个文件。

awk -F, 'NF==6,000" file.csv > fixed_file.csv

运行*.src结果:

downloads

这不是最佳解决方案,但我希望此功能能够进入主线流。

答案 3 :(得分:0)

我根据问题的解决方案编写了脚本。 基本上,我需要为所有源创建一个cscope项目,因此我需要列出所有URI并克隆所有存储库。 我写了2个脚本1)列出所有SRC_URI和Branches                   2)将所有代码安装(克隆)到一个目录中

listURI.sh

#!/bin/bash
TMP_FILE="___x__2242230p.txt"
SRCH_FILE="log.do_fetch"
TIME=$(date +%Y-%m-%d-%H-%M)
OUT_FILE="Project-$TIME.txt"
DEF_BRANCH="master"
BRANCH=""
SRC_URI=""

function usage {
    echo "Usage : $0 < -f | -g > <Component-List-file>"
    echo "Options :"
    echo "        -f    : Run bitbake fetch and collect URI"
    echo "        -g    : Get URI from Already fetched Project"
}

if [ $# -eq 0 ]
then
    usage
    exit
fi

if [ "$1" == "-f" ] || [ "$1" == "-g" ];then
    if [ "$1" == "-f" ] && [  -z "$2" ];then
        echo "Should pass Project-Name after -f Option"
        exit
    fi
else
    echo "Unknown Option"
    usage
    exit
fi
POKYROOTDIR=`basename "$PWD"`
#echo $POKYROOTDIR
if [[ $POKYROOTDIR != "build" ]];then
    echo "You are not on poky/build (Sourced Poky) Directory"
    exit 0
fi
POKYROOTDIR=$PWD

if [ "$1" == "-f" ];then
    echo "Running === bitbake -c fetchall $2 -f --no-setscene =="
     bitbake -c fetchall $2 -f --no-setscene
fi

if [ "$1" == "-g" ];then
    if [ ! -d tmp/work ];then
        echo " Please run == bitbake -c fetchall <image> -f --no-setscene == before this"
        usage
        exit
    fi
fi

echo "Looking for URIs --- It may take couple of minuites!"

rm -rf $OUT_FILE
cd tmp/work
find . -name $SRCH_FILE -exec grep -i 'DEBUG: For url git' {} \; -print > $POKYROOTDIR/$TMP_FILE
cd $POKYROOTDIR

while IFS= read -r line
do
      #echo "$line"
      BRANCH=$(echo $line | awk -F"branch=" '/branch=/{print $2}' | sed -e 's/;/ /' | awk '{print $1}')
      SRC_URI=$(echo $line | cut -d';' -f1-1 | awk -F"url" '/url/{print $2}' | awk '{print $1}' | sed -e 's/git:/ssh:/')

      if [ ! -z "$BRANCH" ] && [ ! -z "$SRC_URI" ];then
          echo "$BRANCH  $SRC_URI" >> $OUT_FILE
      elif [ ! -z "$SRC_URI" ];then
          echo "$DEF_BRANCH  $SRC_URI" >> $OUT_FILE
      fi

    if [ ! -z "$BRANCH" ];then
      echo "Found URI : BRANCH:$BRANCH URI:$SRC_URI"
    elif [ ! -z "$SRC_URI" ];then
        echo "Found URI : BRANCH:Default URI:$SRC_URI"
    fi
      #echo "$BRANCH  $SRC_URI" >> $OUT_FILE
done < "$TMP_FILE"

#echo "=================== OUT PUT ==========================="
#cat $OUT_FILE

rm -rf $TMP_FILE


echo "----------------INFO-----------------"
echo "Project Creation: Success"
echo "Project Path      : $POKYROOTDIR"
echo "Project file      : $OUT_FILE"

echo "-------------------------------------"

installURI.sh

#!/bin/bash

function usage {
    echo "Usage : $0 <List-file>"
}

if [ $# -eq 0 ]
then
    usage
    exit
fi

if [ -z "$1" ];then
    usage
    exit
fi


if [ ! -z "$(ls -A $PWD)" ]; then
    echo "Directory ($PWD) must be Empty.... else it will mess up project creation"
    exit
fi

if [ ! -f $1 ];then
    echo "list file ($1) not found"
    usage
    exit
fi

filename=$1
while read -r line; do
    name="$line"
    echo "Fetching Projects"
    git clone -b $line
done < "$filename"

echo "----------------INFO-----------------"
echo "Project Creation: Success"
echo "Project Path    : $PWD"
echo "-------------------------------------"