Index: Source/CPack/cmCPackDebGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CPack/cmCPackDebGenerator.cxx,v
retrieving revision 1.21
diff -u -r1.21 cmCPackDebGenerator.cxx
--- Source/CPack/cmCPackDebGenerator.cxx	29 Mar 2008 00:23:01 -0000	1.21
+++ Source/CPack/cmCPackDebGenerator.cxx	1 Apr 2008 14:15:47 -0000
@@ -200,6 +200,33 @@
   cmd = "\"";
   cmd += cmakeExecutable;
   cmd += "\" -E tar cfz control.tar.gz ./control ./md5sums";
+  const char* control_extra = 
+    this->GetOption("CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA");
+  if( control_extra )
+    {
+    // copy/paste from cmTarget.cxx
+    std::string depline = control_extra;
+    std::string::size_type start = 0;
+    std::string::size_type end;
+    end = depline.find( ";", start );
+    while( end != std::string::npos )
+      {
+      std::string l = depline.substr( start, end-start );
+      std::string filenamename = cmsys::SystemTools::GetFilenameName(l);
+      std::string localcopy = toplevel;
+      localcopy += "/";
+      localcopy += filenamename;
+      // if we can copy the file, it means it does exist, let's add it:
+      if( cmsys::SystemTools::CopyFileIfDifferent(l.c_str(), localcopy.c_str()) )
+        {
+        // debian is picky and need relative to ./ path in the tar.gz
+        cmd += " ./";
+        cmd += filenamename;
+        }
+      start = end+1; // skip the ;
+      end = depline.find( ";", start );
+      }
+    }
   res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output,
     &retVal, toplevel, this->GeneratorVerbose, 0);
 
Index: Modules/CPackDeb.cmake
===================================================================
RCS file: /cvsroot/CMake/CMake/Modules/CPackDeb.cmake,v
retrieving revision 1.13
diff -u -r1.13 CPackDeb.cmake
--- Modules/CPackDeb.cmake	1 Apr 2008 13:56:41 -0000	1.13
+++ Modules/CPackDeb.cmake	1 Apr 2008 14:15:47 -0000
@@ -88,6 +88,17 @@
 # Suggests:
 # You should set: CPACK_DEBIAN_PACKAGE_SUGGESTS
 
+# CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
+# This variable allow advanced user to add custom script to the control.tar.gz (inside the .deb archive)
+# Typical examples are: 
+# - conffiles
+# - postinst
+# - postrm
+# - prerm"
+# Usage:
+# SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA 
+#    "${CMAKE_CURRENT_SOURCE_DIR/prerm;${CMAKE_CURRENT_SOURCE_DIR}/postrm")
+
 
 # For debian source packages:
 # debian/control