Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question] Instructions to bootstrap Fedora RPM repository using dnf and rpm? #2095

Closed
yurivict opened this issue May 10, 2024 · 3 comments
Closed

Comments

@yurivict
Copy link

I would like to bootstrap the Fedora repository and install packages on a non-Fedora machine.

Are there instructions how to do this, when there is no dnf installed?
What are the prerequisites?

@evan-goode
Copy link
Member

I'm not sure we have this documented anywhere, but I have a couple ideas how to do it:

  1. Method using Nix. This might not be worth it if you're not already familiar with Nix, but it's what I would do personally, so I'll mention it:

    1. Install Nix on either the target system or a separate system.

    2. If you're already on the target machine, run nix-shell -p dnf4 rpm to get a temporary shell with DNF 4 and RPM.

    3. Otherwise, if you're on a separate machine, you could use nix bundle nixpkgs#dnf4 and nix bundle nixpkgs#rpm to create portable, static executables, then transfer them to the target system.

    4. Download and install the RPMS fedora-repos-40 and fedora-gpg-keys-40 to set up the Fedora repositories. You'll need to install them with --no-deps, otherwise there's a dependency on Fedora's filesystem package, and that's not gonna be able to coexist with whatever existing system you have:

      wget https://dl.fedoraproject.org/pub/fedora/linux/releases/40/Everything/x86_64/os/Packages/f/fedora-repos-40-1.noarch.rpm
      wget https://dl.fedoraproject.org/pub/fedora/linux/releases/40/Everything/x86_64/os/Packages/f/fedora-gpg-keys-40-1.noarch.rpm
      rpm -i --no-deps *.rpm

    5. Install packages with DNF 4: dnf4 install --releasever=40 whatever. The releasever will need to be specified each time since your /etc/os-release will be for a non-Fedora system.

  2. Method using an existing Fedora/DNF/rpm system (you could use a Fedora container):

    1. Create a Fedora chroot with DNF 5 (I find DNF 5 a little easier to use here):
      dnf5 --installroot="$(realpath ./chroot)" --releasever=40 --use-host-config install dnf5 -y
    2. Transfer the chroot to your target machine
    3. On the target, mount necessary filesystems inside the chroot, including the root FS (we're doing sort of an inverted-chroot thing):
      cd /path/to/chroot
      mount -t proc /proc proc/ # these steps might be different depending on your system
      mount -t sysfs /sys sys/
      mount --rbind /dev dev/
      mount --rbind /run run/
      mount --bind / /root
    4. Enter the chroot and install packages to the /root mount:
      chroot .
      dnf5 --installroot=/root --use-host-config install whatever

I think no matter what, you're not going to get very far installing most packages (including installing dnf and rpm) since you'll run into file conflicts with the existing system. But this could be useful for installing certain packages with few dependencies or working with different installroots.

There is also the INSTALL document in the RPM repository if you want to go the route of installing each dependency from source, without Nix or a separate system to help bootstrap.

I hope that's somewhat helpful, let me know if I can clarify anything. There may be errors in these instructions since I jotted them down quickly.

@ppisar
Copy link
Contributor

ppisar commented May 15, 2024

If you want to port Fedora to a new platform, you need to to be familiar with bootstrapping Linux systems (binutils, gcc, glibc) and with building Fedora (rpmbuild, Mock, Koji). For the later I recommend you contacting RISC-V people https://fedoraproject.org/wiki/Architectures/RISC-V who have the latest experience.

If you want simply to install Fedora packages into a Fedora-supported platform, don't do it as the installed files will probably collide with the files from your original system. Rather use chroot/name spaces/virtual machines. For the chroot method, build RPM and DNF for your original system from sources, and then use "dnf --installroot" to populate a subdirectory with Fedora packages. Or download a container image https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Container/x86_64/images/ and unpack it. Container images are basically tar archives. Then you can simply chroot inside.

@jan-kolarik
Copy link
Member

If you need further help, feel free to reach out to us. However, since detailed answers have already been provided and this issue is not directly related to DNF, I am closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants