summaryrefslogtreecommitdiffstats
path: root/packaging
diff options
context:
space:
mode:
authorRené de Hesselle <dehesselle@web.de>2019-09-05 18:47:52 +0000
committerRené de Hesselle <dehesselle@web.de>2019-09-05 18:47:52 +0000
commit48e7c744051a6bff765b3207e94589f49e010c99 (patch)
tree73c8f84eb487a3e38f695916b47a640b83335a62 /packaging
parentFix a crash on ubuntu by a icon missing (diff)
downloadinkscape-48e7c744051a6bff765b3207e94589f49e010c99.tar.gz
inkscape-48e7c744051a6bff765b3207e94589f49e010c99.zip
Fix error in GTK launch script
Determine git repo version like it's done in the cmakefile. Refactor usage of 'sed'. Do not extract everything from toolset cache.
Diffstat (limited to 'packaging')
-rw-r--r--packaging/macos/020-vars.sh2
-rw-r--r--packaging/macos/030-funcs.sh66
-rwxr-xr-xpackaging/macos/220-inkscape-package.sh18
-rwxr-xr-xpackaging/macos/build_toolset.sh2
4 files changed, 66 insertions, 22 deletions
diff --git a/packaging/macos/020-vars.sh b/packaging/macos/020-vars.sh
index b59532303..d5e8c7123 100644
--- a/packaging/macos/020-vars.sh
+++ b/packaging/macos/020-vars.sh
@@ -75,7 +75,7 @@ TOOLSET_CACHE_ENABLE=true
# In regards to (2), using an arbitrary system-level location like
# $DEFAULT_SYSTEM_WRK_DIR is considered optional as in "you have to opt-in"
# (and not mandatory at all). You can tell us that you "opted-in" by creating
-# that directory beforehand and ensuring it's writable (2a). Than it's going to
+# that directory beforehand and ensuring it's writable (2a). Then it's going to
# be used. (I don't like writing scripts that write to arbitrary locations on
# their own. Also, that would require 'sudo' permission.)
# If $DEFAULT_SYSTEM_WRK_DIR does not exist, it means that you did not
diff --git a/packaging/macos/030-funcs.sh b/packaging/macos/030-funcs.sh
index 59d936e70..85b2c7d6e 100644
--- a/packaging/macos/030-funcs.sh
+++ b/packaging/macos/030-funcs.sh
@@ -18,8 +18,8 @@
function get_repo_version
{
local repo=$1
- #echo $(git -C $repo describe --tags --dirty)
- echo $(git -C $repo log --pretty=format:'%h' -n 1)
+ # do it the same way as in CMakeScripts/inkscape-verson.cmake
+ echo $(git -C $repo rev-parse --short HEAD)
}
### get Inkscape version from CMakeLists.txt ###################################
@@ -59,7 +59,8 @@ function get_comp_flag
function get_source
{
local url=$1
- local target_dir=$2 # optional argument, defaults to $SRC_DIR
+ local target_dir=$2 # optional: target directory, defaults to $SRC_DIR
+ local options=$3 # optional: additional options for 'tar'
[ ! -d $TMP_DIR ] && mkdir -p $TMP_DIR
local log=$(mktemp $TMP_DIR/$FUNCNAME.XXXX)
@@ -69,9 +70,9 @@ function get_source
cd $target_dir
# This downloads a file and pipes it directly into tar (file is not saved
- # to disk) to extract it. Output is saved temporarily to determine
- # the directory the files have been extracted to.
- curl -L $url | tar xv$(get_comp_flag $url) 2>$log
+ # to disk) to extract it. Output from stderr is saved temporarily to
+ # determine the directory the files have been extracted to.
+ curl -L $url | tar xv$(get_comp_flag $url) $options 2>$log
cd $(head -1 $log | awk '{ print $2 }')
[ $? -eq 0 ] && rm $log || echo "$FUNCNAME: check $log"
}
@@ -125,6 +126,11 @@ function cmake_make_makeinstall
### create and mount ramdisk ###################################################
+# There is a more common approach to do this using
+# diskutil eraseVolume HFS+ VolName $(hdiutil attach -nomount ram://<size>)
+# but that always attaches the ramdisk below '/Volumes'.
+# To have full control, we need to do it as follows.
+
function create_ramdisk
{
local dir=$1 # mountpoint
@@ -139,7 +145,8 @@ function create_ramdisk
### insert line into a textfile ################################################
-# insert_before [filename] '[insert before this pattern]' '[line to insert]'
+# usage:
+# insert_before <filename> <insert before this pattern> <line to insert>
function insert_before
{
@@ -153,12 +160,37 @@ function insert_before
rm $file_tmp
}
+### escape replacement string for sed ##########################################
+
+# Escape slashes, backslashes and ampersands in strings to be used s as
+# replacement strings when using 'sed'. Newlines are not taken into
+# consideartion here.
+# reference: https://stackoverflow.com/a/2705678
+
+function escape_sed
+{
+ local string="$*"
+
+ echo "$string" | sed -e 's/[\/&]/\\&/g'
+}
+
+### replace line that matches pattern ##########################################
+
+function replace_line
+{
+ local file=$1
+ local pattern=$2
+ local replacement=$3
+
+ sed -i '' "s/.*${pattern}.*/$(escape_sed $replacement)/" $file
+}
+
### relocate a library dependency ##############################################
function relocate_dependency
{
local target=$1 # fully qualified path and library name to new location
- local library=$2 # library where 'source' get changed to 'target'
+ local library=$2 # library to be modified (change 'source' to 'target'I
local source_lib=${target##*/} # get library filename from target location
local source=$(otool -L $library | grep $source_lib | awk '{ print $1 }')
@@ -183,7 +215,7 @@ function relocate_neighbouring_libs
### 'readlink -f' replacement ##################################################
-# This is what the oneliner used to set SELF_DIR is based on.
+# This is what the oneliner setting SELF_DIR (see top of file) is based on.
function readlinkf
{
@@ -207,16 +239,16 @@ function readlinkf
echo $(pwd -P)/$file
}
-### run script and echo comments prefixed with three hashes ####################
+### run script and echo comments enclosed by three hashes ######################
# This little magic trick
# - reads the current file
# - turns every line that matches "### text here ###" into an echo statement
# (whatever follows after the last three hashes is ignored)
# - adds script name and line number as prefix
-# - sets background color for that "echo" to blue
-# - removes the call to run_annotated to avoid recursion
-# - set SELF_DIR to correct value (piping into bash breaks existing one)
+# - sets background color for that 'echo' to blue
+# - removes the call to 'run_annotated' to avoid recursion
+# - sets SELF_DIR to the correct value (piping into bash breaks it)
#
# Known side effects:
# - SELF_NAME no longer works (is now "bash")
@@ -226,7 +258,7 @@ function run_annotated
{
# The newlines in the last 'sed' statement are significant!
- sed 's/\(^### .* ###\).*/echo \-e "\\033[1;44m['$SELF_NAME':$(printf '%03d' $LINENO)] \1\\033[0m"/g' $SELF_DIR/$SELF_NAME | sed 's/^run_annotated/#run_annotated/' | sed '/SELF_DIR=/a\
+ sed 's/\(^### .* ###\).*/echo \-e "\\033[1;44m\\033[1;37m['$SELF_NAME':$(printf '%03d' $LINENO)] \1\\033[0m"/g' $SELF_DIR/$SELF_NAME | sed 's/^run_annotated/#run_annotated/' | sed '/SELF_DIR=/a\
SELF_DIR='$SELF_DIR'\
' | bash
@@ -242,18 +274,18 @@ function create_dmg
local cfg=$3
# set application
- sed "s/PLACEHOLDERAPPLICATION/${app//\//\\/}/" $SELF_DIR/$(basename $cfg) > $cfg
+ sed "s/PLACEHOLDERAPPLICATION/$(escape_sed $app)/" $SELF_DIR/$(basename $cfg) > $cfg
# set disk image icon (if it exists)
local icon=$SRC_DIR/$(basename -s .py $cfg).icns
if [ -f $icon ]; then
- sed -i '' "s/PLACEHOLDERICON/${icon//\//\\/}/" $cfg
+ sed -i '' "s/PLACEHOLDERICON/$(escape_sed $icon)/" $cfg
fi
# set background image (if it exists)
local background=$SRC_DIR/$(basename -s .py $cfg).png
if [ -f $background ]; then
- sed -i '' "s/PLACEHOLDERBACKGROUND/${background//\//\\/}/" $cfg
+ sed -i '' "s/PLACEHOLDERBACKGROUND/$(escape_sed $background)/" $cfg
fi
# create disk image
diff --git a/packaging/macos/220-inkscape-package.sh b/packaging/macos/220-inkscape-package.sh
index ce3dbdb78..6873f08db 100755
--- a/packaging/macos/220-inkscape-package.sh
+++ b/packaging/macos/220-inkscape-package.sh
@@ -177,9 +177,9 @@ ln -sf ../../Frameworks/Python.framework/Versions/Current/bin/python3 python
# add override check to launch script
insert_before $APP_EXE_DIR/Inkscape '\$EXEC' '\
-INKSCAPE_PREFERENCES=$HOME/Library/Application\\ Support/Inkscape/config/inkscape/preferences.xml\
-if [ -f $INKSCAPE_PREFERENCES ]; then # Has Inkscape been launched before?\
- PYTHON_INTERPRETER=$\(xmllint --xpath '\''string\(//inkscape/group[@id=\"extensions\"]/@python-interpreter\)'\'' $INKSCAPE_PREFERENCES\)\
+INKSCAPE_PREFERENCES=\"$HOME/Library/Application Support/Inkscape/config/inkscape/preferences.xml\"\
+if [ -f \"$INKSCAPE_PREFERENCES\" ]; then # Has Inkscape been launched before?\
+ PYTHON_INTERPRETER=$\(xmllint --xpath '\''string\(//inkscape/group[@id=\"extensions\"]/@python-interpreter\)'\'' \"$INKSCAPE_PREFERENCES\"\)\
if [ -z $PYTHON_INTERPRETER ]\; then # No override for Python interpreter?\
export PATH=$bundle_bin:$PATH # make bundled Python default one\
fi\
@@ -213,3 +213,15 @@ cp $SELF_DIR/fonts.conf $APP_ETC_DIR/fonts
# (https://developer.gnome.org/gio//2.52/running-gio-apps.html)
insert_before $APP_EXE_DIR/Inkscape '\$EXEC' 'export GIO_MODULE_DIR=$bundle_lib/gio/modules'
+### fix messages in GTK launch script ##########################################
+
+# Some parts of the GTK launch script cause unnecessary messages.
+
+# silence "does not exist" message
+replace_line $APP_EXE_DIR/Inkscape AppleCollationOrder \
+ 'APPLECOLLATION=$(defaults read .GlobalPreferences AppleCollationOrder 2>/dev/null)'
+
+# add quotes so test does not complain to missing (because empty) argument
+replace_line $APP_EXE_DIR/Inkscape '-a -n $APPLECOLLATION;' \
+ 'if test -z ${LANG} -a -n "$APPLECOLLATION"; then'
+
diff --git a/packaging/macos/build_toolset.sh b/packaging/macos/build_toolset.sh
index 0a50b7bcb..7dad48f53 100755
--- a/packaging/macos/build_toolset.sh
+++ b/packaging/macos/build_toolset.sh
@@ -28,7 +28,7 @@ else
# on the runner and is disabled on CI.
[ ! -z $CI_JOB_ID ] && RAMDISK_ENABLE=false
$SELF_DIR/110-sysprep.sh
- get_source $URL_TOOLSET_CACHE $WRK_DIR
+ get_source $URL_TOOLSET_CACHE $WRK_DIR "--exclude opt/src/boost* --exclude opt/src/checkout --exclude opt/tmp/jhbuild/build"
mkdir -p $HOME/.config
rm -f $HOME/.config/jhbuild*
ln -sf $DEVCONFIG/jhbuild* $HOME/.config