Skip to content

Instantly share code, notes, and snippets.

@goproslowyo
Created April 3, 2022 10:32
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save goproslowyo/fe95c8e07c73593e2099687eeda78bc5 to your computer and use it in GitHub Desktop.
Save goproslowyo/fe95c8e07c73593e2099687eeda78bc5 to your computer and use it in GitHub Desktop.
Repackage a Package Because dpkg on Ubuntu Doesn't Known the Compression of the Member Inside

What does the problem look like?

Because of this bug the libnet1 dpkg installation fails.

$ sudo dpkg -i --force-overwrite /var/cache/apt/archives/libnet1_1.1.6+dfsg-3.1build2_amd64.deb
dpkg-deb: error: archive '/var/cache/apt/archives/libnet1_1.1.6+dfsg-3.1build2_amd64.deb' uses unknown compression for member 'control.tar.zst', giving up
dpkg: error processing archive /var/cache/apt/archives/libnet1_1.1.6+dfsg-3.1build2_amd64.deb (--install):
 dpkg-deb --control subprocess returned error exit status 2
Errors were encountered while processing:
 /var/cache/apt/archives/libnet1_1.1.6+dfsg-3.1build2_amd64.deb

The genericized error is: error: archive [somepackage.deb] uses unknown compression for member [control.tar.zst], giving up

Why?

It appears that whatever created the libnet1 package compressed the control and data tarballs with zstd.

The system dpkg binary is expected xz compression so we can fix it.

Copy, extract, decompress, recompress, repackage to fix

~$ cd $(mktemp -d)
/tmp/tmp.AYtfrTV9Lh$ cp /var/cache/apt/archives/libnet1_1.1.6+dfsg-3.1build2_amd64.deb .
/tmp/tmp.AYtfrTV9Lh$ ar x libnet1_1.1.6+dfsg-3.1build2_amd64.deb 
/tmp/tmp.AYtfrTV9Lh$ zstd -d < control.tar.zst| xz > control.tar.xz  
/tmp/tmp.AYtfrTV9Lh$ zstd -d < data.tar.zst| xz > data.tar.xz  
/tmp/tmp.AYtfrTV9Lh$ ar -m -c -a sdsd libnet1_repacked.deb debian-binary control.tar.xz data.tar.xz
/tmp/tmp.AYtfrTV9Lh$ rm debian-binary control.tar.xz data.tar.xz control.tar.zst data.tar.zst 
/tmp/tmp.AYtfrTV9Lh$ ls
libnet1_1.1.6+dfsg-3.1build2_amd64.deb libnet1_repacked.deb

Does it work now?

$ sudo dpkg -i --force-overwrite libnet1_repacked.deb
(Reading database ... 435333 files and directories currently installed.)
Preparing to unpack libnet1_repacked.deb ...
Unpacking libnet1:amd64 (1.1.6+dfsg-3.1build2) over (1.1.6+dfsg-3.1build2) ...
Setting up libnet1:amd64 (1.1.6+dfsg-3.1build2) ...
Processing triggers for libc-bin (2.34-0ubuntu3.2) ...

Credit

Hat tip to this random user running into a siliar issue and the developer showing how to repackage it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment