-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #153 from h0tw1r3/feature/packaging
Packaging
- Loading branch information
Showing
14 changed files
with
301 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>English</string> | ||
<key>CFBundleIconFile</key> | ||
<string>attract.icns</string> | ||
<key>CFBundleExecutable</key> | ||
<string>launch.sh</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>org.attractmode.attract</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>Attract</string> | ||
<key>CFBundleDisplayName</key> | ||
<string>AttradeMode</string> | ||
<key>CFBundleSpokenName</key> | ||
<string>Attract Mode</string> | ||
<key>CFBundlePackageType</key> | ||
<string>APPL</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>%%SHORTVERSION%%</string> | ||
<key>CFBundleSignature</key> | ||
<string>????</string> | ||
<key>CFBundleVersion</key> | ||
<string>%%BUNDLEVERSION%%</string> | ||
</dict> | ||
</plist> |
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/usr/bin/env python | ||
# coding: utf-8 | ||
|
||
# Recursively change dynamic library link paths for non-system libraries | ||
# to be relative to the linked program and copy them to <program>/../libs | ||
# | ||
# TODO: parse individual architectures (necessary?) | ||
# modify temp lib instead of assuming path changes work | ||
# | ||
# Gist: https://gist.github.com/h0tw1r3/b12752f8e33f70422fbe | ||
# Copyright: © 2015 Jeffrey Clark | ||
# License: GPLv3 (http://www.gnu.org/licenses/gpl-3.0.html) | ||
|
||
import os, stat, sys, subprocess, re, shutil | ||
|
||
toolchain = os.getenv('TOOLCHAIN') | ||
if toolchain == None: | ||
toolchain = "" | ||
else: | ||
toolchain += "-" | ||
otool = toolchain + "otool" | ||
install_name_tool = toolchain + "install_name_tool" | ||
|
||
def runOtool(filename): | ||
p = subprocess.Popen([otool, '-XL', filename], stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
return iter(p.stdout.readline, b'') | ||
|
||
def fixname(filename, old, new): | ||
p = subprocess.Popen([install_name_tool, '-change', old, new, filename], stdout=subprocess.PIPE) | ||
p.communicate() | ||
return | ||
|
||
def fixid(filename, newid): | ||
p = subprocess.Popen([install_name_tool, '-id', '@loader_path/../libs/' + newid, filename], stdout=subprocess.PIPE) | ||
p.communicate() | ||
return | ||
|
||
def cmd_exists(cmd): | ||
return subprocess.call("type " + cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0 | ||
|
||
def mainloop(filename): | ||
for line in runOtool(filename): | ||
m = re.search('\s+/((usr|opt)/local/.*) \(.*\)$', line) | ||
if m and len(m.group(1)) != 0: | ||
path = os.path.realpath( os.path.join(os.getenv('LIB_BASE_PATH','/'),m.group(1)) ) | ||
linkname = os.path.basename( path ) | ||
if os.path.isfile( '../libs/' + linkname ) is False: | ||
try: | ||
shutil.copy2(path, '../libs/') | ||
os.chmod('../libs/' + linkname, stat.S_IRWXU | stat.S_IRGRP | stat.S_IROTH ) | ||
fixid('../libs/' + linkname, linkname) | ||
mainloop('../libs/' + linkname) | ||
except IOError as e: | ||
print e | ||
continue | ||
fixname( filename, '/' + m.group(1), '@loader_path/../libs/' + linkname ) | ||
else: | ||
m = re.search('\s+(@rpath(.*)) \(.*\)$', line) | ||
if m and len(m.group(2)) != 0: | ||
path = os.path.realpath(os.path.join(os.getenv('LIB_BASE_PATH','/'), 'usr/local/lib', m.group(2))) | ||
print path | ||
linkname = os.path.basename(path) | ||
fixname(filename, m.group(1), '@loader_path/../libs/' + linkname) | ||
|
||
if (len(sys.argv) != 2): | ||
print "Usage: " + os.path.basename(sys.argv[0]) + " executable" | ||
sys.exit(1) | ||
if (not cmd_exists(otool)): | ||
raise ValueError('Unable to execute otool: ' + otool) | ||
if (not cmd_exists(install_name_tool)): | ||
raise ValueError('Unable to execute install_name_tool: ' + install_name_tool) | ||
if (not os.path.isfile(sys.argv[1])): | ||
raise ValueError('File does not exist: ' + sys.argv[1]) | ||
if (not os.access(sys.argv[1], os.W_OK)): | ||
raise ValueError('Unable to write to file: ' + sys.argv[1]) | ||
|
||
mainloop(sys.argv[1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Copyright: © 2015 Jeffrey Clark | ||
# License: GPLv3 (http://www.gnu.org/licenses/gpl-3.0.html) | ||
|
||
### begin: init | ||
set -o pipefail | ||
set -o errtrace | ||
|
||
error() { | ||
echo "ERROR in $0 : line $1 exit code $2" | ||
exit $2 | ||
} | ||
trap 'error ${LINENO} ${?}' ERR | ||
|
||
SCRIPT_PATH="${BASH_SOURCE[0]}"; | ||
if ([ -h "${SCRIPT_PATH}" ]) then | ||
while([ -h "${SCRIPT_PATH}" ]) do SCRIPT_PATH=`readlink "${SCRIPT_PATH}"`; done | ||
fi | ||
pushd . > /dev/null | ||
cd `dirname ${SCRIPT_PATH}` > /dev/null | ||
SCRIPT_PATH=`pwd`; | ||
cd .. | ||
### end: init | ||
|
||
LASTTAG=$(git describe --tag --abbrev=0) | ||
VERSION=$(git describe --tag | sed 's/-[^-]*$//') | ||
REVCOUNT=$(git rev-list HEAD --count) | ||
BUNDLEVERSION=${VERSION//[v-]/.}; BUNDLEVERSION=${BUNDLEVERSION#"."} | ||
SHORTVERSION=${LASTTAG//v/} | ||
|
||
### begin: make | ||
PLATFORM=$(uname) | ||
MAKEOPTS="" | ||
|
||
# osxcross auto-detect | ||
if [[ "$PLATFORM" != "Darwin" ]]; then | ||
! [ -x "$(command -v hfsplus)" ] && echo "FATAL: 'hfsplus' not found" && exit 1 | ||
! [ -x "$(command -v mkfs.hfsplus)" ] && echo "FATAL: 'mkfs.hfs' not found" && exit 1 | ||
! [ -x "$(command -v dmg)" ] && echo "FATAL: 'dmg' not found" && exit 1 | ||
|
||
if [[ -z ${OSXCROSS_TARGET_DIR} || -z ${OSXCROSS_TARGET} ]]; then | ||
echo "osxcross not initialized. add osxcross-conf and osxcross-env to the current environment" && exit 1 | ||
fi | ||
|
||
[[ -z ${TOOLCHAIN} ]] && export TOOLCHAIN=x86_64-apple-${OSXCROSS_TARGET} | ||
[[ -z ${LIB_BASE_PATH} ]] && export LIB_BASE_PATH="$(realpath ${OSXCROSS_TARGET_DIR}/macports/pkgs)" | ||
|
||
MAKEOPTS="$MAKEOPTS CROSS=1 TOOLCHAIN=${TOOLCHAIN} FE_MACOSX_COMPILE=1 EXTRA_CFLAGS=\"-arch i386 -arch x86_64\"" | ||
fi | ||
|
||
NPROC=$(getconf _NPROCESSORS_ONLN) | ||
LLIMIT=$(awk 'BEGIN{printf"%.1f",'${NPROC}'/2}') | ||
|
||
make -C .. clean | ||
eval make -C .. -j${NPROC} -l${LLIMIT} ${MAKEOPTS} DATA_PATH=../config/ $@ | ||
### end: make | ||
|
||
function finish { | ||
if [[ ! -z $SCRATCH && -d $SCRATCH ]] ; then | ||
rm -rf "${SCRATCH}" | ||
fi | ||
} | ||
trap finish EXIT | ||
|
||
SCRATCH=$(mktemp -d -t package.XXXXXXXX) | ||
APPCONTENT="${SCRATCH}"/disk/Attract.app/Contents | ||
|
||
# Create bundle folder structure | ||
mkdir -p "${APPCONTENT}"/{MacOS,Resources,libs} | ||
|
||
cp -r ../config "${APPCONTENT}"/ | ||
[[ -d ../../extras ]] && cp -r ../../extras/* "${APPCONTENT}"/config/ | ||
cp -a ../attract "${APPCONTENT}"/MacOS/ | ||
cp -a "${SCRIPT_PATH}"/attract.icns "${APPCONTENT}"/Resources/ | ||
cp -a "${SCRIPT_PATH}"/launch.sh "${APPCONTENT}"/MacOS/ | ||
|
||
# Documentation | ||
mkdir "${SCRATCH}/disk/Documentation" | ||
cp -a ../License.txt ${SCRATCH}/disk/Documentation/ | ||
cp ../*.md "${SCRATCH}"/disk/Documentation/ | ||
./output-changelog-md.sh ${LASTTAG} > "${SCRATCH}"/disk/Documentation/Changelog.md | ||
|
||
# convert markdown to html if possible | ||
find "${SCRATCH}"/disk/Documentation/ -name '*.md' | while read f | ||
do | ||
fp="${X%.md}" | ||
if ! [ -x "$(command -v pandoc)" ]; then | ||
mv "${f}" "${fp}.txt" | ||
else | ||
pandoc -f markdown_github -t html5 "${f}" -o "${fp}.html" && rm "${f}" | ||
fi | ||
done | ||
|
||
cat "${SCRIPT_PATH}"/Info.plist | sed 's/%%SHORTVERSION%%/'${SHORTVERSION}'/' | sed 's/%%BUNDLEVERSION%%/'${BUNDLEVERSION}'/' > "${APPCONTENT}"/Info.plist | ||
|
||
cp osx/DS_Store "${SCRATCH}/disk/.DS_Store" | ||
cp osx/VolumeIcon.icns "${SCRATCH}/disk/.VolumeIcon.icns" | ||
mkdir "${SCRATCH}/disk/.background" | ||
cp osx/background.png "${SCRATCH}/disk/.background/background.png" | ||
|
||
# Copy extra libs to bundle and fix link path | ||
pushd "${APPCONTENT}"/MacOS >/dev/null | ||
${SCRIPT_PATH}/bundlelibs.py attract | ||
popd >/dev/null | ||
|
||
if [[ "$PLATFORM" != "Darwin" ]]; then | ||
WORKDMG="${SCRATCH}/uncompressed.dmg" | ||
dd if=/dev/zero of="${WORKDMG}" bs=1M count=128 | ||
mkfs.hfsplus -v "AttractMode" "${WORKDMG}" | ||
hfsplus "${WORKDMG}" addall "${SCRATCH}/disk/" | ||
hfsplus "${WORKDMG}" attr / C | ||
hfsplus "${WORKDMG}" symlink " " /Applications | ||
# TODO: genisoimage has drawbacks, but most people dont have libdmg-hfsplus built | ||
# make conditional package based on best available tools. | ||
# genisoimage -D -V "AttractMode ${VERSION#v}" -no-pad -r -apple -o ${SCRATCH}/uncompressed.dmg ${SCRATCH}/disk/ | ||
dmg dmg "${WORKDMG}" ../attract-${VERSION#v}.dmg | ||
else | ||
# TODO: mount dmg and set file attributes (volume icon) and create Application symlink | ||
hdiutil create -volname "AttractMode" -srcfolder ${SCRATCH}/disk/ -ov -format UDBZ ../attract-${VERSION#v}.dmg | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
cd "${0%/*}" | ||
./attract |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/bin/bash | ||
# | ||
# Generate markdown format changelog | ||
# from tag (default HEAD) to previous tag | ||
# grouped by author | ||
# | ||
# Copyright: © 2015 Jeffrey Clark | ||
# License: GPLv3 (http://www.gnu.org/licenses/gpl-3.0.html) | ||
|
||
# set cwd | ||
SCRIPT_PATH="${BASH_SOURCE[0]}"; | ||
if ([ -h "${SCRIPT_PATH}" ]) then | ||
while([ -h "${SCRIPT_PATH}" ]) do SCRIPT_PATH=`readlink "${SCRIPT_PATH}"`; done | ||
fi | ||
pushd . > /dev/null | ||
cd `dirname ${SCRIPT_PATH}` > /dev/null | ||
SCRIPT_PATH=`pwd`; | ||
cd ${SCRIPT_PATH}/.. | ||
|
||
if [ $# -eq 0 ] ; then | ||
TAG=$(git describe --tag) | ||
else | ||
## Just for attractmode | ||
if [[ $1 =~ ^v ]]; then | ||
TAG=$1 | ||
else | ||
TAG=v$1 | ||
fi | ||
fi | ||
PRETAG=$(git describe --tag --abbrev=0 ${TAG}^) | ||
|
||
IFS=$'\r\n' | ||
|
||
echo -e "# Changelog #" | ||
|
||
RANGE="${TAG}..HEAD" | ||
i=0 | ||
for author in $(git --no-pager log --no-merges --pretty=format:"%an" ${RANGE} | sort | uniq -c) ; | ||
do | ||
[ $i -eq 0 ] && echo -e "\n## Commits made after ${TAG} ##" | ||
name=$(echo $author | sed 's/^\ *\([0-9]*\)\ \(.*\)$/\2/') | ||
count=$(echo $author | sed 's/^\ *\([0-9]*\)\ \(.*\)$/\1/') | ||
echo -e "\n### $name ($count commits)\n" | ||
git --no-pager log --author="$name" --date=short --no-merges --pretty=format:"* %s" ${RANGE} | grep -v "(nw)\| NW\| nw" | ||
(( i++ )) | ||
done | ||
|
||
RANGE="${PRETAG}..${TAG}" | ||
|
||
echo -e "\n## Commits from ${PRETAG} to ${TAG}" | ||
|
||
for author in $(git --no-pager log --no-merges --pretty=format:"%an" ${RANGE} | sort | uniq -c) ; | ||
do | ||
name=$(echo $author | sed 's/^\ *\([0-9]*\)\ \(.*\)$/\2/') | ||
count=$(echo $author | sed 's/^\ *\([0-9]*\)\ \(.*\)$/\1/') | ||
echo -e "\n### $name ($count commits)\n" | ||
git --no-pager log --author="$name" --date=short --no-merges --pretty=format:"* %s" ${RANGE} | grep -v "(nw)\| NW\| nw" | ||
done |