コード例 #1
0
 def __makeFileGenerator(self):
     """return cmake related make file generator"""
     if self.makeProgram == "ninja":
         return "Ninja"
     if OsUtils.isWin():
         if CraftCore.compiler.isMSVC(
         ) and not CraftCore.compiler.isIntel():
             return "NMake Makefiles"
         if CraftCore.compiler.isMinGW():
             return "MinGW Makefiles"
     elif OsUtils.isUnix():
         return "Unix Makefiles"
     else:
         CraftCore.log.critical(f"unknown {CraftCore.compiler} compiler")
コード例 #2
0
 def setDependencies(self):
     self.buildDependencies["frameworks/extra-cmake-modules"] = "default"
     self.buildDependencies["dev-util/python2"] = "default"
     self.runtimeDependencies["libs/qt5/qtwebkit"] = "default"
     self.runtimeDependencies["virtual/base"] = "default"
     self.runtimeDependencies["frameworks/tier1/kcoreaddons"] = "default"
     self.runtimeDependencies["frameworks/tier1/kconfig"] = "default"
     self.runtimeDependencies["frameworks/tier1/kwidgetsaddons"] = "default"
     self.runtimeDependencies["frameworks/tier1/kguiaddons"] = "default"
     self.runtimeDependencies[
         "frameworks/tier1/breeze-icons"] = "default"  # hard dependency for now
     self.runtimeDependencies["extragear/kproperty"] = "default"
     # TODO Windows/Mac: add marble libs (we only need marble widget), for now marble libs are disabled there
     if not OsUtils.isWin() and not OsUtils.isMac():
         self.runtimeDependencies["kde/applications/marble"] = "default"
コード例 #3
0
    def __init__(self):
        CMakePackageBase.__init__(self)
        self.translations = CraftPackageObject.get("extragear/rkward/rkward-translations").instance

        if OsUtils.isWin():
            if CraftCore.compiler.isX64():
                self.r_dir = os.path.join(CraftCore.standardDirs.craftRoot(), "lib", "R", "bin", "x64")
            else:
                self.r_dir = os.path.join(CraftCore.standardDirs.craftRoot(), "lib", "R", "bin", "i386")
            self.subinfo.options.configure.args = " -DR_EXECUTABLE=" + OsUtils.toUnixPath(os.path.join(self.r_dir, "R.exe"))
        elif OsUtils.isMac():
            self.subinfo.options.configure.args = " -DR_EXECUTABLE=" + os.path.join(CraftCore.standardDirs.craftRoot(), "lib", "R", "R.framework", "Resources", "R")

        if self.subinfo.hasSvnTarget:
            self.subinfo.options.configure.args += f" -DTRANSLATION_SRC_DIR={OsUtils.toUnixPath(self.translations.sourceDir())}"
コード例 #4
0
ファイル: utils.py プロジェクト: LlianeFR/craft
def cleanDirectory(directory):
    CraftCore.log.debug("clean directory %s" % directory)
    if (os.path.exists(directory)):
        for root, dirs, files in os.walk(directory, topdown=False):
            for name in files:
                if not OsUtils.rm(os.path.join(root, name), True):
                    CraftCore.log.critical("couldn't delete file %s\n ( %s )" %
                                           (name, os.path.join(root, name)))
            for name in dirs:
                if not OsUtils.rmDir(os.path.join(root, name), True):
                    CraftCore.log.critical(
                        "couldn't delete directory %s\n( %s )" %
                        (name, os.path.join(root, name)))
    else:
        os.makedirs(directory)
