- code restructured: move code from builder_package to _create
This commit is contained in:
parent
353bd1754c
commit
2b2446002b
@ -41,8 +41,7 @@ OPSI_REPOS_BASE_DIR=$HOME/.opsi-repository
|
|||||||
OPSI_REPOS_PRODUCT_DIR=${OPSI_REPOS_BASE_DIR}/${STATUS}/${VENDOR}/${PN}/${VERSION}-${RELEASE}
|
OPSI_REPOS_PRODUCT_DIR=${OPSI_REPOS_BASE_DIR}/${STATUS}/${VENDOR}/${PN}/${VERSION}-${RELEASE}
|
||||||
|
|
||||||
# OPSI-package filepattern
|
# OPSI-package filepattern
|
||||||
OPSI_REPOS_FILE_PATTERN=${PN}_${VERSION}-${CREATOR_TAG}${RELEASE}.opsi
|
OPSI_REPOS_FILE_PATTERN=${PN}_${VERSION}-${CREATOR_TAG}${RELEASE}
|
||||||
|
|
||||||
|
|
||||||
# Force alway upload to opsi repos
|
# Force alway upload to opsi repos
|
||||||
# OPSI_REPOS_FORCE_UPLOAD=1
|
# OPSI_REPOS_FORCE_UPLOAD=1
|
||||||
|
@ -57,8 +57,8 @@ builder_config() {
|
|||||||
builder_prepare() {
|
builder_prepare() {
|
||||||
|
|
||||||
# Check if the package is still build
|
# Check if the package is still build
|
||||||
if [ -z "$OPSI_REPOS_FORCE_UPLOAD" ] && [ -f ${OPSI_REPOS_PRODUCT_DIR}/${OPSI_REPOS_FILE_PATTERN} ] ; then
|
if [ -z "$OPSI_REPOS_FORCE_UPLOAD" ] && [ -d ${OPSI_REPOS_PRODUCT_DIR} ] ; then
|
||||||
echo "ERROR: package ${OPSI_REPOS_PRODUCT_DIR}/${OPSI_REPOS_FILE_PATTERN} already generated"
|
echo "Directory ${OPSI_REPOS_PRODUCT_DIR} already exists."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -134,34 +134,29 @@ builder_retrieve() {
|
|||||||
####################
|
####################
|
||||||
builder_create() {
|
builder_create() {
|
||||||
|
|
||||||
|
# prepare
|
||||||
|
INST_DIR=$OUTPUT_DIR/$PN
|
||||||
|
mkdir $INST_DIR
|
||||||
|
|
||||||
|
# Copy files and convert text files to dos format
|
||||||
|
cp -Rv ${PRODUCT_DIR}/OPSI $INST_DIR
|
||||||
|
cp -Rv ${PRODUCT_DIR}/CLIENT_DATA $INST_DIR
|
||||||
|
find $INST_DIR/CLIENT_DATA -type f | xargs -n1 -iREP sh -c 'file -i $0 | grep "text/plain" && dos2unix $0' REP
|
||||||
|
|
||||||
# converting icon file
|
# converting icon file
|
||||||
local iconfile_src=${DIST_FILE[$ICON_FILE_INDEX]}
|
local iconfile_src=${DIST_FILE[$ICON_FILE_INDEX]}
|
||||||
ICONFILE=$OUTPUT_DIR/$PN.png
|
ICONFILE=$OUTPUT_DIR/$PN.png
|
||||||
convert -colorspace rgb $iconfile_src -transparent white -background transparent -resize 160x160 \
|
convert -colorspace rgb $iconfile_src -transparent white -background transparent -resize 160x160 \
|
||||||
-size 160x160 xc:transparent +swap -gravity center -composite $ICONFILE
|
-size 160x160 xc:transparent +swap -gravity center -composite $ICONFILE
|
||||||
builder_check_error "converting image"
|
builder_check_error "converting image"
|
||||||
|
cp -a $ICONFILE $INST_DIR/CLIENT_DATA
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#####################
|
|
||||||
# build opsi package
|
|
||||||
#####################
|
|
||||||
builder_package() {
|
|
||||||
|
|
||||||
# prepare
|
|
||||||
local inst_dir=$OUTPUT_DIR/$PN
|
|
||||||
mkdir $inst_dir
|
|
||||||
|
|
||||||
# Copy files and convert text files to dos format
|
|
||||||
cp -Rv ${PRODUCT_DIR}/OPSI $inst_dir
|
|
||||||
cp -Rv ${PRODUCT_DIR}/CLIENT_DATA $inst_dir
|
|
||||||
find $inst_dir/CLIENT_DATA -type f | xargs -n1 -iREP sh -c 'file -i $0 | grep "text/plain" && dos2unix $0' REP
|
|
||||||
|
|
||||||
# copy binaries
|
# copy binaries
|
||||||
for (( i = 0 ; i < ${#SOURCE[@]} ; i++ )) ; do
|
for (( i = 0 ; i < ${#SOURCE[@]} ; i++ )) ; do
|
||||||
distfile=${DIST_FILE[$i]}
|
distfile=${DIST_FILE[$i]}
|
||||||
mkdir -p $inst_dir/CLIENT_DATA/${ARCH[$i]}
|
mkdir -p $INST_DIR/CLIENT_DATA/${ARCH[$i]}
|
||||||
cp ${DIST_FILE[$i]} $inst_dir/CLIENT_DATA/${ARCH[$i]}
|
cp ${DIST_FILE[$i]} $INST_DIR/CLIENT_DATA/${ARCH[$i]}
|
||||||
done
|
done
|
||||||
|
|
||||||
# create variables
|
# create variables
|
||||||
@ -181,14 +176,13 @@ builder_package() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
# copy image and create variable
|
# copy image and create variable
|
||||||
cp -a $ICONFILE $inst_dir/CLIENT_DATA
|
|
||||||
echo "DefVar \$IconFile\$" >>$var_file
|
echo "DefVar \$IconFile\$" >>$var_file
|
||||||
echo "Set \$IconFile\$ = \"%ScriptPath%\\`basename $ICONFILE`\"" >>$var_file
|
echo "Set \$IconFile\$ = \"%ScriptPath%\\`basename $ICONFILE`\"" >>$var_file
|
||||||
|
|
||||||
echo >>$var_file
|
echo >>$var_file
|
||||||
|
|
||||||
# add the new vaiables to all *.ins winst files
|
# add the new vaiables to all *.ins winst files
|
||||||
for inst_file in `find ${inst_dir}/CLIENT_DATA -type f -name "*.ins"` ; do
|
for inst_file in `find ${INST_DIR}/CLIENT_DATA -type f -name "*.ins"` ; do
|
||||||
sed -i -e "/@@BUILDER_VARIABLES@@/ {
|
sed -i -e "/@@BUILDER_VARIABLES@@/ {
|
||||||
r "$var_file"
|
r "$var_file"
|
||||||
d
|
d
|
||||||
@ -197,7 +191,7 @@ builder_package() {
|
|||||||
|
|
||||||
# replace variables from OPSI control
|
# replace variables from OPSI control
|
||||||
local release_new=${CREATOR_TAG}${RELEASE}
|
local release_new=${CREATOR_TAG}${RELEASE}
|
||||||
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
|
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
|
||||||
|
|
||||||
# Create changelog based on git - if available
|
# Create changelog based on git - if available
|
||||||
if [ -d "${PRODUCT_DIR}/.git" ] ; then
|
if [ -d "${PRODUCT_DIR}/.git" ] ; then
|
||||||
@ -206,41 +200,53 @@ builder_package() {
|
|||||||
awk '/^Author/ {sub(/\\$/,""); getline t; print $0 t; next}; 1' | \
|
awk '/^Author/ {sub(/\\$/,""); getline t; print $0 t; next}; 1' | \
|
||||||
sed -e 's/^Author: //g' | \
|
sed -e 's/^Author: //g' | \
|
||||||
sed -e 's/>Date: \([0-9]*-[0-9]*-[0-9]*\)/>\t\1/g' | \
|
sed -e 's/>Date: \([0-9]*-[0-9]*-[0-9]*\)/>\t\1/g' | \
|
||||||
sed -e 's/^\(.*\) \(\)\t\(.*\)/\3 \1 \2/g' > $inst_dir/OPSI/changelog.txt
|
sed -e 's/^\(.*\) \(\)\t\(.*\)/\3 \1 \2/g' > $INST_DIR/OPSI/changelog.txt
|
||||||
else
|
else
|
||||||
echo "No git repository present."
|
echo "No git repository present."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Callback
|
|
||||||
call_entry_point result cb_package_makeproductfile
|
|
||||||
|
|
||||||
# building package
|
|
||||||
local opsi_file=${PN}_${VERSION}-${release_new}.opsi
|
|
||||||
pushd ${OUTPUT_DIR}
|
|
||||||
rm -f ${opsi_file} $OPSI_REPOS_FILE_PATTERN
|
|
||||||
opsi-makeproductfile -v $inst_dir
|
|
||||||
builder_check_error "Building OPSI-package"
|
|
||||||
popd
|
|
||||||
|
|
||||||
# rename opsi package file
|
|
||||||
if [ "${opsi_file}" != "$OPSI_REPOS_FILE_PATTERN" ]; then
|
|
||||||
mv ${OUTPUT_DIR}/${opsi_file} ${OUTPUT_DIR}/$OPSI_REPOS_FILE_PATTERN
|
|
||||||
builder_check_error "can't move file ${OUTPUT_DIR}/${opsi_file} ${OUTPUT_DIR}/$OPSI_REPOS_FILE_PATTERN"
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#####################
|
#####################
|
||||||
# build opsi package
|
# build opsi package
|
||||||
#####################
|
#####################
|
||||||
|
builder_package() {
|
||||||
|
|
||||||
|
# creating package
|
||||||
|
local release_new=${CREATOR_TAG}${RELEASE}
|
||||||
|
local opsi_file=${PN}_${VERSION}-${release_new}.opsi
|
||||||
|
pushd ${OUTPUT_DIR}
|
||||||
|
rm -f ${opsi_file} ${OPSI_REPOS_FILE_PATTERN}.opsi
|
||||||
|
opsi-makeproductfile -v $INST_DIR
|
||||||
|
builder_check_error "Building OPSI-package"
|
||||||
|
popd
|
||||||
|
|
||||||
|
# rename opsi package file
|
||||||
|
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"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# create source package
|
||||||
|
zip -r ${OUTPUT_DIR}/${OPSI_REPOS_FILE_PATTERN}.zip $INST_DIR
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#####################
|
||||||
|
# publish
|
||||||
|
#####################
|
||||||
builder_publish() {
|
builder_publish() {
|
||||||
|
|
||||||
# Upload file to repository
|
# Upload file to repository
|
||||||
mkdir -p ${OPSI_REPOS_PRODUCT_DIR}
|
mkdir -p ${OPSI_REPOS_PRODUCT_DIR}
|
||||||
local src=$OUTPUT_DIR/${OPSI_REPOS_FILE_PATTERN}
|
|
||||||
|
echo "Publishing opsi-package to ${OPSI_REPOS_PRODUCT_DIR}"
|
||||||
|
local src=${OUTPUT_DIR}/${OPSI_REPOS_FILE_PATTERN}
|
||||||
local dst=${OPSI_REPOS_PRODUCT_DIR}/${OPSI_REPOS_FILE_PATTERN}
|
local dst=${OPSI_REPOS_PRODUCT_DIR}/${OPSI_REPOS_FILE_PATTERN}
|
||||||
echo "Publishing opsi-package to $dst"
|
|
||||||
cp $src $dst
|
# copy files
|
||||||
|
cp ${src}.opsi ${dst}.opsi
|
||||||
builder_check_error "Can't upload file $dst --> $dst"
|
builder_check_error "Can't upload file $dst --> $dst"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
#
|
#
|
||||||
# Abstract:
|
# Abstract:
|
||||||
# target order: config, prepare, retrieve, create, package, publish, commit, cleanup
|
# target order: config, prepare, retrieve, create, package, publish, commit, cleanup
|
||||||
# callbacks: cb_package_makeproductfile
|
# callbacks: <none>
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
@ -45,10 +45,6 @@ function package() {
|
|||||||
builder_package
|
builder_package
|
||||||
}
|
}
|
||||||
|
|
||||||
function cb_package_makeproductfile() {
|
|
||||||
echo "May add/replace files to the files to $inst_dir"
|
|
||||||
}
|
|
||||||
|
|
||||||
function publish() {
|
function publish() {
|
||||||
echo "Publish"
|
echo "Publish"
|
||||||
builder_publish
|
builder_publish
|
||||||
|
Loading…
Reference in New Issue
Block a user