收集所有rpm依赖项以部署项目 [英] Collect all rpm dependencies to deploy a project

查看:142
本文介绍了收集所有rpm依赖项以部署项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将软件项目(打包为rpm)从开发者机器部署到服务器中。我正在使用Fedora 23以及dnf软件包管理器。在部署到服务器之前,我必须收集所有rpm的依赖关系。由于内部监管,服务器无法连接到互联网(但是我可以在其上安装ssh)。运行存储库镜像等不是一个选项。恐怕我只需要收集开发者机器上的所有依赖关系,并将它们scp(或可以)安装到服务器上,然后安装在服务器上。

I need to deploy a software project (packaged as an rpm) from a developer machine into a server. I'm using Fedora 23, along with the dnf package manager. I have to collect all dependencies of my rpm before I deploy to the server. The server can't be connected to the internet due to internal regulation (But I can ssh onto it). Running repository mirrors, etc. is not an option. I'm afraid I just have to collect all dependencies on the developer machine, scp (or ansible) them to the server and install them on the server.

我希望dnf中的 - installroot 选项可能会有很大的帮助,因为我可以检索将被安装到dnf认为是空系统的所有rpms。但是这不行。

I hoped that --installroot option in dnf could be of much help, as I could retrieve all rpms that would get installed into what dnf thinks is an empty system. This however doesn't work.

mkdir foo&& sudo dnf install --installroot = $ PWD / foo golang

给出错误:

无法为repo'fedora'同步缓存

为什么会失败?我有什么选择?

Why does this fail? What are my options?

我想看到一个优雅而强大的解决方案。我不想在服务器上安装任何东西(我最乐意做一个单一的scp,后跟一个或两个命令通过ssh)。 rpm + yum / dnf魔术的组合将是巨大的,但其他解决方案,包括apt + deb也是很有意思的。我不喜欢使用docker,我强烈反对运行任何其他基础设施(docker注册表,rpm镜像等)。

I'd like to see an elegant and robust solution. I'd prefer not to install anything on the server (I'd be most happy to do a single scp followed by one or two commands over ssh). A combination of rpm + yum/dnf magic would be great, but other solutions, including apt + deb are also of interest. I'd prefer not to use docker, and I'm strongly against running any additional infrastructure (docker registry, rpm mirror, etc.)

推荐答案

这是一个(临时的,轻微测试的)脚本(假设您已经安装了rpm系统)来生成安装给定软件包所需的所有rpm软件包名称的列表(脚本假定为bash ,编辑以品尝)

Here is a (ad hoc, lightly tested) script (assuming you have an already installed rpm system) to generate the list of all the rpm package names needed to install a given package (the script assumes goal="bash", edit to taste).

将输出名称输入到dnf / yum进行安装。

Feed the output names to dnf/yum to install.

#!/bin/sh
goal=bash
deps=$(rpm -q --qf '[%{REQUIRENAME}\n]'  $goal | egrep -v '^(rpmlib|rtld|config|/)')
goals=
while true; do
  subs=$(rpm -q --qf '%{NAME}\n' --whatprovides $deps | sort -u | tr '\n' ' ')
  if [ ."$subs" = ."$goals" ]; then
    echo "--- packages needed"
    echo "$goals" | tr ' ' '\n'
    exit 0
  fi
  goals=$(echo $goals $subs | tr ' ' '\n' | sort -u | tr '\n' ' ')
  for sub in $subs; do
    subdeps=$(rpm -q --qf '[%{REQUIRENAME}\n]' $sub | egrep -v '^(rpmlib|rtld|config|/)')
    deps=$(echo $deps $subdeps | sort -u)
  done
done

这篇关于收集所有rpm依赖项以部署项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