rickysarraf / apt-offline

Offline APT Package Manager
http://rickysarraf.github.io/apt-offline/
GNU General Public License v3.0
219 stars 37 forks source link

Get dependencies for local deb file? #107

Open metal450 opened 4 years ago

metal450 commented 4 years ago

Given a local .deb file, is it possible to use apt-offline to generate a bundle of just the dependencies required to install that .deb file?

i.e. rather than

apt-offline set vim.sig --install-packages vim
apt-offline get vim.sig --bundle vim.zip

Something to the effect of

app-offline set x.sig --install-dependencies ./x.deb
app-offline get x.sig --bundle dependanciesForX.zip

?

rickysarraf commented 4 years ago

Hi,

On Wed, 2020-04-29 at 20:06 -0700, metal450 wrote:

Given a local .deb file, is it possible to use apt-offline to generate a bundle of just the dependencies required to install that .deb file?

i.e. rather than

apt-offline set vim.sig --install-packages vim apt-offline get vim.sig --bundle vim.zip Something to the effect of

app-offline set x.sig --install-dependencies ./x.deb app-offline get x.sig --bundle dependanciesForX.zip ?

No. Currently apt-offline doesn't deal with .debs for this information. It rather relies on apt.

But this could be a feature to have. Just that it'd be some scraping to be done from the .deb's metadata. When using apt, we delegate that to it instead and apt does a good job there.

Depends: python3:any, apt-offline (= 1.8.2-2), python3-pyqt5

Depends: libacl1 (>= 2.2.23), libblkid1 (>= 2.24), libc6 (>= 2.30), libkmod2 (>= 5~), libselinux1 (>= 2.1.9), adduser, dpkg (>= 1.19.3) | systemd-sysv, libudev1 (= 245.5-2), util-linux (>= 2.27.1)

Depends: kio, libc6 (>= 2.14), libkf5configcore5 (>= 4.97.0), libkf5coreaddons5 (>= 4.100.0), libkf5dbusaddons5 (>= 4.97.0), libkf5guiaddons5 (>= 4.96.0), libkf5i18n5 (>= 4.97.0), libkf5iconthemes5 (>= 4.96.0), libkf5kiocore5 (>= 5.62.0~), libkf5notifications5 (>= 4.96.0), libkf5textwidgets5 (>= 4.96.0), libkf5widgetsaddons5 (>= 4.96.0), libkf5windowsystem5 (>= 5.62.0), libqt5core5a (>= 5.12.2), libqt5dbus5 (>= 5.0.2), libqt5gui5 (>= 5.7.0) | libqt5gui5-gles (>= 5.7.0), libqt5widgets5 (>= 5.6.0~beta), libstdc++6 (>= 4.4.0), libx11-6

Depends: libc6 (>= 2.14), libcamel-1.2-62 (= 3.36.2-1), libcanberra-gtk3-0 (>= 0.25), libcanberra0 (>= 0.2), libdb5.3, libebackend-1.2-10 (= 3.36.2-1), libebook-1.2-20 (>= 3.17), libebook-contacts-1.2-3 (>= 3.25.90), libecal-2.0-1 (>= 3.33.4), libedata-book-1.2-26 (>= 3.33.91), libedata-cal-2.0-1 (>= 3.26.2), libedataserver-1.2-24 (>= 3.35.91), libedataserverui-1.2-2 (= 3.36.2-1), libgcr-base-3-1 (>= 3.8.0), libgcr-ui-3-1 (>= 3.8.0), libgdata22 (>= 0.17.10), libglib2.0-0 (>= 2.45.6), libgoa-1.0-0b (>= 3.11.90), libgtk-3-0 (>= 3.10), libgweather-3-16 (>= 3.10.0), libical3 (>= 3.0.7), libldap-2.4-2 (>= 2.4.7), libpango-1.0-0 (>= 1.14.0), libsecret-1-0 (>= 0.7), libsoup2.4-1 (>= 2.42), libxml2 (>= 2.9.0), evolution-data-server-common (>= 3.36.2-1), gnome-keyring

