我是 NetBSD 新手,尽管经常在 ubuntu 上使用 pkgsrc。我可以从源代码构建和安装软件包,而不会对 ubuntu 的软件包依赖项产生任何影响。
例如,即使 ruby 2.2 是通过 apt-get 安装的,我也可以$HOME/pkg/bin
通过 pkgsrc 构建并安装 ruby 2.3。我可以使用 ruby 2.3,没有任何依赖性问题。
这个功能对我非常有帮助,这就是我到目前为止喜欢 pkgsrc 的原因。
现在我将 NetBSD 7.1 安装到我的另一台 PC 上。我想要下载 pkgsrc 作为我自己的包管理器,并且想要将包构建到我的主目录 ( $HOME/pkg/bin
) 中,而不会像我在 ubuntu 上所做的那样对系统范围产生任何影响,即使 NetBSD 本身使用 pkgsrc。
当我./bootstrap --unpriviledged
在主目录中尝试时,它不起作用。在我问为什么有详细的错误消息之前,让我先问一下NetBSD是否设计或考虑到为每个用户下载并使用另一个pkgsrc而不会对系统环境产生任何影响。
PS 英语不是我的母语;请原谅打字、语法或/和单词选择错误。
更新(2017/04/08)
感谢 Greg A. Woods 的回答,我明白我必须显示详细的错误消息。
起初,我总是使用 root 帐户使用 pkg_add 从二进制安装。
-bash-4.4$ uname -a
NetBSD hello-netbsd 7.1 NetBSD 7.1 (GENERIC.201703111743Z) amd64
-bash-4.4$ pkg_info -a
sudo-1.8.17p1 Allow others to run commands as root
bash-4.4.012 The GNU Bourne Again Shell
cvs-1.12.13nb4 Concurrent Versions System
gcc6-6.3.0 The GNU Compiler Collection (GCC) - 6 Release Series
然后我以非 root 用户身份登录,下载了 pkgsrc 和 bootstrap。
-bash-4.4$ cvs -q -z2 -d [email protected]:/cvsroot checkout -r pkgsrc-2017Q1 -P pkgsrc
-bash-4.4$ cd pkgsrc/bootstrap
-bash-4.4$ ./bootstrap --unprivileged
...
...
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/home/vagrant/pkgsrc/bootstrap/work/bmake':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
===> exited with status 1
aborted.
我修改了$PATH
。
-bash-4.4$ vi ~/.profile
PATH=$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R7/bin:/usr/X11R6/bin:/usr/pkg/bin
PATH=${PATH}:/usr/pkg/sbin:/usr/games:/usr/local/bin:/usr/local/sbin
GCC_PATH=/usr/pkg/gcc6/bin
PATH=${PATH}:${GCC_PATH}
-bash-4.4$ . ~/.profile
-bash-4.4$ echo $PATH
/home/vagrant/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R7/bin:/usr/X11R6/bin:/usr/pkg/bin:/usr/pkg/sbin:/usr/games:/usr/local/bin:/usr/local/sbin:/usr/pkg/gcc6/bin
然后再试一次。
-bash-4.4$ rm -fr work
-bash-4.4$ ./bootstrap --unprivileged
...
...
checking for gcc... gcc
checking for C compiler default output file name...
configure: error: in `/home/vagrant/pkgsrc/bootstrap/work/bmake':
configure: error: C compiler cannot create executables
See `config.log' for more details.
===> exited with status 77
aborted.
config.log 是这样的:
-bash-4.4$ view work/bmake/config.log
1 This file contains any messages produced by compilers while
2 running configure, to aid debugging if configure makes a mistake.
3
4 It was created by bmake configure 20140214, which was
5 generated by GNU Autoconf 2.64. Invocation command line was
6
7 $ configure --prefix=/home/vagrant/pkgsrc/bootstrap/work --with-default-sys-path=/home/vagrant/pkgsrc/bootstrap/work
/share/mk --with-machine-arch=x86_64
8
9 ## --------- ##
10 ## Platform. ##
11 ## --------- ##
12
13 hostname = hello-netbsd
14 uname -m = amd64
15 uname -r = 7.1
16 uname -s = NetBSD
17 uname -v = NetBSD 7.1 (GENERIC.201703111743Z)
18
19 /usr/bin/uname -p = x86_64
20 /bin/uname -X = unknown
21
22 /bin/arch = unknown
23 /usr/bin/arch -k = unknown
24 /usr/convex/getsysinfo = unknown
25 /usr/bin/hostinfo = unknown
26 /bin/machine = unknown
27 /usr/bin/oslevel = unknown
28 /bin/universe = unknown
29
30 PATH: /home/vagrant/pkg/bin
31 PATH: /home/vagrant/pkg/sbin
32 PATH: .
33 PATH: /home/vagrant/bin
34 PATH: /bin
34 PATH: /bin
35 PATH: /sbin
36 PATH: /usr/bin
37 PATH: /usr/sbin
38 PATH: /usr/X11R7/bin
39 PATH: /usr/X11R6/bin
40 PATH: /usr/pkg/bin
41 PATH: /usr/pkg/sbin
42 PATH: /usr/games
43 PATH: /usr/local/bin
44 PATH: /usr/local/sbin
45 PATH: /usr/pkg/gcc6/bin
46 PATH: /sbin
47 PATH: /usr/sbin
48
49
50 ## ----------- ##
51 ## Core tests. ##
52 ## ----------- ##
53
54 configure:2371: checking for gcc
55 configure:2387: found /usr/pkg/gcc6/bin/gcc
56 configure:2398: result: gcc
57 configure:2627: checking for C compiler version
58 configure:2636: gcc --version >&5
59 gcc (GCC) 6.3.0
60 Copyright (C) 2016 Free Software Foundation, Inc.
61 This is free software; see the source for copying conditions. There is NO
62 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
63
64 configure:2647: $? = 0
65 configure:2636: gcc -v >&5
66 Using built-in specs.
67 COLLECT_GCC=gcc
68 COLLECT_LTO_WRAPPER=/usr/pkg/gcc6/libexec/gcc/x86_64--netbsd/6.3.0/lto-wrapper
69 Target: x86_64--netbsd
70 Configured with: ../gcc-6.3.0/configure --disable-libstdcxx-pch --enable-nls --with-libiconv-prefix=/usr --enable-__cx
a_atexit --with-gxx-include-dir=/usr/pkg/gcc6/include/c++/ --enable-languages='c obj-c++ objc fortran c++' --enable-shared --e
nable-long-long --with-local-prefix=/usr/pkg/gcc6 --disable-libssp --enable-threads=posix --with-boot-ldflags='-static-libstdc
++ -static-libgcc -Wl,-R/usr/pkg/lib ' --with-arch=nocona --with-tune=nocona --with-fpmath=sse --with-gnu-ld --with-ld=/usr/bi
n/ld --with-gnu-as --with-as=/usr/bin/as --prefix=/usr/pkg/gcc6 --build=x86_64--netbsd --host=x86_64--netbsd --infodir=/usr/pk
g/gcc6/info --mandir=/usr/pkg/gcc6/man
71 Thread model: posix
72 gcc version 6.3.0 (GCC)
73 configure:2647: $? = 0
74 configure:2636: gcc -V >&5
75 gcc: error: unrecognized command line option '-V'
76 gcc: fatal error: no input files
77 compilation terminated.
78 configure:2647: $? = 1
79 configure:2636: gcc -qversion >&5
80 gcc: error: unrecognized command line option '-qversion'; did you mean '--version'?
81 gcc: fatal error: no input files
82 compilation terminated.
83 configure:2647: $? = 1
84 configure:2669: checking for C compiler default output file name
85 configure:2691: gcc conftest.c >&5
86 In file included from conftest.c:9:0:
87 /usr/pkg/gcc6/lib/gcc/x86_64--netbsd/6.3.0/include-fixed/stdio.h:54:23: fatal error: sys/cdefs.h: No such file or dire
ctory
88 #include <sys/cdefs.h>
89 ^
90 compilation terminated.
91 configure:2695: $? = 1
92 configure:2732: result:
93 configure: failed program was:
94 | /* confdefs.h */
95 | #define PACKAGE_NAME "bmake"
96 | #define PACKAGE_TARNAME "bmake"
97 | #define PACKAGE_VERSION "20140214"
98 | #define PACKAGE_STRING "bmake 20140214"
99 | #define PACKAGE_BUGREPORT "[email protected]"
100 | #define PACKAGE_URL ""
101 | /* end confdefs.h. */
102 | #include <stdio.h>
103 | int
104 | main ()
105 | {
106 | FILE *f = fopen ("conftest.out", "w");
107 | return ferror (f) || fclose (f) != 0;
108 |
109 | ;
110 | return 0;
111 | }
112 configure:2738: error: in `/home/vagrant/pkgsrc/bootstrap/work/bmake':
113 configure:: error: C compiler cannot create executables
114 See `config.log' for more details.
115
116 ## ---------------- ##
117 ## Cache variables. ##
118 ## ---------------- ##
119
120 ac_cv_env_CC_set=
121 ac_cv_env_CC_value=
122 ac_cv_env_CFLAGS_set=
123 ac_cv_env_CFLAGS_value=
124 ac_cv_env_CPPFLAGS_set=
125 ac_cv_env_CPPFLAGS_value=
126 ac_cv_env_CPP_set=
127 ac_cv_env_CPP_value=
128 ac_cv_env_LDFLAGS_set=
129 ac_cv_env_LDFLAGS_value=
130 ac_cv_env_LIBS_set=
131 ac_cv_env_LIBS_value=
132 ac_cv_env_build_alias_set=
133 ac_cv_env_build_alias_value=
134 ac_cv_env_host_alias_set=
135 ac_cv_env_host_alias_value=
136 ac_cv_env_target_alias_set=
137 ac_cv_env_target_alias_value=
138 ac_cv_prog_ac_ct_CC=gcc
139
140 ## ----------------- ##
141 ## Output variables. ##
142 ## ----------------- ##
143
144 CC='gcc'
145 CFLAGS=''
146 CPP=''
147 CPPFLAGS=''
148 DEFS=''
149 ECHO_C=''
150 ECHO_N='-n'
151 ECHO_T=''
152 EGREP=''
153 EXEEXT=''
154 GCC=''
155 GREP=''
156 INSTALL=''
157 INSTALL_DATA=''
158 INSTALL_PROGRAM=''
159 INSTALL_SCRIPT=''
160 LDFLAGS=''
161 LIBOBJS=''
162 LIBS=''
163 LTLIBOBJS=''
164 OBJEXT=''
165 PACKAGE_BUGREPORT='[email protected]'
166 PACKAGE_NAME='bmake'
167 PACKAGE_STRING='bmake 20140214'
168 PACKAGE_TARNAME='bmake'
169 PACKAGE_URL=''
170 PACKAGE_VERSION='20140214'
171 PATH_SEPARATOR=':'
172 SHELL='/bin/sh'
173 ac_ct_CC='gcc'
174 ac_exe_suffix=''
175 bindir='${exec_prefix}/bin'
176 bmake_path_max=''
177 build_alias=''
178 datadir='${datarootdir}'
179 datarootdir='${prefix}/share'
180 default_sys_path=''
181 diff_u=''
182 docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
183 dvidir='${docdir}'
184 exec_prefix='NONE'
185 filemon_h='no'
186 force_machine=''
187 host_alias=''
188 htmldir='${docdir}'
189 includedir='${prefix}/include'
190 infodir='${datarootdir}/info'
191 libdir='${exec_prefix}/lib'
192 libexecdir='${exec_prefix}/libexec'
193 localedir='${datarootdir}/locale'
194 localstatedir='${prefix}/var'
195 machine=''
196 machine_arch=''
197 mandir='${datarootdir}/man'
198 mksrc=''
199 oldincludedir='/usr/include'
200 pdfdir='${docdir}'
201 prefix='/home/vagrant/pkgsrc/bootstrap/work'
202 program_transform_name='s,x,x,'
203 psdir='${docdir}'
204 sbindir='${exec_prefix}/sbin'
205 sharedstatedir='${prefix}/com'
206 sysconfdir='${prefix}/etc'
207 target_alias=''
208 use_meta='yes'
209
210 ## ----------- ##
211 ## confdefs.h. ##
212 ## ----------- ##
213
214 /* confdefs.h */
215 #define PACKAGE_NAME "bmake"
216 #define PACKAGE_TARNAME "bmake"
217 #define PACKAGE_VERSION "20140214"
218 #define PACKAGE_STRING "bmake 20140214"
219 #define PACKAGE_BUGREPORT "[email protected]"
220 #define PACKAGE_URL ""
221
222 configure: exit 77
我猜想有些文件丢失了,但不明白该怎么办。
更新2(2017/04/11) 以下是“gcc -v”的结果
-bash-4.4$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/pkg/gcc6/libexec/gcc/x86_64--netbsd/6.3.0/lto-wrapper
Target: x86_64--netbsd
Configured with: ../gcc-6.3.0/configure --disable-libstdcxx-pch --enable-nls --with-libiconv-prefix=/usr --enable-__cxa_atexit --with-gxx-include-dir=/usr/pkg/gcc6/include/c++/ --enable-languages='c obj-c++ objc fortran c++' --enable-shared --enable-long-long --with-local-prefix=/usr/pkg/gcc6 --disable-libssp --enable-threads=posix --with-boot-ldflags='-static-libstdc++ -static-libgcc -Wl,-R/usr/pkg/lib ' --with-arch=nocona --with-tune=nocona --with-fpmath=sse --with-gnu-ld --with-ld=/usr/bin/ld --with-gnu-as --with-as=/usr/bin/as --prefix=/usr/pkg/gcc6 --build=x86_64--netbsd --host=x86_64--netbsd --infodir=/usr/pkg/gcc6/info --mandir=/usr/pkg/gcc6/man
Thread model: posix
gcc version 6.3.0 (GCC)
而且我在安装过程中选择了最小化安装。这有错吗?
答案1
始终提供详细的错误消息! (或者至少足以提供有关遇到的实际问题的线索,因为这避免了不必要的额外交流——如果没有足够的信息来提供任何有意义的方向,许多人会简单地忽略问题)
无论如何,./bootstrap --unprivileged
应该在 NetBSD 主机上工作(它对我有用)。
但我不确定这是个好主意。有些东西不会(也不能)以非特权模式安装,因为它们必须修改系统文件,或者安装 setuid 等。
我以普通用户身份构建软件包,但始终将它们安装为root
.
答案2
看起来你没有安装 netbsd 的“comp”集,即 C 编译器(等等)。尝试运行“gcc -v”。
FWIW,最好的 NetBSD 和 pkgsrc 帮助是通过邮件列表实现的,我只是偶然在这里看到了这个,通过http://netbsd.fi/
答案3
我终于解决了这个问题。正如他们所说,我应该做的是下载 comp.tgz 并解压。此外,还有一个NetBSD 网站常见问题解答。
# cd /
# ftp ftp://ftp.netbsd.org (as an anonymous user)
> cd pub/NetBSD/NetBSD-7.1/amd64/binary/sets
> get comp.tgz
> exit
# tar --unlink -zxvpf comp.tgz
完成此操作后,./bootstrap --unprivileged
在我的主目录中工作(作为非 root 用户)。