Mac distribution build scripts: put all files and scripts into separate directory on macbuilder machine to ensure that files from different builds don't interfere

This commit is contained in:
nik
2016-02-11 11:23:45 +03:00
parent bb7233b39c
commit 36cd1aa516
3 changed files with 67 additions and 54 deletions
+17 -7
View File
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import com.intellij.util.PathUtilRt
import org.apache.tools.ant.types.Path
import org.apache.tools.ant.util.SplitClassLoader
@@ -45,14 +44,19 @@ class MacDistributionBuilder {
*/
String dmgImagePath
private String remoteDir
/**
* Converts ${targetFileName}.mac.zip file to ${targetFileName}.dmg installer with signed application inside
* @return path to created .dmg file
*/
String signAndBuildDmg(String targetFileName) {
defineTasks()
remoteDir = "intellij-builds/$fullBuildNumber"
def sitFilePath = "$artifactsPath/${targetFileName}.sit"
ant.copy(file: "$artifactsPath/${targetFileName}.mac.zip", tofile: sitFilePath)
ftpAction("mkdir") {
}
signMacZip(targetFileName, sitFilePath)
return buildDmg(targetFileName)
}
@@ -65,6 +69,7 @@ class MacDistributionBuilder {
ant.fileset(file: dmgImageCopy)
}
ant.delete(file: dmgImageCopy)
ftpAction("put", false, "777") {
ant.fileset(dir: "$communityHome/build/mac") {
include(name: "makedmg.sh")
@@ -72,16 +77,20 @@ class MacDistributionBuilder {
}
}
sshExec("./makedmg.sh ${sitFileName} ${fullBuildNumber}")
sshExec("$remoteDir/makedmg.sh ${sitFileName} ${fullBuildNumber}")
ftpAction("get", true, null, 3) {
ant.fileset(dir: artifactsPath) {
include(name: "${sitFileName}.dmg")
}
}
ftpAction("delete") {
ant.fileset(dir: artifactsPath) {
include(name: "${sitFileName}.sit")
include(name: "${sitFileName}.dmg")
ant.fileset() {
include(name: "**")
}
}
ftpAction("rmdir", true, null, 0, PathUtilRt.getParentPath(remoteDir)) {
ant.fileset() {
include(name: "${PathUtilRt.getFileName(remoteDir)}/**")
}
}
def dmgFilePath = "$artifactsPath/${sitFileName}.dmg"
@@ -114,7 +123,7 @@ class MacDistributionBuilder {
}
}
sshExec("./signapp_ce.sh ${sitFileName} ${fullBuildNumber} ${macHostProperties.userName} ${macHostProperties.password} \"${macHostProperties.codesignString}\" \"${PathUtilRt.getFileName(customJDKTarPath)}\"")
sshExec("$remoteDir/signapp_ce.sh ${sitFileName} ${fullBuildNumber} ${macHostProperties.userName} ${macHostProperties.password} \"${macHostProperties.codesignString}\" \"${PathUtilRt.getFileName(customJDKTarPath)}\"")
ftpAction("get", true, null, 3) {
ant.fileset(dir: artifactsPath) {
include(name: "${sitFileName}.sit")
@@ -162,12 +171,13 @@ class MacDistributionBuilder {
)
}
def ftpAction(String action, boolean binary = true, String chmod = null, int retriesAllowed = 0, Closure filesets) {
def ftpAction(String action, boolean binary = true, String chmod = null, int retriesAllowed = 0, String overrideRemoteDir = null, Closure filesets) {
Map<String, String> args = [
server : macHostProperties.host,
userid : macHostProperties.userName,
password : macHostProperties.password,
action : action,
remotedir : overrideRemoteDir ?: remoteDir,
binary : binary ? "yes" : "no",
passive : "yes",
retriesallowed: "$retriesAllowed"
+25 -23
View File
@@ -1,39 +1,41 @@
#!/bin/bash
# make sure only one dmg is built at a given moment
cd $(dirname $0)
EXPLODED=$2.exploded
test -d ${EXPLODED} && chmod -R u+wx ~/${EXPLODED}/*
rm -rf ~/${EXPLODED}
rm -f ~/$1.dmg
rm -f ~/pack.temp.dmg
test -d ${EXPLODED} && chmod -R u+wx ${EXPLODED}/*
rm -rf ${EXPLODED}
rm -f $1.dmg
rm -f pack.temp.dmg
mkdir ~/${EXPLODED}
mkdir ${EXPLODED}
echo "Unzipping $1.sit to ${EXPLODED}..."
ditto -x -k $1.sit ~/${EXPLODED}/
cd ~
ditto -x -k $1.sit ${EXPLODED}/
rm $1.sit
BUILD_NAME=$(ls ~/${EXPLODED}/)
BUILD_NAME=$(ls ${EXPLODED}/)
VOLNAME=`echo $BUILD_NAME | sed 's/\.app$//'`
BG_PIC="$2.png"
chmod a+x ~/${EXPLODED}/"$BUILD_NAME"/Contents/MacOS/*
chmod a+x ~/${EXPLODED}/"$BUILD_NAME"/Contents/bin/*.sh
chmod a+x ~/${EXPLODED}/"$BUILD_NAME"/Contents/bin/fs*
chmod a+x ~/${EXPLODED}/"$BUILD_NAME"/Contents/bin/relaunch
chmod a+x ${EXPLODED}/"$BUILD_NAME"/Contents/MacOS/*
chmod a+x ${EXPLODED}/"$BUILD_NAME"/Contents/bin/*.sh
chmod a+x ${EXPLODED}/"$BUILD_NAME"/Contents/bin/fs*
chmod a+x ${EXPLODED}/"$BUILD_NAME"/Contents/bin/relaunch
mkdir ~/${EXPLODED}/.background
mv ~/${BG_PIC} ~/${EXPLODED}/.background
ln -s /Applications ~/${EXPLODED}/" "
mkdir ${EXPLODED}/.background
mv ${BG_PIC} ${EXPLODED}/.background
ln -s /Applications ${EXPLODED}/" "
# allocate space for .DS_Store
dd if=/dev/zero of=~/${EXPLODED}/DSStorePlaceHolder bs=1024 count=512
dd if=/dev/zero of=${EXPLODED}/DSStorePlaceHolder bs=1024 count=512
echo "Creating unpacked r/w disk image ${VOLNAME}..."
hdiutil create -srcfolder ./${EXPLODED} -volname "$VOLNAME" -anyowners -nospotlight -quiet -fs HFS+ -fsargs "-c c=64,a=16,e=16" -format UDRW ~/$2.temp.dmg
hdiutil create -srcfolder ./${EXPLODED} -volname "$VOLNAME" -anyowners -nospotlight -quiet -fs HFS+ -fsargs "-c c=64,a=16,e=16" -format UDRW $2.temp.dmg
# mount this image
echo "Mounting unpacked r/w disk image..."
device=$(hdiutil attach -readwrite -noverify -noautoopen ~/$2.temp.dmg | egrep '^/dev/' | sed 1q | awk '{print $1.dmg}')
device=$(hdiutil attach -readwrite -noverify -noautoopen $2.temp.dmg | egrep '^/dev/' | sed 1q | awk '{print $1.dmg}')
echo "Mounted as ${device}."
sleep 10
@@ -44,9 +46,9 @@ perl makedmg.pl "$VOLNAME" ${BG_PIC}
sync;sync;sync
hdiutil detach ${device}
echo "Compressing r/w disk image to ~/$1.dmg..."
hdiutil convert ~/$2.temp.dmg -quiet -format UDZO -imagekey zlib-level=9 -o ~/$1.dmg
rm -f ~/$2.temp.dmg
echo "Compressing r/w disk image to $1.dmg..."
hdiutil convert $2.temp.dmg -quiet -format UDZO -imagekey zlib-level=9 -o $1.dmg
rm -f $2.temp.dmg
hdiutil internet-enable -no ~/$1.dmg
rm -rf ~/${EXPLODED}
hdiutil internet-enable -no $1.dmg
rm -rf ${EXPLODED}
+25 -24
View File
@@ -5,64 +5,65 @@ EXPLODED=$2.exploded
USERNAME=$3
PASSWORD=$4
CODESIGN_STRING=$5
test -d ${EXPLODED} && chmod -R u+wx ~/${EXPLODED}/*
rm -rf ~/${EXPLODED}
rm -f ~/$1.dmg
rm -f ~/pack.temp.dmg
mkdir ~/${EXPLODED}
cd $(dirname $0)
test -d ${EXPLODED} && chmod -R u+wx ${EXPLODED}/*
rm -rf ${EXPLODED}
rm -f $1.dmg
rm -f pack.temp.dmg
mkdir ${EXPLODED}
echo "Unzipping $1.sit to ${EXPLODED}..."
unzip -q $1.sit -d ~/${EXPLODED}/
unzip -q $1.sit -d ${EXPLODED}/
rm $1.sit
BUILD_NAME=$(ls ~/${EXPLODED}/)
BUILD_NAME=$(ls ${EXPLODED}/)
if [ $# -eq 6 ] && [ -f $6 ]; then
archiveJDK="$6"
echo "Modifying Info.plist"
sed -i -e 's/1.6\*/1.6\+/' ~/${EXPLODED}/"$BUILD_NAME"/Contents/Info.plist
sed -i -e 's/1.6\*/1.6\+/' ${EXPLODED}/"$BUILD_NAME"/Contents/Info.plist
jdk=jdk-bundled
if [[ $1 == *custom-jdk-bundled* ]]; then
jdk=custom-"$jdk"
fi
sed -i -e 's/NoJavaDistribution/'$jdk'/' ~/${EXPLODED}/"$BUILD_NAME"/Contents/Info.plist
rm -f ~/${EXPLODED}/"$BUILD_NAME"/Contents/Info.plist-e
sed -i -e 's/NoJavaDistribution/'$jdk'/' ${EXPLODED}/"$BUILD_NAME"/Contents/Info.plist
rm -f ${EXPLODED}/"$BUILD_NAME"/Contents/Info.plist-e
echo "Info.plist has been modified"
echo "Copying JDK: $archiveJDK to ~/${EXPLODED}/"$BUILD_NAME"/Contents"
cd ~/${EXPLODED}/"$BUILD_NAME"/Contents
tar xvf ~/$archiveJDK --exclude='._jdk'
chmod -R u+w ~/${EXPLODED}/"$BUILD_NAME"/Contents/*
echo "Copying JDK: $archiveJDK to ${EXPLODED}/"$BUILD_NAME"/Contents"
tar xvf $archiveJDK -C ${EXPLODED}/"$BUILD_NAME"/Contents --exclude='._jdk'
chmod -R u+w ${EXPLODED}/"$BUILD_NAME"/Contents/*
echo "JDK has been copied"
cd ~
rm -f ~/$archiveJDK
rm -f $archiveJDK
fi
HELP_FILE=`ls ~/${EXPLODED}/"$BUILD_NAME"/Contents/Resources/ | grep -i help`
HELP_DIR=~/${EXPLODED}/"$BUILD_NAME"/Contents/Resources/"$HELP_FILE"/Contents/Resources/English.lproj/
HELP_FILE=`ls ${EXPLODED}/"$BUILD_NAME"/Contents/Resources/ | grep -i help`
HELP_DIR=${EXPLODED}/"$BUILD_NAME"/Contents/Resources/"$HELP_FILE"/Contents/Resources/English.lproj/
echo "Building help indices for $HELP_DIR"
hiutil -Cagvf "$HELP_DIR/search.helpindex" "$HELP_DIR"
for f in ~/${EXPLODED}/"$BUILD_NAME"/Contents/bin/*.jnilib ; do
for f in ${EXPLODED}/"$BUILD_NAME"/Contents/bin/*.jnilib ; do
b="$(basename "$f" .jnilib)"
ln -sf "$b.jnilib" "$(dirname "$f")/$b.dylib"
done
for f in ~/${EXPLODED}/"$BUILD_NAME"/Contents/*.txt; do
for f in ${EXPLODED}/"$BUILD_NAME"/Contents/*.txt; do
echo "Moving $f"
mv "$f" ~/${EXPLODED}/"$BUILD_NAME"/Contents/Resources
mv "$f" ${EXPLODED}/"$BUILD_NAME"/Contents/Resources
done
# Make sure *.p12 is imported into local KeyChain
security unlock-keychain -p ${PASSWORD} /Users/${USERNAME}/Library/Keychains/login.keychain
codesign -v --deep --force -s "${CODESIGN_STRING}" ~/${EXPLODED}/"$BUILD_NAME"
codesign -v --deep --force -s "${CODESIGN_STRING}" ${EXPLODED}/"$BUILD_NAME"
echo "signing is done"
echo "check sign"
codesign -v ~/${EXPLODED}/"$BUILD_NAME" -vvvvv
codesign -v ${EXPLODED}/"$BUILD_NAME" -vvvvv
echo "check sign done"
echo "Zipping ${BUILD_NAME} to $1.sit..."
cd ${EXPLODED}
ditto -c -k --sequesterRsrc --keepParent "${BUILD_NAME}" ../$1.sit
cd ..
rm -rf ~/${EXPLODED}
rm -rf ${EXPLODED}