[已解决]打包完的文件在/usr/local/nginx的子目录下怎么办?

我尝试打包的程序是基于 BSD 的 Nginx。
打包完成后,文件位置在
/usr/local/nginx/ 下
包括 bin/lib/include 等。
我查了一下 wiki,
没有这个目录的宏言
具体的文件列表如下

RPM build errors:
    Installed (but unpackaged) file(s) found:
   /usr/local/nginx/conf/browsers
   /usr/local/nginx/conf/fastcgi.conf
   /usr/local/nginx/conf/fastcgi.conf.default
   /usr/local/nginx/conf/fastcgi_params
   /usr/local/nginx/conf/fastcgi_params.default
   /usr/local/nginx/conf/koi-utf
   /usr/local/nginx/conf/koi-win
   /usr/local/nginx/conf/mime.types
   /usr/local/nginx/conf/mime.types.default
   /usr/local/nginx/conf/module_stubs
   /usr/local/nginx/conf/nginx.conf
   /usr/local/nginx/conf/nginx.conf.default
   /usr/local/nginx/conf/scgi_params
   /usr/local/nginx/conf/scgi_params.default
   /usr/local/nginx/conf/uwsgi_params
   /usr/local/nginx/conf/uwsgi_params.default
   /usr/local/nginx/conf/win-utf
   /usr/local/nginx/html/50x.html
   /usr/local/nginx/html/index.html
   /usr/local/nginx/include/nginx.h
   /usr/local/nginx/include/ngx_alloc.h
   /usr/local/nginx/include/ngx_array.h
   /usr/local/nginx/include/ngx_atomic.h
   /usr/local/nginx/include/ngx_auto_config.h
   /usr/local/nginx/include/ngx_auto_headers.h
   /usr/local/nginx/include/ngx_buf.h
   /usr/local/nginx/include/ngx_channel.h
   /usr/local/nginx/include/ngx_conf_file.h
   /usr/local/nginx/include/ngx_config.h
   /usr/local/nginx/include/ngx_connection.h
   /usr/local/nginx/include/ngx_core.h
   /usr/local/nginx/include/ngx_crc.h
   /usr/local/nginx/include/ngx_crc32.h
   /usr/local/nginx/include/ngx_crypt.h
   /usr/local/nginx/include/ngx_cycle.h
   /usr/local/nginx/include/ngx_errno.h
   /usr/local/nginx/include/ngx_event.h
   /usr/local/nginx/include/ngx_event_busy_lock.h
   /usr/local/nginx/include/ngx_event_connect.h
   /usr/local/nginx/include/ngx_event_openssl.h
   /usr/local/nginx/include/ngx_event_pipe.h
   /usr/local/nginx/include/ngx_event_posted.h
   /usr/local/nginx/include/ngx_event_timer.h
   /usr/local/nginx/include/ngx_file.h
   /usr/local/nginx/include/ngx_files.h
   /usr/local/nginx/include/ngx_gcc_atomic_x86.h
   /usr/local/nginx/include/ngx_hash.h
   /usr/local/nginx/include/ngx_http.h
   /usr/local/nginx/include/ngx_http_busy_lock.h
   /usr/local/nginx/include/ngx_http_cache.h
   /usr/local/nginx/include/ngx_http_config.h
   /usr/local/nginx/include/ngx_http_core_module.h
   /usr/local/nginx/include/ngx_http_reqstat.h
   /usr/local/nginx/include/ngx_http_request.h
   /usr/local/nginx/include/ngx_http_script.h
   /usr/local/nginx/include/ngx_http_ssi_filter_module.h
   /usr/local/nginx/include/ngx_http_ssl_module.h
   /usr/local/nginx/include/ngx_http_upstream.h
   /usr/local/nginx/include/ngx_http_upstream_round_robin.h
   /usr/local/nginx/include/ngx_http_variables.h
   /usr/local/nginx/include/ngx_inet.h
   /usr/local/nginx/include/ngx_linux.h
   /usr/local/nginx/include/ngx_linux_config.h
   /usr/local/nginx/include/ngx_list.h
   /usr/local/nginx/include/ngx_log.h
   /usr/local/nginx/include/ngx_md5.h
   /usr/local/nginx/include/ngx_murmurhash.h
   /usr/local/nginx/include/ngx_open_file_cache.h
   /usr/local/nginx/include/ngx_os.h
   /usr/local/nginx/include/ngx_palloc.h
   /usr/local/nginx/include/ngx_parse.h
   /usr/local/nginx/include/ngx_pipe.h
   /usr/local/nginx/include/ngx_proc.h
   /usr/local/nginx/include/ngx_process.h
   /usr/local/nginx/include/ngx_process_cycle.h
   /usr/local/nginx/include/ngx_queue.h
   /usr/local/nginx/include/ngx_radix_tree.h
   /usr/local/nginx/include/ngx_rbtree.h
   /usr/local/nginx/include/ngx_regex.h
   /usr/local/nginx/include/ngx_resolver.h
   /usr/local/nginx/include/ngx_segment_tree.h
   /usr/local/nginx/include/ngx_setaffinity.h
   /usr/local/nginx/include/ngx_setproctitle.h
   /usr/local/nginx/include/ngx_sha1.h
   /usr/local/nginx/include/ngx_shmem.h
   /usr/local/nginx/include/ngx_shmtx.h
   /usr/local/nginx/include/ngx_slab.h
   /usr/local/nginx/include/ngx_socket.h
   /usr/local/nginx/include/ngx_string.h
   /usr/local/nginx/include/ngx_sysinfo.h
   /usr/local/nginx/include/ngx_syslog.h
   /usr/local/nginx/include/ngx_thread.h
   /usr/local/nginx/include/ngx_time.h
   /usr/local/nginx/include/ngx_times.h
   /usr/local/nginx/include/ngx_trie.h
   /usr/local/nginx/include/ngx_user.h
   /usr/local/nginx/sbin/nginx