コード例 #5
0
    def configureOptions(self, defines=""):
        """returns default configure options"""
        options = "-DBUILD_TESTING={testing} ".format(
            testing="ON" if self.buildTests else "OFF")
        options += BuildSystemBase.configureOptions(self)

        craftRoot = OsUtils.toUnixPath(CraftCore.standardDirs.craftRoot())
        options += f" -DCMAKE_INSTALL_PREFIX=\"{craftRoot}\""
        options += f" -DCMAKE_PREFIX_PATH=\"{craftRoot}\""

        if self.buildType() is not None:
            options += " -DCMAKE_BUILD_TYPE=%s" % self.buildType()

        #if CraftCore.compiler.isGCC() and not CraftCore.compiler.isNative():
        #    options += " -DCMAKE_TOOLCHAIN_FILE=%s" % os.path.join(CraftStandardDirs.craftRoot(), "craft", "bin", "toolchains", "Toolchain-cross-mingw32-linux-%s.cmake" % CraftCore.compiler.architecture)

        if CraftCore.settings.getboolean("CMake", "KDE_L10N_AUTO_TRANSLATIONS",
                                         False):
            options += " -DKDE_L10N_AUTO_TRANSLATIONS=ON"

        if OsUtils.isWin():
            # people use InstallRequiredSystemLibraries.cmake wrong and unconditionally install the
            # msvc crt...
            options += " -DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=ON"

        if OsUtils.isMac():
            options += f" -DKDE_INSTALL_BUNDLEDIR=\"{OsUtils.toUnixPath(CraftCore.standardDirs.craftRoot())}/Applications/KDE\" -DAPPLE_SUPPRESS_X11_WARNING=ON"

        if CraftCore.compiler.isWindows or CraftCore.compiler.isMacOS:
            options += " -DKDE_INSTALL_USE_QT_SYS_PATHS=ON"

        if self.subinfo.options.buildTools:
            options += " " + self.subinfo.options.configure.toolsDefine + " "
        if self.subinfo.options.buildStatic and self.subinfo.options.configure.staticArgs:
            options += " " + self.subinfo.options.configure.staticArgs + " "
        if CraftCore.compiler.isIntel():
            # this is needed because otherwise it'll detect the MSVC environment
            options += " -DCMAKE_CXX_COMPILER=\"%s\" " % os.path.join(
                os.getenv("BIN_ROOT"), os.getenv("ARCH_PATH"),
                "icl.exe").replace("\\", "/")
            options += " -DCMAKE_C_COMPILER=\"%s\" " % os.path.join(
                os.getenv("BIN_ROOT"), os.getenv("ARCH_PATH"),
                "icl.exe").replace("\\", "/")
            options += " -DCMAKE_LINKER=\"%s\" " % os.path.join(
                os.getenv("BIN_ROOT"), os.getenv("ARCH_PATH"),
                "xilink.exe").replace("\\", "/")
        options += " \"%s\"" % self.configureSourceDir()
        return options
コード例 #6
0
ファイル: Snore.py プロジェクト: juergenhoetzel/craft
 def notify(self, title, message, alertClass):
     try:
         snore = CraftCore.cache.findApplication("snoresend")
         if not snore:
             return
         command = [
             snore, "-t", title, "-m", message, "-i", self.icon, "-a",
             "Craft", "--silent"
         ]
         if alertClass:
             command += ["-c", alertClass]
         if OsUtils.isWin():
             command += [
                 "--bring-window-to-front",
                 str(ctypes.windll.kernel32.GetConsoleWindow())
             ]
         CraftCore.log.debug(command)
         subprocess.Popen(
             command,
             stdout=subprocess.DEVNULL,
             stderr=subprocess.DEVNULL,
             cwd=CraftCore.standardDirs.craftRoot(
             ))  # make sure that nothing is spawned in a build dir
     except Exception as e:
         CraftCore.log.debug(e)
         return
コード例 #7
0
    def createPackage(self):
        """create 7z package with digest files located in the manifest subdir"""
        cacheMode = CraftCore.settings.getboolean("Packager", "CreateCache",
                                                  False)
        if cacheMode:
            if self.subinfo.options.package.disableBinaryCache:
                return True
            dstpath = self.cacheLocation()
        else:
            dstpath = self.packageDestinationDir()

        extention = CraftCore.settings.get(
            "Packager", "7ZipArchiveType",
            "7z" if OsUtils.isWin() else "tar.xz")

        self._compress(
            self.binaryArchiveName(fileType=extention,
                                   includePackagePath=cacheMode,
                                   includeTimeStamp=cacheMode),
            self.imageDir(), dstpath)
        if not self.subinfo.options.package.packSources:
            return True
        if CraftCore.settings.getboolean("Packager", "PackageSrc", "True"):
            self._compress(
                self.binaryArchiveName("-src",
                                       fileType=extention,
                                       includePackagePath=cacheMode,
                                       includeTimeStamp=cacheMode),
                self.sourceDir(), dstpath)
        return True
コード例 #8
0
    def _compress(self,
                  archiveName,
                  sourceDir,
                  destDir,
                  createDigests=True) -> bool:
        archive = os.path.join(destDir, archiveName)
        utils.createDir(os.path.dirname(archive))
        if os.path.isfile(archive):
            utils.deleteFile(archive)
        if OsUtils.isUnix():
            if not self.__xz(archive, sourceDir):
                return False
        else:
            if not self.__7z(archive, sourceDir):
                return False

        if createDigests:
            if not CraftCore.settings.getboolean("Packager", "CreateCache"):
                self._generateManifest(destDir, archiveName)
                CraftHash.createDigestFiles(archive)
            else:
                if CraftCore.settings.getboolean("ContinuousIntegration",
                                                 "UpdateRepository", False):
                    manifestUrls = [self.cacheRepositoryUrls()[0]]
                else:
                    manifestUrls = None
                self._generateManifest(destDir,
                                       archiveName,
                                       manifestLocation=self.cacheLocation(),
                                       manifestUrls=manifestUrls)
        return True
