macOS LibreOffice 编译错误解决

错误1

checking for bogus pkg-config... configure: error: yes, from unknown origin. This *will* break the build. Please modify your PATH variable so that pkgconf-2.5.1/pkgconf is no longer found by configure scripts.

排查思路:

  1. 怀疑是自编译未make install pkg-config环境变量配置问题,但是执行pkg-config --version命令,返回0.29.2,说明pkg-config环境变量配置正确。
  2. 检查环境变量PKG_CONFIG_PATH也没有问题,执行pkgconf --libs openssl返回 -L/opt/homebrew/Cellar/openssl@3/3.5.0/lib -lssl -lcrypto,说明pkg-config环境变量配置正确。
  3. 检查configure文件,发现如下内容
继续阅读“macOS LibreOffice 编译错误解决”

LibreOffice macOS 解决编译问题

LibreOffice 编译时依赖需要 graphite, 而graphite的编译又依赖pkg-config。但是不想使用homebrew或者 MacPorts,喜欢下载源码自己编译。
pkg-config编译成功后,并且指定了环境变量。
然而make总是报checking for bogus pkg-config... configure: error: yes, from unknown origin. This *will* break the build. Please modify your PATH variable so that $PKG_CONFIG is no longer found by configure scripts.

排查configure.ac发现pkg-config 检查出错后,就退出了。
pkg-config的作用主要是为了编译graphite,而graphite是一种“智能字体”系统,专门为处理世界上鲜为人知的语言的复杂性而开发。
然而,对于中文字体可能影响不大。试试忽略这部分功能。于是修改代码如下:

diff --git a/configure.ac b/configure.ac
index 99ccaf54f748..dbb727422dec 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7099,7 +7099,8 @@ if test $_os = Darwin; then
                 if test -z "$($PKG_CONFIG --list-all |grep -v '^libpkgconf')" ; then
                     AC_MSG_RESULT([yes, accepted since no packages available in default searchpath])
                 else
-                    AC_MSG_ERROR([yes, from unknown origin. This *will* break the build. Please modify your PATH variable so that $PKG_CONFIG is no longer found by configure scripts.])
+                    # AC_MSG_ERROR([yes, from unknown origin. This *will* break the build. Please modify your PATH variable so that $PKG_CONFIG is no longer found by configure scripts.])
+                    echo here ;
                 fi
             fi
         fi

注掉后,执行make,果然成功了。

bash zsh awk按列表整理文件

背景

我们有一堆文件,在文件夹A中,需要按照文件列表list.txt 复制文件到B中,A中文件和list.txt 中文件均较多

1、文件列表

list.txt类似如下

mnist_test_644.png

mnist_test_2180.png

mnist_test_122.png

mnist_test_2816.png

2、bash

b=`sed ‘r/g’ list.txt`

for i in $b;

do

cp -r “A/”$i “B/”;

done

3、zsh

for i (${(s: :)$(<list.txt)});

do

cp -r “A/”$i “B/”;

done

或者(不推荐,如果txt每行有空格,导致错误,上面兼容更好)

fl=$(<list.txt)

for i (${(f)fl});

do

cp -r “A/”$i “B/”;

done

4、awk 拼接语句管道执行

awk ‘{print “cp -r A/”$1″ B/;” }’ list.txt |sh 

bash zsh awk字符串分割

fl.txt文件
12
34
56
78


Bash

1、IFS定义分隔符,默认空格、tab、换行、回车

bash-3.2$ a="a b c d"
bash-3.2$ for i in $a;
> do
> echo $i","
> done
a,
b,
c,
d,

bash-3.2$ b=`sed 'r/g' fl.txt`
bash-3.2$ for i in $b; do echo $i","; done
12,
34,
56,
78,

a="a,b,c,d"
#换行符分割
IFS=$'\n'

bash-3.2$ a="a,b,c,d"
bash-3.2$ for i in $a;
> do 
> echo $i;
> done
a,b,c,d

设置分隔符为逗号
bash-3.2$ IFS=$','
bash-3.2$ for i in $a; do  echo $i; done
a
b
c
d

2、使用分割符生成数组
bash-3.2$ aa="hello,shell,split,test"
bash-3.2$ array=(${aa//,/})
bash-3.2$ for i in ${array[@]}
> do
> echo $i
> done
Helloshellsplittest

bash-3.2$ array=(${aa/\n/,/})
bash-3.2$ for i in ${array[@]}; do echo $i; done
hello
shell
split
Test

bash-3.2$ echo ${array[0]}
hello
bash-3.2$ echo ${array[1]}
Shell


Zsh 
Zsh 不会默认使用空格、tab、换行、回车分割

1、(f)按行分割

str=$(<fl.txt)

% echo $str
12 
34 
56 
78

for i (${(f)str}){
echo $i"#"
}
12#
34# 
56# 
78#

注意,写在一起这样不行
for i (${(f)$(<fl.txt)});
do 
echo $i",";
done
12 34 56 78#

直接输出和使用变量行为不一致
echo $(<fl.txt)
12 34 56 78
aa=$(<fl.txt)
echo $aa
12
34
56
78


需要使用(s:chr:)方式
for i (${(s: :)$(<fl.txt)});
do 
echo $i",";
done


或者使用sed读取
aa=`sed 'r/g' fl.txt`;
for i (${(f)aa});
do 
echo $i",";
Done



2、(s:chr:)

s='foo,bar,baz'
#仅s也可,见过p w @,:可以用其他符号代替
for i  in ${(ps:,:)s} ; do   
echo "$i END"
done
foo END
bar END
baz END


awk

bash-3.2$ aa=`awk '{print $1}' fl.txt`
bash-3.2$ for i in $aa
> do
> echo $i
> done
12
34
56
78