Dealing with a .deb metadata would mean:

But this is a nice handy feature to have. I don't have bandwidth to implement this soon but I would be delighted to see this feature.

I'll mark it as a wishlist for now and wishfully hope someone else to beat me at it.

Thanks, Ritesh

-- Ritesh Raj Sarraf RESEARCHUT - http://www.researchut.com "Necessity is the mother of invention."

metal450 commented 4 years ago

Cool...thanks for the quick reply, bummer it isn't there yet or on the horizon, but glad it sounds useful & may be someday! :)

I'm afraid I don't have the capability personally either, but in the interim, I suppose I can just manually churn out a long command for the few .debs I have that are distributed outside of apt (i.e. --install-packages dep1 dep2 dep3 dep4, etc).

Fingers crossed that this ends up getting tackled & eases the task of future reformats :)

rahedges commented 3 months ago

I was looking for this feature too.

Is there a way to pass the dependency from the Depends line to the set command? From the above example, could one call this:

sudo apt-offline set local-deb-offline.sig --install-packages libacl1 (>= 2.2.23), libblkid1 (>= 2.24), libc6 (>= 2.30), libkmod2 (>= 5~), libselinux1 (>= 2.1.9), adduser, dpkg (>= 1.19.3) | systemd-sysv, libudev1 (= 245.5-2), util-linux (>= 2.27.1)

I don't know how to specify the version ranges to the set command.

This would be similar to the apt-get satisfy command.

I am wanting to do this because I have an apt package coming from a PPA which is not configured on the offline machine. The application is the only .deb that will come from the PPA, the dependencies will all come from repos known to the offline system.

rickysarraf commented 3 months ago

I was looking for this feature too.

Is there a way to pass the dependency from the Depends line to the set command? From the above example, could one call this:

sudo apt-offline set local-deb-offline.sig --install-packages libacl1 (>= 2.2.23), libblkid1 (>= 2.24), libc6 (>= 2.30), libkmod2 (>= 5~), libselinux1 (>= 2.1.9), adduser, dpkg (>= 1.19.3) | systemd-sysv, libudev1 (= 245.5-2), util-linux (>= 2.27.1)

I don't know how to specify the version ranges to the set command.

This would be similar to the apt-get satisfy command.

This approach is bound to break. The dependencies listed above are that of dpkg. apt only manipulates versions, that are present in the repository, against what the user requests.

apt-offline ensures to not duplicate steps that are better dealt by dpkg/apt.

I am wanting to do this because I have an apt package coming from a PPA which is not configured on the offline machine. The application is the only .deb that will come from the PPA, the dependencies will all come from repos known to the offline system.

Why not ? It is an offline machine. So you could just enable that PPA repository and then let apt and apt-offline do the work of extracting the dependency.

There's this fairly new library: https://github.com/memory/python-dpkg

Python 3.12.4 (main, Jul 15 2024, 12:17:32) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pydpkg
>>> deb = pydpkg.D
pydpkg.Dpkg(  pydpkg.Dsc(   
>>> deb = pydpkg.Dpkg("zstd_1.5.6+dfsg-1_amd64.deb")
>>> deb
'Package: zstd\nSource: libzstd\nVersion: 1.5.6+dfsg-1\nArchitecture: amd64\nMaintainer:
 RPM packaging team <team+pkg-rpm@tracker.debian.org>\nInstalled-Size: 2247\nDepends: li
bc6 (>= 2.34), libgcc-s1 (>= 3.0), liblz4-1 (>= 1.8.0), liblzma5 (>= 5.1.1alpha+20120614
), libstdc++6 (>= 12), zlib1g (>= 1:1.1.4)\nSection: utils\nPriority: optional\nMulti-Ar
ch: foreign\nHomepage: https://github.com/facebook/zstd\nDescription: fast lossless comp
ression algorithm -- CLI tool\n Zstd, short for Zstandard, is a fast lossless compressio
n algorithm, targeting\n real-time compression scenarios at zlib-level compression ratio
.\n .\n This package contains the CLI program implementing zstd.\n\n'

>>> deb.get('Depends')
'libc6 (>= 2.34), libgcc-s1 (>= 3.0), liblz4-1 (>= 1.8.0), liblzma5 (>= 5.1.1alpha+20120
614), libstdc++6 (>= 12), zlib1g (>= 1:1.1.4)'

>>> deb.get('Depends').split(",")
['libc6 (>= 2.34)', ' libgcc-s1 (>= 3.0)', ' liblz4-1 (>= 1.8.0)', ' liblzma5 (>= 5.1.1a
lpha+20120614)', ' libstdc++6 (>= 12)', ' zlib1g (>= 1:1.1.4)']

>>> deb.epoch
0

>>> deb.version
'1.5.6+dfsg-1'

>>> deb.Depends
'libc6 (>= 2.34), libgcc-s1 (>= 3.0), liblz4-1 (>= 1.8.0), liblzma5 (>= 5.1.1alpha+20120
614), libstdc++6 (>= 12), zlib1g (>= 1:1.1.4)'
>>> 

