forked from suse-edge/Factory
		
	Compare commits
	
		
			17 Commits
		
	
	
		
			kubectl-1.
			...
			devel
		
	
	| Author | SHA256 | Date | |
|---|---|---|---|
| b1dfe698ff | |||
| 9581e030ce | |||
| 76036c2dd8 | |||
| 0c6db5d5cc | |||
| 0b03d14cee | |||
| 9f2dc045e9 | |||
| 
						 | 
					f90f614746 | ||
| 35f06da226 | |||
| 8dd6d7d9d7 | |||
| f9c5a29a9f | |||
| 1b83b54b58 | |||
| c6b64a252f | |||
| 689c80ffcc | |||
| d8745fe060 | |||
| 9e39bdcf7f | |||
| 9e376ffb74 | |||
| 0fc166ff06 | 
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -1,3 +1,4 @@
 | 
			
		||||
*/.osc
 | 
			
		||||
*/__pycache__
 | 
			
		||||
.venv/
 | 
			
		||||
.idea/
 | 
			
		||||
@@ -1,3 +1,3 @@
 | 
			
		||||
PROJECT = "isv:SUSE:Edge:Factory"
 | 
			
		||||
PROJECT = "isv:SUSE:Edge:Factory:Devel"
 | 
			
		||||
REPOSITORY = "https://src.opensuse.org/suse-edge/Factory"
 | 
			
		||||
BRANCH = "main"
 | 
			
		||||
BRANCH = "devel"
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										65
									
								
								.obs/trigger_package.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								.obs/trigger_package.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,65 @@
 | 
			
		||||
import xml.etree.ElementTree as ET
 | 
			
		||||
import subprocess
 | 
			
		||||
 | 
			
		||||
from sync_packages import get_local_packages
 | 
			
		||||
from common import PROJECT
 | 
			
		||||
 | 
			
		||||
def get_service_repo(package):
 | 
			
		||||
    with open(f"{package}/_service") as service:
 | 
			
		||||
        root = ET.parse(service).getroot()
 | 
			
		||||
        for service in root.findall("service"):
 | 
			
		||||
            if service.get("mode") in ["manual", "disabled"]:
 | 
			
		||||
                continue
 | 
			
		||||
            if service.get("name") not in ["obs_scm", "tar_scm"]:
 | 
			
		||||
                continue
 | 
			
		||||
            ref = service.find("param[@name='revision']").text
 | 
			
		||||
            repo = service.find("param[@name='url']").text
 | 
			
		||||
            return (repo, ref)
 | 
			
		||||
    return None
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
def get_remote_ref(project, package):
 | 
			
		||||
    files = subprocess.run(["osc", "ls", "-e", project, package], encoding='utf-8' , capture_output=True).stdout.splitlines()
 | 
			
		||||
    for filename in files:
 | 
			
		||||
        if filename.startswith("_service") and filename.endswith(".obsinfo"):
 | 
			
		||||
            obsinfo = subprocess.run(["osc", "cat", project, package, filename], encoding='utf-8' , capture_output=True).stdout.splitlines()
 | 
			
		||||
            for line in obsinfo:
 | 
			
		||||
                if line.startswith("commit:"):
 | 
			
		||||
                    return line.split(':')[-1].strip()
 | 
			
		||||
 | 
			
		||||
def get_upstream_ref(repo, ref):
 | 
			
		||||
    refs = subprocess.run(["git", "ls-remote", repo, ref, f"{ref}^{{}}"], encoding='utf-8' , capture_output=True).stdout.splitlines()
 | 
			
		||||
    refpath = ref.split('/')
 | 
			
		||||
    best = None
 | 
			
		||||
    for rref in refs:
 | 
			
		||||
        value = rref.split('\t')
 | 
			
		||||
        (sha, name) = (value[0].strip(), value[1].strip())
 | 
			
		||||
        namepath = name.split('/')
 | 
			
		||||
        if len(namepath) == len(refpath) or len(namepath) - 2 == len(refpath):
 | 
			
		||||
            if name.endswith(ref) and best is None:
 | 
			
		||||
                best = sha
 | 
			
		||||
            if name.endswith("^{}"):
 | 
			
		||||
                best = sha
 | 
			
		||||
    return best
 | 
			
		||||
 | 
			
		||||
def trigger_service(project, package):
 | 
			
		||||
    subprocess.run(["osc", "service", "remoterun", project, package], encoding="utf-8",check=True)
 | 
			
		||||
 | 
			
		||||
def main():
 | 
			
		||||
    packages = get_local_packages()
 | 
			
		||||
    for package in packages:
 | 
			
		||||
        try:
 | 
			
		||||
            (repo, ref) = get_service_repo(package)
 | 
			
		||||
            print(f"{package} uses {repo} at {ref}")
 | 
			
		||||
        except: # Package is not using server side scm service
 | 
			
		||||
            continue
 | 
			
		||||
        remote_ref = get_remote_ref(PROJECT, package)
 | 
			
		||||
        upstream_ref = get_upstream_ref(repo, ref)
 | 
			
		||||
        if upstream_ref != remote_ref:
 | 
			
		||||
            print(f"\t{package} needs a refresh")
 | 
			
		||||
            print(f"\tOBS ref is {remote_ref}")
 | 
			
		||||
            print(f"\tgit ref is {upstream_ref}")
 | 
			
		||||
            trigger_service(PROJECT, package)
 | 
			
		||||
            
 | 
			
		||||
