When a package can't be published, print which distribution the error is
[arvados-dev.git] / jenkins / run_upload_packages.py
index 0840f2fc560a64b4d4708389d33b512cf80f94f1..bc4f4ffc6ae11096fcb742333ab6aa9c077941a4 100755 (executable)
@@ -5,6 +5,7 @@
 # SPDX-License-Identifier: AGPL-3.0
 
 import argparse
+import errno
 import functools
 import glob
 import locale
@@ -50,6 +51,15 @@ def run_and_grep(cmd, read_output, *regexps,
 class TimestampFile:
     def __init__(self, path):
         self.path = path
+        # Make sure the dirname for `path` exists
+        p = os.path.dirname(path)
+        try:
+            os.makedirs(p)
+        except OSError as exc:
+            if exc.errno == errno.EEXIST and os.path.isdir(p):
+                pass
+            else:
+                raise
         self.start_time = time.time()
 
     def last_upload(self):
@@ -59,9 +69,18 @@ class TimestampFile:
             return -1
 
     def update(self):
-        os.close(os.open(self.path, os.O_CREAT | os.O_APPEND))
-        os.utime(self.path, (time.time(), self.start_time))
-
+        try:
+            os.close(os.open(self.path, os.O_CREAT | os.O_APPEND))
+            os.utime(self.path, (time.time(), self.start_time))
+        except:
+            # when the packages directory is created/populated by a build in a
+            # docker container, as root, the script that runs the upload
+            # doesn't always have permission to touch a timestamp file there.
+            # In production, we build/upload from ephemeral machines, which
+            # means that the timestamp mechanism is not used. We print a
+            # warning and move on without erroring out.
+            print("Warning: unable to update timestamp file",self.path,"permission problem?")
+            pass
 
 class PackageSuite:
     NEED_SSH = False
@@ -227,7 +246,7 @@ cd "$1"; shift
 REPODIR=$1; shift
 rpmsign --addsign "$@" </dev/null
 mv "$@" "$REPODIR"
-createrepo "$REPODIR"
+createrepo -c ~/.createrepo-cache --update "$REPODIR"
 """
     REPO_ROOT = '/var/www/rpm.arvados.org/'