This is not enough information to craft the complete url.

rickysarraf commented 3 months ago

There's also the option to manipulate .dsc

@ python
Python 3.12.4 (main, Jul 15 2024, 12:17:32) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pydpkg
>>> dsc = pydpkg.D
pydpkg.Dpkg(  pydpkg.Dsc(   
>>> dsc = pydpkg.Dsc("user-mode-linux_6.10um1.dsc")
>>> dsc
dsc file user-mode-linux_6.10um1.dsc is not signed or has a corrupt sig: Expected: ASCII-armored PGP data
'Format: 3.0 (native)\nSource: user-mode-linux\nBinary: user-mode-linux\nArchitecture: i386 amd64\nVersion: 6.10um1\nMaintainer: User Mode Linux Maintainers <team+uml@tracker.debian.org>\nUploaders: Ritesh Raj Sarraf <rrs@debian.org>\nHomepage: https://user-mode-linux.sourceforge.net/\nStandards-Version: 4.6.1\nVcs-Browser: https://salsa.debian.org/uml-team/user-mode-linux\nVcs-Git: https://salsa.debian.org/uml-team/user-mode-linux.git\nBuild-Depends: debhelper-compat (= 13), quilt, linux-source-6.10, python3-docutils, xz-utils, m4, kmod, libvdeplug-dev | libvdeplug2-dev, libpcap-dev, bc, dpkg (>= 1.16.2), libssl-dev, bison, flex, gcc-multilib\nPackage-List: \n user-mode-linux deb kernel optional arch=i386,amd64\nChecksums-Sha1: \n e21c416dbc8961ca02c6d46751370be9ec3d6100 35296 user-mode-linux_6.10um1.tar.xz\n ae32ac205ba955177c8d424e118d57ba89085d00 1001 user-mode-linux_6.10um1.dsc\nChecksums-Sha256: \n 7afee03b97b390e3fe6eb9f37c599b28dac639880b8ae245ad76df05849f92ab 35296 user-mode-linux_6.10um1.tar.xz\n c529d6d56e405a16364173da67fd346e78efe737498fc27f36afd8238fdc0668 1001 user-mode-linux_6.10um1.dsc\nFiles: \n 6a911e050dd5a3b426cf0021d72b28c5 35296 user-mode-linux_6.10um1.tar.xz\n 44edbc4cef216da1b7c5ebcbe5a05ace 1001 user-mode-linux_6.10um1.dsc\n\n'

>>> dsc.
dsc.all_checksums_correct  dsc.get(                   dsc.pgp_message
dsc.all_files_present      dsc.headers                dsc.sizes
dsc.checksums              dsc.message                dsc.source_files
dsc.corrected_checksums    dsc.message_str            dsc.validate()
dsc.filename               dsc.missing_files          

>>> dsc.source_files
['/var/tmp/Debian-Build/Result/user-mode-linux_6.10um1.tar.xz', '/var/tmp/Debian-Build/Result/user-mode-linux_6.10um1.dsc']
>>> 

So what'll be needed is a cross-platform python-apt library, which to my knowledge is not cross-platform.