if __name__ == "__main__":
 | 
			
		||||
    main()
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
#!BuildTag: %%IMG_PREFIX%%edge-image-builder:1.2.0-rc1
 | 
			
		||||
#!BuildTag: %%IMG_PREFIX%%edge-image-builder:1.2.0-rc1-%RELEASE%
 | 
			
		||||
#!BuildTag: %%IMG_PREFIX%%edge-image-builder:%PACKAGE_VERSION%
 | 
			
		||||
#!BuildTag: %%IMG_PREFIX%%edge-image-builder:%PACKAGE_VERSION%-%RELEASE%
 | 
			
		||||
#!BuildVersion: 15.6
 | 
			
		||||
ARG SLE_VERSION
 | 
			
		||||
FROM registry.suse.com/bci/bci-base:$SLE_VERSION
 | 
			
		||||
@@ -15,11 +15,11 @@ RUN zypper --non-interactive install --no-recommends edge-image-builder qemu-x86
 | 
			
		||||
LABEL org.opencontainers.image.authors="SUSE LLC (https://www.suse.com/)"
 | 
			
		||||
LABEL org.opencontainers.image.title="SLE edge-image-builder Container Image"
 | 
			
		||||
LABEL org.opencontainers.image.description="edge-image-builder based on the SLE Base Container Image."
 | 
			
		||||
LABEL org.opencontainers.image.version="1.2.0-rc1"
 | 
			
		||||
LABEL org.opencontainers.image.version="%PACKAGE_VERSION%"
 | 
			
		||||
LABEL org.opencontainers.image.url="https://www.suse.com/products/server/"
 | 
			
		||||
LABEL org.opencontainers.image.created="%BUILDTIME%"
 | 
			
		||||
LABEL org.opencontainers.image.vendor="SUSE LLC"
 | 
			
		||||
LABEL org.opensuse.reference="%%IMG_REPO%%/%%IMG_PREFIX%%edge-image-builder:1.2.0-rc1-%RELEASE%"
 | 
			
		||||
LABEL org.opensuse.reference="%%IMG_REPO%%/%%IMG_PREFIX%%edge-image-builder:%PACKAGE_VERSION%-%RELEASE%"
 | 
			
		||||
LABEL org.openbuildservice.disturl="%DISTURL%"
 | 
			
		||||
LABEL com.suse.supportlevel="%%SUPPORT_LEVEL%%"
 | 
			
		||||
LABEL com.suse.eula="SUSE Combined EULA February 2024"
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,10 @@
 | 
			
		||||
<services>
 | 
			
		||||
  <service mode="buildtime" name="kiwi_metainfo_helper"/>
 | 
			
		||||
  <service name="replace_using_package_version" mode="buildtime">
 | 
			
		||||
      <param name="file">Dockerfile</param>
 | 
			
		||||
      <param name="regex">%PACKAGE_VERSION%</param>
 | 
			
		||||
      <param name="package">edge-image-builder</param>
 | 
			
		||||
    </service>
 | 
			
		||||
  <service name="replace_using_env" mode="buildtime">
 | 
			
		||||
    <param name="file">Dockerfile</param>
 | 
			
		||||
    <param name="eval">IMG_PREFIX=$(rpm --macros=/root/.rpmmacros -E %{?img_prefix})</param>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,15 +1,12 @@
 | 
			
		||||
<services>
 | 
			
		||||
  <service name="obs_scm">
 | 
			
		||||
    <param name="url">https://github.com/suse-edge/edge-image-builder.git</param>
 | 
			
		||||
    <param name="versionformat">@PARENT_TAG@_%h.%ad</param>
 | 
			
		||||
    <param name="scm">git</param>
 | 
			
		||||
    <param name="exclude">.git</param>
 | 
			
		||||
    <param name="revision">v1.2.0-rc1</param>
 | 
			
		||||
    <!-- Uncomment and set this For Pre-Release Version -->
 | 
			
		||||
    <param name="version">1.2.0~rc1</param>
 | 
			
		||||
    <!-- Uncomment and this for regular version -->
 | 
			
		||||
    <!-- <param name="versionformat">@PARENT_TAG@</param> -->
 | 
			
		||||
    <param name="versionrewrite-pattern">v(\d+).(\d+).(\d+)</param>
 | 
			
		||||
    <param name="versionrewrite-replacement">\1.\2.\3</param>
 | 
			
		||||
    <param name="revision">main</param>
 | 
			
		||||
    <param name="versionrewrite-pattern">v(.*)</param>
 | 
			
		||||
    <param name="versionrewrite-replacement">\1</param>
 | 
			
		||||
    <param name="changesgenerate">enable</param>
 | 
			
		||||
  </service>
 | 
			
		||||
  <service mode="buildtime" name="tar">
 | 
			
		||||
 
 | 
			
		||||
@@ -17,7 +17,7 @@
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Name:           edge-image-builder
 | 
			
		||||
Version:        1.2.0~rc1
 | 
			
		||||
Version:        0
 | 
			
		||||
Release:        0
 | 
			
		||||
Summary:        Edge Image Builder
 | 
			
		||||
License:        Apache-2.0
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user