コード例 #9
0
ファイル: utils.py プロジェクト: cmollekopf/craft
def createShim(shim,
               target,
               args=None,
               guiApp=False,
               useAbsolutePath=False) -> bool:
    if not OsUtils.isWin():
        return True
    app = CraftCore.cache.findApplication("shimgen")
    if not app:
        CraftCore.log.error(
            f"Failed to detect shimgen, please install dev-util/shimgen")
        return False
    if not useAbsolutePath and os.path.isabs(target):
        srcPath = shim
        if srcPath.endswith(".exe"):
            srcPath = os.path.dirname(srcPath)
        target = os.path.relpath(target, srcPath)
    if not os.path.exists(os.path.dirname(shim)):
        os.makedirs(os.path.dirname(shim))
    command = [app, "--output", shim, "--path", target]
    if args:
        command += ["--command", args]
    if guiApp:
        command += ["--gui"]
    return system(command, stdout=subprocess.DEVNULL)
コード例 #10
0
def un7zip(fileName, destdir, flag=None):
    kw = {}
    progressFlags = []
    type = []
    resolveSymlinks = False
    app = utilsCache.findApplication("7za")
    if utilsCache.checkCommandOutputFor(app, "-bs"):
        progressFlags = ["-bso2", "-bsp1"]
        kw["stderr"] = subprocess.PIPE

    if flag == ".7z":
        # Actually this is not needed for a normal archive.
        # But git is an exe file renamed to 7z and we need to specify the type.
        # Yes it is an ugly hack.
        type = ["-t7z"]
    if re.match("(.*\.tar.*$|.*\.tgz$)", fileName):
        type = ["-ttar"]
        kw["pipeProcess"] = subprocess.Popen([app, "x", fileName, "-so"],
                                             stdout=subprocess.PIPE)
        if OsUtils.isWin():
            resolveSymlinks = True
            command = [app, "x", "-si", f"-o{destdir}"] + type + progressFlags
        else:
            tar = utilsCache.findApplication("tar")
            command = [tar, "--directory", destdir, "-xvf", "-"]
            kw = {}
    else:
        command = [app, "x", "-r", "-y", f"-o{destdir}", fileName
                   ] + type + progressFlags

    # While 7zip supports symlinks cmake 3.8.0 does not support symlinks
    return system(
        command, displayProgress=True, **
        kw) and not resolveSymlinks or replaceSymlinksWithCopys(destdir)
コード例 #11
0
ファイル: kate.py プロジェクト: dschmidt/craft-blueprints-kde
 def setDependencies(self):
     self.runtimeDependencies["virtual/base"] = "default"
     self.buildDependencies["frameworks/extra-cmake-modules"] = "default"
     self.runtimeDependencies["libs/qt5/qtbase"] = "default"
     self.runtimeDependencies["frameworks/tier1/kconfig"] = "default"
     self.runtimeDependencies["frameworks/tier2/kdoctools"] = "default"
     self.runtimeDependencies["frameworks/tier1/kguiaddons"] = "default"
     self.runtimeDependencies["frameworks/tier1/ki18n"] = "default"
     self.runtimeDependencies["frameworks/tier3/kinit"] = "default"
     self.runtimeDependencies["frameworks/tier2/kjobwidgets"] = "default"
     self.runtimeDependencies["frameworks/tier3/kio"] = "default"
     self.runtimeDependencies["frameworks/tier3/kparts"] = "default"
     self.runtimeDependencies["frameworks/tier3/ktexteditor"] = "default"
     self.runtimeDependencies["frameworks/tier1/kwindowsystem"] = "default"
     self.runtimeDependencies["frameworks/tier3/kxmlgui"] = "default"
     self.runtimeDependencies["frameworks/tier1/kdbusaddons"] = "default"
     self.runtimeDependencies["frameworks/tier1/kitemmodels"] = "default"
     self.runtimeDependencies["frameworks/tier3/kactivities"] = "default"
     if self.options.features.fullplasma:
         self.runtimeDependencies[
             "frameworks/tier3/plasma-framework"] = "default"
     self.runtimeDependencies["frameworks/tier1/threadweaver"] = "default"
     self.runtimeDependencies["frameworks/tier3/knewstuff"] = "default"
     if OsUtils.isUnix():
         self.runtimeDependencies["kde/applications/konsole"] = "default"
コード例 #12
0
ファイル: CraftSetupHelper.py プロジェクト: dschmidt/craft
    def subst(self):
        if not OsUtils.isWin():
            return

        def _subst(path, drive):
            if not os.path.exists(path):
                os.makedirs(path)
            SetupHelper._getOutput(
                ["subst",
                 CraftCore.settings.get("ShortPath", drive), path])

        if CraftCore.settings.getboolean("ShortPath", "Enabled", False):
            with TemporaryUseShortpath(False):
                if ("ShortPath", "RootDrive") in CraftCore.settings:
                    _subst(CraftStandardDirs.craftRoot(), "RootDrive")
                if ("ShortPath", "DownloadDrive") in CraftCore.settings:
                    _subst(CraftStandardDirs.downloadDir(), "DownloadDrive")
                if ("ShortPath", "GitDrive") in CraftCore.settings:
                    _subst(CraftStandardDirs.gitDir(), "GitDrive")

        if CraftCore.settings.getboolean("ShortPath", "EnableJunctions",
                                         False):
            with TemporaryUseShortpath(False):
                if ("ShortPath", "JunctionDrive") in CraftCore.settings:
                    _subst(CraftCore.standardDirs._junctionDir.longPath,
                           "JunctionDrive")
