Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync alienv to CVMFS automatically #1459

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions publish/aliPublishS3
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env python3

import logging, gzip, sys, json, yaml, errno, boto3, requests
import filecmp
import shutil
import botocore.exceptions
from glob import glob
from argparse import ArgumentParser
@@ -769,6 +771,24 @@ def sync(pub, architectures, s3Client, bucket, baseUrl, basePrefix, rules,
error("%s / %s / %s: publish script failed with %d",
arch, pack["name"], pack["ver"], rv)

# Update the alienv script in CVMFS if it has changed
try:
new_alienv = dirname(realpath(__file__)) / ".." / "cvmfs" / "alienv"
old_alienv = "/cvmfs/alice.cern.ch/bin/alienv"

# Create backup with timestamp if files are different
if not filecmp.cmp(new_alienv, old_alienv, shallow=False):
timestamp = datetime.now().strftime("%Y%m%d-%H%M%S")
backup_alienv = f"/cvmfs/alice.cern.ch/bin/alienv.safe-{timestamp}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should have a separate folder for the backups (or limit the backups to just a few).

info("Creating backup of current alienv at %s", backup_alienv)
shutil.copy(old_alienv, backup_alienv)

info("Replacing ../cvmfs/alienv with /cvmfs/alice.cern.ch/bin/alienv")
shutil.copy(old_alienv, new_alienv)
except FileNotFoundError as e:
error("File not found: %s", e)


# Publish eventually
if pub.publish(architectures.values()):
totSuccess = 0