1

I've been already made a bootable Linux-based OS using the kernel, busybox only, and testing it in the QEMU emulator is successful. The next step I need is to install dpkg and APT (Debian package manager) on my custom Linux.

How can I do that?

Just install the Debian Package manager source code and compile and then porting to rfs of my system? I don't know what to do exactly.

(installing the Debian package manager is the only way to achieve my goal because my professor instructs like that. So other ways are not useful to me)

Newbyte
  • 1,036
  • Broad questions like this are poorly suited for Stack Exchange unfortunately. This will likely be closed if you don't narrow down your question and clarify. (that said, I'm not a moderator, so I might be wrong) – Newbyte Oct 15 '20 at 08:01
  • @Newbyte installing Debian package manager has too large range? – Jinwoo Bae Oct 15 '20 at 08:18
  • 2
    dpkg is a super fundamental package. I think @Newbyte is simply worried that you'll get it installed, but getting it working well is a different beast. You'll likely end up with packages that conflict with manually-installed files in your system and that goes down a rabbit hole that is too obscure to support. – Stewart Oct 15 '20 at 08:49
  • 1
    I can't help but worry that either you and your professor have distinctly different ideas about the task they want you to perform. I recommend you talk to them and ask them what exactly they meant. – Shadur-don't-feed-the-AI Oct 19 '20 at 09:30

1 Answers1

2

Before I continue let me disclaim:

  1. If your professor is using apt, then she is using a debian-based system. I recommend using the same distro instead of your own "from-scratch" system. If you and using a from-scratch system because you want a custom kernel, then you can install that kernel a debian-based system.

  2. If you do use apt, you'll end up downloading packages from somewhere. Where do you want that to be? Ubuntu's archive? Debian's archive? Elementary's archive? You'll also need to know which version of things to download. Debian stretch has many incompatibilities with Debian buster and Ubuntu bionic. When you use apt to install packages, you'll run into dependency problems if you're not installing all software from the same version of the same distro. Therefore, if you're installing everything from a distro anyways, just start with that distro and replace the kernel if that's something you're trying to do.

  3. On a debian-based system, Everything is tracked by dpkg, including dpkg itself and and very low-level dependencies. Most things depend on libc and you probably already have it installed. That will cause a conflict as it was installed without dpkg, dpkg can't know that it exists on your system and can't verify the version of libc you have is compatible with the package you are trying to install.


I think the simplest way is to download the dpkg binary package (dpkg_<version>_<arch>.deb) for your architecture and unzip it manually. Certainly get that working before you make any attempt with apt.

If you're using a debian-based host, you can apt download dpkg, otherwise, go get the binaries from the archive directly.

You'll need to manually perform on dpkg*.deb what dpkg normally does (the only maintainer script for dpkg is postrm so that's not going to be relevant).

  1. Download dpkg_<version>_<arch>.deb
  2. Extract contents with ar -x *.deb
  3. Extract control.tar.xz with tar -xf
    1. Inspect the control file and check that all dependencies are installed
  4. Extract data.tar.xz to /

After that, you should be able to dpkg -i *.deb on any deb package you install assuming you first install its dependencies installed with dpkg.


The general advice is: If you want to use dpkg or apt, use a distribution that comes with it. There are too many things that can go wrong if you don't.

Stewart
  • 13,677
  • 1
    The hard part is the last sentence here: “assuming you have the dependencies installed with dpkg”. Tools such as the Debian installer and debootstrap jump through hoops to build a basic system where dpkg will work; it’s not something which can be waved away as an exercise left for the reader. – Stephen Kitt Oct 15 '20 at 08:51
  • Totally agree. I added disclaimer #3 which addresses that. – Stewart Oct 15 '20 at 09:01
  • Thanks :-). The kernel has nothing to do with this however, there are no dependencies on kernel images by default. (This is documented somewhere, but I can’t find it now; the main reason is to allow users to build their own kernel, or even provide one externally — consider containers, debootstrap etc.) Your disclaimer stands with the C library on its own. – Stephen Kitt Oct 15 '20 at 09:12
  • Thank you for your answer. But my professor doesn't want to start from the Debian distro. So I have to install and compile to dependencies of the dpkg, APT first. And then install source code of dpkg , APT followed by compiling them. But I confuse that my plan is right. – Jinwoo Bae Oct 17 '20 at 06:21
  • Something doesn't sound right. What sources does the prof use with apt (i.e. what's her /etc/apt/sources.list)? If she doesn't want you using a distro, then it doesn't make sense to use apt since that simply fetches packages from a specific distro. – Stewart Oct 17 '20 at 13:23
  • It also sounds like you're doing a linux-from-scratch project. – Stewart Oct 17 '20 at 13:30
  • @Stewart yes, my project almost the same as linux-from-scratch. My prof want to linux based OS that has debian package manager , kernel, busybox only and dependencies. – Jinwoo Bae Oct 19 '20 at 10:40