4

I am trying to write a script that uses some not shell builtin commands (such as expect) and I am plannig to use it offline.

Normally, I can install expect in Fedora using sudo yum install expect or Ubuntu using sudo apt install expect.

But I want to download expect package and all it's depends using sudo apt-cache depends expect (after learning depends use...) sudo apt download <depends>.

I tried it and downloaded some .deb files. And I also tried this:

  1. Extract data.tar files from .deb files ( I didn't want to use dpkg -i <some_pkg.deb> because I didn't succeded all time and I want to use it in Fedora -which is not using dpkg-).

  2. Extract all files using tar -xhf data.tar -C ~/demo

  3. Finally I manually copy all files in system dirs using cp -rPn ~/demo/bin/* /bin ~/demo/etc/* /etc ...

But when I do this -espacially using this .deb type packages inside Fedora-, I got segmentation fault (core dumped) error and my system is dead.

I know I am trying not recommended and dangerous approach to achieve my goal, but is there a way to this (espacially backup a command eg. /usr/bin/expect and all its depends) to use it offline?

muru
  • 72,889

2 Answers2

5

You can try alien it will convert packages between different package systems.

It's not bulletproof, dependencies will apply and there might be other issues, but it's worth a try.

5

Don’t try to mix and match packages across distributions, it’s unlikely to work reliably except in the very simplest of cases.

Instead, use the target distribution’s tools. You’ve found out how to download packages and their dependencies on Debian-based distributions; this is also possible on Fedora-based distributions. To download expect and all its dependencies, create a temporary root and a temporary download directory, and tell dnf to download the packages needed to install expect in the temporary root:

mkdir /tmp/expectroot
mkdir /tmp/expectdeps
sudo dnf install --installroot /tmp/expectroot \
                 --downloadonly --downloaddir /tmp/expectdeps \
                 --releasever 32 expect

(replacing “32” as appropriate).

You will then find all the packages you need for an offline installation, regardless of the existing dependencies on the target system, in /tmp/expectdeps.

Stephen Kitt
  • 434,908