2013-04-21 22:17:47 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
import lutinDebug as debug
|
|
|
|
import lutinTarget
|
2013-04-22 21:37:13 +02:00
|
|
|
import lutinTools
|
|
|
|
import os
|
|
|
|
import stat
|
2013-04-21 22:17:47 +02:00
|
|
|
|
2013-04-22 21:37:13 +02:00
|
|
|
class Target(lutinTarget.Target):
|
2013-04-21 22:17:47 +02:00
|
|
|
def __init__(self, typeCompilator, debugMode):
|
2013-04-22 21:37:13 +02:00
|
|
|
lutinTarget.Target.__init__(self, "Linux", typeCompilator, debugMode, "", "")
|
|
|
|
|
|
|
|
def generateListSeparateComa(self, list):
|
|
|
|
result = ""
|
|
|
|
fistTime = True
|
|
|
|
for elem in list:
|
|
|
|
if fistTime == True:
|
|
|
|
fistTime = False
|
|
|
|
else:
|
|
|
|
result += ","
|
|
|
|
result += elem
|
|
|
|
return result
|
|
|
|
|
|
|
|
def MakePackage(self, pkgName, pkgProperties):
|
|
|
|
# http://alp.developpez.com/tutoriels/debian/creer-paquet/
|
|
|
|
debug.debug("------------------------------------------------------------------------")
|
2013-04-26 22:17:09 +02:00
|
|
|
debug.info("Generate package '" + pkgName + "' v"+pkgProperties["VERSION"])
|
2013-04-22 21:37:13 +02:00
|
|
|
debug.debug("------------------------------------------------------------------------")
|
|
|
|
self.GetStagingFolder(pkgName)
|
2013-04-24 12:50:14 +02:00
|
|
|
targetOutFolderDebian=self.GetStagingFolder(pkgName) + "/DEBIAN/"
|
2013-04-22 21:37:13 +02:00
|
|
|
finalFileControl = targetOutFolderDebian + "control"
|
|
|
|
finalFilepostRm = targetOutFolderDebian + "postrm"
|
|
|
|
# create the folders :
|
|
|
|
lutinTools.CreateDirectoryOfFile(finalFileControl)
|
|
|
|
lutinTools.CreateDirectoryOfFile(finalFilepostRm)
|
|
|
|
## Create the control file
|
|
|
|
tmpFile = open(finalFileControl, 'w')
|
|
|
|
tmpFile.write("Package: " + pkgName + "\n")
|
|
|
|
tmpFile.write("Version: " + pkgProperties["VERSION"] + "\n")
|
|
|
|
tmpFile.write("Section: " + self.generateListSeparateComa(pkgProperties["SECTION"]) + "\n")
|
|
|
|
tmpFile.write("Priority: " + pkgProperties["PRIORITY"] + "\n")
|
|
|
|
tmpFile.write("Architecture: all\n")
|
|
|
|
tmpFile.write("Depends: bash\n")
|
|
|
|
tmpFile.write("Maintainer: " + self.generateListSeparateComa(pkgProperties["MAINTAINER"]) + "\n")
|
|
|
|
tmpFile.write("Description: " + pkgProperties["DESCRIPTION"] + "\n")
|
|
|
|
tmpFile.write("\n")
|
2013-04-23 21:48:36 +02:00
|
|
|
tmpFile.flush()
|
|
|
|
tmpFile.close()
|
2013-04-22 21:37:13 +02:00
|
|
|
## Create the PostRm
|
|
|
|
tmpFile = open(finalFilepostRm, 'w')
|
|
|
|
tmpFile.write("#!/bin/bash\n")
|
|
|
|
tmpFile.write("touch ~/." + pkgName + "\n")
|
|
|
|
if pkgName != "":
|
2013-04-24 12:50:14 +02:00
|
|
|
tmpFile.write("touch ~/.local/share/" + pkgName + "\n")
|
|
|
|
tmpFile.write("rm -r ~/.local/share/" + pkgName + "\n")
|
2013-04-22 21:37:13 +02:00
|
|
|
tmpFile.write("\n")
|
2013-04-23 21:48:36 +02:00
|
|
|
tmpFile.flush()
|
|
|
|
tmpFile.close()
|
2013-04-22 21:37:13 +02:00
|
|
|
## Enable Execution in script
|
|
|
|
os.chmod(finalFilepostRm, stat.S_IRWXU + stat.S_IRGRP + stat.S_IXGRP + stat.S_IROTH + stat.S_IXOTH);
|
|
|
|
# copy licence and information :
|
2013-04-24 12:50:14 +02:00
|
|
|
lutinTools.CopyFile("os-Linux/README", self.GetStagingFolder(pkgName) + "/usr/share/doc/"+ pkgName + "/README")
|
|
|
|
lutinTools.CopyFile("license.txt", self.GetStagingFolder(pkgName) + "/usr/share/doc/"+ pkgName + "/copyright")
|
|
|
|
lutinTools.CopyFile("changelog", self.GetStagingFolder(pkgName) + "/usr/share/doc/"+ pkgName + "/changelog")
|
2013-04-22 21:37:13 +02:00
|
|
|
debug.debug("pachage : " + self.GetStagingFolder(pkgName) + "/" + pkgName + ".deb")
|
2013-04-24 12:50:14 +02:00
|
|
|
os.system("cd " + self.GetStagingFolder("") + " ; dpkg-deb --build " + pkgName)
|
2013-04-22 21:37:13 +02:00
|
|
|
lutinTools.CreateDirectoryOfFile(self.GetFinalFolder())
|
2013-04-24 12:50:14 +02:00
|
|
|
lutinTools.CopyFile(self.GetStagingFolder("") + "/" + pkgName + self.suffix_package, self.GetFinalFolder() + "/" + pkgName + self.suffix_package)
|
2013-04-21 22:17:47 +02:00
|
|
|
|
2013-04-22 21:37:13 +02:00
|
|
|
def InstallPackage(self, pkgName):
|
|
|
|
debug.debug("------------------------------------------------------------------------")
|
|
|
|
debug.info("Install package '" + pkgName + "'")
|
|
|
|
debug.debug("------------------------------------------------------------------------")
|
2013-04-23 21:48:36 +02:00
|
|
|
os.system("sudo dpkg -i " + self.GetFinalFolder() + "/" + pkgName + self.suffix_package)
|
2013-04-21 22:17:47 +02:00
|
|
|
|
2013-04-23 21:48:36 +02:00
|
|
|
def UnInstallPackage(self, pkgName):
|
2013-04-22 21:37:13 +02:00
|
|
|
debug.debug("------------------------------------------------------------------------")
|
|
|
|
debug.info("Un-Install package '" + pkgName + "'")
|
|
|
|
debug.debug("------------------------------------------------------------------------")
|
2013-04-23 21:48:36 +02:00
|
|
|
os.system("sudo dpkg -r " + self.GetFinalFolder() + "/" + pkgName + self.suffix_package)
|