Mhurd has submitted this change and it was merged.

Change subject: Fix for T94534 not working on iPads
......................................................................


Fix for T94534 not working on iPads

Shell script was setting names based on the assets file but file names in the 
catalog are apparently is not uniform.
The fix is using the files in the app bundle for the source.
This actually simplifies the script quite a bit, so win win!
Additionally had to do some dangling to loop over paths that have spaces

Change-Id: Ic3f909e250b7eddfd115131c4115a7aef09b8c1b
---
M scripts/process-icons.sh
1 file changed, 40 insertions(+), 59 deletions(-)

Approvals:
  Mhurd: Looks good to me, approved
  Bgerstle: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/scripts/process-icons.sh b/scripts/process-icons.sh
index 8e1664e..08efd2d 100755
--- a/scripts/process-icons.sh
+++ b/scripts/process-icons.sh
@@ -1,99 +1,76 @@
 #This script will overlay version, git, and build configuration information 
over the icon for non-app store builds
 #Inspiration: 
http://www.merowing.info/2013/03/overlaying-application-version-on-top-of-your-icon/
 
-#Info to overlay on Icon
-commit=`git rev-parse --short HEAD`
-branch=`git rev-parse --abbrev-ref HEAD`
-version=`agvtool what-marketing-version -terse1`
-build=`/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${INFOPLIST_FILE}"`
+export PATH=$PATH:/usr/local/bin
 
-#Where to save the files
-target_path="${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/"
+#Don't run if imagemagick is not installed
+if ! convert -version > /dev/null; then
+       exit 0
+fi
+
+#Don't do this for App Store Releases
+if [ "$CONFIGURATION" == "Release" ]; then
+       exit 0
+fi
 
 function processIconSet() {
 
-       export PATH=$PATH:/usr/local/bin
+       #Get build number from info.plist
+       build=`/usr/libexec/PlistBuddy -c "Print CFBundleVersion" 
"${INFOPLIST_FILE}"`
 
-       #Don't do this for App Store or Instore Release
-       if [ "$CONFIGURATION" == "Release" ]; then
-               exit 0
-       fi
+       #Get path to icons in app bundle
+       
icon_directory_path="${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
+       echo "icon directory: "$icon_directory_path
 
-       #Make path to existing icons
-       source_icon_set=$1
-       source_icon_set_folder_name=$source_icon_set".appiconset"
-       echo $source_icon_set_folder_name
+       #Set the prefix of icon files so that we can find them in the the app 
bundle
+       source_icon_set_prefix=$1
+       echo "Source icon Prefix: "$source_icon_set_prefix
 
-       #Find existing icons
-       source_icon_set_directory=`find . -name $source_icon_set_folder_name 
-type d`
-       echo "Source icon directory: "$source_icon_set_directory
+       #Fine the icons in the app bundle
+       source_icons=`find "$icon_directory_path" -name 
"$source_icon_set_prefix*.png" -type f`
+       echo "Source icons: "$source_icons
 
-       #Make target base file name - same as asset collection name
-       target_base_file_name=$source_icon_set
-       echo "Target base file name: "$target_base_file_name
+       #Looping through unescaped paths is fraught with peril
+       #Tip found here: 
http://www.cyberciti.biz/tips/handling-filenames-with-spaces-in-bash.html
+       SAVEIFS=$IFS
+       IFS=$(echo -en "\n\b")
+       echo "Set IFS for unescaped for loop paths"
 
        #Loop through icons
-       for source_icon_path in $(find $source_icon_set_directory -name "*.png" 
-type f); do
+       for source_icon_path in ${source_icons}; do
+
+               echo "Source icon path: $source_icon_path"
 
                #Image meta
                minimum_width=""
-               retina_suffix=""
-               width=""
-               height=""
-               icon_size_suffix=""
-               width_suffix=""
-               height_suffix=""
+               width=`identify -format %w "$source_icon_path"`
+               height=`identify -format %h "$source_icon_path"`
 
+               #Overlay Height
                overlay_height=""
                overlay_color="#0008"
 
-               #Populate the image meta based on retina and size
+               #Set minimum width and overlay height based on icon size
                if [[ $source_icon_path == *"@3x"* ]]; then
-                       minimum_width=114
-                       retina_suffix="@3x"
-                       width=`identify -format %w "$source_icon_path"`
-                       height=`identify -format %h "$source_icon_path"`
-                       width_suffix=$width
-                       height_suffix=$height
-                       let "width_suffix/=3"
-                       let "height_suffix/=3"
+                       minimum_width=171
                        overlay_height=60
                elif [[ $source_icon_path == *"@2x"* ]]; then
                        minimum_width=114
-                       retina_suffix="@2x"
-                       width=`identify -format %w "$source_icon_path"`
-                       height=`identify -format %h "$source_icon_path"`
-                       width_suffix=$width
-                       height_suffix=$height
-                       let "width_suffix/=2"
-                       let "height_suffix/=2"
                        overlay_height=40
                else
                        minimum_width=57
-                       retina_suffix=""
-                       width=`identify -format %w "$source_icon_path"`
-                       height=`identify -format %h "$source_icon_path"`
-                       width_suffix=$width
-                       height_suffix=$height
                        overlay_height=20
                fi
 
-               icon_size_suffix=$width_suffix"x"$height_suffix
-
-               #Only process icons that show on home screens (larger ones)
+               #Only process icons that show on home screens (> minimum_width)
                if [ $width -ge $minimum_width ]; then
 
                        echo "Overlaying source Image "$source_icon_path
 
-                       #Assemble the final file path
-                       
target_icon_file_name=$target_base_file_name$icon_size_suffix$retina_suffix".png"
-                       target_icon_path=$target_path$target_icon_file_name
-                       echo $source_icon_path" = "$target_icon_path
-
                        #Overlay Image
                        convert -background $overlay_color -fill white -gravity 
center -size ${width}x${overlay_height}\
                        caption:"${CONFIGURATION}\n(${build})"\
-                       "${source_icon_path}" +swap -gravity south -composite 
"${target_icon_path}"
+                       "${source_icon_path}" +swap -gravity south -composite 
"${source_icon_path}"
 
                else
 
@@ -103,5 +80,9 @@
 
        done
 
+       IFS=$SAVEIFS
+       echo "Reset IFS"
+
 }
+
 processIconSet "AppIcon"

-- 
To view, visit https://gerrit.wikimedia.org/r/202909
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic3f909e250b7eddfd115131c4115a7aef09b8c1b
Gerrit-PatchSet: 8
Gerrit-Project: apps/ios/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Fjalapeno <[email protected]>
Gerrit-Reviewer: Bgerstle <[email protected]>
Gerrit-Reviewer: Dr0ptp4kt <[email protected]>
Gerrit-Reviewer: Fjalapeno <[email protected]>
Gerrit-Reviewer: Mhurd <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to