Skip to content

Commit

Permalink
Add 'relax-apply'
Browse files Browse the repository at this point in the history
  • Loading branch information
scenee committed May 6, 2018
1 parent 298a9e1 commit 9733f12
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 50 deletions.
2 changes: 1 addition & 1 deletion completions/relax.bash
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ _relax() {

if [[ -n $special ]]; then
case $special in
archive|build|export|show|package|upload|resign)
apply|archive|build|dist|export|show|package|upload|resign)
if [[ $prev = $special ]]; then
COMPREPLY=( $( compgen -W "$(relax completions $special)" -- $cur ) )
else
Expand Down
Binary file modified go/bin/relparser
Binary file not shown.
6 changes: 5 additions & 1 deletion go/src/relparser/relfile/distribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,14 @@ func (d Distribution) writeSource(name string, out *os.File) {
source += fmt.Sprintf("export %v=\"%v\"\n", "_BUNDLE_VERSION", d.BundleVersion)

infos := FindProvisioningProfile(d.ProvisioningProfile, "")

if len(infos) == 0 {
logger.Fatalf("Not installed \"%s\"", d.ProvisioningProfile)
}

pp := infos[0].Pp
source += fmt.Sprintf("export %v=\"%v\"\n", "_TEAM_ID", pp.TeamID())
source += fmt.Sprintf("export %v=\"%v\"\n", "_IDENTITY", pp.CertificateType())

// fmt/Println("--- Build settings\n")
build_settings = strings.Join([]string{PREFIX, name, "build_settings"}, "_")

Expand Down
3 changes: 2 additions & 1 deletion go/src/relparser/relfile/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package relfile

import (
"log"
"os"
)

var logger *log.Logger
var logger = log.New(os.Stderr, "", 0)
4 changes: 3 additions & 1 deletion go/src/relparser/relfile/provisioning_profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ func TestNewProvisioningProfile(t *testing.T) {
func TestFindProvisioningProfile(t *testing.T) {
ClearCache()
infos := FindProvisioningProfile("Relax", "")

if len(infos) != 2 {
t.Errorf("Failed")
t.Errorf("Failed %v", infos)
}

for _, info := range infos {
fmt.Println(info.Name, info.Pp.Name)
if _, err := os.Stat(info.Name); err != nil {
Expand Down
13 changes: 3 additions & 10 deletions go/src/relparser/relparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ import (
"relparser/relfile"
)

//
// Global variables
//

var logger *log.Logger

//
// Utils
//
Expand All @@ -31,7 +25,6 @@ func usage() {
// Main
//
func init() {
logger = log.New(os.Stderr, "error: ", 0)
}

func main() {
Expand Down Expand Up @@ -68,11 +61,11 @@ func main() {

rel, err = relfile.LoadRelfile(in)
if err != nil {
logger.Fatal(err)
log.Fatal(err)
}

if rel.Version == "" || len(rel.Distributions) == 0 {
logger.Fatalf("Please update your Relfile format to 2.x. See https://github.com/SCENEE/relax#relfile")
log.Fatalf("Please update your Relfile format to 2.x. See https://github.com/SCENEE/relax#relfile")
}

switch cmd {
Expand All @@ -88,7 +81,7 @@ func main() {

case "export_options":
if infoPlist == "" {
logger.Fatalf("Pass a Info.plist path using '-plist' option")
log.Fatalf("Pass a Info.plist path using '-plist' option")
}
rel.GenOptionsPlist(dist, infoPlist, out)

Expand Down
2 changes: 1 addition & 1 deletion libexec/keychain/keychain
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ help)
die "No such $module command \`$command'"
fi

TRAP "clean_temp; teardown;"
TRAP "clean_temp;"
make_temp

"$command_path" "$@"
Expand Down
2 changes: 1 addition & 1 deletion libexec/profile/profile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ help)
die "No such $module command \`$command'"
fi

TRAP "clean_temp; teardown;"
TRAP "clean_temp;"
make_temp

"$command_path" "$@"
Expand Down
4 changes: 2 additions & 2 deletions libexec/relax
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ case $command in
check_toolchain

case $command in
build|archive|export|upload|package|show|completions|dist)
build|archive|export|upload|package|show|completions|apply|dist)
REL_CONFIG_PATH="$(config_find)"
REL_DISTRIBUTIONS="$(config_get_distributions $REL_CONFIG_PATH | tr '\r\n' ' ')"
;;
Expand All @@ -145,7 +145,7 @@ case $command in
commands|completions|show|ls-certs)
;;
*)
TRAP "clean_temp; teardown;"
TRAP "clean_temp;"
make_temp
;;
esac
Expand Down
28 changes: 28 additions & 0 deletions libexec/relax-apply
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash -eu
# Summary: Apply a Relfile customization into your project

usage () {
cat <<-EOM
Usage: ${ME} apply <distribution>
Apply your Info.plist and Build settings for a distribution in Relfile into your project.
EOM
fin
}

Distribution=

while [[ $# != 0 ]]; do
arg=$1
shift
case $arg in
*)
Distribution="$arg"
;;
esac
done

[[ -n "$Distribution" ]] || usage

setup_build $Distribution
18 changes: 6 additions & 12 deletions libexec/util
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,11 @@ clean_temp () {
if [[ ! -z $REL_TEMP_DIR ]] && [[ -d $REL_TEMP_DIR ]]; then
rm -rf $REL_TEMP_DIR
fi
}

teardown () {
if [ -f $REL_CONFIG ]; then
find $HERE -name "*.$BAK_EXT" |\
while IFS= read bak
do
cp "$bak" "${bak%.$BAK_EXT}"
rm "$bak"
done
fi
find $HERE -name "*.$BAK_EXT" |\
while IFS= read bak
do
rm "$bak"
done
}

fin () {
Expand Down Expand Up @@ -169,4 +163,4 @@ declare -x -f check_toolchain compare_versions
declare -x -f fin die die_with_status
declare -x -f logi logv logd logw loge __log
declare -x -f make_temp clean_temp
declare -x -f teardown TRAP kill_childprocesses
declare -x -f TRAP kill_childprocesses
35 changes: 15 additions & 20 deletions libexec/util-build
Original file line number Diff line number Diff line change
Expand Up @@ -239,16 +239,17 @@ __replace_development_team () {
local pbxproj="$PROJECT_FILE_PATH/project.pbxproj"

if ! grep -q "DEVELOPMENT_TEAM = .*;" "$pbxproj"; then
sed -i.bak '
sed -i.temp'
/PRODUCT_NAME = .*/a \
DEVELOPMENT_TEAM = TGKEN7XA5C;\
' "$pbxproj"
else
sed -i.$BAK_EXT -e "
sed -i.temp -e "
s:\(DEVELOPMENT_TEAM = \)\(.*\);:\1$_TEAM_ID;:g;
s:\(DevelopmentTeam = \)\(.*\);:\1$_TEAM_ID;:g;
" "$pbxproj"
fi
rm "${pbxproj}.temp"

export DEVELOPMENT_TEAM=$_TEAM_ID
}
Expand Down Expand Up @@ -443,19 +444,11 @@ print_info_plist () {
teardown_build () {
__kill_bg_xcodebuid_task

if [[ ${INFO_PLIST_PATH:-undefined} != undefined ]]; then
if [[ -f $INFO_PLIST_PATH.$BAK_EXT ]]; then
cp "$INFO_PLIST_PATH".$BAK_EXT "$INFO_PLIST_PATH"
fi
fi
if [[ ${PROJECT_FILE_PATH:-undefined} != undefined ]]; then
if [[ -f "$PROJECT_FILE_PATH"/project.pbxproj.$BAK_EXT ]]; then
rm "$PROJECT_FILE_PATH"/*.$BAK_EXT
fi
if [[ -f "$PROJECT_FILE_PATH"/project.pbxproj.org ]]; then
mv "$PROJECT_FILE_PATH"/project.pbxproj.org "$PROJECT_FILE_PATH"/project.pbxproj
fi
fi
find $HERE -name "*.$BAK_EXT" |\
while IFS= read bak
do
cp "$bak" "${bak%.$BAK_EXT}"
done
}

# setup_build [--export <archive-path>] <release>
Expand Down Expand Up @@ -499,7 +492,7 @@ setup_build () {
test -n "$_PROVISIONING_PROFILE" || die "Relfile requires 'provisioning_profile' field for $release."
fi

cp -a "$PROJECT_FILE_PATH"/project.pbxproj "$PROJECT_FILE_PATH"/project.pbxproj.org
cp -a "$PROJECT_FILE_PATH"/project.pbxproj "$PROJECT_FILE_PATH"/project.pbxproj.$BAK_EXT

if [[ "${team_id:-undefined}" != undefined ]]; then
__replace_development_team $_TEAM_ID
Expand Down Expand Up @@ -565,9 +558,10 @@ setup_build () {

# Override CFBundleIdentifier from Relfile
if [[ "${_BUNDLE_ID:-undefined}" != undefined ]]; then
sed -i .$BAK_EXT \
sed -i .temp \
-e "s/\(PRODUCT_BUNDLE_IDENTIFIER = \)\($PRODUCT_BUNDLE_IDENTIFIER\);/\1$_BUNDLE_ID;/" \
"$PROJECT_FILE_PATH"/project.pbxproj
rm "$PROJECT_FILE_PATH"/project.pbxproj.temp

/usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier $_BUNDLE_ID" "$INFO_PLIST_PATH"

Expand Down Expand Up @@ -631,16 +625,17 @@ setup_build () {
## Switch to Manual Signing
if is_xcode_version ">=" 8; then
if grep -q ProvisioningStyle "$PROJECT_FILE_PATH"/project.pbxproj; then
sed -i .$BAK_EXT \
sed -i .temp \
-e "s/\(ProvisioningStyle = \)Automatic/\1Manual/" \
"$PROJECT_FILE_PATH"/project.pbxproj
else
s='[[:space:] ]*'
sed -i .$BAK_EXT \
sed -i .temp \
-e "s/\($s\)\(DevelopmentTeam = .*;\)/\1\2\\
\1ProvisioningStyle = Manual;\
/" "$PROJECT_FILE_PATH"/project.pbxproj
/" "$PROJECT_FILE_PATH"/project.pbxproj
fi
rm "$PROJECT_FILE_PATH"/project.pbxproj.temp
logi "$ARROW Switch to Manual signing with '$_PROVISIONING_PROFILE' provisioning profile"
fi
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
Expand Down

0 comments on commit 9733f12

Please sign in to comment.