如何在没有 root 权限的情况下构建自定义 FreeBSD 版本?

如何在没有 root 权限的情况下构建自定义 FreeBSD 版本?

我正在尝试从源代码构建一个自定义 FreeBSD 磁盘映像,然后我可以使用 bhyve 加载该映像。

这是我使用的脚本:

export MAKEOBJDIRPREFIX="$HOME/obj"
export CHROOTDIR="$HOME/var"
ncpu="$(sysctl -n hw.ncpu)"

set -e   

cd 
mkdir -p obj
mkdir -p var

svn co http://svn.freebsd.org/base/head ./src
cd src
make -j$ncpu -DNO_CLEAN buildworld buildkernel

cd release
make release -DNODOC -DNOSRC -DNOPORTS
make install DESTDIR=../../var

我的问题是make release失败了。

怎么了?


以下是错误消息的部分内容make release

...

.:      user (0, 1001, not modified: Operation not permitted)
bin:    user (0, 1001, not modified: Operation not permitted)
boot:   user (0, 1001, not modified: Operation not permitted)
boot/defaults:
        user (0, 1001, not modified: Operation not permitted)
boot/dtb:
        user (0, 1001, not modified: Operation not permitted)
boot/firmware:
        user (0, 1001, not modified: Operation not permitted)
boot/kernel:
        user (0, 1001, not modified: Operation not permitted)
boot/modules:
        user (0, 1001, not modified: Operation not permitted)
boot/zfs:
        user (0, 1001, not modified: Operation not permitted)
dev:    user (0, 1001, not modified: Operation not permitted)
etc:    user (0, 1001, not modified: Operation not permitted)

...

--------------------------------------------------------------
>>> Distributing everything
--------------------------------------------------------------
cd /usr/home/m/src; make -f Makefile.inc1 distribute
===> lib (distribute)
===> lib/csu (distribute)
===> lib/csu/amd64 (distribute)
cd /usr/home/m/src/lib/csu/amd64;  make install installconfig -DNO_SUBDIR DESTDIR=/usr/home/m/obj/usr/home/m/src/release/dist/base SHARED=copies
install  -o root -g wheel  -m 444 crt1.o crti.o crtn.o Scrt1.o gcrt1.o /usr/home/m/obj/usr/home/m/src/release/dist/base/usr/lib/
install: /usr/home/m/obj/usr/home/m/src/release/dist/base/usr/lib/crt1.o: chown/chgrp: Operation not permitted
*** Error code 71

...

答案1

可以将NO_ROOT环境变量传递给make:参见Makefile.inc1更多细节。

相关内容