From 5dcbc6109878ab9fb1e1ff58bd5f701aa6d8ac3b Mon Sep 17 00:00:00 2001 From: Yoann Gini Date: Fri, 1 Sep 2017 08:22:42 +0200 Subject: [PATCH 01/20] Update the BuildAndPackage script to deny a build request when there is some uncommited change. Also update the script to use a variable for the build identity. --- package/BuildAndPackage.command | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/package/BuildAndPackage.command b/package/BuildAndPackage.command index 106944b..a40be7b 100755 --- a/package/BuildAndPackage.command +++ b/package/BuildAndPackage.command @@ -2,7 +2,9 @@ CONFIGURATION="Release" -GIT_ROOT_DIR="$(dirname $(dirname ${BASH_SOURCE[0]}))" +DEVELOPER_ID_INSTALLER="Developer ID Installer: Yoann GINI (CRXPBZF3N4)" + +GIT_ROOT_DIR="$(git rev-parse --show-toplevel)" PROJECT_DIR="${GIT_ROOT_DIR}/src" BUILT_PRODUCTS_DIR="$(mktemp -d)" @@ -15,6 +17,16 @@ RELEASE_LOCATION="${BASE_RELEASE_LOCATION}/${PKG_VERSION}-${CONFIGURATION}" RELEASE_PRODUCT_LOCATION="${RELEASE_LOCATION}/Products" RELEASE_DSYM_LOCATION="${RELEASE_LOCATION}/dSYM" + +UNCOMMITED_CHANGE=$(git status -s | wc -l | bc) + +if [ $UNCOMMITED_CHANGE -ne 0 ] +then + echo "There is some uncommited change to the repo" + echo "Please, commit and try again" + exit 1 +fi + PKG_ROOT="$(mktemp -d)" mkdir -p "${BUILT_PRODUCTS_DIR}/dSYM" @@ -54,7 +66,7 @@ cp -r "${GIT_ROOT_DIR}/package/LaunchAgents/com.github.ygini.hello-it.plist" "${ #sudo chown -R root:wheel "${PKG_ROOT}" -pkgbuild --sign "Developer ID Installer: Yoann GINI (CRXPBZF3N4)" --root "${PKG_ROOT}" --scripts "${GIT_ROOT_DIR}/package/pkg_scripts" --identifier "com.github.ygini.hello-it" --version "${PKG_VERSION}" "${RELEASE_LOCATION}/Hello-IT-${PKG_VERSION}-${CONFIGURATION}.pkg" +pkgbuild --sign "${DEVELOPER_ID_INSTALLER}" --root "${PKG_ROOT}" --scripts "${GIT_ROOT_DIR}/package/pkg_scripts" --identifier "com.github.ygini.hello-it" --version "${PKG_VERSION}" "${RELEASE_LOCATION}/Hello-IT-${PKG_VERSION}-${CONFIGURATION}.pkg" rm -rf "${PKG_ROOT}" From 78759954d79de7e3d13b3df2068af7f0fe3c1523 Mon Sep 17 00:00:00 2001 From: Yoann Gini Date: Fri, 1 Sep 2017 08:35:57 +0200 Subject: [PATCH 02/20] Update IP and Hostname script to copy the value on click, add a public-IP script. Public and private IP now display what kind of IP is shown to the end user. --- .../com.github.ygini.hello-it.hostname.sh | 10 +- .../com.github.ygini.hello-it.ip.sh | 39 ++++---- .../com.github.ygini.hello-it.public-ip.sh | 95 +++++++++++++++++++ 3 files changed, 125 insertions(+), 19 deletions(-) create mode 100755 src/Plugins/ScriptedItem/CustomScripts/com.github.ygini.hello-it.public-ip.sh diff --git a/src/Plugins/ScriptedItem/CustomScripts/com.github.ygini.hello-it.hostname.sh b/src/Plugins/ScriptedItem/CustomScripts/com.github.ygini.hello-it.hostname.sh index 720848c..bf68d35 100755 --- a/src/Plugins/ScriptedItem/CustomScripts/com.github.ygini.hello-it.hostname.sh +++ b/src/Plugins/ScriptedItem/CustomScripts/com.github.ygini.hello-it.hostname.sh @@ -13,7 +13,7 @@ . "$HELLO_IT_SCRIPT_FOLDER/com.github.ygini.hello-it.scriptlib.sh" -function updateTitleWithArgs { +function getHostname { hostname=$(scutil --get HostName) localhostname=$(scutil --get LocalHostName) computername=$(scutil --get ComputerName) @@ -25,12 +25,18 @@ function updateTitleWithArgs { format="%C" fi - title=$(echo "$format" | sed "s/%C/$computername/g" | sed "s/%H/$hostname/g" | sed "s/%L/$localhostname/g") + echo "$format" | sed "s/%C/$computername/g" | sed "s/%H/$hostname/g" | sed "s/%L/$localhostname/g" + +} + +function updateTitleWithArgs { + title=$(getHostname) updateTitle "Hostname: $title" } function onClickAction { updateTitleWithArgs "$@" + getHostname | pbcopy } function fromCronAction { diff --git a/src/Plugins/ScriptedItem/CustomScripts/com.github.ygini.hello-it.ip.sh b/src/Plugins/ScriptedItem/CustomScripts/com.github.ygini.hello-it.ip.sh index 09f4baf..1d169b1 100755 --- a/src/Plugins/ScriptedItem/CustomScripts/com.github.ygini.hello-it.ip.sh +++ b/src/Plugins/ScriptedItem/CustomScripts/com.github.ygini.hello-it.ip.sh @@ -14,6 +14,20 @@ . "$HELLO_IT_SCRIPT_FOLDER/com.github.ygini.hello-it.scriptlib.sh" +mode=0 +mainBSDInterface=$(route -n get 8.8.8.8 | grep "interface: " | awk -F ": " '{print $2}') + +while getopts "m:i:" o; do + case "${o}" in + m) + mode=${OPTARG} + ;; + i) + mainBSDInterface=${OPTARG} + ;; + esac +done + function handleStateUpdate { mode=$1 requestedState=$2 @@ -37,23 +51,13 @@ function handleStateUpdate { fi } -function updateTitleWithArgs { - mode=0 - mainBSDInterface=$(route -n get 8.8.8.8 | grep "interface: " | awk -F ": " '{print $2}') - - while getopts "m:i:" o; do - case "${o}" in - m) - mode=${OPTARG} - ;; - i) - mainBSDInterface=${OPTARG} - ;; - esac - done - - ipAddress=$(ifconfig "$mainBSDInterface" | grep "inet " | sed "s/.*inet \([0-9.]*\).*/\1/" | head -n1) +function getIP { + ifconfig "$mainBSDInterface" | grep "inet " | sed "s/.*inet \([0-9.]*\).*/\1/" | head -n1 +} +function updateTitleWithArgs { + ipAddress=$(getIP "$@") + if [ -z "$ipAddress" ] then updateTitle "No IP Address" @@ -66,7 +70,7 @@ function updateTitleWithArgs { updateTooltip "No network connection available" fi else - updateTitle "IP: $ipAddress" + updateTitle "Local IP: $ipAddress" handleStateUpdate $mode ${STATE[0]} updateTooltip "Having an IP address doesn't mean you've Internet access" fi @@ -75,6 +79,7 @@ function updateTitleWithArgs { function onClickAction { updateTitleWithArgs "$@" + getIP "$@" | pbcopy } function fromCronAction { diff --git a/src/Plugins/ScriptedItem/CustomScripts/com.github.ygini.hello-it.public-ip.sh b/src/Plugins/ScriptedItem/CustomScripts/com.github.ygini.hello-it.public-ip.sh new file mode 100755 index 0000000..59c15a6 --- /dev/null +++ b/src/Plugins/ScriptedItem/CustomScripts/com.github.ygini.hello-it.public-ip.sh @@ -0,0 +1,95 @@ +#!/bin/bash + +# Display Public IP address as title +# With no option, the script detect the public +# address using https://ip.abelionni.com/script/ +# +# You can specify the test URL using -u +# +# You can specify the behavior if no IP +# are found with -m option: +# 0: show IP if available, hide if not +# 1: show IP if available, specify if not, no $STATE +# 2: show IP if available, specify if not, use $STATE + +. "$HELLO_IT_SCRIPT_FOLDER/com.github.ygini.hello-it.scriptlib.sh" + +mode=0 +public_ip_url="https://ip.abelionni.com/script/" + +while getopts "m:u:" o; do + case "${o}" in + m) + mode=${OPTARG} + ;; + u) + public_ip_url=${OPTARG} + ;; + esac +done + +function handleStateUpdate { + mode=$1 + requestedState=$2 + + if [ $mode -eq 0 ] + then + if [ "$requestedState" == ${STATE[0]} ] + then + setHidden NO + else + setHidden YES + fi + else + setHidden NO + if [ $mode -eq 1 ] + then + updateState ${STATE[4]} + else + updateState $requestedState + fi + fi +} + +function getIP { + curl -s "$public_ip_url" +} + +function updateTitleWithArgs { + ipAddress=$(curl -s "$public_ip_url") + + if [ -z "$ipAddress" ] + then + updateTitle "No IP Address" + if [[ "$HELLO_IT_NETWORK_STATE" == "1" ]] + then + handleStateUpdate $mode ${STATE[2]} + updateTooltip "Please, check your Ethernet or WiFi connection" + else + handleStateUpdate $mode ${STATE[3]} + updateTooltip "No internet connection available" + fi + else + updateTitle "Public IP: $ipAddress" + handleStateUpdate $mode ${STATE[0]} + updateTooltip "You should have access to Internet" + fi + +} + +function onClickAction { + updateTitleWithArgs "$@" + getIP "$@" | pbcopy +} + +function fromCronAction { + updateTitleWithArgs "$@" +} + +function setTitleAction { + updateTitleWithArgs "$@" +} + +main "$@" + +exit 0 From 73a22e5ecde43248249191ba04bd7b7be10e00c0 Mon Sep 17 00:00:00 2001 From: Yoann Gini Date: Fri, 1 Sep 2017 09:16:28 +0200 Subject: [PATCH 03/20] Updated build script to grab app version from release branch name --- package/BuildAndPackage.command | 44 ++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/package/BuildAndPackage.command b/package/BuildAndPackage.command index a40be7b..e752b72 100755 --- a/package/BuildAndPackage.command +++ b/package/BuildAndPackage.command @@ -10,23 +10,49 @@ BUILT_PRODUCTS_DIR="$(mktemp -d)" cd "${GIT_ROOT_DIR}" -PKG_VERSION=$(/usr/libexec/PlistBuddy -c "print CFBundleShortVersionString" "${PROJECT_DIR}/Hello IT/Info.plist") - -BASE_RELEASE_LOCATION="${GIT_ROOT_DIR}/package/build" -RELEASE_LOCATION="${BASE_RELEASE_LOCATION}/${PKG_VERSION}-${CONFIGURATION}" -RELEASE_PRODUCT_LOCATION="${RELEASE_LOCATION}/Products" -RELEASE_DSYM_LOCATION="${RELEASE_LOCATION}/dSYM" +CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) +if [[ "$CURRENT_BRANCH" == "master" ]] +then + CONFIGURATION="Release" +elif [[ "$CURRENT_BRANCH" == "release/*" ]] +then + CONFIGURATION="Release" +else + CONFIGURATION="Debug" +fi UNCOMMITED_CHANGE=$(git status -s | wc -l | bc) -if [ $UNCOMMITED_CHANGE -ne 0 ] +if [ $UNCOMMITED_CHANGE -ne 0 ] && [ "$CONFIGURATION" == "Release" ] then - echo "There is some uncommited change to the repo" - echo "Please, commit and try again" + echo "Your are on ${CURRENT_BRANCH} and there" + echo "is some uncommited change to the repo." + echo "Please, commit and try again or use" + echo "a development branch." exit 1 fi +PKG_VERSION=$(/usr/libexec/PlistBuddy -c "print CFBundleShortVersionString" "${PROJECT_DIR}/Hello IT/Info.plist") + +if [[ "$CURRENT_BRANCH" == "release/*" ]] +then + CONFIGURATION="Release" + VERSION_FROM_BRANCH=$(echo "${CURRENT_BRANCH}" | awk -F'/' '{print $2}') + if [[ "$VERSION_FROM_BRANCH" =~ ^[0-9]+\.[0-9]+ ]] + then + PKG_VERSION=$VERSION_FROM_BRANCH + /usr/libexec/PlistBuddy -c "Set CFBundleShortVersionString $PKG_VERSION" "${PROJECT_DIR}/Hello IT/Info.plist" + git add "${PROJECT_DIR}/Hello IT/Info.plist" + git commit -m "Update app version number according to release branch" + fi +fi + +BASE_RELEASE_LOCATION="${GIT_ROOT_DIR}/package/build" +RELEASE_LOCATION="${BASE_RELEASE_LOCATION}/${PKG_VERSION}-${CONFIGURATION}" +RELEASE_PRODUCT_LOCATION="${RELEASE_LOCATION}/Products" +RELEASE_DSYM_LOCATION="${RELEASE_LOCATION}/dSYM" + PKG_ROOT="$(mktemp -d)" mkdir -p "${BUILT_PRODUCTS_DIR}/dSYM" From 776867e3760ca579ccdccf11372ad0c1f6ae0653 Mon Sep 17 00:00:00 2001 From: Yoann Gini Date: Fri, 1 Sep 2017 09:17:00 +0200 Subject: [PATCH 04/20] Add a documentation for release process --- package/README.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 package/README.md diff --git a/package/README.md b/package/README.md new file mode 100644 index 0000000..b4bb737 --- /dev/null +++ b/package/README.md @@ -0,0 +1,31 @@ +# Building Hello-IT + +To prepare a new Hello-IT release, somes steps must be followed in a specific order. + +## Preparation + +General code submission follow the gitflow pattern. + +Once `develop` branch is ready for a new version, a new `release` branch named with the version number only (no `v` first). + +## Building the release + +To build the release once in the release branch, use the `BuildAndPackage.command` script. + +Be sure to be on a device with `Developer ID Installer: Yoann GINI (CRXPBZF3N4)` identity available. + +The script will build the app with all dependencies in the right order, sign it, create the package, and sign it too. + +The script will build the app in `Release` config when the current branch is under `release` or is `master`. All other branch will be built in `Debug` config. + +App version will be grabbed from git branch name or let unoutched if the branch name does not match the pattern `release/version`. If version number is updated, it will automatically be commited before building the release. + +Build version is generated from the number of git commits in the history from the current branch point of view. + +Once built and tested, and only for final release (not for beta), the release branch must be merged in the master tree. Last commit to merge should be the one updating the app version. Returning to this exact commit will allow a developer to recreate the app in the exact same states (and so build version will be the same). + +The build will deny to start if there is some uncommited change to the repo. + +## Distribution + +The pkg created at the previous step can now be updated into the Github Release system with a nice description and the pkg as the only payload. \ No newline at end of file From 3b585a840ef7ab5435c1436affc535e04c36a533 Mon Sep 17 00:00:00 2001 From: Yoann Gini Date: Wed, 13 Sep 2017 17:38:08 +0200 Subject: [PATCH 05/20] Allow building script to use another developer ID --- package/BuildAndPackage.command | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/package/BuildAndPackage.command b/package/BuildAndPackage.command index e752b72..63151a6 100755 --- a/package/BuildAndPackage.command +++ b/package/BuildAndPackage.command @@ -2,7 +2,10 @@ CONFIGURATION="Release" -DEVELOPER_ID_INSTALLER="Developer ID Installer: Yoann GINI (CRXPBZF3N4)" +DEFAULT_DEVELOPER_ID_INSTALLER="Developer ID Installer: Yoann GINI (CRXPBZF3N4)" +DEVELOPER_ID_INSTALLER=${CUSTOM_DEVELOPER_ID_INSTALLER:-${DEFAULT_DEVELOPER_ID_INSTALLER}} + +echo "Packaging will use ${DEVELOPER_ID_INSTALLER}" GIT_ROOT_DIR="$(git rev-parse --show-toplevel)" PROJECT_DIR="${GIT_ROOT_DIR}/src" From 9f39f3717a4c7e71016269ba2dfa195d1591e0e6 Mon Sep 17 00:00:00 2001 From: Yoann Gini Date: Wed, 13 Sep 2017 17:41:38 +0200 Subject: [PATCH 06/20] Improved building documentation --- package/README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package/README.md b/package/README.md index b4bb737..74bc45c 100644 --- a/package/README.md +++ b/package/README.md @@ -1,10 +1,10 @@ # Building Hello-IT -To prepare a new Hello-IT release, somes steps must be followed in a specific order. +To prepare a new Hello-IT release, some steps must be followed in a specific order. ## Preparation -General code submission follow the gitflow pattern. +General code submission follows the git flow pattern. Once `develop` branch is ready for a new version, a new `release` branch named with the version number only (no `v` first). @@ -12,19 +12,19 @@ Once `develop` branch is ready for a new version, a new `release` branch named w To build the release once in the release branch, use the `BuildAndPackage.command` script. -Be sure to be on a device with `Developer ID Installer: Yoann GINI (CRXPBZF3N4)` identity available. +By default, build script will look for the Developer ID Installer named `Developer ID Installer: Yoann GINI (CRXPBZF3N4)`. Use `CUSTOM_DEVELOPER_ID_INSTALLER` environmental variable to specify your own. The script will build the app with all dependencies in the right order, sign it, create the package, and sign it too. -The script will build the app in `Release` config when the current branch is under `release` or is `master`. All other branch will be built in `Debug` config. +The script will build the app in `Release` config when the current branch is under `release` or is `master`. All other branches will be built in `Debug` config. -App version will be grabbed from git branch name or let unoutched if the branch name does not match the pattern `release/version`. If version number is updated, it will automatically be commited before building the release. +App version will be grabbed from git branches name or let untouched if the branch name does not match the pattern `release/version`. If version number is updated, it will automatically be committed before building the release. Build version is generated from the number of git commits in the history from the current branch point of view. Once built and tested, and only for final release (not for beta), the release branch must be merged in the master tree. Last commit to merge should be the one updating the app version. Returning to this exact commit will allow a developer to recreate the app in the exact same states (and so build version will be the same). -The build will deny to start if there is some uncommited change to the repo. +The build will deny to start if there is some uncommitted change to the repo. ## Distribution From 2583a19b9cd5adcbab36ea87182fa4eb156b8963 Mon Sep 17 00:00:00 2001 From: Yoann Gini Date: Wed, 13 Sep 2017 17:41:55 +0200 Subject: [PATCH 07/20] Improve code readability --- src/Hello IT/AppDelegate.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Hello IT/AppDelegate.m b/src/Hello IT/AppDelegate.m index e9c22d4..c9764cc 100644 --- a/src/Hello IT/AppDelegate.m +++ b/src/Hello IT/AppDelegate.m @@ -293,7 +293,7 @@ - (void)loadMenu { - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { if ([keyPath isEqualToString:@"testState"]) { - int substate = 0; + int substate = HITPluginTestStateNone; if ([self.statusMenuManager respondsToSelector:@selector(testState)]) { substate |= [self.statusMenuManager testState]; From 1c23b479293412b30e1ec4b2d49db5381646827a Mon Sep 17 00:00:00 2001 From: Yoann Gini Date: Wed, 13 Sep 2017 17:42:26 +0200 Subject: [PATCH 08/20] LaunchD will now keep Hello IT alive. --- package/LaunchAgents/com.github.ygini.hello-it.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/LaunchAgents/com.github.ygini.hello-it.plist b/package/LaunchAgents/com.github.ygini.hello-it.plist index afc78a1..c57acce 100644 --- a/package/LaunchAgents/com.github.ygini.hello-it.plist +++ b/package/LaunchAgents/com.github.ygini.hello-it.plist @@ -3,7 +3,7 @@ KeepAlive - + Label com.github.ygini.hello-it ProgramArguments From 52bbe637c23aee72ebd61c9bef9b3ba63a146c53 Mon Sep 17 00:00:00 2001 From: Yoann Gini Date: Wed, 13 Sep 2017 17:54:53 +0200 Subject: [PATCH 09/20] Fix bulding script to properly detect release branch --- package/BuildAndPackage.command | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/BuildAndPackage.command b/package/BuildAndPackage.command index 63151a6..b34a3c4 100755 --- a/package/BuildAndPackage.command +++ b/package/BuildAndPackage.command @@ -18,7 +18,7 @@ CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) if [[ "$CURRENT_BRANCH" == "master" ]] then CONFIGURATION="Release" -elif [[ "$CURRENT_BRANCH" == "release/*" ]] +elif [[ "$CURRENT_BRANCH" == release* ]] then CONFIGURATION="Release" else From daa870610bb53e9cd4fa1c82309f8237daab9477 Mon Sep 17 00:00:00 2001 From: Yoann Gini Date: Wed, 13 Sep 2017 17:56:07 +0200 Subject: [PATCH 10/20] Fix bulding script to properly detect release branch --- package/BuildAndPackage.command | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/package/BuildAndPackage.command b/package/BuildAndPackage.command index b34a3c4..ca64dfd 100755 --- a/package/BuildAndPackage.command +++ b/package/BuildAndPackage.command @@ -38,7 +38,7 @@ fi PKG_VERSION=$(/usr/libexec/PlistBuddy -c "print CFBundleShortVersionString" "${PROJECT_DIR}/Hello IT/Info.plist") -if [[ "$CURRENT_BRANCH" == "release/*" ]] +if [[ "$CURRENT_BRANCH" == release* ]] then CONFIGURATION="Release" VERSION_FROM_BRANCH=$(echo "${CURRENT_BRANCH}" | awk -F'/' '{print $2}') @@ -51,6 +51,8 @@ then fi fi +exit 0 + BASE_RELEASE_LOCATION="${GIT_ROOT_DIR}/package/build" RELEASE_LOCATION="${BASE_RELEASE_LOCATION}/${PKG_VERSION}-${CONFIGURATION}" RELEASE_PRODUCT_LOCATION="${RELEASE_LOCATION}/Products" From 22f6e6321a06b89bee1a9f0b2a3f1c7654fac3b5 Mon Sep 17 00:00:00 2001 From: Yoann Gini Date: Wed, 13 Sep 2017 17:56:15 +0200 Subject: [PATCH 11/20] Update app version number according to release branch --- src/Hello IT/Info.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Hello IT/Info.plist b/src/Hello IT/Info.plist index ff4953a..924b9fa 100644 --- a/src/Hello IT/Info.plist +++ b/src/Hello IT/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.2.11 + 1.2.12 CFBundleSignature ???? CFBundleVersion From 8c0fae077fce728aeebf08c3209d6149886a8cd3 Mon Sep 17 00:00:00 2001 From: Yoann Gini Date: Wed, 13 Sep 2017 17:56:51 +0200 Subject: [PATCH 12/20] Fix bulding script to properly detect release branch --- package/BuildAndPackage.command | 2 -- 1 file changed, 2 deletions(-) diff --git a/package/BuildAndPackage.command b/package/BuildAndPackage.command index ca64dfd..0ad9095 100755 --- a/package/BuildAndPackage.command +++ b/package/BuildAndPackage.command @@ -51,8 +51,6 @@ then fi fi -exit 0 - BASE_RELEASE_LOCATION="${GIT_ROOT_DIR}/package/build" RELEASE_LOCATION="${BASE_RELEASE_LOCATION}/${PKG_VERSION}-${CONFIGURATION}" RELEASE_PRODUCT_LOCATION="${RELEASE_LOCATION}/Products" From 7d3efba7e03d84b30d3a2089b751bad866ff94bf Mon Sep 17 00:00:00 2001 From: Yoann Gini Date: Wed, 13 Sep 2017 18:51:19 +0200 Subject: [PATCH 13/20] Change packaging option to deny bundle relocalisation --- package/BuildAndPackage.command | 2 +- package/pkgbuild_options.plist | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 package/pkgbuild_options.plist diff --git a/package/BuildAndPackage.command b/package/BuildAndPackage.command index 0ad9095..2b9e9f8 100755 --- a/package/BuildAndPackage.command +++ b/package/BuildAndPackage.command @@ -95,7 +95,7 @@ cp -r "${GIT_ROOT_DIR}/package/LaunchAgents/com.github.ygini.hello-it.plist" "${ #sudo chown -R root:wheel "${PKG_ROOT}" -pkgbuild --sign "${DEVELOPER_ID_INSTALLER}" --root "${PKG_ROOT}" --scripts "${GIT_ROOT_DIR}/package/pkg_scripts" --identifier "com.github.ygini.hello-it" --version "${PKG_VERSION}" "${RELEASE_LOCATION}/Hello-IT-${PKG_VERSION}-${CONFIGURATION}.pkg" +pkgbuild --component-plist "${GIT_ROOT_DIR}/package/pkgbuild_options.plist" --sign "${DEVELOPER_ID_INSTALLER}" --root "${PKG_ROOT}" --scripts "${GIT_ROOT_DIR}/package/pkg_scripts" --identifier "com.github.ygini.hello-it" --version "${PKG_VERSION}" "${RELEASE_LOCATION}/Hello-IT-${PKG_VERSION}-${CONFIGURATION}.pkg" rm -rf "${PKG_ROOT}" diff --git a/package/pkgbuild_options.plist b/package/pkgbuild_options.plist new file mode 100644 index 0000000..3d8b0cc --- /dev/null +++ b/package/pkgbuild_options.plist @@ -0,0 +1,11 @@ + + + + + + BundleIsRelocatable + + + + + From ae11887fb85702f3be61ff753e32bbfb161764b0 Mon Sep 17 00:00:00 2001 From: Yoann Gini Date: Wed, 13 Sep 2017 19:07:28 +0200 Subject: [PATCH 14/20] Update app version number according to release branch --- src/Hello IT/Info.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Hello IT/Info.plist b/src/Hello IT/Info.plist index 924b9fa..4c900fe 100644 --- a/src/Hello IT/Info.plist +++ b/src/Hello IT/Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 178 + 193 LSApplicationCategoryType public.app-category.utilities LSMinimumSystemVersion From 9c1b171d87384e4f7951d714b9b059684678fe25 Mon Sep 17 00:00:00 2001 From: Yoann Gini Date: Wed, 13 Sep 2017 19:11:56 +0200 Subject: [PATCH 15/20] Update app version number according to release branch --- src/Hello IT/Info.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Hello IT/Info.plist b/src/Hello IT/Info.plist index 4c900fe..236cb55 100644 --- a/src/Hello IT/Info.plist +++ b/src/Hello IT/Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 193 + 194 LSApplicationCategoryType public.app-category.utilities LSMinimumSystemVersion From 7685af90ffa5fe7dbccb08b9db7ebcf30a9b69b1 Mon Sep 17 00:00:00 2001 From: Yoann Gini Date: Wed, 13 Sep 2017 19:13:07 +0200 Subject: [PATCH 16/20] Update app version number according to release branch --- src/Hello IT/Info.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Hello IT/Info.plist b/src/Hello IT/Info.plist index 236cb55..415ef07 100644 --- a/src/Hello IT/Info.plist +++ b/src/Hello IT/Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 194 + 195 LSApplicationCategoryType public.app-category.utilities LSMinimumSystemVersion From 7fd7249a130b1e55901a368fb6dc7005158bd592 Mon Sep 17 00:00:00 2001 From: Yoann Gini Date: Wed, 13 Sep 2017 19:17:30 +0200 Subject: [PATCH 17/20] Update app version number according to release branch --- src/Hello IT/Info.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Hello IT/Info.plist b/src/Hello IT/Info.plist index 415ef07..b5485a0 100644 --- a/src/Hello IT/Info.plist +++ b/src/Hello IT/Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 195 + 196 LSApplicationCategoryType public.app-category.utilities LSMinimumSystemVersion From 1fd8e8bdecb295ee195b0412f52e73b0eea29579 Mon Sep 17 00:00:00 2001 From: Yoann Gini Date: Wed, 13 Sep 2017 19:17:52 +0200 Subject: [PATCH 18/20] Update app version number according to release branch --- src/Hello IT/Info.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Hello IT/Info.plist b/src/Hello IT/Info.plist index b5485a0..4847733 100644 --- a/src/Hello IT/Info.plist +++ b/src/Hello IT/Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 196 + 197 LSApplicationCategoryType public.app-category.utilities LSMinimumSystemVersion From 6f84be2140bed2ddcec896b707835f7a63e782dc Mon Sep 17 00:00:00 2001 From: Yoann Gini Date: Wed, 13 Sep 2017 19:18:56 +0200 Subject: [PATCH 19/20] Update app version number according to release branch --- src/Hello IT/Info.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Hello IT/Info.plist b/src/Hello IT/Info.plist index 4847733..ff04528 100644 --- a/src/Hello IT/Info.plist +++ b/src/Hello IT/Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 197 + 198 LSApplicationCategoryType public.app-category.utilities LSMinimumSystemVersion From cb1f94c134bacde7649a2ce7e63fa2c136eafa74 Mon Sep 17 00:00:00 2001 From: Yoann Gini Date: Wed, 13 Sep 2017 19:23:05 +0200 Subject: [PATCH 20/20] Updating build system to support force build even on release branch, and manage package building option to deny relocation dynamically (and so, relative path are automatically computed based on just created root) --- package/BuildAndPackage.command | 30 ++++++++++++------- package/pkgbuild_options.plist | 11 ------- src/HITDevKit/HITDevKit/Info.plist | 2 +- src/Hello IT/Info.plist | 2 +- .../OpenApplication/Info.plist | 2 +- .../OpenResource/OpenResource/Info.plist | 2 +- src/Plugins/Quit/Quit/Info.plist | 2 +- .../ScriptedItem/ScriptedItem/Info.plist | 2 +- src/Plugins/Separator/Separator/Info.plist | 2 +- src/Plugins/SubMenu/SubMenu/Info.plist | 2 +- src/Plugins/TestHTTP/TestHTTP/Info.plist | 2 +- src/Plugins/Title/Title/Info.plist | 2 +- 12 files changed, 29 insertions(+), 32 deletions(-) delete mode 100644 package/pkgbuild_options.plist diff --git a/package/BuildAndPackage.command b/package/BuildAndPackage.command index 2b9e9f8..40c827b 100755 --- a/package/BuildAndPackage.command +++ b/package/BuildAndPackage.command @@ -27,25 +27,28 @@ fi UNCOMMITED_CHANGE=$(git status -s | wc -l | bc) -if [ $UNCOMMITED_CHANGE -ne 0 ] && [ "$CONFIGURATION" == "Release" ] +if [ -z $FORCE_SKIP_REPO_STATE ] then - echo "Your are on ${CURRENT_BRANCH} and there" - echo "is some uncommited change to the repo." - echo "Please, commit and try again or use" - echo "a development branch." - exit 1 + if [ $UNCOMMITED_CHANGE -ne 0 ] && [ "$CONFIGURATION" == "Release" ] + then + echo "Your are on ${CURRENT_BRANCH} and there" + echo "is some uncommited change to the repo." + echo "Please, commit and try again or use" + echo "a development branch." + exit 1 + fi fi PKG_VERSION=$(/usr/libexec/PlistBuddy -c "print CFBundleShortVersionString" "${PROJECT_DIR}/Hello IT/Info.plist") if [[ "$CURRENT_BRANCH" == release* ]] then - CONFIGURATION="Release" + CONFIGURATION="Release" VERSION_FROM_BRANCH=$(echo "${CURRENT_BRANCH}" | awk -F'/' '{print $2}') - if [[ "$VERSION_FROM_BRANCH" =~ ^[0-9]+\.[0-9]+ ]] + if [[ "$VERSION_FROM_BRANCH" =~ ^[0-9]+\.[0-9]+ ]] then - PKG_VERSION=$VERSION_FROM_BRANCH - /usr/libexec/PlistBuddy -c "Set CFBundleShortVersionString $PKG_VERSION" "${PROJECT_DIR}/Hello IT/Info.plist" + PKG_VERSION=$VERSION_FROM_BRANCH + /usr/libexec/PlistBuddy -c "Set CFBundleShortVersionString $PKG_VERSION" "${PROJECT_DIR}/Hello IT/Info.plist" git add "${PROJECT_DIR}/Hello IT/Info.plist" git commit -m "Update app version number according to release branch" fi @@ -95,7 +98,12 @@ cp -r "${GIT_ROOT_DIR}/package/LaunchAgents/com.github.ygini.hello-it.plist" "${ #sudo chown -R root:wheel "${PKG_ROOT}" -pkgbuild --component-plist "${GIT_ROOT_DIR}/package/pkgbuild_options.plist" --sign "${DEVELOPER_ID_INSTALLER}" --root "${PKG_ROOT}" --scripts "${GIT_ROOT_DIR}/package/pkg_scripts" --identifier "com.github.ygini.hello-it" --version "${PKG_VERSION}" "${RELEASE_LOCATION}/Hello-IT-${PKG_VERSION}-${CONFIGURATION}.pkg" +PBK_BUILD_COMPONENT="${BUILT_PRODUCTS_DIR}/components.plist" +pkgbuild --analyze --root "${PKG_ROOT}" "${PBK_BUILD_COMPONENT}" + +/usr/libexec/PlistBuddy -c "Set 0:BundleIsRelocatable bool false" "${PBK_BUILD_COMPONENT}" +/usr/libexec/PlistBuddy -c "Print" "${PBK_BUILD_COMPONENT}" +pkgbuild --component-plist "${PBK_BUILD_COMPONENT}" --sign "${DEVELOPER_ID_INSTALLER}" --root "${PKG_ROOT}" --scripts "${GIT_ROOT_DIR}/package/pkg_scripts" --identifier "com.github.ygini.hello-it" --version "${PKG_VERSION}" "${RELEASE_LOCATION}/Hello-IT-${PKG_VERSION}-${CONFIGURATION}.pkg" rm -rf "${PKG_ROOT}" diff --git a/package/pkgbuild_options.plist b/package/pkgbuild_options.plist deleted file mode 100644 index 3d8b0cc..0000000 --- a/package/pkgbuild_options.plist +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - BundleIsRelocatable - - - - - diff --git a/src/HITDevKit/HITDevKit/Info.plist b/src/HITDevKit/HITDevKit/Info.plist index 1ad6ce0..78963ca 100644 --- a/src/HITDevKit/HITDevKit/Info.plist +++ b/src/HITDevKit/HITDevKit/Info.plist @@ -19,7 +19,7 @@ CFBundleSignature ???? CFBundleVersion - 178 + 199 NSHumanReadableCopyright Copyright © 2015 Yoann Gini (Open Source Project). All rights reserved. NSPrincipalClass diff --git a/src/Hello IT/Info.plist b/src/Hello IT/Info.plist index ff04528..bad3981 100644 --- a/src/Hello IT/Info.plist +++ b/src/Hello IT/Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 198 + 199 LSApplicationCategoryType public.app-category.utilities LSMinimumSystemVersion diff --git a/src/Plugins/OpenApplication/OpenApplication/Info.plist b/src/Plugins/OpenApplication/OpenApplication/Info.plist index b02c3da..d05f4fe 100644 --- a/src/Plugins/OpenApplication/OpenApplication/Info.plist +++ b/src/Plugins/OpenApplication/OpenApplication/Info.plist @@ -19,7 +19,7 @@ CFBundleSignature ???? CFBundleVersion - 178 + 199 HITPFunctionIdentifier public.open.application NSHumanReadableCopyright diff --git a/src/Plugins/OpenResource/OpenResource/Info.plist b/src/Plugins/OpenResource/OpenResource/Info.plist index 677b56a..acff105 100644 --- a/src/Plugins/OpenResource/OpenResource/Info.plist +++ b/src/Plugins/OpenResource/OpenResource/Info.plist @@ -19,7 +19,7 @@ CFBundleSignature ???? CFBundleVersion - 178 + 199 HITPFunctionIdentifier public.open.resource NSHumanReadableCopyright diff --git a/src/Plugins/Quit/Quit/Info.plist b/src/Plugins/Quit/Quit/Info.plist index b0abbcd..2fa4c04 100644 --- a/src/Plugins/Quit/Quit/Info.plist +++ b/src/Plugins/Quit/Quit/Info.plist @@ -19,7 +19,7 @@ CFBundleSignature ???? CFBundleVersion - 178 + 199 HITPFunctionIdentifier public.quit NSHumanReadableCopyright diff --git a/src/Plugins/ScriptedItem/ScriptedItem/Info.plist b/src/Plugins/ScriptedItem/ScriptedItem/Info.plist index 1517372..7bd501a 100644 --- a/src/Plugins/ScriptedItem/ScriptedItem/Info.plist +++ b/src/Plugins/ScriptedItem/ScriptedItem/Info.plist @@ -19,7 +19,7 @@ CFBundleSignature ???? CFBundleVersion - 178 + 199 HITPFunctionIdentifier public.script.item NSHumanReadableCopyright diff --git a/src/Plugins/Separator/Separator/Info.plist b/src/Plugins/Separator/Separator/Info.plist index 1891f94..28d1d97 100644 --- a/src/Plugins/Separator/Separator/Info.plist +++ b/src/Plugins/Separator/Separator/Info.plist @@ -19,7 +19,7 @@ CFBundleSignature ???? CFBundleVersion - 178 + 199 HITPFunctionIdentifier public.separator NSHumanReadableCopyright diff --git a/src/Plugins/SubMenu/SubMenu/Info.plist b/src/Plugins/SubMenu/SubMenu/Info.plist index 9756999..0a5a3bc 100644 --- a/src/Plugins/SubMenu/SubMenu/Info.plist +++ b/src/Plugins/SubMenu/SubMenu/Info.plist @@ -19,7 +19,7 @@ CFBundleSignature ???? CFBundleVersion - 178 + 199 HITPFunctionIdentifier public.submenu NSHumanReadableCopyright diff --git a/src/Plugins/TestHTTP/TestHTTP/Info.plist b/src/Plugins/TestHTTP/TestHTTP/Info.plist index 9da8421..0f2db5d 100644 --- a/src/Plugins/TestHTTP/TestHTTP/Info.plist +++ b/src/Plugins/TestHTTP/TestHTTP/Info.plist @@ -19,7 +19,7 @@ CFBundleSignature ???? CFBundleVersion - 178 + 199 HITPFunctionIdentifier public.test.http NSHumanReadableCopyright diff --git a/src/Plugins/Title/Title/Info.plist b/src/Plugins/Title/Title/Info.plist index 70d3ace..4639402 100644 --- a/src/Plugins/Title/Title/Info.plist +++ b/src/Plugins/Title/Title/Info.plist @@ -19,7 +19,7 @@ CFBundleSignature ???? CFBundleVersion - 178 + 199 HITPFunctionIdentifier public.title NSHumanReadableCopyright