我该如何写 %files 块呢?

可以直接写 /usr/local/nginx 的,或者自己定义一个宏。

PS:这个编译目录应该是可以变的,你找找 nginx 的编译指南。最好是 /usr 吧。

知道可以变,但是习惯性都是这个目录,因为是为LnMP包做准备的。

通过 G750-T01 发表

哎呀,我觉得这种官方有的包看一下人家的 spec 学习一下就好了。没有必要自己动手吧。如果只是为了 LNMP 没有必要自己打包吧。

zh.opensuse.org/SDB:%E6%90%AD%E5%BB%BALNMP%E6%9C%8D%E5%8A%A1%E5%99%A8

自己编译的才习惯性是 /usr/local,很奇怪可以说所有发行版都会有这些常用的包,但是很多教程都是教人家自己编译的。打包表示很少见安装到 /usr/local 的。你看 openSUSE 官方的 spec 文件的这一行。

%define ngx_prefix     %{_prefix}

我觉得你自己打肯定打不了那么专业的。人家还有那么多补丁和编译选项呢,要打出高质量的包是一门艺术啊。

#
# spec file for package nginx
#
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


Name:           nginx
Version:        1.4.7
Release:        3.9.1
#
%define pkg_name nginx
#
%define ngx_prefix     %{_prefix}
%define ngx_sbin_path  %{_sbindir}/nginx
%define ngx_conf_dir   %{_sysconfdir}/nginx
%define ngx_conf_path  %{ngx_conf_dir}/nginx.conf
%define ngx_log_dir    /var/log/nginx
%define ngx_error_log  %{ngx_log_dir}/error.log
%define ngx_access_log %{ngx_log_dir}/access.log
%define ngx_pid_path   /var/run/nginx.pid
%define ngx_lock_path  /var/run/nginx.lock
%define ngx_home       /var/lib/nginx
%define ngx_tmp_http   %{ngx_home}/tmp/
%define ngx_tmp_proxy  %{ngx_home}/proxy/
%define ngx_tmp_fcgi   %{ngx_home}/fastcgi/
%define ngx_tmp_scgi   %{ngx_home}/scgi/
%define ngx_tmp_uwsgi  %{ngx_home}/uwsgi/
%define ngx_user_group nginx
%define with_cpp_test  0
%define with_google_perftools 0
%if 0%{?suse_version} >= 1110
# passenger is required by webyast
%define with_passenger 1
%define with_libatomic 1
%endif
#
#
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  GeoIP-devel
BuildRequires:  gcc-c++
BuildRequires:  gd-devel
%if 0%{?with_google_perftools}
BuildRequires:  google-perftools-devel
%endif
%if 0%{?with_libatomic}
BuildRequires:  libatomic-ops-devel
%endif
BuildRequires:  libxslt-devel
BuildRequires:  openssl-devel
BuildRequires:  pcre-devel
BuildRequires:  pkgconfig
BuildRequires:  zlib-devel
%if 0%{?with_passenger}
BuildRequires:  curl-devel
BuildRequires:  ruby-devel
BuildRequires:  rubygem-passenger-devel-static
Recommends:     packageand(rubygem-passenger:rubygem-passenger-nginx)
%endif
%if 0%{?suse_version} >= 1210
BuildRequires:  systemd
%{?systemd_requires}
%define has_systemd 1
%endif
Recommends:     logrotate
PreReq:         %fillup_prereq
PreReq:         %insserv_prereq
PreReq:         pwdutils
#
Conflicts:      nginx-0.5 nginx-0.6 nginx-0.7 nginx-0.8 nginx-0.9 nginx-1.0 nginx-1.2 nginx-1.3
%requires_eq    perl
#
Url:            http://nginx.net/
Source:         http://www.nginx.org/download/nginx-%{version}.tar.gz
Source1:        nginx.init
Source2:        nginx.logrotate
Source3:        nginx.service
# PATCH-FIX-UPSTREAM nginx-0.4.0-no_Werror.patch
Patch:          nginx-0.4.0-no_Werror.patch
# PATCH-FIX-UPSTREAM nginx-0.6.38-html.patch
Patch2:         nginx-0.6.38-html.patch
# PATCH-FIX-UPSTREAM nginx-1.2.4-perl_vendor_install.patch
Patch3:         nginx-1.2.4-perl_vendor_install.patch
# PATCH-FIX-UPSTREAM nginx-1.0.4_default_config.patch
Patch4:         nginx-1.0.4_default_config.patch
# PATCH for fixing docs/html path
Patch5:         nginx-1.0.15_docs.patch
# PATCH-FIX-UPSTREAM nginx-aio.patch fix support for Linux AIO
Patch6:         nginx-aio.patch
Patch7:         nginx-1.4.2-passenger_fix.patch
Summary:        A HTTP server and IMAP/POP3 proxy server
License:        BSD-2-Clause
Group:          Productivity/Networking/Web/Proxy
Provides:       http_daemon
Provides:       httpd

