7

I'm playing with dpkg, but I got rather strange problem: Package can not be build second time after 1st package was successfully build.

dpkg-buildpackage -sa
....
dpkg-source: warning: newly created empty file 'build/lib.linux-x86_64-2.7/neutron/api/__init__.py' will not be represented in diff
(repeats 100500 times for different files).

How can I to rebuild deb second time?

It looks like I miss some cleanup command.

tripleee
  • 175,061
  • 34
  • 275
  • 318
George Shuklin
  • 6,952
  • 10
  • 39
  • 80

4 Answers4

15

the debian/rules file is actually a Makefile, and it MUST (according to the Debian policy) have a clean target to cleanup the build.

if this target is not run automatically, you can call it explictely with something like:

 dpkg-buildpackage -rfakeroot -Tclean
umläute
  • 28,885
  • 9
  • 68
  • 122
  • 1
    But `dpkg-buildpackage` already runs this target, doesn't it? – tripleee May 26 '14 at 14:53
  • I done this, and even remove all *.pyc files, and remove build directory. Now it failing with dpkg-source: info: local changes detected, the modified files are: neutron-2013.2.3/neutron.egg-info/entry_points.txt neutron-2013.2.3/neutron.egg-info/requires.txt dpkg-source: info: you can integrate the local changes with dpkg-source --commit ...seems package is broken. Thanks. – George Shuklin May 26 '14 at 14:54
  • @tripleee afaik it *should* run the `clean` target *before* starting the build (rather than *after* the build) – umläute May 26 '14 at 15:02
  • @GeorgeShuklin in this case: yes, probably the package is broken. you might have more luck by getting the [package via git](git://anonscm.debian.org/openstack/neutron.git) and just make sure that the git-tree is clean before rebuilding... – umläute May 26 '14 at 15:04
  • 1
    Right; but then the OP wold not be getting this error in the first place if it actually worked, right? – tripleee May 26 '14 at 15:05
  • `man dpkg-buildpackage`: "If one or more specific targets have been selected with the -T or --target option, it calls those targets and stops here. Otherwise it runs the preclean hook and calls fakeroot debian/rules clean to clean the build-tree (unless -nc or --no-pre-clean is specified)." – Quasímodo Jun 18 '22 at 19:16
4

Another possibility is to use debuild instead of calling dpkg-buildpackage directly. Simplest method is to build the binary packages along with unsigned source and unsigned changelog, cd to the debian/ directory of the source and:

$ debuild -uc -us

You can call the clean target on debuild to clean up.

$ debuild -T clean
Stewart
  • 4,356
  • 2
  • 27
  • 59
Alex
  • 1,602
  • 20
  • 33
  • The command `debuild clean` doesn't appear to work without the `-T` flag first. It passes this to `dpkg-buildpackage` directly, as shown in the error: `dpkg-buildpackage -us -uc -ui -sa clean` `dpkg-buildpackage: error: unknown option or argument clean` Adding the `-T` flag first works: `debuild -T clean` gives: `dpkg-buildpackage -us -uc -ui -sa -T clean`, and then shows that it runs the `clean` target of `debian/rules`: `fakeroot debian/rules clean` – TrinitronX May 23 '20 at 20:44
2

The debian/rules file is usually set up to clean out old build artefacts, but yours seems to have a bug, or simply lack this functionality. (Submit a bug report?)

Without more knowledge about your package, this is speculative, but try removing the build directory.

In the worst case, start over by unpacking the sources anew.

tripleee
  • 175,061
  • 34
  • 275
  • 318
  • A lot of packages are broken in this way. From the three general purpose answers here, this is the only one that is correct. See also https://utcc.utoronto.ca/~cks/space/blog/linux/DebianSourcePackageBuildExplosion – Quasímodo Jun 18 '22 at 19:22
1

Thanks everyone for help.

In my case problem was spitted into two parts:

  • uncleaned files (and original package has no proper cleaning rules)
  • Incorrectly packed neutron_2013.2.3.orig.tar.gz, with neutron.egg-info (it even added to .gitignore on repo on github)

So in my case solution was rather complex:

  1. Repack neutron_2013.2.3.orig.tar.gz without neutron.egg-info
  2. Change md5sum/sha1sum/sha256sum and filesizes in neutron_2013.2.3-0ubuntu1~cloud0.dsc
  3. Unpack source again with dpkg-source -x neutron_2013.2.3-0ubuntu1~cloud0.dsc
  4. (patch/bump version)
  5. dpkg-buildpackage -sa
  6. To pack again, remove in neutron-2013.2.3:
    1. rm -r build neutron.egg-info
    2. find . -name "*.py" | xargs rm
  7. dpkg-buildpackage -sa
George Shuklin
  • 6,952
  • 10
  • 39
  • 80