summaryrefslogtreecommitdiff
path: root/lib/builder-utils.sh
diff options
context:
space:
mode:
authorMario Fetka <[email protected]>2013-09-09 03:06:01 (GMT)
committer Mario Fetka <[email protected]>2013-09-09 03:06:01 (GMT)
commitdf3c29f0d90c1c6afa11de4b948ec038745fe1e0 (patch)
treee5bc9a4bbac41c04b0c04052dab6230b260563ff /lib/builder-utils.sh
parent019b384e8a123e686edd27ef3b9ba8f23260b30d (diff)
remove opsi and change to 7z create
Diffstat (limited to 'lib/builder-utils.sh')
-rw-r--r--lib/builder-utils.sh236
1 files changed, 55 insertions, 181 deletions
diff --git a/lib/builder-utils.sh b/lib/builder-utils.sh
index cb87ef8..88b5e77 100644
--- a/lib/builder-utils.sh
+++ b/lib/builder-utils.sh
@@ -138,159 +138,6 @@ log_info() {
fi
}
-###################
-# Convert image
-###################
-convert_image() {
- local src=$1
- local dst=$2
-
- local hight=`${CMD_identify} -format "%h" $src`
- local wight=`${CMD_identify} -format "%w" $src`
- ${CMD_identify} -format "%wx%h" $src
-
- # Add a white border to the image so that the convert to transparent can go around an image
- convert -bordercolor White -border 3x3 $src $OUTPUT_DIR/bigger.png
-
- # first resize the image to the new aspect ratio and add white borders
- if [ $wight -lt $hight ] ; then
- # Its higher so force x166 and let imagemagic decide the right wight
- # then add white to the rest of the image to fit 166x166
- log_debug "Icon Wight: $wight < Hight: $hight"
- convert $OUTPUT_DIR/bigger.png -colorspace RGB -resize x166 \
- -size 166x166 xc:white +swap -gravity center -composite \
- -modulate 110 -colors 256 png8:$OUTPUT_DIR/resize.png
- builder_check_error "converting image"
- elif [ $wight -gt $hight ] ; then
- # Its wider so force 166x and let imagemagic decide the right hight
- # then add white to the rest of the image to fit 166x166
- log_debug "Icon Wight: $wight > Hight: $hight"
- convert $OUTPUT_DIR/bigger.png -colorspace RGB -resize 166x \
- -size 166x166 xc:white +swap -gravity center -composite \
- -modulate 110 -colors 256 png8:$OUTPUT_DIR/resize.png
- builder_check_error "converting image"
- elif [ $wight -eq $hight ] ; then
- # Its scare so force 166x166
- log_debug "Icon Wight: $wight = Hight: $hight"
- convert $OUTPUT_DIR/bigger.png -colorspace RGB -resize 166x166 \
- -size 166x166 xc:white +swap -gravity center -composite \
- -modulate 110 -colors 256 png8:$OUTPUT_DIR/resize.png
- builder_check_error "converting image"
- else
- # Imagemagic is unable to detect the aspect ratio so just force 166x166
- # this could result in streched images
- log_debug "Icon Wight: $wight unknown Hight: $hight"
- convert $OUTPUT_DIR/bigger.png -colorspace RGB -resize 166x166 \
- -size 166x166 xc:white +swap -gravity center -composite \
- -modulate 110 -colors 256 png8:$OUTPUT_DIR/resize.png
- builder_check_error "converting image"
- fi
-
- # create a diffence image from the source
- convert $OUTPUT_DIR/resize.png \( +clone -fx 'p{0,0}' \) -compose Difference -composite \
- -modulate 100,0 +matte $OUTPUT_DIR/difference.png
-
- # remove the black, replace with transparency
- convert $OUTPUT_DIR/difference.png -bordercolor white -border 1x1 -matte \
- -fill none -fuzz 7% -draw 'matte 1,1 floodfill' -shave 1x1 \
- $OUTPUT_DIR/removed_black.png
-
- # create the matte
- if [ `convert | grep Version | awk '{print $3}' | sed "s/-.*//" | sed "s/\.//g"` -le 670 ] ; then
- convert $OUTPUT_DIR/removed_black.png -channel matte -separate +matte \
- $OUTPUT_DIR/matte.png
- else
- convert $OUTPUT_DIR/removed_black.png -channel matte -negate -separate +matte \
- $OUTPUT_DIR/matte.png
- fi
-
- # negate the colors
- convert $OUTPUT_DIR/matte.png -negate -blur 0x1 \
- $OUTPUT_DIR/matte-negated.png
-
- # you are going for: white interior, black exterior
- composite -compose CopyOpacity $OUTPUT_DIR/matte-negated.png $OUTPUT_DIR/resize.png \
- $OUTPUT_DIR/smaller.png
-
- # now remove the added border that was added eaerlier
- # Chop 3 pixels from the top and left side of
- convert -chop 3x3 -rotate 180 $OUTPUT_DIR/smaller.png $OUTPUT_DIR/rotate.png
-
- # Chop 3 pixels from the bottom and right side
- convert -chop 3x3 -rotate 180 $OUTPUT_DIR/rotate.png $dst
-
- # New size
- # identify -format "%wx%h" $dst
- hight=`${CMD_identify} -format "%h" $dst`
- wight=`${CMD_identify} -format "%w" $dst`
- log_debug "Opsi Icon Wight: $wight Hight: $hight"
-
-}
-
-
-###################
-# Create variable file
-#
-# Create a file containing all important winst variables
-# (declaration and setings)
-#
-# Parameter
-# file: file to create
-#
-###################
-create_winst_varfile() {
- local var_file=$1
-
- echo -n >$var_file
- echo "; Opsi Builder Variables" >>$var_file
-
- # make the scriptpath for the binarys configurable
- echo "DefVar \$PackagePath\$" >>$var_file
- echo "Set \$PackagePath\$ = \"%ScriptPath%\"" >>$var_file
-
- echo >>$var_file
- for (( i = 0 ; i < ${#DL_SOURCE[@]} ; i++ )) ; do
- if [ -z ${DL_WINST_NAME[$i]} ] ; then continue ; fi
-
- if [ ! -z "${DL_ARCH[$i]}" ] ; then arch_str="${DL_ARCH[$i]}\\" ; fi
- echo "DefVar \$${DL_WINST_NAME[$i]}\$" >>$var_file
- echo "Set \$${DL_WINST_NAME[$i]}\$ = \$PackagePath\$ + \"\\${arch_str}${DL_FILE[$i]}\"" >>$var_file
- done
-
- # publish some other variables
- for var in VENDOR PN VERSION RELEASE PRIORITY NAME ADVICE TYPE CREATOR_TAG CREATOR_NAME CREATOR_EMAIL ; do
- echo "DefVar \$${var}\$" >>$var_file
- echo "Set \$${var}\$ = \"${!var}\"" >>$var_file
- done
-
- # copy image and create variable
- echo "DefVar \$IconFile\$" >>$var_file
- echo "Set \$IconFile\$ = \"%ScriptPath%\\`basename $ICONFILE`\"" >>$var_file
-
- # publish custom variables
- for (( i = 0 ; i < ${#WINST_NAME[@]} ; i++ )) ; do
-
- # replace DL_EXTRACT_WINST_PATH
- local index=`echo ${WINST_VALUE[$i]} | sed -e "s#.*@DL_EXTRACT_WINST_PATH\[\([0-9]\)\]@.*#\1#"`
- log_debug "calculated (DL_EXTRACT_WINST_PATH), Index: $index"
- if [ "$index" != "${WINST_VALUE[$i]}" ] ; then
- if [ ! -z "${DL_ARCH[$index]}" ] ; then arch_part="\\\\${DL_ARCH[$index]}" ; fi
- if [ ! -z "${DL_EXTRACT_WINST_PATH[$index]}" ] ; then extr_part="\\\\${DL_EXTRACT_WINST_PATH[$index]}" ; fi
- local new_val="\$PackagePath\$ + $arch_part$extr_part"
- WINST_VALUE[$i]=`echo ${WINST_VALUE[$i]} | sed -e "s#@DL_EXTRACT_WINST_PATH\[[0-9]\]@#$new_val#"`
- log_debug "calculated (DL_EXTRACT_WINST_PATH) WINST_VALUE: ${WINST_VALUE[$i]}"
- fi
-
- echo "DefVar \$${WINST_NAME[$i]}\$" >>$var_file
- echo "Set \$${WINST_NAME[$i]}\$ = \"${WINST_VALUE[$i]}\"" >>$var_file
- done
-
- # correct me im a hack
- sed -e 's#"\$PackagePath\$ +#\$PackagePath\$ + "#' -i $var_file
- sed -e 's#\$PackagePath\$ + " #\$PackagePath\$ + "#' -i $var_file
- echo >>$var_file
-}
-
#####################
# void calc_release()
#
@@ -304,8 +151,8 @@ create_winst_varfile() {
function calc_release() {
# Find all revision files and sort them
- local file_list=`mktemp /tmp/opsi-builder.calc_release.XXXXXXXXXXX`
- for cfg_file in `find ${OPSI_REPOS_BASE_DIR} -name "${PN}-${VERSION}-${CREATOR_TAG}*.cfg" -print ` ; do
+ local file_list=`mktemp /tmp/aio-builder.calc_release.XXXXXXXXXXX`
+ for cfg_file in `find ${AIO_REPOS_BASE_DIR} -name "${PN}-${VERSION}-${CREATOR_TAG}*.cfg" -print ` ; do
. ${cfg_file}
printf "%08d;$cfg_file\n" $REV_RELEASE >> ${file_list}
done
@@ -335,43 +182,70 @@ function calc_release() {
###################
write_ini_file() {
local ini_file=$1
- local var_file=$2
-
- # create file if not exist
+ local ini_section=$2
+ local ini_option=$3
+ local ini_value=$4
+
touch $ini_file
+ $CMD_inifile $(cygpath -pw "$ini_file") [$ini_section] $ini_option=$ini_value
+}
+
+
+###################
+# Get Verison of File
+#
+# Copy file only if it is newer
+#
+# Parameter
+# File: to process
+# Var:
+#
+###################
+get_file_version() {
+ local getver_file=$1
+ local getver_var=$2
- # publish some other variables
- for var in VENDOR PN VERSION RELEASE TYPE CREATOR_TAG CREATOR_NAME CREATOR_EMAIL ; do
- $CMD_iniset $ini_file --COMMON ${var}="${!var}"
- done
-
- echo "; Opsi INI File Variables" >>$var_file
- echo >>$var_file
- # publish custom variables
- for (( i = 0 ; i < ${#OPSI_INI_OPTION[@]} ; i++ )) ; do
- $CMD_iniset $ini_file --${OPSI_INI_SECTION[$i]} ${OPSI_INI_OPTION[$i]}="${OPSI_INI_VALUE[$i]}"
- echo "DefVar \$${OPSI_INI_OPTION[$i]}\$" >>$var_file
- echo "Set \$${OPSI_INI_OPTION[$i]}\$ = \"${OPSI_INI_VALUE[$i]}\"" >>$var_file
- done
+ if [ -f "$getver_file" ] ; then
+ $CMD_showver $getver_file | grep FileVersion: | rev | cut -d: -f1 | rev | tr -d ' ' > $getver_ver
+ echo "file $getver_file has version $getver_ver"
+ else
+ echo "$getver_file not found"
+ fi
+}
+
+###################
+# Copy Verison
+#
+# Copy file only if it is newer
+#
+# Parameter
+# source: sourcefiel
+# target: Targetfile
+#
+###################
+copyver() {
+ local source_file=$1
+ local target_file=$2
+ local source_ver
+ local target_ver
- echo >>$var_file
+ get_file_version $source_file $source_ver
}
###################
-# Write control file
+# Tidy xml
#
-# Create a ini file containing needed information for package uninstall
+# Tidy XML files (mainly Sereby package.xml)
#
# Parameter
-# file: file to create / modify
+# source: sourcefiel
+# target: Targetfile
#
###################
-write_control_file() {
- local control_file=$1
- local control_section=$2
- local control_option=$3
- local control_value=$4
+tidy_xml() {
+ local source_file=$1
+ local target_file=$2
- sed -i -e "/^\[$control_section\]/,/^\[.*\]/ s|^\($control_option[ \t]*:[ \t]*\).*$|\1$control_value|" "$control_file"
+ cat $source_file | $CMD_tidy -utf8 -xml -w 255 -i -c -q -asxml | sed -e 's!&gt;!>!g' -e 's!&lt;!<!g' > $target_file
}

Powered by Domaintechnik.at | Hosting - Domain - Webspace