rpm-software-management / microdnf

Lightweight implementation of dnf in C
GNU General Public License v2.0
220 stars 34 forks source link

microdnf --installroot=xxx does not work #113

Closed mikhailnov closed 2 years ago

mikhailnov commented 3 years ago

Using latest release

[user@rosa2019 ~]$ sudo microdnf --config=/etc/dnf/dnf.conf --setopt=cachedir=/var/cache/microdnf --setopt=reposdir=/etc/yum.repos.d --setopt=varsdir=/etc/dnf --installroot=/tmp/microdnf-root install basesystem-build

error: The "--installroot" argument must be used together with "--config", "--noplugins", "--setopt=cachedir=<path>", "--setopt=reposdir=<path>", "--setopt=varsdir=<path>" arguments.
mikhailnov commented 3 years ago

I've removed this check:

diff --git a/dnf/dnf-main.c b/dnf/dnf-main.c
index f26f36e..caebc9c 100644
--- a/dnf/dnf-main.c
+++ b/dnf/dnf-main.c
@@ -497,15 +497,6 @@ main (int   argc,
    */
   if (!show_help)
     {
-      if (installroot_used &&
-          !(config_used && disable_plugins_loading && cachedir_used && reposdir_used && varsdir_used))
-        {
-          error = g_error_new_literal (G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE,
-            "The \"--installroot\" argument must be used together with \"--config\", "
-            "\"--noplugins\", \"--setopt=cachedir=<path>\", \"--setopt=reposdir=<path>\", "
-            "\"--setopt=varsdir=<path>\" arguments.");
-          goto out;
-        }

       if (disable_plugins_loading)
         dnf_context_set_plugins_all_disabled (disable_plugins_loading);

Now I get: "error: Could not find os-release in etc/, usr/etc, or usr/lib under source root '/tmp/microdnf-root'"

I expected microdnf to be able to bootstrap a chroot from scratch :(

mikhailnov commented 3 years ago

I have created /tmp/microdnf-root/etc/os-release, there is nothing elase in this directory, and now microdnf works

[user@rosa2019 ~]$ mkdir -p /tmp/microdnf-root/etc
[user@rosa2019 ~]$ cp -v /etc/os-release /tmp/microdnf-root/etc
'/etc/os-release' -> '/tmp/microdnf-root/etc/os-release'
Conan-Kudo commented 3 years ago

This kind of goes back to the thing that the $releasever detection should be able to use the distroverpkg method like DNF does.

jrohel commented 2 years ago

@mikhailnov Microdnf does not know which release you want to install in the newly created (empty) "installroot". However, there is no need to create an "os-release" file. Releasever can be set with the command line argument --releasever.

eg --releasever=35 for Fedora35

microdnf --noplugins --config=/etc/dnf/dnf.conf --setopt=cachedir=/var/cache/microdnf --setopt=reposdir=/etc/yum.repos.d --setopt=varsdir=/etc/dnf --installroot=/tmp/microdnf-root --releasever=35 install basesystem

You do not need to use the --releasever command line argument in next run. The example installs the release file package in the installroot directory. So the next time you run it, microdnf will use it for autodetection.

DNF has the same behavior.