Example #1
0
def uploadImage():
    """
    Upload already build images.
    It only works if images are build in the toslive setting.
    Otherwise the repository will be incomplete
    """
    result = fd.CMD(["./build.sh", "-u"]).execute(True)
    if not result.exitcode == 0:
        logger.log("Something went wrong when moving existing images",logger.LOG_ERROR)
        raise Exception(result.stderr)
    result = fd.CMD(["./upload.sh", "-y"]).execute(True)
    if not result.exitcode == 0:
        logger.log("Something went wrong when uploading data to the server",logger.LOG_ERROR)
        raise Exception(result.stderr)
Example #2
0
def listPackages():
    """
    List packages that will be build for the current repo
    """
    packages = fd.CMD([
        "bash", "-c", """
    grep -R -h "^pkgname=[a-zA-Z0-9-]*\s*" BUILD | sed -e 's:pkgname=::g' -e ':["$_]*::'
    """
    ]).execute()
    print(packages.stdout)
    packages = fd.CMD([
        "bash", "-c",
        "sed -e 's:#.*::g' -e '/^\s*$/d' packages.conf | tr -s ' ' "
    ]).execute()
    print(packages.stdout)
Example #3
0
def checkYay():
    """
    Check if yay is installed
    If it doesn't exist then try to build it
    """
    state = installer.Package("yay")
    if not state.isInstalled():
        logger.log(
            "Yay is not installed. We will try to compile it in order to install our aur based packages",
            logger.LOG_WARM)
        checks.checkRoot("Installing packages requires root permission")
        result = fd.CMD([
            "bash", "-c", """git clone https://aur.archlinux.org/yay.git
            cd yay || exit 1
            makepkg -si
            cd ../ || exit 1
            rm -rf yay"""
        ]).execute(True)
        if not result.exitcode == 0:
            logger.log("Unexpected error happend when installing yay",
                       logger.LOG_ERROR)
            raise Exception(result.stderr)
        else:
            logger.log("yay has been succesfully installed")
    else:
        logger.log("yay has been detected, AUR support is enabled")
Example #4
0
 def isInstalled(self):
     packages = filedescriptor.CMD(['pacman',
                                    '-Q']).execute().stdout.split("\n")
     # strip out version number
     packages = [package.split(" ")[0] for package in packages]
     mock = MockPackage(self.package)
     mock.setMockInstalled(packages)
     return mock.isInstalled()
Example #5
0
def downloadRepo(subpath="toslive"):
    """
    Try to download the tos image repository and make that the current directory
    """
    result = fd.CMD(["git", "clone", "https://github.com/ODEX-TOS/tos-live.git"]).execute(True)
    if not result.exitcode == 0:
        logger.log("Something went wrong when trying to download build files, checking for existing build files", logger.LOG_ERROR)
    os.chdir("tos-live/"+subpath)
Example #6
0
 def Install(self):
     result = filedescriptor.CMD(
         ['yay', "-Syu", "--noconfirm", self.package]).execute(True)
     if not result.exitcode == 0:
         logger.log(
             "Something failed during the package installation procedure",
             logger.LOG_ERROR)
         return False
     return self.isInstalled()
Example #7
0
def buildFonts(bUpload=True):
    """
    Build all fonts
    """
    result = fd.CMD(["./build.sh", "-f"]).execute(True)
    if not result.exitcode == 0:
        logger.log("Something went wrong when building fonts")
        raise Exception(result.stderr)
    upload(bUpload)
Example #8
0
def buildBase(bUpload=True):
    """
    Build all base packages
    """
    result = fd.CMD(["./build.sh", "-a"]).execute(True)
    if not result.exitcode == 0:
        logger.log("Something went wrong when building packages")
        raise Exception(result.stderr)
    upload(bUpload)
Example #9
0
def listFonts():
    """
    List all fonts to build
    """
    packages = fd.CMD([
        "bash", "-c",
        "sed -e 's:#.*::g' -e '/^\s*$/d' packages.conf | tr -s ' ' "
    ]).execute()
    print(packages.stdout)
Example #10
0
def uploadRepo():
    """
    Upload an existing repository.
    Only execute this if a full repository exists.
    Otherwise the repository will be incomplete
    """
    result = fd.CMD(["./upload.sh", "-y"]).execute(True)
    if not result.exitcode == 0:
        logger.log("Something went wrong when uploading data to the server",logger.LOG_ERROR)
        raise Exception(result.stderr)
Example #11
0
def syncRepo(bUpload=True):
    """
    Sync the repository packages with the package database
    """
    result = fd.CMD(
        ["bash", "-c",
         "cd arch && repo-add tos.db.tar.gz *.pkg.tar.*"]).execute(True)
    if not result.exitcode == 0:
        logger.log("Something went wrong when syncing packages to the repo")
        raise Exception(result.stderr)
    upload(bUpload)
Example #12
0
def BuildServer(local=""):
    """
    local is the command to be supplied to the build script
    only call this command if you are have the build files in the current directory
    """
    result = fd.CMD(["bash", "-c",
                     "./start.sh -s {}".format(local)]).execute(True)
    if not result.exitcode == 0:
        logger.log("Failed to build the package, please review the logs",
                   logger.LOG_ERROR)
        raise Exception(result.stderr)
Example #13
0
def inCorrectDirectory(subpath="toslive"):
    """
    try to check if the current directory is the directory containing the build files
    """
    # check if the current repo is correct
    result = fd.CMD(["git", "remote", "-v"]).execute()
    if not result.exitcode == 0:
        logger.log(
            "Something went wrong when scanning the current directory for build files"
        )
        raise Exception(result.stderr)
    if not "ODEX-TOS/tos-live" in result.stdout:
        logger.log(
            "Current directory does not contain build files, downloading files"
        )
        return False
    result = fd.CMD(["git", "rev-parse", "--show-toplevel"]).execute()
    if not result.exitcode == 0:
        logger.log("Could not move to the correct location in the repo")
        raise Exception(result.stderr)
    os.chdir(result.stdout + "/" + subpath)
    return True
 def test_real_cmd_runner_works_with_printf(self):
     desc = filedescriptor.CMD(['printf', 'hello']).execute()
     self.assertTrue(desc.stdout == "hello")
     self.assertFalse(desc.stderr == "hello")