Add new bump scripts
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
#!/bin/bash
|
||||
# Author: Daniele Rondina, geaaru@sabayonlinux.org
|
||||
|
||||
set -xe
|
||||
|
||||
BASE_DIR="${BASE_DIR:-/sabayon/rsync/rsync.sabayon.org/entropy/standard}"
|
||||
SOURCE_DIR=${SOURCE_DIR:-${BASE_DIR}/sabayonlinux.org}
|
||||
DEST_DIR=${DEST_DIR:-${BASE_DIR}/sabayon-weekly}
|
||||
SSH_KEY=${SSH_KEY:-/sabayon/conf/ssh/id_rsa}
|
||||
|
||||
RSYNC_BIN=${RSYNC_BIN:-/usr/bin/rsync}
|
||||
RSYNC_ARGS=${RSYNC_ARGS:--avP --delay-updates}
|
||||
RSYNC_BASE_PARAMS=${RSYNC_BASE_PARAMS:---exclude packages*/* --exclude *.asc --delete --delete-during --delete-excluded}
|
||||
|
||||
SSH_BIN=${SSH_BIN:-/usr/bin/ssh}
|
||||
SSH_ARGS=${SSH_ARGS:--i ${SSH_KEY} -p 9222}
|
||||
REMOTE_HOST=${REMOTE_HOST:-entropy@pkg.sabayon.org}
|
||||
REMOTE_DIR=${REMOTE_DIR:-~/standard/sabayon-weekly}
|
||||
|
||||
STAGING_DIR=${STAGING_DIR:-$(mktemp -u -d)}
|
||||
FIXUP_REPO_SCRIPT=${FIXUP_REPO_SCRIPT:-fixup_repository.py}
|
||||
|
||||
main () {
|
||||
# Run local rsync to a staging dir to fix treeupdates
|
||||
|
||||
# Clean previous staging dir if exists
|
||||
rm -rf ${STAGING_DIR} || true
|
||||
mkdir -p ${STAGING_DIR}
|
||||
|
||||
local temp_dest_dir=${STAGING_DIR}/update_sabayon_weekly_repo
|
||||
|
||||
${RSYNC_BIN} ${RSYNC_ARGS} ${SOURCE_DIR} ${temp_dest_dir} ${RSYNC_BASE_PARAMS}
|
||||
|
||||
# recreate:
|
||||
# - packages.db.bz2
|
||||
# - packages.db.dumplight.bz2
|
||||
# - packages.db.light.bz2
|
||||
local dbdir=${temp_dest_dir}/database
|
||||
local archdir=${dbdir}/amd64
|
||||
local branchdir=${archdir}/5
|
||||
|
||||
${FIXUP_REPO_SCRIPT} ${branchdir}
|
||||
|
||||
# rsync from the staging directory to the final
|
||||
${RSYNC_BIN} ${RSYNC_ARGS} ${temp_dest_dir}/ ${DEST_DIR}/
|
||||
|
||||
# create remote directory
|
||||
${SSH_BIN} ${SSH_ARGS} ${REMOTE_HOST} mkdir -p ${REMOTE_DIR} || true
|
||||
|
||||
# push the repo to packages.sabayon.org
|
||||
${RSYNC_BIN} ${RSYNC_ARGS} "--rsh=${SSH_ARGS}" ${DEST_DIR}/ ${REMOTE_HOST}:${REMOTE_DIR}/
|
||||
|
||||
# WHY?????
|
||||
local weekly_db=${branchdir}/packages.db.bz2
|
||||
local remote_weekly_dir=${REMOTE_DIR}/database/amd64/5
|
||||
local remote_weekly_db=${remote_weekly_dir}/packages.db.bz2
|
||||
|
||||
${RSYNC_BIN} ${RSYNC_ARGS} "--rsh=${SSH_ARGS}" ${weekly_db} ${REMOTE_HOST}:${remote_weekly_db}
|
||||
|
||||
# final touch to notify the web service
|
||||
local remote_weekly_eapi3_upd=${remote_weekly_dir}/packages.db.eapi3_updates
|
||||
${SSH_BIN} ${SSH_ARGS} touch ${remote_weekly_eapi3_upd}
|
||||
|
||||
rm -rf ${temp_dest_dir}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
main $@
|
||||
exit $?
|
||||
@@ -0,0 +1,87 @@
|
||||
import bz2
|
||||
import os
|
||||
import sys
|
||||
sys.path.insert(0, "/usr/lib/entropy/lib")
|
||||
import entropy.tools
|
||||
from entropy.db.sqlite import EntropySQLiteRepository
|
||||
|
||||
|
||||
def fixup_repository(repository_dir):
|
||||
print("Repository fixup for %s" % (repository_dir,))
|
||||
bz2_path = os.path.join(repository_dir, "packages.db.bz2")
|
||||
db_path = entropy.tools.unpack_bzip2(bz2_path)
|
||||
repo = EntropySQLiteRepository(
|
||||
dbFile=db_path,
|
||||
name="sabayon-weekly",
|
||||
indexing=False,
|
||||
skipChecks=True)
|
||||
updates = repo.listAllTreeUpdatesActions()
|
||||
new_updates = []
|
||||
for idupdate, repository, command, branch, date in updates:
|
||||
if repository == "sabayonlinux.org":
|
||||
repository = "sabayon-weekly"
|
||||
new_updates.append(
|
||||
(idupdate, repository, command, branch, date))
|
||||
repo.bumpTreeUpdatesActions(new_updates)
|
||||
repo.clean()
|
||||
repo.dropAllIndexes()
|
||||
repo.dropContentSafety()
|
||||
repo.vacuum()
|
||||
repo.commit()
|
||||
# now close, amen
|
||||
repo.close()
|
||||
# update packages.db.bz2
|
||||
f_out = bz2.BZ2File(bz2_path + ".tmp", "wb")
|
||||
with open(db_path, "rb") as f_in:
|
||||
data = f_in.read(1024000)
|
||||
while data:
|
||||
f_out.write(data)
|
||||
data = f_in.read(1024000)
|
||||
f_out.close()
|
||||
os.rename(bz2_path + ".tmp", bz2_path)
|
||||
entropy.tools.create_md5_file(bz2_path)
|
||||
# update packages.db.light.bz2, reopen repo
|
||||
repo = EntropySQLiteRepository(
|
||||
dbFile=db_path,
|
||||
name="sabayon-weekly",
|
||||
indexing=False,
|
||||
skipChecks=True)
|
||||
repo.dropContent()
|
||||
repo.dropChangelog()
|
||||
repo.vacuum()
|
||||
repo.commit()
|
||||
# update packages.db.dumplight
|
||||
dumplight_path = os.path.join(repository_dir, "packages.db.dumplight.bz2")
|
||||
f_out = bz2.BZ2File(dumplight_path + ".tmp", "wb")
|
||||
repo.exportRepository(f_out)
|
||||
f_out.close()
|
||||
os.rename(dumplight_path + ".tmp", dumplight_path)
|
||||
entropy.tools.create_md5_file(dumplight_path)
|
||||
# now close, amen
|
||||
repo.close()
|
||||
light_path = os.path.join(repository_dir, "packages.db.light.bz2")
|
||||
f_out = bz2.BZ2File(light_path + ".tmp", "wb")
|
||||
with open(db_path, "rb") as f_in:
|
||||
data = f_in.read(1024000)
|
||||
while data:
|
||||
f_out.write(data)
|
||||
data = f_in.read(1024000)
|
||||
f_out.close()
|
||||
os.rename(light_path + ".tmp", light_path)
|
||||
entropy.tools.create_md5_file(light_path)
|
||||
os.remove(db_path)
|
||||
# add UPDATE_EAPI=2 to packages.db.webservices
|
||||
ws_path = os.path.join(repository_dir, "packages.db.webservices")
|
||||
if os.path.isfile(ws_path):
|
||||
with open(ws_path, "a+") as ws:
|
||||
ws.write("\n")
|
||||
ws.write("UPDATE_EAPI=2\n")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
_repodir = sys.argv[1]
|
||||
if len(_repodir) == 0:
|
||||
print("Invalid repo dir")
|
||||
sys.exit(1)
|
||||
fixup_repository(_repodir)
|
||||
sys.exit(0)
|
||||
Reference in New Issue
Block a user