I've fought against Xcode with regards to this before, where I want to add a list of files and directories to be copied into the built app-package, and XCode only wants to let me add entire folders. Now I need a proper solution...
I have a workspace with multiple targets, one per application. I have a directory structure with lots of assets/data files structured a bit like this:
- Data
|- Common
| |-Scripts
| |-Images
|- AppA
| |-Scripts
| |-Images
|- AppB
| |-Scripts
| |-Images
I want to add Data/Common/* to my targets AppA & AppB, and then Data/AppA/* to AppA, etc.
What I find is if I add a folder reference to Data to my XCode project, I cannot select workspaces - I only can set which targets Data is associated with.
I could add folder references to each subfolder individually but then I think this would break the directory structure I want to achieve. Also, it just seems to get messy... say I don't want all of Common in both apps, but to cherry-pick certain sub-dirs/files for each app?
So, is there a more arbitrary way in XCode[4] to tell it which files go where? I'm aware I can write a custom bash-script build phase, I used to do that in fact but it was really bad for build performance.
Option 1) Create a bash installer and hardcode the paths inside the main project:
## Compression Script
mkdir -vp installer/payload
cd installer/
tar tvf files.tar
echo "Running Installer"
mkdir $HOME/files
tar ./files.tar -C $HOME/files
## Decompression Script
#!/bin/bash
echo ""
echo "Self Extracting Installer"
echo ""
export TMPDIR=`mktemp -d /tmp/selfextract.XXXXXX`
ARCHIVE=`awk '/^__ARCHIVE_BELOW__/ {print NR + 1; exit 0; }' $0`
tail -n+$ARCHIVE $0 | tar xzv -C $TMPDIR
CDIR=`pwd`
cd $TMPDIR
./installer
cd $CDIR
rm -rf $TMPDIR
exit 0
__ARCHIVE_BELOW__
Option 2) Use pkgbuild, productbuild and pkgutil like so:
Making OS X Installer Packages like a Pro - Xcode Developer ID ready pkg
Related
I want to display my git version on my app. From some research, it looks like I can accomplish this via a run-script.
This code below will create a file at Resources/GitVersion.swift
version=$(git rev-parse --verify HEAD | cut -c 1-10)
commitDate=$(git log -n 1 HEAD --pretty=format:"%h - %cd" | cut -c 12-)
filesource="//\n// GitVersion.swift\n//\n// Commit Date:$commitDate\n//\n\nlet gitVersion = \"$version\"\n"
cd ${SOURCE_ROOT}/${PROJECT_NAME}
echo "$filesource" > Resources/GitVersion.swift
touch Resources/GitVersion.swift
The file will look like: let gitVersion = XXX, and will update each time the code runs.
Great, except GitVersion.swift isn't in my project, so I can't reference gitVersion anywhere to access the git hash.
How can I add GitVersion.swift via a runscript to my project, such that every time I run my build, it creates the file and dynamically adds the dependency to the project?
I work on a Maven project that need to copy mode than 10 GB of artifacts in a target repository from a maven local repository (after downloaded them).
In some cases (e.g. for tests), I'd like to replace this copy by a symlink creation in order to save few minutes.
My question is: Is there a way to ask to plugin maven-dependency-plugin goal copy-dependencies to create a symlink OR is there any maven plugin that can do it.
The copy-dependencies goal cannot, to my knowledge, do this out of the box. However, you can use a shell script:
#!/bin/sh
outputDir=target/dependency
mkdir -p "$outputDir"
mvn dependency:resolve |
grep ':\(compile\|runtime\)' | sed 's/\[INFO\] *//' |
while read gav
do
case "$gav" in
*:*:*:*:*:*) # G:A:P:C:V:S
g="${gav%%:*}"; remain="${gav#*:}"
a="${remain%%:*}"; remain="${remain#*:}"
p="${remain%%:*}"; remain="${remain#*:}"
c="${remain%%:*}"; remain="${remain#*:}"
v="${remain%%:*}"
s="${remain#*:}"
;;
*:*:*:*:*) # G:A:P:V:S
g="${gav%%:*}"; remain="${gav#*:}"
a="${remain%%:*}"; remain="${remain#*:}"
p="${remain%%:*}"; remain="${remain#*:}"
c=""
v="${remain%%:*}"
s="${remain#*:}"
;;
esac
g=$(echo "$g" | sed 's/\./\//g')
test -n "$c" && artName="$a-$v-$c" || artName="$a-$v"
ln -s "$HOME/.m2/repository/$g/$a/$v/$artName.$p" "$outputDir"
done
I'm creating a tarball of a large codebase managed in ClearCase. Every directory has a sub-directory named ".CC". I'd like to exclude these from my tarball.
I've found Excluding directory when creating a .tar.gz file, but excluding that would appear to require passing each and every .CC directory on the commndline. This is impractical in my case.
Is there a way to exclude directories that meet a particular pattern?
EDIT:
I am not asking how to exclude a specific finite list of directories. I am asking how to exclude all directories that end in a particular pattern.
Instead of manually typing --exclude 'root/a/.CC' --exclude 'root/b/.CC' ... you can type $(find root -type d -name .CC -exec echo "--exclude \'{}\'" \;|xargs)
You can use whatever patterns find supports, or even use something like grep inbetween find and xargs.
The following bash script should do the trick. It uses the answer given by #Marcus Sundman.
#!/bin/bash
echo -n "Please enter the name of the tar file you wish to create with out extension "
read nam
echo -n "Please enter the path to the directories to tar "
read pathin
echo tar -czvf $nam.tar.gz
excludes=`find $pathin -iname "*.CC" -exec echo "--exclude \'{}\'" \;|xargs`
echo $pathin
echo tar -czvf $nam.tar.gz $excludes $pathin
This will print out the command you need and you can just copy and paste it back in. There is probably a more elegant way to provide it directly to the command line.
*.CC could be exchanged for any other common extension and this should still work.
I am looking for functionality where we have a directory with some files in it.
Whenever any one makes a change in any of the files in the directory, jenkins shoukd trigger a build.
Is there any plugin or mathod for this functionality. Please advise.
Thanks in advance.
I have not tried it myself, but The FSTrigger plugin seems to do what you want:
FSTrigger provides polling mechanisms to monitor a file system and
trigger a build if a file or a set of files have changed.
If you can monitor the directory with a script, you can trigger the build with a HTTP GET, for example with wget or curl:
wget -O- $JENKINS_URL/job/JOBNAME/build
Although slightly related.. it seems like this issue was about monitoring static files on system.. however there are many version control systems for just this purpose.
I answered this in another post if you're using git to track changes on the files themselves:
#!/bin/bash
set -e
job_name="whatever"
JOB_URL="http://myserver:8080/job/${job_name}/"
FILTER_PATH="path/to/folder/to/monitor"
python_func="import json, sys
obj = json.loads(sys.stdin.read())
ch_list = obj['changeSet']['items']
_list = [ j['affectedPaths'] for j in ch_list ]
for outer in _list:
for inner in outer:
print inner
"
_affected_files=`curl --silent ${JOB_URL}${BUILD_NUMBER}'/api/json' | python -c "$python_func"`
if [ -z "`echo \"$_affected_files\" | grep \"${FILTER_PATH}\"`" ]; then
echo "[INFO] no changes detected in ${FILTER_PATH}"
exit 0
else
echo "[INFO] changed files detected: "
for a_file in `echo "$_affected_files" | grep "${FILTER_PATH}"`; do
echo " $a_file"
done;
fi;
You can add the check directly to the top of the job's exec shell, and it will exit 0 if no changes detected.. Hence, you can always poll the top level of the repo for check-in's to trigger a build. And only complete a build if the files in question change.
I have been developing an app for an iDevice, and I wanted to create a .deb file of my app, so I created a simple app in Xcode to test things out, but I am having difficulty creating the .deb file.
I did the following steps:
1) deleted the .DS_Store files, *$ rm -rf .DS_Store*
2) $ dpkg-deb -b ~/repo/debs
When it creates the .deb file it is only 16KB which I know the test app should be a little bigger.
The directory structure for the app is as follows:
+- MyProgram
+- Applications
| +- MyProgram.app
| +- Info.plist
| +- MyProgram
| +- icon.png
+- DEBIAN
| +- control
+- System
+- Library
+- LaunchDaemons
+- com.saurik.MyProgram.plist
I didn't include a com.saurik.MyProgram.plist file because I didn't see a file resembling one in the build directory, when I built the app in Xcode.
Basically the app is a simple viewcontroller with a label. The app does contain a .storyboard file if that makes a difference.
I got this working, and created a shell script in the process. The shell script is as follows:
#!/bin/bash
echo "Update Repo Script Started"
cd ~/Projects/<ProjectName>
ldid -S app/<Project.app>/<Project>
cp -R app/<Project.app> ~/packages/<Project>/Applications/
cd ~/packages
echo $PWD
dpkg-deb -b <Project> ~/repo/debs/
cd ~/repo
dpkg-scanpackages debs / > Packages
bzip2 -fks Packages
cd ..
ssh -n <host> 'rm -rf /path/to/your/repo'
scp -r repo <host>:/home/<user>/www/
echo "Repo Updated"