I have already seen Easily unpack DEB, edit postinst, and repack DEB - however, that one doesn't explain how to properly change the .deb version number if I want to do some changes the original .deb file.I'm on Ubuntu 14.04, and let's take hostapd for an example:$ mkdir /tmp/debtest$ cd /tmp/debtest/$ apt-get download hostapdGet:1 http://dk.archive.ubuntu.com/ubuntu/ trusty-updates/universe hostapd amd64 1:2.1-0ubuntu1.4 [423 kB]Fetched 423 kB in 1s (361 kB/s)  $ ls -la hostapd_1%3a2.1-0ubuntu1.4_amd64.deb -rw-rw-r-- 1 myuser myuser 422846 Nov 10  2015 hostapd_1%3a2.1-0ubuntu1.4_amd64.debNow we can unpack as in the cited link above:$ mkdir unpack-hostapd$ dpkg-deb -R hostapd_1%3a2.1-0ubuntu1.4_amd64.deb unpack-hostapd$ ls -la unpack-hostapd/total 20drwxr-xr-x 5 myuser myuser 4096 Jan 26 11:31 .drwxrwxr-x 3 myuser myuser 4096 Jan 26 11:31 ..drwxr-xr-x 2 myuser myuser 4096 Nov  9  2015 DEBIANdrwxr-xr-x 6 myuser myuser 4096 Nov  9  2015 etcdrwxr-xr-x 4 myuser myuser 4096 Nov  9  2015 usrLet's say I want to make a trival change, say appending a line of text to README.Debian:echo Just a test line >> unpack-hostapd/usr/share/doc/hostapd/README.Debian... and now I want to repack this as a new .deb.First question - is there a way to retrieve the current (old) version of the package from the unpacked state? Because I don't trust filenames, I'd usually do:$ apt-cache policy hostapdhostapd:  Installed: (none)  Candidate: 1:2.1-0ubuntu1.4...... and this tells me I've downloaded version 1:2.1-0ubuntu1.4 of the package when I used apt-get download... - but not necessarily what is the version inside the unpack-hostapd directory. Is there a command that will tell me the package version of the originating .deb that was unpacked into the unpack-hostapd directory?Now, I've used debchange as dch -i before to auto-increment a version number (although in other source projects), but when I try it here:$ cd unpack-hostapd$ pwd/tmp/debtest/unpack-hostapd$ dch -edch: fatal error at line 580:Cannot find debian/changelog anywhere!Are you in the source code tree?(You could use --create if you wish to create this file.)$ find . -name 'changelog*'./usr/share/doc/hostapd/changelog.Debian.gz$ dpkg -c ../hostapd_1%3a2.1-0ubuntu1.4_amd64.deb | grep changelog-rw-r--r-- root/root      2126 2015-11-09 14:56 ./usr/share/doc/hostapd/changelog.Debian.gz... but, I cannot change any of that here. So, my second question is: is there an easy way (like dch -i is for source packages) to change the .deb package version number, and possibly add a changelog, to an unpacked .deb package like this? Of course, ultimately I'd like to re-pack this new version as a .deb package, for which the link above suggests something like dpkg-deb -b unpack-hostapd hostapd_1%3a2.1-0ubuntu1.4_amd64.deb; although, say here I'd rather use version 1:2.2, so I'd finally use a filename like dpkg-deb -b unpack-hostapd hostapd_1%3a2.2_amd64.deb - however, that version should also match what is recorded inside the .deb, and I don't know how to do that...
Easily unpack deb, repack deb with new version
debian;packaging;deb
The version is defined in the binary control file, which is extracted in DEBIAN/control when using dpkg-deb -R. Look for a Version: field:Version: 1:2.5.2+v2.4-3+b1This is where you'd edit the version number for your new package. (You can optionally add a changelog entry to the changelog in usr/share/doc/hostapd/changelog.Debian.gz.) Then you can rebuild your package like this, so that dpkg-deb determines the correct file name for you:mkdir newpkgdpkg-deb -b hostapd newpkgThis will produce a new package in the newpkg directory, named appropriately.Ideally you should check your new binaries' library requirements and update the dependency information in control too!