Clean target usually got no dependencies, but mainly contains only commands necessary to clean up the package after being built. When applying a patch system, like dpatch is obligatory to add unpatch as direct dependency, this will allow the clean process to de-apply changes provided by the patch system previously added. Clean target is usefull also for deleting generated manpages (or usually autogenerated config logs like config.status or config.log itself) from the build process, if not they will be stored in both source and debian folder. Here is what a clean rule looks like:


rm -f build-stamp 

Add here commands to clean up after the build process.
-$(MAKE) distclean 
-rm -f $(CURDIR)/foo.1 
-rm -f $(CURDIR)/config.log 

Let's analyse clean target closely, explaining what is and what it does every command listed there:



Checks whether you are in the right folder to build the debian package, making sure that debian/control and others file the developer has specified really exists in that folder.



Checks whether you are root as far as the package can be built only in root-mode, otherwise you're suggested to use a fakeroot system specifying it while running dpkg-buildpackage commmand. (e.g dpkg-buildpackage -rfakeroot).

そのパッケージがrootモードでのみビルドされるので、管理者権限で実行されているかどうかを確認します。管理者権限ではない場合は、dpkg-buildpackageコマンドを実行する際にfakerootを利用することが提案されます(例:dpkg-buildpackage -rfakeroot)。

rm -f build-stamp

Remove the generated files created by running make into sources folder, where application's makefile resides.


After executing this commands, the developer will be free to add any other command to clean up the package after comment:


Add here commands to clean up after the build process.

In our case, two commands have been specified (make distclean and dh_clean are specified by default). Basically we can summarize them as it follow:

今回の場合、二つのコマンドが追加されています(make distcleanとdh_cleanについては最初から書かれています)。基本的に、これらは以下のように要約できます:

make distclean

It's intended to return the concerned subset or directory to its pristine, or unbuilt state, removing all files potentially built by source's Makefile. It should not be used prior to install target, otherwise it will fail. (clean process won't stop)


rm -f $(CURDIR)/foo.1

This command will delete the generated manpage created under binary-arch commands by dh_installman (If source directory is named foo-1.0, $(CURDIR) variable will take its place during build process).


rm -f $(CURDIR)/config.log

This command will delete autogenerated logs created by launching ./configure command. It's safe to -not- have those files, to prevent confusing builds. As its shown they can be safely removed in clean target, alwais using previous folder variables. e.g $(CURDIR).



This command (part of debhelper) is responsible for cleaning up after a package has been built, removing build directories and other files like debian/substvars, debian/files and any other files related to debhelper command. (e.g debian/-.debhelper).


It's important to understand you won't find alwais this structure while making a new package as far as each package has different practices, setups and particolar needings.







UbuntuJapaneseWiki: UbuntuPackagingGuideJa/ch04s05 (最終更新日時 2012-01-10 11:49:14 更新者 匿名)