From a69b04e032f1543430e12e15d8338557aad32315 Mon Sep 17 00:00:00 2001 From: Mario Fetka Date: Sat, 15 Nov 2014 22:31:34 +0100 Subject: [PATCH] add a script to copy everything to testing --- bin/opsi-all-release.sh | 65 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100755 bin/opsi-all-release.sh diff --git a/bin/opsi-all-release.sh b/bin/opsi-all-release.sh new file mode 100755 index 0000000..656b302 --- /dev/null +++ b/bin/opsi-all-release.sh @@ -0,0 +1,65 @@ +#! /bin/bash + +BASE_DIR="`dirname $0`/.." +SCRIPT=$(readlink -f $0) +BIN_DIR=`dirname $SCRIPT` +OPSI_WEB_ROOT="" + +# Source local build configuration (must be done AFTER sourcing the builder-product.cfg.cfg) +test -f $HOME/.opsi-administration.cfg && . $HOME/.opsi-administration.cfg + + +name_list=`mktemp /tmp/opsi-admin.name-list.XXXXXXXXXXX` +name_list_sort=`mktemp /tmp/opsi-admin.name-list-sort.XXXXXXXXXXX` +file_list=`mktemp /tmp/opsi-admin.file-list.XXXXXXXXXXX` +file_sort_list=`mktemp /tmp/opsi-admin.file-sort-list.XXXXXXXXXXX` +file_sort_list_version=`mktemp /tmp/opsi-admin.file-sort-list-verison.XXXXXXXXXXX` +file_sort_list_release=`mktemp /tmp/opsi-admin.file-sort-list-relase.XXXXXXXXXXX` +file_sort_list_final=`mktemp /tmp/opsi-admin.file-sort-list-final.XXXXXXXXXXX` + +pushd ${OPSI_WEB_ROOT} +for pkg_root in public restricted ; do + # Find all revision files and sort them + for cfg_file in `find ${OPSI_WEB_ROOT}/${pkg_root}/testing -name "*.cfg" -print ` ; do + . ${cfg_file} + echo "$REV_PN" >> ${name_list} + done + sort ${name_list} | uniq > ${name_list_sort} + + # first uniq sort all cfg based on version + for pkg_name in `cat ${name_list_sort}` ; do + cat /dev/null > ${file_list} + for cfg_file in `find ${OPSI_WEB_ROOT}/${pkg_root}/testing -name "${pkg_name}-*.cfg" -print ` ; do + . ${cfg_file} + echo $REV_VERSION >> ${file_list} + done + sort -V ${file_list} | uniq > ${file_sort_list_version} + + # second uniq sort all versions based in release + cat /dev/null > ${file_sort_list_release} + for pkg_version in `cat ${file_sort_list_version}` ; do + for cfg_file_ver in ${OPSI_WEB_ROOT}/${pkg_root}/testing/${pkg_name}-${pkg_version}-*.cfg ; do + . ${cfg_file_ver} + echo ${pkg_version}-$REV_CREATOR_TAG$REV_RELEASE >> ${file_sort_list_release} + done + done + sort -V ${file_sort_list_release} | uniq > ${file_sort_list_final} + + # third create versionrelease + cat /dev/null > ${file_sort_list} + for release_file_list in `cat ${file_sort_list_final}` ; do + . ${OPSI_WEB_ROOT}/${pkg_root}/testing/${pkg_name}-${release_file_list}.cfg + echo "${OPSI_WEB_ROOT}/${pkg_root}/testing/${pkg_name}-${release_file_list}.cfg" >> ${file_sort_list} + done + + # Delete the oldest files + #for cfg_sort_file in `head -n-1 ${file_sort_list}` ; do + for cfg_sort_file in `tail -n 1 ${file_sort_list}` ; do + . ${cfg_sort_file} + echo "${BIN_DIR}/opsi-administration.sh --root ${OPSI_WEB_ROOT} --name ${REV_PN} --type ${pkg_root} --from testing --to release --version ${REV_VERSION}-${REV_CREATOR_TAG}${REV_RELEASE} --purge" + ${BIN_DIR}/opsi-administration.sh --root ${OPSI_WEB_ROOT} --name ${REV_PN} --type ${pkg_root} --from testing --to release --version ${REV_VERSION}-${REV_CREATOR_TAG}${REV_RELEASE} --purge + done + done +done +popd +