How to properly set installed-size for deb package?
Asked Answered
N

3

9

I'm developing debian packages and I have troubles with correctly defining 'Installed-Size' under DEBIAN/control.
I have created a script that continuously checks svn repository for new revisions, and if found some changes then calculates code's size (excluding DEBIAN folder) with du -s command and then this value is placed to 'Installed-size'.

DEBIAN/control file looks like follows:

Package: myfirstdebpackage
Version: 1.0
Architecture: all
Maintainer: me
Installed-Size: 16664
Depends: python (>=2.7), python-appindicator, python-numpy, python-suds
Section: extras
Priority: optional
Homepage: www.example.com
Description: My first deb package

Application's folder structure:

myfirstdebpackage/DEBIAN
myfirstdebpackage/usr/bin/myfirstdebpackage/<files>

First installation goes well (via apt repository) but after creating a newer version and trying to update package I got 'size-mismatch' or 'Hash Sum mismatch' error.

What's wrong?

Nakamura answered 16/8, 2013 at 13:35 Comment(0)
Y
3

I'm assuming that you are generating the binary package with the same version but with different content each time. Do not do that. This will confuse apt and many other tools, which expect and assume that each pkgname-version-arch tuple denotes a unique and different package.

Regarding the Installed-Size, dpkg-gencontrol would generate it automatically for you, but I'm assuming you are creating the DEBIAN/control file by hand. I'd recommend against that, because it means more manual work which is more prone to error.

Yoshi answered 22/9, 2016 at 21:15 Comment(3)
Why the downvote? The proper way to set the Installed-Size is by using dpkg-gencontrol. It could be generated by hand, but that's rather unorthodox. to do so, you'd need to use the same algorithm, which is no longer the one documented in debian-policy, but the one referenced in bugs.debian.org/793499. Of course that has nothing to do with the error mentioned later on in the question, which is related to the meta indices being out of sync with the source and binary package, but that's not what the question was about.Yoshi
Can you provide an example of how to use dpkg-gencontrol? I can't seem to get it to work without spitting errors at meCachalot
In a source tree, its usage requires well formed debian/control and debian/changelog files, and if run as-is, also the debian/tmp/DEBIAN/ directory. If the packages ships programs dynamically linked then you will want to run dpkg-shlibdeps beforehand. Then running dpkg-gencontrol -p<package-name> should generate it (-p only necessary when debian/control contains multiple packages). But this is all necessarily really brief as it amounts to "How to package without a helper like debhelper", which I'd advise against, unless one really knows what they are doing.Yoshi
W
2
Package: xx-xx-xx-app
Version: 1.0
Architecture: all
Essential: no
Priority: optional
Installed-Size: `du -ks usr|cut -f 1`
Maintainer: XXX Team
Description: XXX Service
Welch answered 21/6, 2022 at 8:42 Comment(3)
this doesn't work with the dpkg-deb --build command. There is some pre-step, I'm clearly missing if this works for you. please add directions to your postCachalot
@Cachalot `du -ks usr | cut -f 1` should be evaluated in the shell. You can assign it to a variable first installed_size=`du -ks usr | cut -f 1` and then substitute it in a control file.Coaly
Execute this inside the package folder: size=$(du -ks * | grep -v DEBIAN | cut -f1 | xargs | sed -e 's/\ /+/g' | bc); sed -ri "s/^Installed-Size.*$/Installed-Size: $size/g" ./DEBIAN/controlChromatid
E
-1

I don't expect that you should change that value manually. Instead, run debuild (part of devscripts package) in the root directory of the package. A binary package will be created in that root's parent directory and will, of course, have the field automatically filled in for you.

Enesco answered 17/8, 2013 at 10:11 Comment(2)
I have removed the 'Installed-Size' field from control file and the package has been created successfully. However the problem still exists. Maybe something wrong with my apt repository? Anytime I create a new deb package I copy it to the repository ('binary' folder) and then execute 'dpkg-scanpackages binary /dev/null | gzip -9c > binary/Packages.gz' command...Nakamura
Do not run dpkg-scanpackages manually. Rather use a helper tool like reprepro: serverfault.com/a/224635.Enesco

© 2022 - 2025 — McMap. All rights reserved.