コード例 #13
0
ファイル: utils.py プロジェクト: LlianeFR/craft
def createShim(shim,
               target,
               args=None,
               guiApp=False,
               useAbsolutePath=False) -> bool:
    if not useAbsolutePath and os.path.isabs(target):
        target = os.path.relpath(target, os.path.dirname(shim))

    createDir(os.path.dirname(shim))
    if not OsUtils.isWin():
        command = (f"#!/bin/bash\n"
                   "parent_path=$(dirname \"${BASH_SOURCE[0]}\")\n"
                   f"${{parent_path}}/{target} {args or ''} \"$@\"\n")
        CraftCore.log.info(f"Creating {shim}")
        CraftCore.log.debug(command)
        with open(shim, "wt+") as bash:
            bash.write(command)
        os.chmod(
            shim,
            os.stat(shim).st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
        return True
    else:
        app = CraftCore.cache.findApplication("shimgen")
        if not app:
            CraftCore.log.error(
                f"Failed to detect shimgen, please install dev-util/shimgen")
            return False
        command = [app, "--output", shim, "--path", target]
        if args:
            command += ["--command", args]
        if guiApp:
            command += ["--gui"]
        return system(command, stdout=subprocess.DEVNULL)
コード例 #14
0
ファイル: CraftCache.py プロジェクト: itachi1706/craft
    def findApplication(self, app, path=None, forceCache: bool = False) -> str:
        if app in self._nonPersistentCache.applicationLocations:
            appLocation = self._nonPersistentCache.applicationLocations[app]
            if os.path.exists(appLocation):
                return appLocation
            else:
                self._helpCache.clear()

        # don't look in the build dir etc
        _cwd = os.getcwd()
        os.chdir(CraftCore.standardDirs.craftRoot())
        appLocation = shutil.which(app, path=path)
        os.chdir(_cwd)

        if appLocation:
            if OsUtils.isWin():
                # prettify command
                path, ext = os.path.splitext(appLocation)
                appLocation = path + ext.lower()
            if forceCache or Path(CraftCore.standardDirs.craftRoot()) in Path(
                    appLocation).parents:
                CraftCore.log.debug(f"Adding {app} to app cache {appLocation}")
                self._nonPersistentCache.applicationLocations[
                    app] = appLocation
        else:
            CraftCore.log.debug(
                f"Craft was unable to locate: {app}, in {path}")
            return None
        return appLocation
コード例 #15
0
    def postInstall(self):

        cmakes = [
            os.path.join(self.installDir(), "lib", "cmake",
                         f"aqbanking-{self.subinfo.defaultTarget[:-2]}",
                         "aqbanking-config.cmake")
        ]
        for cmake in cmakes:
            f = open(cmake, "r+")
            cmakeFileContents = f.readlines()
            for i in range(len(cmakeFileContents)):
                if CraftCore.compiler.isMinGW():
                    m = re.search('set_and_check\(prefix "(?P<root>[^"]*)"\)',
                                  cmakeFileContents[i])
                    if m is not None:
                        craftRoot = OsUtils.toUnixPath(
                            CraftStandardDirs.craftRoot())
                        if craftRoot.endswith("/"):
                            craftRoot = craftRoot[:-1]
                        cmakeFileContents[i] = cmakeFileContents[i].replace(
                            m.group('root'), craftRoot)

                    m2 = re.search("libaqbanking.so", cmakeFileContents[i])
                    if m2 is not None:
                        cmakeFileContents[i] = cmakeFileContents[i].replace(
                            "lib/libaqbanking.so", "bin/libaqbanking-35.dll")
                elif CraftCore.compiler.isMacOS:
                    m2 = re.search("libaqbanking.so", cmakeFileContents[i])
                    if m2 is not None:
                        cmakeFileContents[i] = cmakeFileContents[i].replace(
                            "libaqbanking.so", "libaqbanking.35.dylib")
            f.seek(0)
            f.write(''.join(cmakeFileContents))
            f.close()
        return AutoToolsPackageBase.postInstall(self)
コード例 #16
0
 def setXDG(self):
     if OsUtils.isWin():
         self.prependEnvVar(
             "XDG_DATA_DIRS",
             [os.path.join(CraftCore.standardDirs.craftRoot(), "bin/data")])
     else:
         self.prependEnvVar(
             "XDG_DATA_DIRS",
             [os.path.join(CraftCore.standardDirs.craftRoot(), "share")])
         user = os.getenv("USER", self._getOutput(["id", "-u", "-n"])[1])
         self.prependEnvVar("XDG_CONFIG_DIRS", [
             os.path.join(CraftCore.standardDirs.craftRoot(), "etc", "xdg")
         ])
         self.addEnvVar(
             "XDG_DATA_HOME",
             os.path.join(CraftCore.standardDirs.craftRoot(), "home", user,
                          ".local5", "share"))
         self.addEnvVar(
             "XDG_CONFIG_HOME",
             os.path.join(CraftCore.standardDirs.craftRoot(), "home", user,
                          ".config"))
         self.addEnvVar(
             "XDG_CACHE_HOME",
             os.path.join(CraftCore.standardDirs.craftRoot(), "home", user,
                          ".cache"))
コード例 #17
0
def cleanDirectory(directory):
    CraftCore.log.debug("clean directory %s" % directory)
    if os.path.exists(directory):
        # don't delete containg directrory as it might be a symlink and replacing it with a folder
        # breaks the behaviour
        with os.scandir(directory) as scan:
            for f in scan:
                if f.is_dir():
                    if not OsUtils.rmDir(f.path, force=True):
                        return False
                else:
                    if not OsUtils.rm(f.path, force=True):
                        return False
        return True
    else:
        return createDir(directory)
コード例 #18
0
ファイル: rkward.py プロジェクト: sklnet/craft-blueprints-kde
    def createPackage(self):
        self.defines["executable"] = "bin\\rkward.exe"
        self.defines["icon"] = os.path.join(self.sourceDir(), "rkward", "icons", "app-icon", "rkward.ico")

        if OsUtils.isMac():
            # We cannot reliably package R inside the bundle. Users will have to install it separately.
            self.ignoredPackages.append("binary/r-base")

        self.ignoredPackages.append("binary/mysql")
        self.ignoredPackages.append("data/hunspell-dictionaries")
        self.whitelist_file.append(os.path.join(self.packageDir(), 'whitelist.txt'))
        # Certain plugin files defeat codesigning on mac, which is picky about file names
        if OsUtils.isMac():
            self.blacklist_file.append(os.path.join(self.packageDir(), 'blacklist_mac.txt'))

        return TypePackager.createPackage(self)
コード例 #19
0
    def setDependencies(self):
        self.runtimeDependencies["virtual/base"] = None
        self.buildDependencies["kde/frameworks/extra-cmake-modules"] = None
        self.runtimeDependencies["libs/qt5/qtbase"] = None
        self.runtimeDependencies["kde/frameworks/tier1/kconfig"] = None
        self.runtimeDependencies["kde/frameworks/tier2/kdoctools"] = None
        self.runtimeDependencies["kde/frameworks/tier1/kguiaddons"] = None
        self.runtimeDependencies["kde/frameworks/tier1/ki18n"] = None
        self.runtimeDependencies["kde/frameworks/tier3/kinit"] = None
        self.runtimeDependencies["kde/frameworks/tier2/kjobwidgets"] = None
        self.runtimeDependencies["kde/frameworks/tier3/kio"] = None
        self.runtimeDependencies["kde/frameworks/tier3/kparts"] = None
        self.runtimeDependencies["kde/frameworks/tier3/ktexteditor"] = None
        self.runtimeDependencies["kde/frameworks/tier1/kwindowsystem"] = None
        self.runtimeDependencies["kde/frameworks/tier3/kxmlgui"] = None
        self.runtimeDependencies["kde/frameworks/tier1/kdbusaddons"] = None
        self.runtimeDependencies["kde/frameworks/tier1/kitemmodels"] = None
        self.runtimeDependencies["kde/frameworks/tier3/kactivities"] = None
        self.runtimeDependencies["kde/frameworks/tier1/threadweaver"] = None
        self.runtimeDependencies["kde/frameworks/tier3/knewstuff"] = None
        if self.options.dynamic.fullPlasma:
            self.runtimeDependencies["kde/frameworks/tier3/plasma-framework"] = None
        if OsUtils.isUnix():
            self.runtimeDependencies["kde/applications/konsole"] = None

        # try to use Breeze style as Windows style has severe issues for e.g. scaling
        self.runtimeDependencies["kde/plasma/breeze"] = None
コード例 #20
0
ファイル: test_OsUtils.py プロジェクト: juergenhoetzel/craft
 def test_killProcess(self):
     # TODO: find a better test app than the cmd windows
     with tempfile.TemporaryDirectory() as tmp1:
         with tempfile.TemporaryDirectory() as tmp2:
             test1 = os.path.join(tmp1, "craft_test.exe")
             test2 = os.path.join(tmp2, "craft_test.exe")
             cmd = CraftCore.cache.findApplication("cmd")
             self.assertEqual(utils.copyFile(cmd, test1, linkOnly=False), True)
             self.assertEqual(utils.copyFile(cmd, test2, linkOnly=False), True)
             process = subprocess.Popen([test1,"/K"], creationflags=subprocess.CREATE_NEW_PROCESS_GROUP)
             process2 = subprocess.Popen([test2,"/K"], creationflags=subprocess.CREATE_NEW_PROCESS_GROUP)
             try:
                 self.assertEqual(process.poll(), None)
                 self.assertEqual(process2.poll(), None)
                 self.assertEqual(OsUtils.killProcess("craft_test", tmp2), True)
                 self.assertEqual(process.poll(), None)
                 #ensure that process 2 was killed
                 self.assertNotEquals(process2.poll(), None)
             except subprocess.SubprocessError as e:
                 CraftCore.log.warning(e)
             finally:
                 process.kill()
                 process2.kill()
                 process.wait()
                 process2.wait()
コード例 #21
0
 def postInstall(self):
     cmakes = [
         os.path.join(self.installDir(), "lib", "cmake",
                      f"aqbanking-{self.subinfo.buildTarget[:-2]}",
                      "aqbanking-config.cmake")
     ]
     for cmake in cmakes:
         with open(cmake, "rt") as f:
             cmakeFileContents = f.readlines()
         for i in range(len(cmakeFileContents)):
             if CraftCore.compiler.isMinGW():
                 m = re.search('set_and_check\(prefix "(?P<root>[^"]*)"\)',
                               cmakeFileContents[i])
                 if m is not None:
                     craftRoot = OsUtils.toUnixPath(
                         CraftStandardDirs.craftRoot())
                     if craftRoot.endswith("/"):
                         craftRoot = craftRoot[:-1]
                     cmakeFileContents[i] = cmakeFileContents[i].replace(
                         m.group('root'), craftRoot)
             elif CraftCore.compiler.isMacOS:
                 m2 = re.search("(libaqbanking.so.(\d*))",
                                cmakeFileContents[i])
                 if m2 is not None:
                     cmakeFileContents[i] = cmakeFileContents[i].replace(
                         m2.group(1), "libaqbanking.%s.dylib" % m2.group(2))
         with open(cmake, "wt") as f:
             f.write(''.join(cmakeFileContents))
     return AutoToolsPackageBase.postInstall(self)
コード例 #22
0
    def _fixInstallPrefix(self, prefix=CraftStandardDirs.craftRoot()):
        CraftCore.log.debug(f"Begin: fixInstallPrefix {self}: {prefix}")

        def stripPath(path):
            rootPath = os.path.splitdrive(path)[1]
            if rootPath.startswith(os.path.sep) or rootPath.startswith("/"):
                rootPath = rootPath[1:]
            return rootPath

        badPrefix = os.path.join(self.installDir(), stripPath(prefix))

        if os.path.exists(badPrefix) and not os.path.samefile(
                self.installDir(), badPrefix):
            if not utils.mergeTree(badPrefix, self.installDir()):
                return False

        if CraftCore.settings.getboolean("QtSDK", "Enabled", False):
            qtDir = os.path.join(CraftCore.settings.get("QtSDK", "Path"),
                                 CraftCore.settings.get("QtSDK", "Version"),
                                 CraftCore.settings.get("QtSDK", "Compiler"))
            path = os.path.join(self.installDir(), stripPath(qtDir))
            if os.path.exists(path) and not os.path.samefile(
                    self.installDir(), path):
                if not utils.mergeTree(path, self.installDir()):
                    return False

        if stripPath(prefix):
            oldPrefix = OsUtils.toUnixPath(stripPath(prefix)).split("/", 1)[0]
            utils.rmtree(os.path.join(self.installDir(), oldPrefix))

        CraftCore.log.debug(f"End: fixInstallPrefix {self}")
        return True
コード例 #23
0
 def setDependencies(self):
     self.runtimeDependencies["virtual/base"] = "default"
     self.buildDependencies["kde/frameworks/extra-cmake-modules"] = "default"
     self.runtimeDependencies["libs/glib"] = "default" # mdb
     self.runtimeDependencies["libs/sqlite"] = "default" # migration
     self.runtimeDependencies["binary/mysql"] = "default" # migration
     #TODO self.runtimeDependencies["binary/postgresql"] = "default" # migration
     self.runtimeDependencies["libs/qt5/qtbase"] = "default"
     self.runtimeDependencies["libs/qt5/qtwebkit"] = "default"
     self.runtimeDependencies["kdesupport/kdewin"] = "default"
     self.runtimeDependencies["kde/frameworks/tier1/kconfig"] = "default"
     self.runtimeDependencies["kde/frameworks/tier1/kcodecs"] = "default"
     self.runtimeDependencies["kde/frameworks/tier1/kcoreaddons"] = "default"
     self.runtimeDependencies["kde/frameworks/tier1/kguiaddons"] = "default"
     self.runtimeDependencies["kde/frameworks/tier1/ki18n"] = "default"
     self.runtimeDependencies["kde/frameworks/tier1/kwidgetsaddons"] = "default"
     self.runtimeDependencies["kde/frameworks/tier3/kconfigwidgets"] = "default"
     self.runtimeDependencies["kde/frameworks/tier3/kiconthemes"] = "default"
     self.runtimeDependencies["kde/frameworks/tier3/ktextwidgets"] = "default"
     self.runtimeDependencies["kde/frameworks/tier3/kxmlgui"] = "default"
     self.runtimeDependencies["extragear/kdb"] = "default"
     self.runtimeDependencies["extragear/kproperty"] = "default"
     self.runtimeDependencies["extragear/kreport"] = "default"
     # Desktop only:
     self.runtimeDependencies["kde/frameworks/tier2/kcompletion"] = "default"
     self.runtimeDependencies["kde/frameworks/tier3/kio"] = "default"
     self.runtimeDependencies["kde/frameworks/tier3/ktexteditor"] = "default"
     self.runtimeDependencies["kde/frameworks/tier3/ktextwidgets"] = "default"
     if OsUtils.isLinux():
         self.runtimeDependencies["kde/frameworks/tier1/kcrash"] = "default"
コード例 #24
0
ファイル: BoostBuildSystem.py プロジェクト: dschmidt/craft
    def configureOptions(self, defines=""):
        """returns default configure options"""
        options = BuildSystemBase.configureOptions(self)

        if OsUtils.isWin():
            options += " -j" + os.getenv("NUMBER_OF_PROCESSORS")
            options += " --build-dir=" + self.buildDir()
        else:
            # TODO: real value
            options += " install --prefix=%s" % self.buildDir()
            options += " -j10"

        options += (
            " --build-type=minimal"
            #                " --debug-configuration"
            " threading=multi")

        if not self.subinfo.options.buildStatic:
            options += (" link=shared" " runtime-link=shared")
        else:
            options += (" link=static" " runtime-link=shared")
        if CraftCore.compiler.isX64():
            options += " address-model=64 architecture=x86"
        else:
            options += " address-model=32 architecture=x86"

        if self.buildType() == "Debug":
            options += " variant=debug"
        else:
            options += " variant=release"

        options += " toolset="
        if CraftCore.compiler.isClang():
            options += "clang"
            if CraftCore.compiler.isGCC():
                options += " threadapi=pthread"
        elif CraftCore.compiler.isMinGW():
            options += "gcc"
        elif CraftCore.compiler.isMSVC():
            platform = str(CraftCore.compiler.getMsvcPlatformToolset())
            if CraftVersion(self.buildTarget) < CraftVersion(
                    "1_65_1") and CraftCore.compiler.isMSVC2017():
                options += f"msvc-{platform[:2]}.0"
            else:
                options += f"msvc-{platform[:2]}.{platform[2:]}"
        elif CraftCore.compiler.isIntel():
            options += "intel"
            options += " -sINTEL_PATH=\"%s\"" % os.path.join(
                os.getenv("INTELDIR"), "bin", os.getenv("TARGET_ARCH"))
            options += " -sINTEL_BASE_MSVC_TOOLSET=vc-%s" % ({
                "vs2008": "9_0",
                "vs2010": "10_0",
                "vs2012": "11_0"
            }[os.getenv("INTEL_VSSHELL")])
            options += " -sINTEL_VERSION=%s" % os.getenv("PRODUCT_NAME")[-2:]
        craftUserConfig = os.path.join(CraftStandardDirs.craftRoot(), "etc",
                                       "craft-boost-config.jam")
        if os.path.exists(craftUserConfig):
            options += " --user-config=" + os.path.join(craftUserConfig)
        return options
コード例 #25
0
ファイル: CraftShortPath.py プロジェクト: barcharcraz/craft
class CraftShortPath(object):
    _useShortpaths = OsUtils.isWin()
    _shortPaths = {}

    def __init__(self, path, createShortPath=None) -> None:
        self._longPath = path
        self._shortPath = None
        if not createShortPath:
            self._createShortPathLambda = CraftShortPath._createShortPath
        else:
            self._createShortPathLambda = createShortPath

    def path(self, condition):
        return self.shortPath if condition else self.longPath

    @property
    def longPath(self) -> str:
        return self._longPath() if callable(self._longPath) else self._longPath

    @property
    def shortPath(self) -> str:
        if self._shortPath:
            return self._shortPath
        self._shortPath = CraftShortPath._shortPaths.get(self.longPath, None)
        if not self._shortPath:
            self._shortPath = self._createShortPathLambda(self.longPath)
            CraftShortPath._shortPaths[self.longPath] = self._shortPath
        if self._shortPath != self.longPath:
            os.makedirs(self.longPath, exist_ok=True)
            CraftCore.debug.log.debug(f"Mapped \n"
                                f"{self.longPath} to\n"
                                f"{self._shortPath}, gained {len(self.longPath) - len(self._shortPath)}")
        return self._shortPath

    @staticmethod
    def _createShortPath(longPath) -> str:
        import utils
        longPath = OsUtils.toNativePath(longPath)
        if not CraftShortPath._useShortpaths:
            return longPath
        if not os.path.isdir(CraftCore.standardDirs.junctionsDir()):
            os.makedirs(CraftCore.standardDirs.junctionsDir())
        path = OsUtils.toNativePath(os.path.join(CraftCore.standardDirs.junctionsDir(), hex(zlib.crc32(bytes(longPath, "UTF-8")))[2:]))
        if len(longPath) < len(path):
            CraftCore.debug.log.debug(f"Using junctions for {longPath} wouldn't save characters returning original path")
            CraftCore.debug.log.debug(f"{longPath}\n"
                                      f"{path}, gain:{len(longPath) - len(path)}")
            return longPath
        os.makedirs(longPath, exist_ok=True)
        if not os.path.isdir(path):
            # note: mklink is a CMD command => needs shell
            if not utils.system(["mklink", "/J", path, longPath], shell=True, stdout=subprocess.DEVNULL, logCommand=False):
                CraftCore.debug.log.critical(f"Could not create shortpath {path}, for {longPath}")
                return longPath
        else:
            if not os.path.samefile(path, longPath):
                CraftCore.debug.log.critical(f"Existing short path {path}, did not match {longPath}")
                return longPath
        return path
コード例 #26
0
 def patchInstallPrefix(
     self,
     files: [str],
     oldPaths: [str] = None,
     newPath: str = CraftCore.standardDirs.craftRoot()
 ) -> bool:
     if isinstance(oldPaths, str):
         oldPaths = [oldPaths]
     elif not oldPaths:
         oldPaths = [self.subinfo.buildPrefix]
     newPathUnix = OsUtils.toUnixPath(newPath).encode()
     for fileName in files:
         if not os.path.exists(fileName):
             CraftCore.log.warning(f"File {fileName} not found.")
             return False
         with open(fileName, "rb") as f:
             content = f.read()
         dirty = False
         for oldPath in oldPaths:
             assert os.path.isabs(oldPath)
             oldPathPat = OsUtils.toUnixPath(oldPath)
             # allow front and back slashes
             oldPathPat = oldPathPat.replace("/", r"[/\\]+")
             # capture firs seperator
             oldPathPat = oldPathPat.replace(r"[/\\]+", r"(/+|\\+)", 1)
             oldPathPat = f"({oldPathPat})"
             oldPathPat = re.compile(oldPathPat.encode())
             for match in set(oldPathPat.findall(content)):
                 dirty = True
                 oldPath = match[0]
                 newPath = newPathUnix.replace(b"/", match[1])
                 if oldPath != newPath:
                     CraftCore.log.info(
                         f"Patching {fileName}: replacing {oldPath} with {newPath}"
                     )
                     content = content.replace(oldPath, newPath)
                 else:
                     CraftCore.log.debug(
                         f"Skip Patching {fileName}:  prefix is unchanged {newPath}"
                     )
         if dirty:
             with utils.makeWritable(fileName):
                 with open(fileName, "wb") as f:
                     f.write(content)
     return True
コード例 #27
0
 def _findBash(self):
     if OsUtils.isWin():
         msysdir = CraftCore.standardDirs.msysDir()
         bash = CraftCore.cache.findApplication("bash", os.path.join(msysdir, "usr", "bin"))
     else:
         bash = CraftCore.cache.findApplication("bash")
     if not bash:
         CraftCore.log.critical("Failed to detect bash")
     return bash
コード例 #28
0
 def configureOptions(self, defines=""):
     """returns default configure options"""
     options = BuildSystemBase.configureOptions(self)
     prefix = self.shell.toNativePath(self.installPrefix())
     options += [f"--prefix={prefix}"]
     if OsUtils.isWin() and not self.subinfo.options.configure.noDataRootDir:
         options += [f"--datarootdir={self.shell.toNativePath(CraftCore.standardDirs.locations.data)}"]
     options += self.platform
     return options
コード例 #29
0
ファイル: QtIFPackager.py プロジェクト: pasnox/craft
 def __init__(self):
     SevenZipPackager.__init__(self)
     self.__resources = os.path.join(os.path.dirname(__file__), "QtIF")
     self.__packageDir = os.path.join(self.packageDestinationDir(), "qtif")
     self.__sdkMode = OsUtils.isWin() and CraftCore.settings.getboolean(
         "QtSDK", "Enabled", False)
     if self.__sdkMode:
         win = "win32" if CraftCore.compiler.isX86() else "win64"
         self.__depPrefix = f"qt.qt5.{CraftCore.settings.get('QtSDK', 'Version').replace('.', '')}.{win}_{CraftCore.settings.get('QtSDK', 'Compiler')}.kde"
コード例 #30
0
 def preArchive(self):
     if OsUtils.isMac():
         # during packaging, the relative path between rkward and R gets changed, so we need to create an rkward.ini to help rkward find R
         rkward_dir = os.path.join(self.archiveDir(), "Applications", "KDE", "rkward.app", "Contents", "MacOS")
         utils.createDir(rkward_dir)
         rkward_ini = open(os.path.join(rkward_dir, "rkward.ini"), "w")
         rkward_ini.write("R executable=../Frameworks/R/R.framework/Resources/R\n")
         rkward_ini.close()
     return super().preArchive()