Skip to content

Commit

Permalink
Overhaul the packaging scripts:
Browse files Browse the repository at this point in the history
- Ingame mod versions now always match the package version
- Adds macOS compatibility
- Removes trait and lua api docs pending future overhaul
- Individual platform packages can be compiled directly
- Improved error checking
- Removes unnecessary redundancy and indirection
  • Loading branch information
pchote committed Apr 30, 2017
1 parent 3111b2c commit 696b48b
Show file tree
Hide file tree
Showing 11 changed files with 220 additions and 298 deletions.
25 changes: 9 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,6 @@ default: core

core: dependencies game platforms mods utility server

package: all-dependencies core docs version

mods: mod_common mod_cnc mod_d2k

all: dependencies core
Expand All @@ -294,24 +292,26 @@ cli-dependencies:
@ $(CP_R) thirdparty/download/*.dll .
@ $(CP_R) thirdparty/download/*.dll.config .

linux-dependencies: cli-dependencies linux-native-dependencies
linux-dependencies: cli-dependencies geoip-dependencies linux-native-dependencies

linux-native-dependencies:
@./thirdparty/configure-native-deps.sh

windows-dependencies:
windows-dependencies: cli-dependencies geoip-dependencies
@./thirdparty/fetch-thirdparty-deps-windows.sh

osx-dependencies: cli-dependencies
osx-dependencies: cli-dependencies geoip-dependencies
@./thirdparty/fetch-thirdparty-deps-osx.sh
@ $(CP_R) thirdparty/download/osx/*.dylib .
@ $(CP_R) thirdparty/download/osx/*.dll.config .

dependencies: $(os-dependencies)
geoip-dependencies:
@./thirdparty/fetch-geoip-db.sh
@ $(CP) thirdparty/download/GeoLite2-Country.mmdb.gz .

all-dependencies: cli-dependencies windows-dependencies osx-dependencies
dependencies: $(os-dependencies)

all-dependencies: cli-dependencies windows-dependencies osx-dependencies geoip-dependencies

version: mods/ra/mod.yaml mods/cnc/mod.yaml mods/d2k/mod.yaml mods/ts/mod.yaml mods/modcontent/mod.yaml mods/all/mod.yaml
@for i in $? ; do \
Expand All @@ -320,18 +320,14 @@ version: mods/ra/mod.yaml mods/cnc/mod.yaml mods/d2k/mod.yaml mods/ts/mod.yaml m
rm $${i}.tmp; \
done

docs: utility mods version
@mono --debug OpenRA.Utility.exe all --docs > DOCUMENTATION.md
@mono --debug OpenRA.Utility.exe all --lua-docs > Lua-API.md

man-page: utility mods
@mono --debug OpenRA.Utility.exe all --man-page > openra.6

install: install-core
install: default install-core

install-linux-shortcuts: install-linux-scripts install-linux-icons install-linux-desktop

install-core: default
install-core:
@-echo "Installing OpenRA to $(DATA_INSTALL_DIR)"
@$(INSTALL_DIR) "$(DATA_INSTALL_DIR)"
@$(INSTALL_PROGRAM) $(foreach prog,$(CORE),$($(prog)_TARGET)) "$(DATA_INSTALL_DIR)"
Expand Down Expand Up @@ -362,10 +358,7 @@ install-core: default
@$(INSTALL_PROGRAM) Open.Nat.dll "$(DATA_INSTALL_DIR)"
@$(INSTALL_PROGRAM) MaxMind.Db.dll "$(DATA_INSTALL_DIR)"
@$(INSTALL_PROGRAM) SmarIrc4net.dll "$(DATA_INSTALL_DIR)"

ifneq ($(UNAME_S),Darwin)
@$(CP) *.sh "$(DATA_INSTALL_DIR)"
endif

install-linux-icons:
@$(INSTALL_DIR) "$(DESTDIR)$(datadir)/icons/"
Expand Down
76 changes: 0 additions & 76 deletions packaging/checkout-and-build.sh

This file was deleted.

10 changes: 0 additions & 10 deletions packaging/clean.sh

This file was deleted.

63 changes: 41 additions & 22 deletions packaging/linux/buildpackage.sh
Original file line number Diff line number Diff line change
@@ -1,41 +1,60 @@
#!/bin/bash
# OpenRA packaging master script for linux packages

if [ $# -ne "3" ]; then
echo "Usage: `basename $0` tag files-dir outputdir"
command -v curl >/dev/null 2>&1 || { echo >&2 "Linux packaging requires curl."; exit 1; }
command -v markdown >/dev/null 2>&1 || { echo >&2 "Linux packaging requires markdown."; exit 1; }

if [ $# -ne "2" ]; then
echo "Usage: `basename $0` tag outputdir"
exit 1
fi

TAG=$1
VERSION=`echo $TAG | grep -o "[0-9]\\+-\\?[0-9]\\?"`
BUILTDIR=$2
PACKAGEDIR=$3
ROOTDIR=root
# Set the working dir to the location of this script
cd $(dirname $0)

TAG="${1}"
VERSION=`echo ${TAG} | grep -o "[0-9]\\+-\\?[0-9]\\?"`
OUTPUTDIR="${2}"

SRCDIR="$(pwd)/../.."
BUILTDIR="$(pwd)/build"

# Clean up
rm -rf $ROOTDIR
rm -rf ${BUILTDIR}

echo "Building core files"

cd ../..
pushd ${SRCDIR} > /dev/null
make linux-dependencies
make core SDK="-sdk:4.5"
make version VERSION="${TAG}"

# Copy files for OpenRA.Game.exe and OpenRA.Editor.exe as well as all dependencies.
make install prefix="/usr" DESTDIR="$PWD/packaging/linux/$ROOTDIR"
make install-core prefix="/usr" DESTDIR="${BUILTDIR}"
make install-linux-shortcuts prefix="/usr" DESTDIR="${BUILTDIR}"
make install-linux-mime prefix="/usr" DESTDIR="${BUILTDIR}"
make install-linux-appdata prefix="/usr" DESTDIR="${BUILTDIR}"
make install-man-page prefix="/usr" DESTDIR="${BUILTDIR}"

# Install startup scripts, desktop files and icons
make install-linux-shortcuts prefix="/usr" DESTDIR="$PWD/packaging/linux/$ROOTDIR"
make install-linux-mime prefix="/usr" DESTDIR="$PWD/packaging/linux/$ROOTDIR"
make install-linux-appdata prefix="/usr" DESTDIR="$PWD/packaging/linux/$ROOTDIR"
make install-man-page prefix="/usr" DESTDIR="$PWD/packaging/linux/$ROOTDIR"
popd > /dev/null

# Documentation
mkdir -p $PWD/packaging/linux/$ROOTDIR/usr/share/doc/openra/
cp *.html $PWD/packaging/linux/$ROOTDIR/usr/share/doc/openra/
DOCSDIR="${BUILTDIR}/usr/share/doc/openra/"

mkdir -p "${DOCSDIR}"

curl -s -L -O https://raw.githubusercontent.com/wiki/OpenRA/OpenRA/Changelog.md
markdown Changelog.md > "${DOCSDIR}/Changelog.html"
rm Changelog.md

markdown ${SRCDIR}/README.md > "${DOCSDIR}/README.html"
markdown ${SRCDIR}/CONTRIBUTING.md > "${DOCSDIR}/CONTRIBUTING.html"

pushd packaging/linux/deb >/dev/null
echo "Building Debian package."
./buildpackage.sh "$TAG" ../$ROOTDIR "$PACKAGEDIR"
pushd deb >/dev/null
echo "Building Debian package"
./buildpackage.sh "${TAG}" "${BUILTDIR}" "${OUTPUTDIR}"
if [ $? -ne 0 ]; then
echo "Debian package build failed."
fi
popd >/dev/null

rm -rf $PWD/packaging/linux/$ROOTDIR/
rm -rf "${BUILTDIR}"
49 changes: 35 additions & 14 deletions packaging/linux/deb/buildpackage.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
#!/bin/bash
# OpenRA packaging script for Debian based distributions

LINUX_BUILD_ROOT="$(readlink -f "$2")"
DEB_BUILD_ROOT=./root
command -v fakeroot >/dev/null 2>&1 || { echo >&2 "Debian packaging requires fakeroot."; exit 1; }
command -v dpkg-deb >/dev/null 2>&1 || { echo >&2 "Debian packaging requires dpkg-deb."; exit 1; }

LIBDIR=/usr/lib/openra
DOCDIR=/usr/share/doc/openra
LINTIANORDIR=/usr/share/lintian/overrides

E_BADARGS=85
if [ $# -ne "3" ]
then
echo "Usage: `basename $0` version root-dir outputdir"
exit $E_BADARGS
fi
DATE=`echo $1 | grep -o "[0-9]\\+-\\?[0-9]\\?"`

# Set the working dir to the location of this script
cd $(dirname $0)

TAG="${1}"
LINUX_BUILD_ROOT="${2}"
OUTPUTDIR="${3}"

DEB_BUILD_ROOT="$(pwd)/build"

LIBDIR=/usr/lib/openra
DOCDIR=/usr/share/doc/openra
LINTIANORDIR=/usr/share/lintian/overrides
E_BADARGS=85

DATE=`echo ${TAG} | grep -o "[0-9]\\+-\\?[0-9]\\?"`
TYPE=`echo $1 | grep -o "^[a-z]*"`
VERSION="$DATE.$TYPE"
VERSION="${DATE}.${TYPE}"

# Copy template files into a clean build directory (required)
mkdir "${DEB_BUILD_ROOT}"
Expand Down Expand Up @@ -62,21 +72,32 @@ rm "${DEB_BUILD_ROOT}/${LIBDIR}/COPYING"
chmod -R g-w "${DEB_BUILD_ROOT}"

# Create the control file
PACKAGE_SIZE=`du --apparent-size -c "${DEB_BUILD_ROOT}/usr" | grep "total" | awk '{print $1}'`
sed "s/{VERSION}/$VERSION/" DEBIAN/control | sed "s/{SIZE}/$PACKAGE_SIZE/" > "${DEB_BUILD_ROOT}/DEBIAN/control"
if [[ "$OSTYPE" == "darwin"* ]]; then
# BSD du doesn't have an --apparent-size flag, so we must accept a different result
PACKAGE_SIZE=`du -c "${DEB_BUILD_ROOT}/usr" | grep "total" | awk '{print $1}'`
else
PACKAGE_SIZE=`du --apparent-size -c "${DEB_BUILD_ROOT}/usr" | grep "total" | awk '{print $1}'`
fi

sed "s/{VERSION}/${VERSION}/" DEBIAN/control | sed "s/{SIZE}/${PACKAGE_SIZE}/" > "${DEB_BUILD_ROOT}/DEBIAN/control"

# Build it in the temp directory, but place the finished deb in our starting directory
pushd "${DEB_BUILD_ROOT}" >/dev/null

# Calculate md5sums and clean up the ./usr/ part of them
find . -type f -not -path "./DEBIAN/*" -print0 | xargs -0 -n1 md5sum | sed 's|\./usr/|usr/|' > DEBIAN/md5sums
if [[ "$OSTYPE" == "darwin"* ]]; then
find . -type f -not -path "./DEBIAN/*" -print0 | xargs -0 -n1 openssl md5 | awk '{ print $2, substr($1, 7, length($1)-8) }' > DEBIAN/md5sums
else
find . -type f -not -path "./DEBIAN/*" -print0 | xargs -0 -n1 md5sum | sed 's|\./usr/|usr/|' > DEBIAN/md5sums
fi

chmod 0644 DEBIAN/md5sums

# Replace any dashes in the version string with periods
PKGVERSION=`echo $1 | sed "s/-/\\./g"`
PKGVERSION=`echo ${TAG} | sed "s/-/\\./g"`

# Start building, the file should appear in the output directory
fakeroot dpkg-deb -b . "$3/openra_${PKGVERSION}_all.deb"
fakeroot dpkg-deb -b . "${OUTPUTDIR}/openra_${PKGVERSION}_all.deb"

# Clean up
popd >/dev/null
Expand Down
Loading

0 comments on commit 696b48b

Please sign in to comment.