%description
nginx [engine x] is a HTTP server and IMAP/POP3 proxy server written by Igor Sysoev.
It has been running on many heavily loaded Russian sites for more than two years.

Author:
-------
    Igor Sysoev

%prep
%setup -n %{pkg_name}-%{version}
%patch
%patch2
%patch3
%patch4
%patch5
%patch6 -p1

perl -pi -e 's|\r\n|\n|g' contrib/geo2nginx.pl

%if 0%{?with_passenger}
cp -a %{_libdir}/ruby/gems/%{rb_ver}/gems/passenger-* passenger
%patch7 -p1
%endif

%build
./configure                                    \
  --prefix=%{ngx_prefix}/                      \
  --sbin-path=%{ngx_sbin_path}                 \
  --conf-path=%{ngx_conf_path}                 \
  --error-log-path=%{ngx_error_log}            \
  --http-log-path=%{ngx_access_log}            \
  --pid-path=%{ngx_pid_path}                   \
  --lock-path=%{ngx_lock_path}                 \
  --http-client-body-temp-path=%{ngx_tmp_http} \
  --http-proxy-temp-path=%{ngx_tmp_proxy}      \
  --http-fastcgi-temp-path=%{ngx_tmp_fcgi}     \
  --http-uwsgi-temp-path=%{ngx_tmp_uwsgi}      \
  --http-scgi-temp-path=%{ngx_tmp_scgi}        \
  --user=nginx --group=nginx                   \
  --without-select_module                      \
  --without-poll_module                        \
  --with-ipv6                                  \
%if  0%{?suse_version} > 1110
  --with-file-aio                              \
%endif
  --with-http_ssl_module                       \
%if 0%{suse_version} > 1220
  --with-http_spdy_module                      \
%endif
  --with-http_realip_module                    \
  --with-http_addition_module                  \
  --with-http_xslt_module                      \
  --with-http_image_filter_module              \
  --with-http_geoip_module                     \
  --with-http_sub_module                       \
  --with-http_dav_module                       \
  --with-http_flv_module                       \
  --with-http_mp4_module					   \
  --with-http_gzip_static_module               \
  --with-http_random_index_module              \
  --with-http_secure_link_module               \
  --with-http_degradation_module               \
  --with-http_stub_status_module               \
  --with-http_perl_module                      \
  --with-perl=%{_bindir}/perl                  \
  --with-mail                                  \
  --with-mail_ssl_module                       \
  --with-pcre                                  \
  %if 0%{?with_libatomic}
  --with-libatomic                             \
  %endif
  %if 0%{?with_passenger}
  --add-module=passenger/ext/nginx             \
  %endif
  %if 0%{?with_google_perftools}
  --with-google_perftools_module               \
  %endif
  %if 0%{?with_cpp_test}
  --with-cpp_test_module                       \
  %endif
  --with-md5=/usr                              \
  --with-sha1=/usr                             \
%if 0%{?suse_version} > 1000 || 0%{?fedora_version} > 4 || 0%{?mandriva_version} > 2006
  --with-cc-opt="%{optflags} -fPIE -D_GNU_SOURCE -std=gnu99 -fstack-protector" \
  --with-ld-opt="-Wl,-z,relro,-z,now -pie"
