This is an old revision of the document!


Building the Standalone Client

After initial inquiry in a Zotero forum thread, and some trial-and-error, I was able to build the Zotero Standalone client from source using the bash scriptlet shown below). The main things I needed to learn were:

  1. Location of build script: the root directory of the source contains the build_sa bash script
  2. Build prerequisites
    1. Tools: subversion, bash and perl
    2. Non-source inputs: XULRunner. build_sa mentions a requirement for XULRunner runtime 2.0.*. However, Ubuntu does not package a 2.x XULRunner before 11.04, which is currently pre-release. For now, Pre-release xulrunner-2.x runtimes can be obtained from http://ftp.mozilla.org/pub/mozilla.org/xulrunner/nightly/latest-trunk/. build_sa states implicitly that it requires separate runtimes for each target architecture, and expects to find each such runtime in a directory with a conventional name (see bash scriptlet below).
  3. Build control: build_sa uses no config file, takes no arguments, and is non-interactive. build_sa will build one or more of the target OSs (linux, mac or win32), but it decides which architectures are built for each.
  4. Running the built sa (as opposed to running the build): after building, and some perusal of (e.g.) the output of ls -alt ${BUILD_PATH} $(find -executable -type f) | grep -ve '.so$', I found ${BUILD_PATH}/Zotero_${BUILD_ARCH}/zotero.

Bash Scriptlet

I automated a build on 64-bit Ubuntu with the following bash scriptlet:

START="$(date)"
# edit following vars as desired for your build
DOWNLOAD_ROOT="/tmp/xulrunner"
BUILD_ARCH="linux-x86_64"
BUILD_ROOT="${HOME}/bin/zotero/standalone"
BUILD_DIR="20101228"
BUILD_PATH="${BUILD_ROOT}/${BUILD_DIR}"
BUILD_SCRIPT="build_sa"
BUILD_SCRIPT_BAK="${BUILD_SCRIPT}.0"
XULR_SOURCE_ROOT="http://ftp.mozilla.org/pub/mozilla.org/xulrunner/nightly/latest-trunk"
XULR_TARGET_PATH="${BUILD_PATH}/xulrunner_${BUILD_ARCH}"
XULR_VERSION="2.0b9pre.en-US"
XULR_CHECKSUMS_NAME="xulrunner-${XULR_VERSION}.${BUILD_ARCH}.checksums"
XULR_CHECKSUMS_SOURCE="${XULR_SOURCE_ROOT}/${XULR_CHECKSUMS_NAME}"
XULR_CHECKSUMS_TARGET="${DOWNLOAD_ROOT}/${XULR_CHECKSUMS_NAME}"
XULR_ARCHIVE_NAME="xulrunner-${XULR_VERSION}.${BUILD_ARCH}.tar.bz2"
XULR_ARCHIVE_SOURCE="${XULR_SOURCE_ROOT}/${XULR_ARCHIVE_NAME}"
XULR_ARCHIVE_TARGET="${DOWNLOAD_ROOT}/${XULR_ARCHIVE_NAME}"
ZOTERO_SOURCE_ROOT="https://www.zotero.org/svn/standalone/trunk/"
ZOTERO_TARGET_EXEC="${BUILD_PATH}/Zotero_${BUILD_ARCH}/zotero"

