From d1eb7a69ee5b808933f303decd06bb991d45ed0e Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Wed, 9 Apr 2014 16:53:02 +0000 Subject: [PATCH] converted cpack deb to dpkg-deb --- CMakeLists.txt | 44 +------------- ext/toolchain/commands1.py | 118 ++++++++++++++++++++++++++++++++----- res/deb/changelog | 5 ++ res/deb/control.in | 11 ++++ 4 files changed, 121 insertions(+), 57 deletions(-) create mode 100644 res/deb/changelog create mode 100644 res/deb/control.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 27d0cfde..73ef8123 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -342,49 +342,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "IRIX") endif() if (CONF_CPACK) - - if (WIN32) - message(FATAL_ERROR "CPack support for Windows has been removed.") - endif() - - if (UNIX) - if (APPLE) - message(FATAL_ERROR "CPack support for Apple has been removed.") - else () - install(FILES bin/synergy - DESTINATION bin - PERMISSIONS - OWNER_READ OWNER_WRITE OWNER_EXECUTE - GROUP_READ GROUP_EXECUTE - WORLD_READ WORLD_EXECUTE) - - # install gnome menu item - install(FILES res/synergy.desktop - DESTINATION share/applications) - install(FILES res/synergy.ico - DESTINATION share/icons) - endif() - endif() - - # The default CPack behaviour is not to append the system processor - # type, which is undesirable in our case, since we want to support - # both 32-bit and 64-bit processors. - set(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}) - - set(CPACK_PACKAGE_NAME "synergy") - set(CPACK_PACKAGE_VENDOR "The Synergy Project") - set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Synergy server and client") - set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR}) - set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR}) - set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_REV}) - set(CPACK_PACKAGE_VERSION ${VERSION}) - set(CPACK_PACKAGE_CONTACT http://synergy-foss.org/) - set(CPACK_RESOURCE_FILE_LICENSE "${cmake_dir}/License.rtf") - set(CPACK_RESOURCE_FILE_README "${cmake_dir}/Readme.txt") - - # Must be last (since it relies of CPACK_ vars). - include(CPack) - + message(FATAL_ERROR "CPack support has been removed.") endif() if (CONF_DOXYGEN) diff --git a/ext/toolchain/commands1.py b/ext/toolchain/commands1.py index ea4d67cc..d3107dbf 100644 --- a/ext/toolchain/commands1.py +++ b/ext/toolchain/commands1.py @@ -982,9 +982,6 @@ class InternalCommands: self.dist_usage() return - if type != 'win' and type != 'mac': - self.configure(unixTarget, '-DCONF_CPACK:BOOL=TRUE') - moveExt = '' if type == 'src': @@ -1001,8 +998,7 @@ class InternalCommands: elif type == 'deb': if sys.platform == 'linux2': - self.dist_run('cpack -G DEB', unixTarget) - moveExt = 'deb' + self.distDeb() else: package_unsupported = True @@ -1067,6 +1063,92 @@ class InternalCommands: finally: self.restore_chdir() + def distDeb(self): + buildDir = self.getGenerator().buildDir + binDir = self.getGenerator().binDir + resDir = self.cmake_dir + + version = self.getVersionFromCmake() + package = '%s-%s-%s' % ( + self.project, version, self.getLinuxPlatform()) + + debDir = '%s/deb' % buildDir + if os.path.exists(debDir): + shutil.rmtree(debDir) + + metaDir = '%s/%s/DEBIAN' % (debDir, package) + os.makedirs(metaDir) + + templateFile = open(resDir + '/deb/control.in') + template = templateFile.read() + + template = template.replace('${in:version}', + self.getVersionFromCmake()) + + template = template.replace('${in:arch}', + self.getDebianArch()) + + controlPath = '%s/control' % metaDir + + controlFile = open(controlPath, 'w') + controlFile.write(template) + controlFile.close() + + targetBin = '%s/%s/usr/bin' % (debDir, package) + targetShare = '%s/%s/usr/share' % (debDir, package) + + os.makedirs(targetBin) + os.makedirs("%s/applications" % targetShare) + os.makedirs("%s/icons" % targetShare) + os.makedirs("%s/doc/%s" % (targetShare, self.project)) + + binFiles = ['synergy', 'synergyc', 'synergys', 'synergyd', 'syntool'] + for f in binFiles: + shutil.copy("%s/%s" % (binDir, f), targetBin) + + err = os.system("strip %s/%s" % (targetBin, f)) + if err != 0: + raise Exception('strip failed: ' + str(err)) + + shutil.copy( + "%s/synergy.desktop" % resDir, + "%s/applications" % targetShare) + + shutil.copy( + "%s/synergy.ico" % resDir, + "%s/icons" % targetShare) + + docTarget = "%s/doc/%s" % (targetShare, self.project) + + copyrightPath = "%s/deb/copyright" % resDir + shutil.copy(copyrightPath, docTarget) + + shutil.copy("%s/deb/changelog" % resDir, docTarget) + os.system("gzip -9 %s/changelog" % docTarget) + if err != 0: + raise Exception('gzip failed: ' + str(err)) + + target = '../../bin/%s.deb' % package + + try: + self.try_chdir(debDir) + + # TODO: consider dpkg-buildpackage (higher level tool) + cmd = 'fakeroot dpkg-deb --build %s' % package + print "Command: " + cmd + err = os.system(cmd) + if err != 0: + raise Exception('dpkg-deb failed: ' + str(err)) + + cmd = 'lintian %s.deb' % package + print "Command: " + cmd + err = os.system(cmd) + if err != 0: + raise Exception('lintian failed: ' + str(err)) + + self.unixMove('*.deb', target) + finally: + self.restore_chdir() def distSrc(self): version = self.getVersionFromCmake() @@ -1229,7 +1311,23 @@ class InternalCommands: ftp.run(srcDir + src, dest) print 'Done' - + + def getDebianArch(self): + if os.uname()[4][:3] == 'arm': + return 'armel' + + # os_bits should be loaded with '32bit' or '64bit' + import platform + (os_bits, other) = platform.architecture() + + # get platform based on current platform + if os_bits == '32bit': + return 'i386' + elif os_bits == '64bit': + return 'amd64' + else: + raise Exception("unknown os bits: " + os_bits) + def getLinuxPlatform(self): if os.uname()[4][:3] == 'arm': return 'Linux-armv6l' @@ -1294,14 +1392,6 @@ class InternalCommands: replace = '\g<1>-r' + self.find_revision() + '\g<2>' return re.sub(pattern, replace, self.dist_name(type)) - def dist_run(self, command, target=''): - self.try_chdir(self.getBuildDir(target)) - print 'CPack command: ' + command - err = os.system(command) - self.restore_chdir() - if err != 0: - raise Exception('Package failed: ' + str(err)) - def dist_usage(self): print ('Usage: %s package [package-type]\n' '\n' diff --git a/res/deb/changelog b/res/deb/changelog new file mode 100644 index 00000000..69554550 --- /dev/null +++ b/res/deb/changelog @@ -0,0 +1,5 @@ +synergy (1.0) unstable; urgency=low + + * Initial release. + + -- Nick Bolton Wed, 09 Apr 2014 15:16:48 +0100 diff --git a/res/deb/control.in b/res/deb/control.in new file mode 100644 index 00000000..631e815b --- /dev/null +++ b/res/deb/control.in @@ -0,0 +1,11 @@ +Package: synergy +Section: net +Priority: optional +Maintainer: Nick Bolton +Version: ${in:version} +Architecture: ${in:arch} +Depends: libc6 +Installed-Size: 30 +Description: Keyboard and mouse sharing utility + Synergy is free and open source software for sharing one mouse and keyboard + between multiple computers. Works on Windows, Mac OS X and Linux.