diff --git a/.teamcity/asteroid/AsteroidProject.kt b/.teamcity/asteroid/AsteroidProject.kt index a6d8719..a4345cd 100644 --- a/.teamcity/asteroid/AsteroidProject.kt +++ b/.teamcity/asteroid/AsteroidProject.kt @@ -9,73 +9,73 @@ import jetbrains.buildServer.configs.kotlin.v2019_2.projectFeatures.activeStorag import jetbrains.buildServer.configs.kotlin.v2019_2.projectFeatures.versionedSettings object AsteroidProject : Project({ - description = "Base Asteroid Project" + description = "Base Asteroid Project" - // Attach vcsRoots from CoreVCS - for (vcs in CoreVCS.all()) - if (vcs != CoreVCS.MetaSmartwatch) - vcsRoot(vcs) + // Attach vcsRoots from CoreVCS + for (vcs in CoreVCS.all()) + if (vcs != CoreVCS.MetaSmartwatch) + vcsRoot(vcs) - // Attach InitWorkspace build - buildType(InitWorkspace) + // Attach InitWorkspace build + buildType(InitWorkspace) - // Attach the subProjects - // TODO: Link to subprojects externally - subProjects( - asteroid.devices.DevicesProject, - asteroid.packages.PackagesProject, - asteroid.thirdparty.ThirdPartyProject - ) + // Attach the subProjects + // TODO: Link to subprojects externally + subProjects( + asteroid.devices.DevicesProject, + asteroid.packages.PackagesProject, + asteroid.thirdparty.ThirdPartyProject + ) - // Define the build parameters inherited by the subprojects - params { - text( - "system.sstate.server.location", - "/var/www/asteroidos", - label = "Sstate server location", - description = "Path location of the sstate-cache", - readOnly = true, allowEmpty = true - ) - text( - "system.sstate.server.user", - "asteroidos", - label = "SState server user", - description = "Username used to upload sstate-cache", - readOnly = true, - allowEmpty = true - ) - text( - "system.sstate.server.upload_address", - "192.168.0.2", - label = "SState server backend address", - description = "Backend address to upload the sstate-cache", - readOnly = true, - allowEmpty = false - ) - text( - "system.sstate.server.address", - "https://sstate.asteroid.org", - label = "SState server public address", - description = "Public address serving sstate-cache", - readOnly = true, - allowEmpty = false - ) - } + // Define the build parameters inherited by the subprojects + params { + text( + "system.sstate.server.address", + Settings.sstateServer.url, + label = "SState server public address", + description = "Public address serving sstate-cache", + readOnly = true, + allowEmpty = false + ) + if (Settings.deploySstate) { + text( + "system.sstate.server.location", + Settings.sstateServer.location ?: "", + label = "Sstate server location", + description = "Path location of the sstate-cache", + readOnly = true, allowEmpty = true + ) + text( + "system.sstate.server.user", + Settings.sstateServer.user ?: "", + label = "SState server user", + description = "Username used to upload sstate-cache", + readOnly = true, allowEmpty = true + ) + text( + "system.sstate.server.upload_address", + Settings.sstateServer.backendUrl ?: "", + label = "SState server backend address", + description = "Backend address to upload the sstate-cache", + readOnly = true, allowEmpty = false + ) + } + } - features { - activeStorage { - activeStorageID = "DefaultStorage" - } - } -}){ - override fun validate(consumer: ErrorConsumer) { - super.validate(consumer) - if (Settings.deploySstate){ - // TODO: check that SSH key is present - // Currently this feature is unavailable - } - if (Settings.pullRequests || Settings.commitStatus){ - // TODO: check that SSH key and and OAuth token are present - } - } + features { + activeStorage { + activeStorageID = "DefaultStorage" + } + } +}) { + override fun validate(consumer: ErrorConsumer) { + super.validate(consumer) + if (Settings.deploySstate) { + // TODO: check that SSH key is present + // Currently this feature is unavailable + } + if (Settings.pullRequests || Settings.commitStatus) { + // TODO: check that SSH key and and OAuth token are present + } + } } diff --git a/.teamcity/asteroid/InitWorkspace.kt b/.teamcity/asteroid/InitWorkspace.kt index efdee8a..9c94c3b 100644 --- a/.teamcity/asteroid/InitWorkspace.kt +++ b/.teamcity/asteroid/InitWorkspace.kt @@ -4,170 +4,178 @@ import jetbrains.buildServer.configs.kotlin.v2019_2.BuildType import jetbrains.buildServer.configs.kotlin.v2019_2.buildSteps.ScriptBuildStep object InitWorkspace : BuildType({ - name = "Initialize workspace" - description = "Clone sources and initialize workspace" + name = "Initialize workspace" + description = "Clone sources and initialize workspace" - enablePersonalBuilds = false + enablePersonalBuilds = false - vcs { - CoreVCS.attachVCS(this) - } + vcs { + CoreVCS.attachVCS(this) + } }) fun initScript(buildStep: ScriptBuildStep, withSstate: Boolean = true) { - // TODO: Change the hardcoded sturgeon to generic - buildStep.name = "Prepare config files" - val sstateMirror: String = if (withSstate) - """ - SSTATE_MIRRORS ?= " \ - file://.* %system.sstate.server.address%/sturgeon/sstate-cache/PATH;downloadfilename=PATH \n \ - file://.* %system.sstate.server.address%/armv7vehf-neon/sstate-cache/PATH;downloadfilename=PATH \n \ - file://.* %system.sstate.server.address%/allarch/sstate-cache/PATH;downloadfilename=PATH \n \ - file://.* %system.sstate.server.address%/other-sstate/sstate-cache/PATH;downloadfilename=PATH \n \ - " - """.trimIndent() - else - """ - SSTATE_MIRRORS ?= " \ - file://.* %system.sstate.server.address%/other-sstate/sstate-cache/PATH;downloadfilename=PATH \n \ - " - """.trimIndent() - buildStep.scriptContent = """ - mkdir -p build/conf - echo 'DISTRO = "asteroid" - MACHINE = "sturgeon" - PACKAGE_CLASSES = "package_ipk" - ${sstateMirror}' >> build/conf/local.conf - echo 'BBPATH = "${'$'}{TOPDIR}" - SRCDIR = "${'$'}{@os.path.abspath(os.path.join("${'$'}{TOPDIR}", "../src/"))}" - - BBLAYERS = " \ - ${'$'}{SRCDIR}/meta-qt5 \ - ${'$'}{SRCDIR}/oe-core/meta \ - ${'$'}{SRCDIR}/meta-asteroid \ - ${'$'}{SRCDIR}/meta-openembedded/meta-oe \ - ${'$'}{SRCDIR}/meta-openembedded/meta-multimedia \ - ${'$'}{SRCDIR}/meta-openembedded/meta-gnome \ - ${'$'}{SRCDIR}/meta-openembedded/meta-networking \ - ${'$'}{SRCDIR}/meta-smartphone/meta-android \ - ${'$'}{SRCDIR}/meta-openembedded/meta-python \ - ${'$'}{SRCDIR}/meta-openembedded/meta-filesystems \ - "' > build/conf/bblayers.conf - - # Try to initialize OE environment - source ./src/oe-core/oe-init-build-env - """.trimIndent() + // TODO: Change the hardcoded sturgeon to generic + buildStep.name = "Prepare config files" + val sstateMirror: String = if (withSstate) + """ + SSTATE_MIRRORS ?= " \\ + file://.* %system.sstate.server.address%/sturgeon/sstate-cache/PATH;downloadfilename=PATH \\n \\ + file://.* %system.sstate.server.address%/armv7vehf-neon/sstate-cache/PATH;downloadfilename=PATH \\n \\ + file://.* %system.sstate.server.address%/allarch/sstate-cache/PATH;downloadfilename=PATH \\n \\ + file://.* %system.sstate.server.address%/other-sstate/sstate-cache/PATH;downloadfilename=PATH \n \\ + " + """.trimEnd() + else + """ + SSTATE_MIRRORS ?= " \\ + file://.* %system.sstate.server.address%/other-sstate/sstate-cache/PATH;downloadfilename=PATH \\n \\ + " + """.trimEnd() + buildStep.scriptContent = """ + mkdir -p build/conf + cat > build/conf/local.conf <<-EOF + DISTRO = "asteroid" + MACHINE = "sturgeon" + PACKAGE_CLASSES = "package_ipk" + $sstateMirror + EOF + cat > build/conf/bblayers.conf <<-EOF + BBPATH = "\${'$'}{TOPDIR}" + SRCDIR = "\${'$'}{@os.path.abspath(os.path.join("\${'$'}{TOPDIR}", "../src/"))}" + + BBLAYERS = " \\ + \${'$'}{SRCDIR}/meta-qt5 \\ + \${'$'}{SRCDIR}/oe-core/meta \\ + \${'$'}{SRCDIR}/meta-asteroid \\ + \${'$'}{SRCDIR}/meta-openembedded/meta-oe \\ + \${'$'}{SRCDIR}/meta-openembedded/meta-multimedia \\ + \${'$'}{SRCDIR}/meta-openembedded/meta-gnome \\ + \${'$'}{SRCDIR}/meta-openembedded/meta-networking \ + \${'$'}{SRCDIR}/meta-smartphone/meta-android \\ + \${'$'}{SRCDIR}/meta-openembedded/meta-python \\ + \${'$'}{SRCDIR}/meta-openembedded/meta-filesystems \\ + " + EOF + + # Try to initialize OE environment + source ./src/oe-core/oe-init-build-env + """.trimIndent() } fun initScript(buildStep: ScriptBuildStep, device: String, architecture: String, withSstate: Boolean = true) { - buildStep.name = "Prepare config files" - val sstateMirror: String = if (withSstate) - """ - SSTATE_MIRRORS ?= " \ - file://.* %system.sstate.server.address%/${device}/sstate-cache/PATH;downloadfilename=PATH \n \ - file://.* %system.sstate.server.address%/${architecture}/sstate-cache/PATH;downloadfilename=PATH \n \ - file://.* %system.sstate.server.address%/allarch/sstate-cache/PATH;downloadfilename=PATH \n \ - file://.* %system.sstate.server.address%/other-sstate/sstate-cache/PATH;downloadfilename=PATH \n \ - " - """.trimIndent() - else - """ - SSTATE_MIRRORS ?= " \ - file://.* %system.sstate.server.address%/other-sstate/sstate-cache/PATH;downloadfilename=PATH \n \ - " - """.trimIndent() - buildStep.scriptContent = """ - mkdir -p build/conf - echo 'DISTRO = "asteroid" - MACHINE = "$device" - PACKAGE_CLASSES = "package_ipk" - ${sstateMirror}' >> build/conf/local.conf - echo 'BBPATH = "${'$'}{TOPDIR}" - SRCDIR = "${'$'}{@os.path.abspath(os.path.join("${'$'}{TOPDIR}", "../src/"))}" - - BBLAYERS = " \ - ${'$'}{SRCDIR}/meta-qt5 \ - ${'$'}{SRCDIR}/oe-core/meta \ - ${'$'}{SRCDIR}/meta-asteroid \ - ${'$'}{SRCDIR}/meta-openembedded/meta-oe \ - ${'$'}{SRCDIR}/meta-openembedded/meta-multimedia \ - ${'$'}{SRCDIR}/meta-openembedded/meta-gnome \ - ${'$'}{SRCDIR}/meta-openembedded/meta-networking \ - ${'$'}{SRCDIR}/meta-smartphone/meta-android \ - ${'$'}{SRCDIR}/meta-openembedded/meta-python \ - ${'$'}{SRCDIR}/meta-openembedded/meta-filesystems \ - ${'$'}{SRCDIR}/meta-smartwatch/meta-${device} \ - "' > build/conf/bblayers.conf - - # Try to initialize OE environment - source ./src/oe-core/oe-init-build-env - """.trimIndent() + buildStep.name = "Prepare config files" + val sstateMirror: String = if (withSstate) + """ + SSTATE_MIRRORS ?= " \\ + file://.* %system.sstate.server.address%/${device}/sstate-cache/PATH;downloadfilename=PATH \\n \\ + file://.* %system.sstate.server.address%/${architecture}/sstate-cache/PATH;downloadfilename=PATH \\n \\ + file://.* %system.sstate.server.address%/allarch/sstate-cache/PATH;downloadfilename=PATH \\n \\ + file://.* %system.sstate.server.address%/other-sstate/sstate-cache/PATH;downloadfilename=PATH \\n \\ + " + """.trimEnd() + else + """ + SSTATE_MIRRORS ?= " \\ + file://.* %system.sstate.server.address%/other-sstate/sstate-cache/PATH;downloadfilename=PATH \\n \\ + " + """.trimEnd() + buildStep.scriptContent = """ + mkdir -p build/conf + cat > build/conf/local.conf <<-EOF + DISTRO = "asteroid" + MACHINE = "$device" + PACKAGE_CLASSES = "package_ipk" + $sstateMirror + EOF + cat > build/conf/bblayers.conf <<-EOF + BBPATH = "\${'$'}{TOPDIR}" + SRCDIR = "\${'$'}{@os.path.abspath(os.path.join("\${'$'}{TOPDIR}", "../src/"))}" + + BBLAYERS = " \\ + \${'$'}{SRCDIR}/meta-qt5 \\ + \${'$'}{SRCDIR}/oe-core/meta \\ + \${'$'}{SRCDIR}/meta-asteroid \\ + \${'$'}{SRCDIR}/meta-openembedded/meta-oe \\ + \${'$'}{SRCDIR}/meta-openembedded/meta-multimedia \\ + \${'$'}{SRCDIR}/meta-openembedded/meta-gnome \\ + \${'$'}{SRCDIR}/meta-openembedded/meta-networking \\ + \${'$'}{SRCDIR}/meta-smartphone/meta-android \\ + \${'$'}{SRCDIR}/meta-openembedded/meta-python \\ + \${'$'}{SRCDIR}/meta-openembedded/meta-filesystems \\ + \${'$'}{SRCDIR}/meta-smartwatch/meta-${device} \\ + " + EOF + + # Try to initialize OE environment + source ./src/oe-core/oe-init-build-env + """.trimIndent() } fun bitbakeBuild(buildStep: ScriptBuildStep, recipe: String? = null) { - buildStep.scriptContent = """ - source src/oe-core/oe-init-build-env > /dev/null - echo "Starting bitbake" - bitbake --ui=teamcity ${recipe ?: "asteroid-image"} - """.trimIndent() + buildStep.scriptContent = """ + source ./src/oe-core/oe-init-build-env > /dev/null + echo "Starting bitbake" + bitbake --ui=teamcity ${recipe ?: "asteroid-image"} + """.trimIndent() } fun updateSstate(buildStep: ScriptBuildStep, cleanServer: Boolean = false) { - // TODO: Change the hardcoded sturgeon to generic - buildStep.name = "Upload sstate-cache" - val cleanCommand = if (cleanServer) - """ - # Clean destination - mkdir dummy_empty - rsync --delete \ - ./dummy_empty ${'$'}{ServerAddr} - """.trimIndent() - else - "" - buildStep.scriptContent = """ - Opts="-a --prune-empty-dirs --remove-source-files \ - --checksum --progress" - ServerAddr="%system.sstate.server.user%@%system.sstate.server.upload_address%:%system.sstate.server.location%" - - $cleanCommand - rsync ${'$'}{Opts} \ - build/sstate-cache/fedora-35 ${'$'}{ServerAddr}/other-sstate/sstate-cache - rsync ${'$'}{Opts} \ - --include '*/' --include '*:*:*:*:*::*' --exclude '*' \ - build/sstate-cache ${'$'}{ServerAddr}/other-sstate - rsync ${'$'}{Opts} \ - --include '*/' --include '*:*:*:*:*:sturgeon:*' --exclude '*' \ - build/sstate-cache ${'$'}{ServerAddr}/sturgeon - rsync ${'$'}{Opts} \ - --include '*/' --include '*:*:*:*:*:armv7vehf-neon:*' --exclude '*' \ - build/sstate-cache ${'$'}{ServerAddr}/armv7vehf-neon - rsync ${'$'}{Opts} \ - --include '*/' --include '*:*:*:*:*:allarch:*' --exclude '*' \ - build/sstate-cache ${'$'}{ServerAddr}/all-arch - """.trimIndent() + // TODO: Change the hardcoded sturgeon to generic + buildStep.name = "Upload sstate-cache" + val cleanCommand = if (cleanServer) + """ + # Clean destination + mkdir dummy_empty + rsync --delete \ + ./dummy_empty ${'$'}{ServerAddr} + """.trimEnd() + else + "" + buildStep.scriptContent = """ + Opts="-a --prune-empty-dirs --remove-source-files \ + --checksum --progress" + ServerAddr="%system.sstate.server.user%@%system.sstate.server.upload_address%:%system.sstate.server.location%" + + $cleanCommand + rsync ${'$'}{Opts} \ + build/sstate-cache/fedora-35 ${'$'}{ServerAddr}/other-sstate/sstate-cache + rsync ${'$'}{Opts} \ + --include '*/' --include '*:*:*:*:*::*' --exclude '*' \ + build/sstate-cache ${'$'}{ServerAddr}/other-sstate + rsync ${'$'}{Opts} \ + --include '*/' --include '*:*:*:*:*:sturgeon:*' --exclude '*' \ + build/sstate-cache ${'$'}{ServerAddr}/sturgeon + rsync ${'$'}{Opts} \ + --include '*/' --include '*:*:*:*:*:armv7vehf-neon:*' --exclude '*' \ + build/sstate-cache ${'$'}{ServerAddr}/armv7vehf-neon + rsync ${'$'}{Opts} \ + --include '*/' --include '*:*:*:*:*:allarch:*' --exclude '*' \ + build/sstate-cache ${'$'}{ServerAddr}/all-arch + """.trimIndent() } fun updateSstate(buildStep: ScriptBuildStep, device: String, architecture: String, cleanServer: Boolean = false) { - buildStep.name = "Upload sstate-cache" - buildStep.scriptContent = """ - Opts="-a --prune-empty-dirs --remove-source-files \ - --checksum --progress" - ServerAddr="%system.sstate.server.user%@%system.sstate.server.upload_address%:%system.sstate.server.location%" - - rsync ${'$'}{Opts} \ - build/sstate-cache/fedora-35 ${'$'}{ServerAddr}/other-sstate/sstate-cache - rsync ${'$'}{Opts} \ - --include '*/' --include '*:*:*:*:*::*' --exclude '*' \ - build/sstate-cache ${'$'}{ServerAddr}/other-sstate - rsync ${'$'}{Opts} \ - ${if (cleanServer) "--delete" else ""} \ - --include '*/' --include '*:*:*:*:*:${device}:*' --exclude '*' \ - build/sstate-cache ${'$'}{ServerAddr}/${device} - rsync ${'$'}{Opts} \ - --include '*/' --include '*:*:*:*:*:${architecture}:*' --exclude '*' \ - build/sstate-cache ${'$'}{ServerAddr}/${architecture} - rsync ${'$'}{Opts} \ - --include '*/' --include '*:*:*:*:*:allarch:*' --exclude '*' \ - build/sstate-cache ${'$'}{ServerAddr}/all-arch - """.trimIndent() + buildStep.name = "Upload sstate-cache" + buildStep.scriptContent = """ + Opts="-a --prune-empty-dirs --remove-source-files \ + --checksum --progress" + ServerAddr="%system.sstate.server.user%@%system.sstate.server.upload_address%:%system.sstate.server.location%" + + rsync ${'$'}{Opts} \ + build/sstate-cache/fedora-35 ${'$'}{ServerAddr}/other-sstate/sstate-cache + rsync ${'$'}{Opts} \ + --include '*/' --include '*:*:*:*:*::*' --exclude '*' \ + build/sstate-cache ${'$'}{ServerAddr}/other-sstate + rsync ${'$'}{Opts} \ + ${if (cleanServer) "--delete" else ""} \ + --include '*/' --include '*:*:*:*:*:${device}:*' --exclude '*' \ + build/sstate-cache ${'$'}{ServerAddr}/${device} + rsync ${'$'}{Opts} \ + --include '*/' --include '*:*:*:*:*:${architecture}:*' --exclude '*' \ + build/sstate-cache ${'$'}{ServerAddr}/${architecture} + rsync ${'$'}{Opts} \ + --include '*/' --include '*:*:*:*:*:allarch:*' --exclude '*' \ + build/sstate-cache ${'$'}{ServerAddr}/all-arch + """.trimIndent() } \ No newline at end of file diff --git a/.teamcity/asteroid/Settings.kt b/.teamcity/asteroid/Settings.kt index ef0929c..ae63e1d 100644 --- a/.teamcity/asteroid/Settings.kt +++ b/.teamcity/asteroid/Settings.kt @@ -3,25 +3,40 @@ package asteroid import jetbrains.buildServer.configs.kotlin.v2019_2.DslContext object Settings { - val asteroidPackages = DslContext.getParameter("Packages") - .split("[\\s,]".toRegex()).toList() - .filterNot { it.isEmpty() } -// val communityPackages = DslContext.getParameter("CommunityPackages") + val asteroidPackages = DslContext.getParameter("Packages") + .split("[\\s,]".toRegex()).toList() + .filterNot { it.isEmpty() } + + // val communityPackages = DslContext.getParameter("CommunityPackages") // .split("[\\s,]".toRegex()).toList() // .filterNot { it.isEmpty() } - val devices = DslContext.getParameter("Devices") - .split("[\\s,]".toRegex()).toList() - .filterNot { it.isEmpty() } + val devices = DslContext.getParameter("Devices") + .split("[\\s,]".toRegex()).toList() + .filterNot { it.isEmpty() } + + val fork = DslContext.getParameter("Fork") + val upstream = DslContext.getParameter("Upstream", "AsteroidOS") + val deploySstate = DslContext.getParameter("DeploySstate", "false").toBoolean() + + object sstateServer { + val url = DslContext.getParameter("SstateServerURL", "https://sstate.asteroid.org") + val backendUrl = if (deploySstate) + DslContext.getParameter("SstateServerBackendURL", "sstate.asteroid.org") + else null + val user = if (deploySstate) + DslContext.getParameter("SstateServerUser", "asteroidos") + else null + val location = if (deploySstate) + DslContext.getParameter("SstateServerLocation", "") + else null + } - val fork = DslContext.getParameter("Fork") - val upstream = DslContext.getParameter("Upstream","AsteroidOS") - val deploySstate = DslContext.getParameter("DeploySstate", "false").toBoolean() + // TODO: Change to Github app when available + val commitStatus = DslContext.getParameter("CommitStatus", "false").toBoolean() + val commitUser = DslContext.getParameter("CommitUser", fork) + val pullRequests = DslContext.getParameter("PullRequests", "false").toBoolean() - // TODO: Change to Github app when available - val commitStatus = DslContext.getParameter("CommitStatus", "false").toBoolean() - val commitUser = DslContext.getParameter("CommitUser", fork) - val pullRequests = DslContext.getParameter("PullRequests", "false").toBoolean() - init { - // TODO: Check validity of Token and Ssh key - } + init { + // TODO: Check validity of Token and Ssh key + } } \ No newline at end of file