def installProgram(programName, useCache): """ Build the docker image associated with a program and create a tiny executable to add that image to your path. """ print("Installing {0} ...".format(programName)) dockerImageDir = os.path.join(paths.getProgramSrcDir(programName), "docker-image") _DockerfilePath = os.path.join(dockerImageDir, 'Dockerfile') # Check if we use a 'Dockerfile' or a 'MakeBaseImage.sh' if os.path.isfile(paths.getMakeBaseImageScriptPath(programName)): installFromBaseImage(programName, cacheArg) elif os.path.isfile(_DockerfilePath): if useCache: cacheArg = "--no-cache=false" else: cacheArg = "--no-cache=true" docker.runDockerAndExitIfItFails(["build","-rm",cacheArg,"--tag=subuser-"+programName+"",dockerImageDir]) else: sys.exit("No buildfile found: need one of: 'Dockerfile' or 'MakeBaseImage.sh'. PATH: {0}".format(dockerImageDir)) _permissions = permissions.getPermissions(programName) # Create a small executable that just calls the real executable in the docker image. if 'executable' in _permissions: installExecutable(programName) try: lastUpdateTime = _permissions["last-update-time"] except KeyError: lastUpdateTime = installTime.currentTimeString() imageID = dockerImages.getImageID("subuser-{0}".format(programName)) registry.registerProgram(programName, lastUpdateTime, imageID)
def installProgram(programName, useCache): """ Build the docker image associated with a program and create a tiny executable to add that image to your path. """ print("Installing "+programName+" ...") programSrcDir = paths.getProgramSrcDir(programName) _DockerfilePath = paths.getDockerfilePath(programSrcDir) # Check if we use a 'Dockerfile' or a 'BuildImage.sh' if os.path.isfile(paths.getBuildImageScriptPath(programSrcDir)): installFromBaseImage(programName,programSrcDir) elif os.path.isfile(_DockerfilePath): installFromDockerfile(programName,programSrcDir,useCache) else: sys.exit("No buildfile found: There needs to be a 'Dockerfile' or a 'BuildImage.sh' in the docker-image directory.") _permissions = permissions.getPermissions(programName) # Create a small executable that just calls the real executable in the docker image. if 'executable' in _permissions: installExecutable(programName) try: lastUpdateTime = _permissions["last-update-time"] except KeyError: lastUpdateTime = installTime.currentTimeString() imageID = dockerImages.getImageID("subuser-"+programName) registry.registerProgram(programName, lastUpdateTime, imageID)
def available(programName): """ Returns True if the program is available for instalation. """ return not paths.getProgramSrcDir(programName) == None
def available(programName): """ Returns True if the program is available for instalation. """ return os.path.exists(paths.getProgramSrcDir(programName))