# setup xulrunner
# download xulrunner
mkdir -p ${DOWNLOAD_ROOT}
wget -O ${XULR_CHECKSUMS_TARGET} ${XULR_CHECKSUMS_SOURCE}
wget -O ${XULR_ARCHIVE_TARGET} ${XULR_ARCHIVE_SOURCE}
# verify xulrunner
pushd ${DOWNLOAD_ROOT}
# sha512sum -c < ${XULR_CHECKSUMS_TARGET}
# fails with
# > sha512sum: standard input: no properly formatted SHA512 checksum lines found
# I tried (offline) some other invocations, which similarly all failed
# $ sha512sum -c < /tmp/xulrunner/xulrunner-2.0b9pre.en-US.linux-x86_64.checksums 
# sha512sum: standard input: no properly formatted SHA512 checksum lines found
# $ pushd ${DOWNLOAD_ROOT}
# $ sha512sum -c < ${XULR_CHECKSUMS_NAME}
# sha512sum: standard input: no properly formatted SHA512 checksum lines found
# $ sha512sum -c < xulrunner-2.0b9pre.en-US.linux-x86_64.checksums 
# sha512sum: standard input: no properly formatted SHA512 checksum lines found
# $ sha512sum -c xulrunner-2.0b9pre.en-US.linux-x86_64.checksums 
# sha512sum: xulrunner-2.0b9pre.en-US.linux-x86_64.checksums: no properly formatted SHA512 checksum lines found
# unpack xulrunner
tar xjf ${XULR_ARCHIVE_NAME}
mkdir -p ${BUILD_PATH}
# ASSERT: archives expand to ./xulrunner
mv ./xulrunner ${XULR_TARGET_PATH}
popd

# setup sources, including script
# checkout sources
pushd ${BUILD_ROOT}
svn co ${ZOTERO_SOURCE_ROOT} ${BUILD_DIR}
popd
pushd ${BUILD_PATH}
# backup unhacked build script
cp ${BUILD_SCRIPT} ${BUILD_SCRIPT_BAK}
chmod 444 ${BUILD_SCRIPT_BAK}
# hack build script to build only linux
chmod 755 ${BUILD_SCRIPT}
sed -si 's/BUILD_MAC=1/BUILD_MAC=0/g' ${BUILD_SCRIPT}
sed -si 's/BUILD_WIN32=1/BUILD_WIN32=0/g' ${BUILD_SCRIPT}
sed -si 's/BUILD_LINUX=0/BUILD_LINUX=1/g' ${BUILD_SCRIPT}
diff -u ${BUILD_SCRIPT_BAK} ${BUILD_SCRIPT}

# CHECK: you should see stdout like
# --- build_sa.0  2010-12-28 16:45:21.000000000 -0500
# +++ build_sa    2010-12-28 16:45:21.000000000 -0500
# @@ -1,7 +1,7 @@
#  #!/bin/bash
# -BUILD_MAC=1
# +BUILD_MAC=0
#  BUILD_WIN32=0
# -BUILD_LINUX=0
# +BUILD_LINUX=1

# build
BUILD_START="$(date)"
./${BUILD_SCRIPT}
echo -e "build   end=$(date)"
echo -e "build start=${BUILD_START}"

# run the built sa
${ZOTERO_TARGET_EXEC} &
echo -e "  end=$(date)"
echo -e "start=${START}"

The (penultimate) build step produced the output

Getting latest Zotero revision
Got Zotero r7528
Building translators.zip
Building styles.zip
Retrieving Zotero OpenOffice.org Integration
Building Zotero_linux-i686
# several errors here, as I did not have the xulrunner for this arch
Building Zotero_linux-x86_64

The run step puts up a zotero window similar to that normally seen in Firefox. When initially run separately from the terminal, it produced the output

$ ./Zotero_linux-x86_64/zotero &
ERROR: There is no such extension deployed: org.Zotero.integration.openoffice
unopkg failed.

but I have not observed that subsequently.

Unfortunately I don't currently know how to test the built sa (much less from Chrome) aside from the following smoketest: if I

  1. Run the executable (e.g., ${ZOTERO_TARGET_EXEC}, ./Zotero_linux-x86_64/zotero).
  2. Wait for the zotero window, then select “Zotero Quick Start” in its middle pane.
  3. Hit button=View in the rightmost pane.

a browser launches and and opens the quick start guide. That's comforting, but I'd prefer to know:

  1. Is there a more extensive test suite? E.g., what do youse do pre-commit?
  2. How to load up my own (backed up) Zotero data (from my Firefox profile, or wherever else it might be) and do actual work?
dev/building_the_standalone_client.1303088180.txt.gz · Last modified: 2011/04/17 20:56 by rmzelle