【问题标题】:Install rpm and put file into symbolic link directory安装rpm并将文件放入符号链接目录
【发布时间】:2015-02-06 14:08:01
【问题描述】:

我已经制作了一个 rpm 软件包来安装一个程序,它需要将文件复制到的文件夹之一是 symbolic link,因为符号链接指向的程序可能会随着时间而改变,因此更容易通过将文件复制到symbolic link 而不是硬编码路径来维护rpm 包的构建。但是,我收到错误

cp: cannot overwrite directory with non-directory

rpm 包试图将文件复制到符号链接文件夹时。为什么会发生这种情况,除了将文件复制到symbolic link 指向的文件夹之外,我还能做些什么来解决这个错误?我正在运行RHEL 6.6

【问题讨论】:

  • 失败的cp 行到底是什么样的?目标上是否有斜线?
  • 它说不能覆盖目录/opt/tomcat/bin with /foo/opt/tomcat/bin/setenv.sh
  • 我问的是规范文件中的行而不是错误。
  • 哦,我不确定,因为我正在使用 make 文件生成并清理规范文件,但我只是让它做一个 cp,根本没有选项

标签: linux symlink rpm cp rhel6


【解决方案1】:

该错误通常意味着您告诉 cp 将目标视为普通文件(-T 参数)。

$ ls -lR
.:
total 16
drwxr-xr-x 2 root root 4096 Feb  6 09:46 dir
-rw-r--r-- 1 root root    0 Feb  6 09:45 file
lrwxrwxrwx 1 root root    3 Feb  6 09:45 symdir -> dir

./dir:
total 0
$ cp -T file symdir
cp: cannot overwrite non-directory `symdir' with non-directory
$ ls -lR
.:
total 16
drwxr-xr-x 2 root root 4096 Feb  6 09:46 dir
-rw-r--r-- 1 root root    0 Feb  6 09:45 file
lrwxrwxrwx 1 root root    3 Feb  6 09:45 symdir -> dir

./dir:
total 0
$ cp file symdir
$ ls -lR
.:
total 16
drwxr-xr-x 2 root root 4096 Feb  6 09:46 dir
-rw-r--r-- 1 root root    0 Feb  6 09:45 file
lrwxrwxrwx 1 root root    3 Feb  6 09:45 symdir -> dir

./dir:
total 4
-rw-r--r-- 1 root root 0 Feb  6 09:46 file

【讨论】:

    猜你喜欢
    • 2020-12-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-28
    • 1970-01-01
    • 2011-08-07
    • 2018-10-05
    • 1970-01-01
    相关资源
    最近更新 更多