2012-01-27 01:04:47 +01:00
|
|
|
#####################
|
|
|
|
# Call user entry point
|
|
|
|
####################
|
|
|
|
|
|
|
|
# source generic utility functions
|
|
|
|
. $BASEDIR/lib/builder-utils.sh
|
|
|
|
|
|
|
|
#####################
|
|
|
|
# Read config
|
|
|
|
####################
|
|
|
|
builder_config() {
|
2012-01-28 10:29:54 +01:00
|
|
|
|
2012-02-03 14:41:08 +01:00
|
|
|
# Define commands
|
2012-02-05 20:38:10 +01:00
|
|
|
CMD_7z="`which 7z`" ; builder_check_error "Command '7z' not installed"
|
|
|
|
CMD_unzip="`which unzip`" ; builder_check_error "Command 'unzip' not installed"
|
2012-02-18 15:18:46 +01:00
|
|
|
CMD_unrar="`which unrar`" ; builder_check_error "Command 'unrar' not installed"
|
2012-02-05 20:38:10 +01:00
|
|
|
CMD_zip="`which zip`" ; builder_check_error "Command 'zip' not installed"
|
2012-04-20 03:30:46 +02:00
|
|
|
CMD_lha="`which lha`" ; builder_check_error "Command 'lha' not installed"
|
2012-05-16 06:32:07 +02:00
|
|
|
CMD_tar="`which tar`" ; builder_check_error "Command 'tar' not installed"
|
2012-02-05 20:38:10 +01:00
|
|
|
CMD_unix2dos="`which unix2dos`" ; builder_check_error "Command 'unix2dos' not installed"
|
|
|
|
CMD_identify="`which identify`" ; builder_check_error "Command 'identify' (ImageMagick) not installed"
|
|
|
|
CMD_zsyncmake="`which zsyncmake`" ; builder_check_error "Command 'zsyncmake' not installed"
|
2012-02-06 01:15:25 +01:00
|
|
|
CMD_comm="`which comm`" ; builder_check_error "Command 'comm' not installed"
|
2012-02-07 09:02:43 +01:00
|
|
|
CMD_sha1sum="`which sha1sum`" ; builder_check_error "Command 'sha1sum' not installed"
|
2012-02-03 14:41:08 +01:00
|
|
|
|
2012-01-27 01:04:47 +01:00
|
|
|
# Check temp dir
|
|
|
|
test -d ${TMP_DIR}
|
|
|
|
builder_check_error "temp directory not available: $TMP_DIR"
|
|
|
|
|
2012-01-28 11:20:26 +01:00
|
|
|
# project dependent configuration
|
2012-01-28 10:27:46 +01:00
|
|
|
local config=${PRODUCT_DIR}/builder-product.cfg
|
2012-01-30 23:07:08 +01:00
|
|
|
test -f ${config} || builder_check_error "cannot read product config: ${config}"
|
2012-01-28 10:27:46 +01:00
|
|
|
. ${config}
|
2012-01-27 01:04:47 +01:00
|
|
|
|
2012-01-28 11:20:26 +01:00
|
|
|
# set default build configuration and source the user dependent file
|
|
|
|
local config=$BASEDIR/conf/opsi-builder.cfg
|
|
|
|
. ${config}
|
|
|
|
|
|
|
|
# Source local build configuration (must be done AFTER sourcing the builder-product.cfg.cfg)
|
|
|
|
if [ -f "$OPSI_BUILDER" ] ; then
|
|
|
|
config=$OPSI_BUILDER
|
|
|
|
else
|
|
|
|
test -f $HOME/.opsi-builder.cfg && config=$HOME/.opsi-builder.cfg
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Read ONLY the STATUS variable from the build configuration file
|
2012-02-01 22:32:30 +01:00
|
|
|
eval "`grep -E "^(STATUS|STATUS_INTEGRATION_RELEASE)=" $config`"
|
2012-01-28 11:20:26 +01:00
|
|
|
|
|
|
|
# change some variable from the builder-product.cfg dynamically:
|
|
|
|
# autogenerate release number, if we are in status "integration"
|
2012-01-28 10:29:54 +01:00
|
|
|
if [ "$STATUS" = "integration" ] ; then
|
2012-02-06 14:20:56 +01:00
|
|
|
if [ "${STATUS_INTEGRATION_RELEASE}" = "func:inc1" ] ; then
|
|
|
|
. ${config}
|
|
|
|
calc_release
|
|
|
|
else
|
|
|
|
# OPSI/control:RELEASE is limited to max 16 chars - take care in regards to the CREATOR_TAG
|
|
|
|
RELEASE="${STATUS_INTEGRATION_RELEASE}"
|
|
|
|
fi
|
2012-01-28 10:29:54 +01:00
|
|
|
fi
|
|
|
|
|
2012-01-28 11:20:26 +01:00
|
|
|
# Read configurationfile
|
|
|
|
. ${config}
|
|
|
|
echo "Loaded builder configuration: $config"
|
2012-01-27 01:04:47 +01:00
|
|
|
|
|
|
|
# Check variables
|
|
|
|
if [ -z ${OPSI_REPOS_BASE_DIR} ] || [ ! -d ${OPSI_REPOS_BASE_DIR} ] ; then
|
|
|
|
echo "configuration error: OPSI_REPOS_BASE_DIR directory does not exist: $OPSI_REPOS_BASE_DIR"
|
|
|
|
exit 2
|
|
|
|
fi
|
2012-01-30 23:07:08 +01:00
|
|
|
|
2012-02-02 17:29:06 +01:00
|
|
|
if [ "$TYPE" != "public" ] && [ "$TYPE" != "restricted" ] ; then
|
2012-01-30 23:07:08 +01:00
|
|
|
fatal_error "unknown TYPE: $TYPE"
|
|
|
|
fi
|
|
|
|
|
2012-02-06 01:15:25 +01:00
|
|
|
# Check, if variable is numeric
|
|
|
|
if [ ! `expr ${OPSI_REPOS_PURGE_LIMIT} + 1 2> /dev/null` ] ; then
|
|
|
|
fatal_error "OPSI_REPOS_PURGE_LIMIT must be numeric"
|
|
|
|
fi
|
|
|
|
|
2012-01-27 01:04:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#####################
|
|
|
|
# Prepare build
|
|
|
|
####################
|
|
|
|
builder_prepare() {
|
2012-02-05 20:38:10 +01:00
|
|
|
echo "builder_prepare: "
|
2012-01-27 01:04:47 +01:00
|
|
|
# Check if the package is still build
|
2012-02-06 01:15:25 +01:00
|
|
|
if [ "$OPSI_REPOS_FORCE_UPLOAD" != "true" ] && [ -f "${OPSI_REPOS_PRODUCT_DIR}/${OPSI_REPOS_FILE_PATTERN}.opsi" ] ; then
|
|
|
|
echo "File ${OPSI_REPOS_PRODUCT_DIR}/${OPSI_REPOS_FILE_PATTERN}.opsi already exists."
|
2012-01-27 01:04:47 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p $DIST_CACHE_DIR
|
2012-02-05 20:38:10 +01:00
|
|
|
log_debug "Distribution directory: $DIST_CACHE_DIR"
|
2012-01-27 01:04:47 +01:00
|
|
|
|
|
|
|
# setup work directory
|
2012-02-06 21:09:13 +01:00
|
|
|
OUTPUT_DIR="$TMP_DIR/opsi-builder.`date +%Y%m%d-%H%M%S`.$$"
|
2012-02-05 20:38:10 +01:00
|
|
|
mkdir -p ${OUTPUT_DIR}
|
|
|
|
builder_check_error "Cannot create temp directory ${OUTPUT_DIR}"
|
2012-01-27 01:04:47 +01:00
|
|
|
|
2012-01-29 15:10:08 +01:00
|
|
|
# prepare
|
|
|
|
INST_DIR=$OUTPUT_DIR/$PN
|
|
|
|
mkdir $INST_DIR
|
|
|
|
|
2012-02-05 20:38:10 +01:00
|
|
|
log_info " OUTPUT_DIR: $OUTPUT_DIR"
|
2012-01-27 01:04:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#####################
|
|
|
|
# Download all dist files from one of the defined URLs.
|
|
|
|
# and validate the checksum
|
|
|
|
####################
|
|
|
|
builder_retrieve() {
|
|
|
|
|
2012-01-30 23:07:08 +01:00
|
|
|
for (( i = 0 ; i < ${#DL_SOURCE[@]} ; i++ )) ; do
|
|
|
|
local basename=${DL_FILE[$i]}
|
|
|
|
local urls=${DL_SOURCE[$i]}
|
|
|
|
local arch=${DL_ARCH[$i]}
|
2012-01-28 10:29:54 +01:00
|
|
|
local downloaded=0
|
2012-01-29 09:11:01 +01:00
|
|
|
|
|
|
|
# Add private repos to the urls
|
2012-01-27 01:04:47 +01:00
|
|
|
if [ ! -z ${DIST_PRIVATE_REPOS} ]; then
|
|
|
|
urls="${DIST_PRIVATE_REPOS}/$basename;$urls"
|
|
|
|
fi
|
2012-02-01 14:37:59 +01:00
|
|
|
|
2012-01-29 09:11:01 +01:00
|
|
|
# check existence of CRC file only in non devel mode
|
2012-02-01 14:37:59 +01:00
|
|
|
if [ ! -e "${PRODUCT_DIR}/${basename}.sha1sum" ] && [ "$CHECKSUM_AUTOCREATE" != "true" ] ; then
|
|
|
|
fatal_error "You need to create the checksums with: sha1sum ${DIST_CACHE_DIR}/${basename} > ${PRODUCT_DIR}/${basename}.sha1sum"
|
2012-01-27 01:04:47 +01:00
|
|
|
fi
|
2012-01-29 09:11:01 +01:00
|
|
|
|
2012-01-27 01:04:47 +01:00
|
|
|
echo "Downloading $basename"
|
2012-01-29 09:11:01 +01:00
|
|
|
# check downloading from the defined URLs
|
2012-01-30 23:07:08 +01:00
|
|
|
for src in `echo $urls | sed -e 's/[;,]/\n/g'` ; do
|
2012-01-27 01:04:47 +01:00
|
|
|
if [ $downloaded == 1 ]; then continue; fi
|
|
|
|
|
2012-02-01 14:37:59 +01:00
|
|
|
# Download file
|
2012-01-27 01:04:47 +01:00
|
|
|
echo " Info: Downloding from $src"
|
2012-01-30 23:07:08 +01:00
|
|
|
local downloader=${DL_DOWNLOADER[$i]}
|
|
|
|
if [ -z $downloader ]; then downloader="wget" ; fi
|
|
|
|
|
2012-01-27 01:04:47 +01:00
|
|
|
mkdir -p ${DIST_CACHE_DIR}/$arch
|
2012-01-30 23:07:08 +01:00
|
|
|
DL_DIST_FILE[$i]=${DIST_CACHE_DIR}/$arch/$basename
|
|
|
|
retrieve_file $downloader $src ${DL_DIST_FILE[$i]}
|
2012-01-27 01:04:47 +01:00
|
|
|
|
2012-02-01 14:37:59 +01:00
|
|
|
if [ $? != 0 ] ; then
|
|
|
|
echo " Warning: Failed to download file - try next URL"
|
|
|
|
continue;
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check sha1
|
|
|
|
if [ ! -e "${PRODUCT_DIR}/${basename}.sha1sum" ] && [ "$CHECKSUM_AUTOCREATE" == "true" ] ; then
|
2012-02-07 09:02:43 +01:00
|
|
|
$CMD_sha1sum ${DL_DIST_FILE[$i]} > ${PRODUCT_DIR}/${basename}.sha1sum
|
2012-02-01 14:37:59 +01:00
|
|
|
downloaded=1
|
|
|
|
echo " WARNING: SHA1 checksum (${DL_DIST_FILE[$i]}.sha1sum) was created dynamically because auf CHECKSUM_AUTOCREATE=$CHECKSUM_AUTOCREATE"
|
|
|
|
else
|
2012-01-27 01:04:47 +01:00
|
|
|
# testing the checksum of the downloaded files
|
2012-01-30 23:07:08 +01:00
|
|
|
local sha1sum_val=`cat ${PRODUCT_DIR}/${basename}.sha1sum | cut -d " " -f1`
|
|
|
|
local checksum_val=`sha1sum ${DL_DIST_FILE[$i]} | cut -d " " -f1`
|
2012-02-07 09:02:43 +01:00
|
|
|
if [ "$checksum_val" = "$sha1sum_val" ] ; then
|
2012-01-27 01:04:47 +01:00
|
|
|
downloaded=1
|
|
|
|
fi
|
|
|
|
fi
|
2012-02-01 14:37:59 +01:00
|
|
|
|
|
|
|
# Print result
|
|
|
|
if [ "$downloaded" == "1" ] ; then
|
|
|
|
echo " Info: Downloaded successfully"
|
|
|
|
else
|
|
|
|
echo " Error: The checksums do not match - try next URL"
|
|
|
|
fi
|
|
|
|
|
2012-01-27 01:04:47 +01:00
|
|
|
done
|
|
|
|
echo
|
|
|
|
|
|
|
|
# Ups - no URL works
|
|
|
|
if [ $downloaded != 1 ] ; then
|
|
|
|
echo " Error: can download the file or checksum wrong (sha1sum ${DIST_CACHE_DIR}/${basename} > ${basename}.sha1sum)"
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
#####################
|
|
|
|
# Create files
|
|
|
|
####################
|
|
|
|
builder_create() {
|
|
|
|
|
2012-01-28 12:27:03 +01:00
|
|
|
# Copy files and convert text files to dos format
|
|
|
|
cp -Rv ${PRODUCT_DIR}/OPSI $INST_DIR
|
|
|
|
cp -Rv ${PRODUCT_DIR}/CLIENT_DATA $INST_DIR
|
2012-02-05 20:38:10 +01:00
|
|
|
find $INST_DIR/CLIENT_DATA -type f | xargs -n1 -iREP sh -c 'file -i $0 | grep "text/plain" && '$CMD_unix2dos' $0 ' REP >/dev/null
|
2012-01-28 12:27:03 +01:00
|
|
|
|
2012-01-27 01:04:47 +01:00
|
|
|
# converting icon file
|
2012-01-30 23:07:08 +01:00
|
|
|
local iconfile_src=${DL_DIST_FILE[$ICON_DL_INDEX]}
|
2012-01-28 10:29:54 +01:00
|
|
|
ICONFILE=$OUTPUT_DIR/$PN.png
|
2012-01-29 16:58:12 +01:00
|
|
|
convert_image $iconfile_src $ICONFILE
|
2012-01-28 12:27:03 +01:00
|
|
|
cp -a $ICONFILE $INST_DIR/CLIENT_DATA
|
2012-01-28 10:29:54 +01:00
|
|
|
|
2012-01-27 01:04:47 +01:00
|
|
|
# copy binaries
|
2012-01-30 23:07:08 +01:00
|
|
|
for (( i = 0 ; i < ${#DL_SOURCE[@]} ; i++ )) ; do
|
|
|
|
DL_EXTRACT_PATH[$i]=${INST_DIR}/CLIENT_DATA/${DL_ARCH[$i]}/${DL_EXTRACT_TO[$i]}
|
|
|
|
local format=${DL_EXTRACT_FORMAT[$i]}
|
|
|
|
if [ -z "$format" ] ; then format="cp"; fi
|
2012-01-28 10:29:54 +01:00
|
|
|
|
2012-01-30 23:07:08 +01:00
|
|
|
mkdir -p ${DL_EXTRACT_PATH[$i]}
|
|
|
|
process_file $format ${DL_DIST_FILE[$i]} ${DL_EXTRACT_PATH[$i]}
|
2012-01-27 01:04:47 +01:00
|
|
|
done
|
2012-01-28 10:29:54 +01:00
|
|
|
|
2012-01-30 23:07:08 +01:00
|
|
|
# create winst variables
|
|
|
|
local var_file=${OUTPUT_DIR}/variable.ins
|
|
|
|
create_winst_varfile $var_file
|
2012-01-27 01:04:47 +01:00
|
|
|
|
|
|
|
# add the new vaiables to all *.ins winst files
|
2012-01-28 12:27:03 +01:00
|
|
|
for inst_file in `find ${INST_DIR}/CLIENT_DATA -type f -name "*.ins"` ; do
|
2012-01-27 02:35:40 +01:00
|
|
|
sed -i -e "/@@BUILDER_VARIABLES@@/ {
|
|
|
|
r "$var_file"
|
|
|
|
d
|
|
|
|
}" $inst_file
|
2012-01-27 01:04:47 +01:00
|
|
|
done
|
|
|
|
|
2012-01-30 23:07:08 +01:00
|
|
|
# replace variables from file OPSI/control
|
2012-01-28 10:29:54 +01:00
|
|
|
local release_new=${CREATOR_TAG}${RELEASE}
|
2012-01-28 12:27:03 +01:00
|
|
|
sed -e "s!VERSION!$VERSION!g" -e "s!RELEASE!${release_new}!g" -e "s!PRIORITY!$PRIORITY!g" -e "s!ADVICE!$ADVICE!g" ${PRODUCT_DIR}/OPSI/control >$INST_DIR/OPSI/control
|
2012-01-27 01:04:47 +01:00
|
|
|
|
|
|
|
# Create changelog based on git - if available
|
|
|
|
if [ -d "${PRODUCT_DIR}/.git" ] ; then
|
|
|
|
git log --date-order --date=short | \
|
|
|
|
sed -e '/^commit.*$/d' | \
|
|
|
|
awk '/^Author/ {sub(/\\$/,""); getline t; print $0 t; next}; 1' | \
|
|
|
|
sed -e 's/^Author: //g' | \
|
|
|
|
sed -e 's/>Date: \([0-9]*-[0-9]*-[0-9]*\)/>\t\1/g' | \
|
2012-01-28 12:27:03 +01:00
|
|
|
sed -e 's/^\(.*\) \(\)\t\(.*\)/\3 \1 \2/g' > $INST_DIR/OPSI/changelog.txt
|
2012-01-27 01:04:47 +01:00
|
|
|
else
|
|
|
|
echo "No git repository present."
|
|
|
|
fi
|
|
|
|
|
2012-01-28 12:27:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#####################
|
|
|
|
# build opsi package
|
|
|
|
#####################
|
|
|
|
builder_package() {
|
2012-01-27 01:04:47 +01:00
|
|
|
|
2012-01-28 12:27:03 +01:00
|
|
|
# creating package
|
|
|
|
local release_new=${CREATOR_TAG}${RELEASE}
|
2012-01-28 10:29:54 +01:00
|
|
|
local opsi_file=${PN}_${VERSION}-${release_new}.opsi
|
2012-01-30 23:07:08 +01:00
|
|
|
|
2012-01-28 10:29:54 +01:00
|
|
|
pushd ${OUTPUT_DIR}
|
2012-01-28 12:27:03 +01:00
|
|
|
rm -f ${opsi_file} ${OPSI_REPOS_FILE_PATTERN}.opsi
|
2012-01-28 19:13:08 +01:00
|
|
|
LANG="C" opsi-makeproductfile -v $INST_DIR
|
2012-01-27 01:04:47 +01:00
|
|
|
builder_check_error "Building OPSI-package"
|
|
|
|
popd
|
|
|
|
|
|
|
|
# rename opsi package file
|
2012-01-28 12:27:03 +01:00
|
|
|
if [ "${opsi_file}" != "${OPSI_REPOS_FILE_PATTERN}.opsi" ]; then
|
|
|
|
mv ${OUTPUT_DIR}/${opsi_file} ${OUTPUT_DIR}/${OPSI_REPOS_FILE_PATTERN}.opsi
|
|
|
|
builder_check_error "can't move file ${OUTPUT_DIR}/${opsi_file} ${OUTPUT_DIR}/${OPSI_REPOS_FILE_PATTERN}.opsi"
|
2012-01-27 01:04:47 +01:00
|
|
|
fi
|
|
|
|
|
2012-02-07 09:02:43 +01:00
|
|
|
# --exclude \*/.git\*
|
2012-02-01 22:32:30 +01:00
|
|
|
# create source- and binary package package
|
2012-02-07 09:02:43 +01:00
|
|
|
test "${OPSI_REPOS_UPLOAD_BIN}" = "true" && $CMD_zip --exclude \*/.git\* @ -r ${OUTPUT_DIR}/${OPSI_REPOS_FILE_PATTERN}.zip $INST_DIR
|
|
|
|
test "${OPSI_REPOS_UPLOAD_SOURCE}" = "true" && $CMD_zip --exclude \*/.git\* @ -r ${OUTPUT_DIR}/${OPSI_REPOS_FILE_PATTERN}-src.zip ${PRODUCT_DIR}
|
2012-01-27 01:04:47 +01:00
|
|
|
}
|
|
|
|
|
2012-01-30 23:07:08 +01:00
|
|
|
|
2012-01-27 01:04:47 +01:00
|
|
|
#####################
|
2012-01-28 12:27:03 +01:00
|
|
|
# publish
|
2012-01-27 01:04:47 +01:00
|
|
|
#####################
|
|
|
|
builder_publish() {
|
|
|
|
|
|
|
|
# Upload file to repository
|
|
|
|
mkdir -p ${OPSI_REPOS_PRODUCT_DIR}
|
2012-01-28 12:27:03 +01:00
|
|
|
|
|
|
|
echo "Publishing opsi-package to ${OPSI_REPOS_PRODUCT_DIR}"
|
|
|
|
local src=${OUTPUT_DIR}/${OPSI_REPOS_FILE_PATTERN}
|
2012-01-27 10:00:40 +01:00
|
|
|
local dst=${OPSI_REPOS_PRODUCT_DIR}/${OPSI_REPOS_FILE_PATTERN}
|
2012-01-28 12:27:03 +01:00
|
|
|
|
|
|
|
# copy files
|
2012-02-01 22:32:30 +01:00
|
|
|
if [ "${OPSI_REPOS_UPLOAD_OPSI}" = "true" ] ; then
|
|
|
|
cp ${src}.opsi ${dst}.opsi
|
|
|
|
builder_check_error "Can't upload file $dst.opsi --> $dst.opsi"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "${OPSI_REPOS_UPLOAD_BIN}" = "true" ] ; then
|
|
|
|
cp ${src}.zip ${dst}.zip
|
|
|
|
builder_check_error "Can't upload file $dst.zip --> $dst.zip"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "${OPSI_REPOS_UPLOAD_SOURCE}" = "true" ] ; then
|
|
|
|
cp ${src}-src.zip ${dst}-src.zip
|
|
|
|
builder_check_error "Can't upload file ${dst}-src.zip --> ${dst}-src.zip"
|
|
|
|
fi
|
|
|
|
|
2012-02-04 10:55:24 +01:00
|
|
|
if [ "${OPSI_REPOS_OPSIMANAGER_INSTALL}" = "true" ] ; then
|
2012-02-05 20:38:10 +01:00
|
|
|
opsi-package-manager -i -v ${src}.opsi
|
|
|
|
builder_check_error "Can't install ${src}.opsi"
|
2012-02-04 10:55:24 +01:00
|
|
|
fi
|
|
|
|
|
2012-02-01 22:32:30 +01:00
|
|
|
if [ "${OPSI_REPOS_UPLOAD_OPSI_ZSYNC}" = "true" ] ; then
|
2012-02-05 20:38:10 +01:00
|
|
|
md5sum "${src}.opsi" | sed 's/ .*//' > ${dst}.opsi.md5
|
2012-02-01 22:32:30 +01:00
|
|
|
builder_check_error "Can't create md5 file"
|
|
|
|
|
2012-02-05 20:38:10 +01:00
|
|
|
${CMD_zsyncmake} -u ${OPSI_REPOS_FILE_PATTERN}.opsi -o "${dst}.opsi.zsync" "${src}.opsi"
|
2012-02-01 22:32:30 +01:00
|
|
|
builder_check_error "Can't create zsync file"
|
|
|
|
fi
|
|
|
|
|
2012-02-06 01:15:25 +01:00
|
|
|
# Create revision file for this
|
|
|
|
local rev_file=${OPSI_REPOS_PRODUCT_DIR}/${PN}-${VERSION}-${CREATOR_TAG}${RELEASE}.cfg
|
|
|
|
cat > $rev_file <<EOF
|
2012-02-06 19:13:57 +01:00
|
|
|
REV_VENDOR=${VENDOR}
|
2012-02-06 01:15:25 +01:00
|
|
|
REV_PN=${PN}
|
|
|
|
REV_VERSION=${VERSION}
|
|
|
|
REV_RELEASE=${RELEASE}
|
2012-02-06 19:13:57 +01:00
|
|
|
REV_TYPE=${TYPE}
|
|
|
|
REV_STATUS=${STATUS}
|
|
|
|
REV_TIMESTAMP=`date +"%s"`
|
2012-02-06 01:15:25 +01:00
|
|
|
REV_CREATOR_TAG=${CREATOR_TAG}
|
|
|
|
REV_OPSI_REPOS_FILE_PATTERN=${OPSI_REPOS_FILE_PATTERN}
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
|
|
# Purge old product versions - defined by limit OPSI_REPOS_PURGE_LIMIT
|
2012-02-06 19:13:57 +01:00
|
|
|
if [ "${OPSI_REPOS_PURGE}" = "true" ] && [ ! -z "${OPSI_REPOS_PURGE_LIMIT}" ] && [ "${OPSI_REPOS_PURGE_LIMIT}" > 0 ] && [ "${STATUS}" = "${OPSI_REPOS_PURGE_STATUS}" ] ; then
|
2012-02-06 01:15:25 +01:00
|
|
|
echo "Autopurging enabled"
|
2012-02-06 14:20:56 +01:00
|
|
|
|
|
|
|
# determinte max version to delete
|
2012-02-06 01:15:25 +01:00
|
|
|
local limit
|
2012-04-23 12:13:59 +02:00
|
|
|
local pn_limit=`echo ${PN} | sed "s/[\.\-]/_/g"`
|
2012-04-23 11:11:37 +02:00
|
|
|
eval "`echo limit=\\$\\{OPSI_REPOS_PURGE_LIMIT_${pn_limit}\\}`"
|
2012-02-07 09:02:43 +01:00
|
|
|
if [ -z "$limit" ] || [ ! `expr $limit + 1 2>/dev/null` ] ; then
|
2012-02-06 01:15:25 +01:00
|
|
|
limit=${OPSI_REPOS_PURGE_LIMIT}
|
|
|
|
fi
|
|
|
|
echo " Purging, max. number of versions: $limit"
|
|
|
|
|
2012-02-06 14:20:56 +01:00
|
|
|
# Find all revision files and sort them
|
2012-02-06 01:15:25 +01:00
|
|
|
local file_list=${OUTPUT_DIR}/product-file-list.txt
|
2012-02-06 14:20:56 +01:00
|
|
|
local file_sort_list=${OUTPUT_DIR}/product-file-sort-list.txt
|
|
|
|
rm -f ${file_list}
|
|
|
|
for cfg_file in `find ${OPSI_REPOS_BASE_DIR} -name "${PN}-${VERSION}-${CREATOR_TAG}*.cfg" -print ` ; do
|
|
|
|
. ${cfg_file}
|
|
|
|
printf "%08d;$cfg_file\n" $REV_RELEASE >> ${file_list}
|
|
|
|
done
|
|
|
|
sort -n ${file_list} > ${file_sort_list}
|
|
|
|
|
|
|
|
# Delete the oldest files
|
|
|
|
log_debug "base list for calculate purge:"
|
|
|
|
for cfg_sort_file in `tail -${limit} ${file_sort_list} | ${CMD_comm} -13 - ${file_sort_list}` ; do
|
|
|
|
|
|
|
|
local cfg_file=`echo $cfg_sort_file | cut -f 2 -d ";"`
|
2012-02-06 01:15:25 +01:00
|
|
|
. ${cfg_file}
|
2012-02-06 19:13:57 +01:00
|
|
|
if [ "${REV_STATUS}" != "${OPSI_REPOS_PURGE_STATUS}" ] ; then continue; fi
|
2012-02-06 01:15:25 +01:00
|
|
|
|
2012-02-06 19:13:57 +01:00
|
|
|
dir_base=`dirname ${cfg_file}`
|
2012-02-06 01:15:25 +01:00
|
|
|
product_file="${dir_base}/${REV_OPSI_REPOS_FILE_PATTERN}"
|
2012-02-07 09:02:43 +01:00
|
|
|
echo " Purging product version: $product_file*"
|
2012-02-06 01:15:25 +01:00
|
|
|
|
|
|
|
# Paranoid ... check the files to delete first
|
2012-02-07 09:02:43 +01:00
|
|
|
if [ ! -z "${dir_base}" ] && [ -d "${OPSI_REPOS_BASE_DIR}" ] && [ ! -z "$product_file" ] ; then
|
|
|
|
rm -f ${product_file}* ${cfg_file}
|
2012-02-06 14:20:56 +01:00
|
|
|
|
|
|
|
# remove directory - if it's empty
|
|
|
|
if [ $(ls -1A ${dir_base} | wc -l) -eq 0 ]; then
|
|
|
|
rmdir ${dir_base}
|
|
|
|
fi
|
|
|
|
fi
|
2012-02-06 01:15:25 +01:00
|
|
|
done
|
|
|
|
fi
|
2012-01-27 01:04:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
###################
|
|
|
|
# Commiting changes to repos
|
|
|
|
###################
|
|
|
|
builder_commit() {
|
|
|
|
if [ -d "${PRODUCT_DIR}/.git" ]; then
|
|
|
|
echo -n
|
2012-01-30 23:07:08 +01:00
|
|
|
log_debug "builder_commit() not implemented yet."
|
2012-01-27 01:04:47 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#####################
|
|
|
|
# build opsi package
|
|
|
|
#####################
|
|
|
|
builder_cleanup() {
|
|
|
|
# Paranoia
|
2012-01-28 10:29:54 +01:00
|
|
|
if [ -d "$OUTPUT_DIR" ] && [[ $OUTPUT_DIR == $TMP_DIR/opsi-builder.* ]] ; then
|
|
|
|
rm -rf $OUTPUT_DIR
|
2012-01-27 01:04:47 +01:00
|
|
|
fi
|
|
|
|
}
|