if ! rpm-ostree compose tree --unified-core --cachedir="${CACHE_DIR}" --repo="${BUILD_REPO}" --add-metadata-string=Build="${METADATA_STR}" "${TREEFILE}"; then
log_struc_error "Error composing ostree" status "$?"
exit
fi
# Prepare deploy
log_info "Prune refs older than 30 days"
if ! ostree --repo="${BUILD_REPO}" prune --refs-only --keep-younger-than='30 days ago'; then
log_struc_error "Error pruning refs" status "$?"
exit
fi
log_struc_info "Pull new ostree commit into deploy repo" deploy_repo "${DEPLOY_REPO}"
if ! ostree --repo="${DEPLOY_REPO}" pull-local --depth=1 "${BUILD_REPO}" "${OSTREE_BRANCH}"; then
log_struc_error "Error pulling new ostree commit into deploy repo" status "$?"
exit
fi
log_struc_info "Remove local build repo" build_repo "${BUILD_REPO}"
rm -rf "${BUILD_REPO}"
log_struc_info "Check filesystem for errors" deploy_repo "${DEPLOY_REPO}" ostree_branch "${OSTREE_BRANCH}"
if ! ostree --repo="${DEPLOY_REPO}" fsck "${OSTREE_BRANCH}"; then
log_struc_error "Error checking filesystem for errors" status "$?"
exit
fi
# Generate deltas
log_info "Check if main ref has parent"
if ! ostree --repo="${DEPLOY_REPO}" show "${OSTREE_BRANCH}"; then
log_info "Main ref has no parent. No deltas will be generated."
else
log_info "Generate static delta from main ref's parent"
if ! ostree --repo="${DEPLOY_REPO}" static-delta generate "${OSTREE_BRANCH}"; then
log_struc_error "Error generating static delta from main ref's parent" status "$?"
exit
fi
log_info "Check if main ref has grandparent"
if ! ostree --repo="${DEPLOY_REPO}" show "${OSTREE_BRANCH}"^^; then
log_info "Main ref has no grandparent. No grand-deltas will be generated."
else
log_info "Generate static delta from main ref's grandparent"
if ! ostree --repo="${DEPLOY_REPO}" static-delta generate --from="${OSTREE_BRANCH}"^^ --to="${OSTREE_BRANCH}"; then
log_struc_error "Error generating static delta from main ref's grandparent."