我希望使我的嵌入式 Linux 发行版的 LGPLv3 许可软件组件可用以遵守许可条款。我正在使用 Yocto 构建我的根文件系统。参考手册有一个漂亮的脚本我采用的是:
#!/bin/bash
src_release_dir="source-release"
mkdir -p $src_release_dir
for a in tmp-glibc/deploy/sources/*; do
for d in $a/*; do
# Get package name from path
p=`basename $d`
p=${p%-*}
p=${p%-*}
# Only archive GPL packages (update *GPL* regex for your license check)
numfiles=`ls tmp-glibc/deploy/licenses/$p/*LGPLv3 2> /dev/null | wc -l`
if [ $numfiles -gt 1 ]; then
echo Archiving $p
mkdir -p $src_release_dir/$p/source
cp $d/* $src_release_dir/$p/source 2> /dev/null
mkdir -p $src_release_dir/$p/license
cp tmp/deploy/licenses/$p/* $src_release_dir/$p/license 2> /dev/null
fi
done
done
问题是我似乎无法让这个脚本来检测这样的文件:
~/build/build$ ls tmp-glibc/deploy/licenses/qtlocation/*LGPLv3
tmp-glibc/deploy/licenses/qtlocation/LICENSE.LGPLv3
帮助!?
[更新] 在以下人员的帮助下修复了一些问题shellcheck.net并添加了“回声”:
就在“如果”之前:
#!/bin/bash
src_release_dir="source-release"
mkdir -p $src_release_dir
for a in tmp-glibc/deploy/sources/*; do
for d in $a/*; do
# Get package name from path
p=$(basename "$d")
p=${p%-*}
p=${p%-*}
# Only archive GPL packages (update *GPL* regex for your license check)
numfiles=$(ls tmp-glibc/deploy/licenses/"$p"/*LGPLv3 2> /dev/null | wc -l)
echo "$p"
if [ "$numfiles" -gt 1 ]; then
echo Archiving "$p"
mkdir -p $src_release_dir/"$p"/source
cp "$d"/* $src_release_dir/"$p"/source 2> /dev/null
mkdir -p $src_release_dir/"$p"/license
cp tmp/deploy/licenses/"$p"/* $src_release_dir/"$p"/license 2> /dev/null
fi
done
done
我从这里运行这个:
$ ls
bitbake-cookerdaemon.log downloads lgpl.sh source-release sstate-cache tmp-glibc
$ ls tmp-glibc/deploy/sources/
allarch-oe-linux arm-oe-linux-gnueabi x86_64-linux
输出:
./lgpl.sh
bt-enable
ca-certificates
eth0-up
iso-codes
liberation-fonts
linux-firmware
matrix-gui-apps-images
matrix-gui-submenus
os-release
packagegroup-arago-tisdk-graphics
packagegroup-core-ssh-openssh
run-postinsts
.
.
.