rpmbuild 设置错误的文件所有权说 root:root(错误的 owner/group build:users)
rpmbuild setting wrong file ownership says root:root (wrong owner/group build:users)
我正在使用 RPM 在目标机器上创建一堆文件和目录,每个文件和目录都有一组不同的 file/dir 权限。我已经创建了一个 spec 文件,它构建了这个 RPM。
规范文件如下所示:
Name: testMultipleFiles
Version: 1.0
Release: 2
Summary: Demo how to package multiple files
Group: DCCA Deployment
License: GPLv2
Source: testMultipleFiles.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-build
AutoReqProv: on
%description
Authors:
--------
Name Raj Kumar Sanpui
%prep
%setup -q
%build
%install
mkdir -p $RPM_BUILD_ROOT/opt/insiteone/dir1
mkdir -p $RPM_BUILD_ROOT/opt/insiteone/dir2
mkdir -p $RPM_BUILD_ROOT/opt/insiteone/dir3
mkdir -p $RPM_BUILD_ROOT/opt/insiteone/dir4
mkdir -p $RPM_BUILD_ROOT/opt/insiteone/dir5
mkdir -p $RPM_BUILD_ROOT/opt/insiteone/dir6
mkdir -p $RPM_BUILD_ROOT/opt/insiteone/dir7
mkdir -p $RPM_BUILD_ROOT/opt/insiteone/dir8
mkdir -p $RPM_BUILD_ROOT/opt/insiteone/dir9
mkdir -p $RPM_BUILD_ROOT/opt/insiteone/dir10
install file1.sh $RPM_BUILD_ROOT/opt/insiteone/dir1
install file2.sh $RPM_BUILD_ROOT/opt/insiteone/dir2
install file3.sh $RPM_BUILD_ROOT/opt/insiteone/dir3
install file4.sh $RPM_BUILD_ROOT/opt/insiteone/dir4
install file5.sh $RPM_BUILD_ROOT/opt/insiteone/dir5
install file6.sh $RPM_BUILD_ROOT/opt/insiteone/dir6
%clean
rm -rf $RPM_BUILD_ROOT
%post
%postun
%files
%defattr(644,insite1,insite1,0755)
/opt/insiteone/dir1/file1.sh
/opt/insiteone/dir2/file2.sh
/opt/insiteone/dir3/file3.sh
%attr(644,insite1,insite1)/opt/insiteone/dir4/file4.sh
%attr(644,insite1,insite1)/opt/insiteone/dir5/file5.sh
%attr(644,insite1,insite1)/opt/insiteone/dir6/file6.sh
%dir %attr(777,insite1,insite1)/opt/insiteone/dir4
%dir %attr(700,insite1,insite1)/opt/insiteone/dir5
%dir %attr(644,insite1,insite1)/opt/insiteone/dir6
%dir %attr(640,insite1,insite1)/opt/insiteone/dir7
%dir %attr(600,insite1,insite1)/opt/insiteone/dir8
%dir %attr(744,insite1,insite1)/opt/insiteone/dir9
%dir %attr(644,insite1,insite1)/opt/insiteone/dir10
然而,当我构建这个 RPM 时,没有错误并且构建成功,但是构建日志显示:
Checking permissions and ownerships - using the permissions files
/tmp/Check.perms.gv6tJD
setting /var/tmp/testMultipleFiles-1.0-build/ to root:root 0755. (wrong owner/group build:users)
setting /var/tmp/testMultipleFiles-1.0-build/opt to root:root 0755. (wrong owner/group build:users)
这意味着,它设置为 root:root 而不是 insite1:insite1 作为用户和组。
这是完整的构建日志。
build@SLES11SP4-185:~/rpmbuild/SPECS> rpmbuild -bb testmulti.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.14760
+ umask 022
+ cd /home/build/rpmbuild/BUILD
+ cd /home/build/rpmbuild/BUILD
+ rm -rf testMultipleFiles-1.0
+ /usr/bin/gzip -dc /home/build/rpmbuild/SOURCES/testMultipleFiles.tar.gz
+ tar -xf -
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd testMultipleFiles-1.0
++ /usr/bin/id -u
+ '[' 1001 = 0 ']'
++ /usr/bin/id -u
+ '[' 1001 = 0 ']'
+ /bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ exit 0
Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.14760
+ umask 022
+ cd /home/build/rpmbuild/BUILD
+ /bin/rm -rf /var/tmp/testMultipleFiles-1.0-build
++ dirname /var/tmp/testMultipleFiles-1.0-build
+ /bin/mkdir -p /var/tmp
+ /bin/mkdir /var/tmp/testMultipleFiles-1.0-build
+ cd testMultipleFiles-1.0
+ exit 0
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.14760
+ umask 022
+ cd /home/build/rpmbuild/BUILD
+ cd testMultipleFiles-1.0
+ mkdir -p /var/tmp/testMultipleFiles-1.0-build/opt/insiteone/dir1
+ mkdir -p /var/tmp/testMultipleFiles-1.0-build/opt/insiteone/dir2
+ mkdir -p /var/tmp/testMultipleFiles-1.0-build/opt/insiteone/dir3
+ mkdir -p /var/tmp/testMultipleFiles-1.0-build/opt/insiteone/dir4
+ mkdir -p /var/tmp/testMultipleFiles-1.0-build/opt/insiteone/dir5
+ mkdir -p /var/tmp/testMultipleFiles-1.0-build/opt/insiteone/dir6
+ mkdir -p /var/tmp/testMultipleFiles-1.0-build/opt/insiteone/dir7
+ mkdir -p /var/tmp/testMultipleFiles-1.0-build/opt/insiteone/dir8
+ mkdir -p /var/tmp/testMultipleFiles-1.0-build/opt/insiteone/dir9
+ mkdir -p /var/tmp/testMultipleFiles-1.0-build/opt/insiteone/dir10
+ install file1.sh /var/tmp/testMultipleFiles-1.0-build/opt/insiteone/dir1
+ install file2.sh /var/tmp/testMultipleFiles-1.0-build/opt/insiteone/dir2
+ install file3.sh /var/tmp/testMultipleFiles-1.0-build/opt/insiteone/dir3
+ install file4.sh /var/tmp/testMultipleFiles-1.0-build/opt/insiteone/dir4
+ install file5.sh /var/tmp/testMultipleFiles-1.0-build/opt/insiteone/dir5
+ install file6.sh /var/tmp/testMultipleFiles-1.0-build/opt/insiteone/dir6
+ /usr/lib/rpm/brp-lib64-linux
sf@suse.de: if you find problems with this script, drop me a note
+ RPM_BUILD_ROOT=/var/tmp/testMultipleFiles-1.0-build
+ export RPM_BUILD_ROOT
+ test -x /usr/sbin/Check -a 1001 = 0 -o -x /usr/sbin/Check -a '!' -z /var/tmp/testMultipleFiles-1.0-build
+ echo 'I call /usr/sbin/Check...'
I call /usr/sbin/Check...
+ /usr/sbin/Check
Checking permissions and ownerships - using the permissions files
/tmp/Check.perms.gv6tJD
setting /var/tmp/testMultipleFiles-1.0-build/ to root:root 0755. (wrong owner/group build:users)
setting /var/tmp/testMultipleFiles-1.0-build/opt to root:root 0755. (wrong owner/group build:users)
+ /usr/lib/rpm/brp-compress
+ /usr/lib/rpm/brp-symlink
Processing files: testMultipleFiles-1.0-2
Finding Provides: /usr/lib/rpm/find-provides testMultipleFiles
Finding Requires: /usr/lib/rpm/find-requires testMultipleFiles
Finding Supplements: /usr/lib/rpm/find-supplements testMultipleFiles
Requires(interp): /bin/sh /bin/sh
Requires(rpmlib): rpmlib(PayloadFilesHavePrefix) <= 4.0-1 rpmlib(CompressedFileNames) <= 3.0.4-1
Requires(post): /bin/sh
Requires(postun): /bin/sh
Checking for unpackaged file(s): /usr/lib/rpm/check-files /var/tmp/testMultipleFiles-1.0-build
Checking for unpackaged file(s): /usr/lib/rpm/check-files /var/tmp/testMultipleFiles-1.0-build
Wrote: /home/build/rpmbuild/RPMS/x86_64/testMultipleFiles-1.0-2.x86_64.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.14760
+ umask 022
+ cd /home/build/rpmbuild/BUILD
+ cd testMultipleFiles-1.0
+ rm -rf /var/tmp/testMultipleFiles-1.0-build
+ exit 0
请注意: insite1:insite1 用户和组将预先存在于目标机器中,RPM 已安装,但它不存在于 RPM 构建机器中,因为我没有理由创建它们。
补充: 我观察到,它会继续并在具有适当权限的目标机器上安装所有文件和目录(insite1:insite1 ), 但是目录 dir1、dir2 和 dir3 仍然设置为 root:root 但是 0755,我期望它是 insite1:insite1 基于 %defattr
放。 难道没有办法设置默认目录权限吗?
当你输入 %files
:
/opt/insiteone/dir1/file1.sh
这意味着在 rpm 中只得到 file1.sh
。 defattr 仅适用于该文件。当然,该文件带有一些路径。因此,如果路径不存在,则会创建它。使用当前用户(通常是 root)。
所以你应该说:
%files
/opt/insiteone/dir1
这将获取 dir1 及其中的所有内容(递归)。
或者:
%files
%dir /opt/insiteone/dir1
/opt/insiteone/dir1/file1.sh
顺便说一句,正确的包应该检查用户和组 "insite1" 是否存在。您可以使用此 %pre 片段 https://fedoraproject.org/wiki/Packaging:UsersAndGroups?rd=Packaging/UsersAndGroups#Dynamic_allocation
我正在使用 RPM 在目标机器上创建一堆文件和目录,每个文件和目录都有一组不同的 file/dir 权限。我已经创建了一个 spec 文件,它构建了这个 RPM。 规范文件如下所示:
Name: testMultipleFiles
Version: 1.0
Release: 2
Summary: Demo how to package multiple files
Group: DCCA Deployment
License: GPLv2
Source: testMultipleFiles.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-build
AutoReqProv: on
%description
Authors:
--------
Name Raj Kumar Sanpui
%prep
%setup -q
%build
%install
mkdir -p $RPM_BUILD_ROOT/opt/insiteone/dir1
mkdir -p $RPM_BUILD_ROOT/opt/insiteone/dir2
mkdir -p $RPM_BUILD_ROOT/opt/insiteone/dir3
mkdir -p $RPM_BUILD_ROOT/opt/insiteone/dir4
mkdir -p $RPM_BUILD_ROOT/opt/insiteone/dir5
mkdir -p $RPM_BUILD_ROOT/opt/insiteone/dir6
mkdir -p $RPM_BUILD_ROOT/opt/insiteone/dir7
mkdir -p $RPM_BUILD_ROOT/opt/insiteone/dir8
mkdir -p $RPM_BUILD_ROOT/opt/insiteone/dir9
mkdir -p $RPM_BUILD_ROOT/opt/insiteone/dir10
install file1.sh $RPM_BUILD_ROOT/opt/insiteone/dir1
install file2.sh $RPM_BUILD_ROOT/opt/insiteone/dir2
install file3.sh $RPM_BUILD_ROOT/opt/insiteone/dir3
install file4.sh $RPM_BUILD_ROOT/opt/insiteone/dir4
install file5.sh $RPM_BUILD_ROOT/opt/insiteone/dir5
install file6.sh $RPM_BUILD_ROOT/opt/insiteone/dir6
%clean
rm -rf $RPM_BUILD_ROOT
%post
%postun
%files
%defattr(644,insite1,insite1,0755)
/opt/insiteone/dir1/file1.sh
/opt/insiteone/dir2/file2.sh
/opt/insiteone/dir3/file3.sh
%attr(644,insite1,insite1)/opt/insiteone/dir4/file4.sh
%attr(644,insite1,insite1)/opt/insiteone/dir5/file5.sh
%attr(644,insite1,insite1)/opt/insiteone/dir6/file6.sh
%dir %attr(777,insite1,insite1)/opt/insiteone/dir4
%dir %attr(700,insite1,insite1)/opt/insiteone/dir5
%dir %attr(644,insite1,insite1)/opt/insiteone/dir6
%dir %attr(640,insite1,insite1)/opt/insiteone/dir7
%dir %attr(600,insite1,insite1)/opt/insiteone/dir8
%dir %attr(744,insite1,insite1)/opt/insiteone/dir9
%dir %attr(644,insite1,insite1)/opt/insiteone/dir10
然而,当我构建这个 RPM 时,没有错误并且构建成功,但是构建日志显示:
Checking permissions and ownerships - using the permissions files
/tmp/Check.perms.gv6tJD
setting /var/tmp/testMultipleFiles-1.0-build/ to root:root 0755. (wrong owner/group build:users)
setting /var/tmp/testMultipleFiles-1.0-build/opt to root:root 0755. (wrong owner/group build:users)
这意味着,它设置为 root:root 而不是 insite1:insite1 作为用户和组。
这是完整的构建日志。
build@SLES11SP4-185:~/rpmbuild/SPECS> rpmbuild -bb testmulti.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.14760
+ umask 022
+ cd /home/build/rpmbuild/BUILD
+ cd /home/build/rpmbuild/BUILD
+ rm -rf testMultipleFiles-1.0
+ /usr/bin/gzip -dc /home/build/rpmbuild/SOURCES/testMultipleFiles.tar.gz
+ tar -xf -
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd testMultipleFiles-1.0
++ /usr/bin/id -u
+ '[' 1001 = 0 ']'
++ /usr/bin/id -u
+ '[' 1001 = 0 ']'
+ /bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ exit 0
Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.14760
+ umask 022
+ cd /home/build/rpmbuild/BUILD
+ /bin/rm -rf /var/tmp/testMultipleFiles-1.0-build
++ dirname /var/tmp/testMultipleFiles-1.0-build
+ /bin/mkdir -p /var/tmp
+ /bin/mkdir /var/tmp/testMultipleFiles-1.0-build
+ cd testMultipleFiles-1.0
+ exit 0
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.14760
+ umask 022
+ cd /home/build/rpmbuild/BUILD
+ cd testMultipleFiles-1.0
+ mkdir -p /var/tmp/testMultipleFiles-1.0-build/opt/insiteone/dir1
+ mkdir -p /var/tmp/testMultipleFiles-1.0-build/opt/insiteone/dir2
+ mkdir -p /var/tmp/testMultipleFiles-1.0-build/opt/insiteone/dir3
+ mkdir -p /var/tmp/testMultipleFiles-1.0-build/opt/insiteone/dir4
+ mkdir -p /var/tmp/testMultipleFiles-1.0-build/opt/insiteone/dir5
+ mkdir -p /var/tmp/testMultipleFiles-1.0-build/opt/insiteone/dir6
+ mkdir -p /var/tmp/testMultipleFiles-1.0-build/opt/insiteone/dir7
+ mkdir -p /var/tmp/testMultipleFiles-1.0-build/opt/insiteone/dir8
+ mkdir -p /var/tmp/testMultipleFiles-1.0-build/opt/insiteone/dir9
+ mkdir -p /var/tmp/testMultipleFiles-1.0-build/opt/insiteone/dir10
+ install file1.sh /var/tmp/testMultipleFiles-1.0-build/opt/insiteone/dir1
+ install file2.sh /var/tmp/testMultipleFiles-1.0-build/opt/insiteone/dir2
+ install file3.sh /var/tmp/testMultipleFiles-1.0-build/opt/insiteone/dir3
+ install file4.sh /var/tmp/testMultipleFiles-1.0-build/opt/insiteone/dir4
+ install file5.sh /var/tmp/testMultipleFiles-1.0-build/opt/insiteone/dir5
+ install file6.sh /var/tmp/testMultipleFiles-1.0-build/opt/insiteone/dir6
+ /usr/lib/rpm/brp-lib64-linux
sf@suse.de: if you find problems with this script, drop me a note
+ RPM_BUILD_ROOT=/var/tmp/testMultipleFiles-1.0-build
+ export RPM_BUILD_ROOT
+ test -x /usr/sbin/Check -a 1001 = 0 -o -x /usr/sbin/Check -a '!' -z /var/tmp/testMultipleFiles-1.0-build
+ echo 'I call /usr/sbin/Check...'
I call /usr/sbin/Check...
+ /usr/sbin/Check
Checking permissions and ownerships - using the permissions files
/tmp/Check.perms.gv6tJD
setting /var/tmp/testMultipleFiles-1.0-build/ to root:root 0755. (wrong owner/group build:users)
setting /var/tmp/testMultipleFiles-1.0-build/opt to root:root 0755. (wrong owner/group build:users)
+ /usr/lib/rpm/brp-compress
+ /usr/lib/rpm/brp-symlink
Processing files: testMultipleFiles-1.0-2
Finding Provides: /usr/lib/rpm/find-provides testMultipleFiles
Finding Requires: /usr/lib/rpm/find-requires testMultipleFiles
Finding Supplements: /usr/lib/rpm/find-supplements testMultipleFiles
Requires(interp): /bin/sh /bin/sh
Requires(rpmlib): rpmlib(PayloadFilesHavePrefix) <= 4.0-1 rpmlib(CompressedFileNames) <= 3.0.4-1
Requires(post): /bin/sh
Requires(postun): /bin/sh
Checking for unpackaged file(s): /usr/lib/rpm/check-files /var/tmp/testMultipleFiles-1.0-build
Checking for unpackaged file(s): /usr/lib/rpm/check-files /var/tmp/testMultipleFiles-1.0-build
Wrote: /home/build/rpmbuild/RPMS/x86_64/testMultipleFiles-1.0-2.x86_64.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.14760
+ umask 022
+ cd /home/build/rpmbuild/BUILD
+ cd testMultipleFiles-1.0
+ rm -rf /var/tmp/testMultipleFiles-1.0-build
+ exit 0
请注意: insite1:insite1 用户和组将预先存在于目标机器中,RPM 已安装,但它不存在于 RPM 构建机器中,因为我没有理由创建它们。
补充: 我观察到,它会继续并在具有适当权限的目标机器上安装所有文件和目录(insite1:insite1 ), 但是目录 dir1、dir2 和 dir3 仍然设置为 root:root 但是 0755,我期望它是 insite1:insite1 基于 %defattr
放。 难道没有办法设置默认目录权限吗?
当你输入 %files
:
/opt/insiteone/dir1/file1.sh
这意味着在 rpm 中只得到 file1.sh
。 defattr 仅适用于该文件。当然,该文件带有一些路径。因此,如果路径不存在,则会创建它。使用当前用户(通常是 root)。
所以你应该说:
%files
/opt/insiteone/dir1
这将获取 dir1 及其中的所有内容(递归)。 或者:
%files
%dir /opt/insiteone/dir1
/opt/insiteone/dir1/file1.sh
顺便说一句,正确的包应该检查用户和组 "insite1" 是否存在。您可以使用此 %pre 片段 https://fedoraproject.org/wiki/Packaging:UsersAndGroups?rd=Packaging/UsersAndGroups#Dynamic_allocation