opsi.admintools/bin/opsi-all-testing.sh
2014-11-15 22:27:23 +01:00

66 lines
2.8 KiB
Bash
Executable File

#! /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}/integration -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}/integration -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}/integration/${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}/integration/${pkg_name}-${release_file_list}.cfg
echo "${OPSI_WEB_ROOT}/${pkg_root}/integration/${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 integration --to testing --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 integration --to testing --version ${REV_VERSION}-${REV_CREATOR_TAG}${REV_RELEASE} --purge
done
done
done
popd