diff --git a/dev-utils/_windows/craft-startmenu-entry/craft-startmenu-entry.py b/dev-utils/_windows/craft-startmenu-entry/craft-startmenu-entry.py index 4404f316..e4fb9568 100644 --- a/dev-utils/_windows/craft-startmenu-entry/craft-startmenu-entry.py +++ b/dev-utils/_windows/craft-startmenu-entry/craft-startmenu-entry.py @@ -1,86 +1,86 @@ # -*- coding: utf-8 -*- # Copyright Hannah von Reth # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. import info class subinfo(info.infoclass): def setTargets(self): self.targets["3"] = "" self.defaultTarget = "3" def registerOptions(self): self.options.dynamic.registerOption("usePowershellCore", False) def setDependencies(self): self.buildDependencies["dev-utils/kshim"] = None from Package.BinaryPackageBase import * class WinPackage(BinaryPackageBase): def __init__(self): BinaryPackageBase.__init__(self) self.subinfo.options.package.disableBinaryCache = True self._shortcutPath = os.path.join(os.environ["APPDATA"], "Microsoft", "Windows", "Start Menu", "Programs", "Craft", f"Craft {os.path.basename(CraftCore.standardDirs.craftRoot())}.lnk") @property def powershell(self): if not self.subinfo.options.dynamic.usePowershellCore: return CraftCore.cache.findApplication("powershell") else: return CraftCore.cache.findApplication("pwsh") def install(self): return utils.createShim(os.path.join(self.installDir(), "bin", "craft.exe"), self.powershell, - f"-NoExit -ExecutionPolicy ByPass -Command {CraftCore.standardDirs.craftBin()}/../craftenv.ps1", + ["-NoExit", "-ExecutionPolicy", "ByPass", "-Command", os.path.join(CraftCore.standardDirs.craftBin(), "..", "craftenv.ps1")], useAbsolutePath=True) def postQmerge(self): root = OsUtils.toNativePath(os.path.join(CraftCore.standardDirs.craftBin(), "..")) utils.createDir(os.path.dirname(self._shortcutPath)) utils.system([self.powershell, "-NoProfile", "-ExecutionPolicy", "ByPass", "-Command", os.path.join(self.packageDir(), "install-lnk.ps1"), "-Path", "'{0}'".format(os.path.join(CraftCore.standardDirs.craftRoot(), "bin", "craft.exe")), "-WorkingDirectory", f"'{root}'", "-Name", f"'{self._shortcutPath}'", "-Icon", "'{0}'".format(os.path.join(CraftCore.standardDirs.craftBin(), "data", "icons", "craft.ico")), "-Description", f"'Craft installed to: {os.path.dirname(root)}'"]) return True def unmerge(self): if os.path.exists(self._shortcutPath): utils.deleteFile(self._shortcutPath) return super().unmerge() from Package.MaybeVirtualPackageBase import * class Package(MaybeVirtualPackageBase): def __init__(self): MaybeVirtualPackageBase.__init__(self, OsUtils.isWin(), classA=WinPackage)