%else
  --with-cc-opt="%{optflags}"
%endif
make %{?_smp_mflags}

%install
make install DESTDIR="%buildroot"
%perl_process_packlist
#
%{__install} -d -m 0750 %{buildroot}%{ngx_home}/{,tmp,proxy,fastcgi,scgi,uwsgi}
#
%{__install} -D -m 0755 %{S:1} %{buildroot}%{_sysconfdir}/init.d/%{pkg_name}
%{__ln_s} -f %{_sysconfdir}/init.d/%{pkg_name} %{buildroot}%{_sbindir}/rc%{pkg_name}

%{__install} -D -m 0644 %{S:2} %{buildroot}%{_sysconfdir}/logrotate.d/%{pkg_name}

%if 0%{?has_systemd}
%{__install} -D -m 0644 %{S:3} %{buildroot}%{_unitdir}/nginx.service
%endif

%{__rm} %{buildroot}/srv/www/htdocs/index.html

%post
%fillup_and_insserv %{pkg_name}

%if 0%{?has_systemd}
%service_add_post nginx.service
%endif

%preun
%stop_on_removal %{pkg_name}

%if 0%{?has_systemd}
%service_del_preun nginx.service
%endif

%postun
%restart_on_update %{pkg_name}
%{insserv_cleanup}

%if 0%{?has_systemd}
%service_del_postun nginx.service
%endif

%pre
/usr/sbin/groupadd -r %{ngx_user_group} &>/dev/null ||:
/usr/sbin/useradd -g %{ngx_user_group} -s /bin/false -r -c "user for %{ngx_user_group}" -d %{ngx_home} %{ngx_user_group} &>/dev/null ||:

%if 0%{?has_systemd}
%service_add_pre nginx.service
%endif

%files
%defattr(-,root,root,-)
%dir %{ngx_conf_dir}/
%config(noreplace) %{ngx_conf_dir}/koi-utf
%config(noreplace) %{ngx_conf_dir}/koi-win
%config(noreplace) %{ngx_conf_dir}/fastcgi_params
%config %{ngx_conf_dir}/fastcgi_params.default
%config(noreplace) %{ngx_conf_dir}/mime.types
%config %{ngx_conf_dir}/mime.types.default
%config(noreplace) %{ngx_conf_dir}/nginx.conf
%config %{ngx_conf_dir}/nginx.conf.default
%config(noreplace) %{ngx_conf_dir}/fastcgi.conf
%config %{ngx_conf_dir}/fastcgi.conf.default
%config(noreplace) %{ngx_conf_dir}/win-utf
%config(noreplace) %{ngx_conf_dir}/scgi_params
%config %{ngx_conf_dir}/scgi_params.default
%config(noreplace) %{ngx_conf_dir}/uwsgi_params
%config %{ngx_conf_dir}/uwsgi_params.default
%{perl_vendorarch}/auto/nginx/
%{perl_vendorarch}/nginx.pm
%{ngx_sbin_path}
%{_mandir}/man3/nginx.3pm*
/srv/www/htdocs/50x.html
%if 0%{?suse_version} && 0%{?suse_version} < 1140
%{_localstatedir}/adm/perl-modules/%{name}
%endif
%{_sysconfdir}/init.d/%{pkg_name}
%{_sbindir}/rc%{pkg_name}
%config(noreplace) %{_sysconfdir}/logrotate.d/%{pkg_name}
%dir %attr(750,%{ngx_user_group},%{ngx_user_group}) /var/log/nginx/
%dir %attr(750,%{ngx_user_group},%{ngx_user_group}) %{ngx_home}/
%dir %attr(750,%{ngx_user_group},%{ngx_user_group}) %{ngx_tmp_http}
%dir %attr(750,%{ngx_user_group},%{ngx_user_group}) %{ngx_tmp_proxy}
%dir %attr(750,%{ngx_user_group},%{ngx_user_group}) %{ngx_tmp_fcgi}
%dir %attr(750,%{ngx_user_group},%{ngx_user_group}) %{ngx_tmp_scgi}
%dir %attr(750,%{ngx_user_group},%{ngx_user_group}) %{ngx_tmp_uwsgi}
%doc CHANGES*
%doc conf/ contrib/
%if 0%{?has_systemd}
%{_unitdir}/nginx.service
%endif

为了练手。。。。

通过 G750-T01 发表

/usr/local 不是软件包应该装的位置。那是用户自行编译使用的 prefix。软件包应该总是指定 prefix 为 /usr (%{_prefix})。三方打包用 /opt。

也就是说我们自己手动编译时,会放在哪里。其他时候都不放在那里是吧。