#!/bin/sh # # Copyright (c) 2005 Kimmo Suominen # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. # 3. The name of the author may not be used to endorse or promote # products derived from this software without specific prior # written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN # IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # Create WordPress/fi_FI tar.gz and zip files. # # 20050222 Kimmo Suominen # 20050315 Kimmo Suominen - Use standard repository layout (UTF-8) # 20050319 Kimmo Suominen - Use gettext theme and branches # 20070601 Kimmo Suominen - Use tags, not branches # export PATH PATH=/bin:/usr/bin:/usr/pkg/bin:/usr/local/bin # verbose=0 # if [ -r "${HOME}/.wpbuildrc" ] then . "${HOME}/.wpbuildrc" fi # usage() { ( echo "Usage: $0 [options] -t themebase directory [...]" echo " $0 [options] -d dist -r repository" echo " " echo "Common options:" echo "-b branch Use branch, if it exists, otherwise use trunk" echo "-d dist The original WordPress distribution" echo "-i revision I18N revision to use in created filenames" echo "-w revision WordPress revision to use in created filenames" ) 1>&2 exit 1 } # copytree() { (cd "${1}" && pax -rw -pp -s '|.*/\..*||' . "${2}") } # mkfilename() { echo -n "${CURDIR}/${BASENAME}" echo -n "${WREV:+-${WREV}}" echo -n "-${LANG}${charset:+.${charset}}" echo "${IREV:+-${IREV}}" } # while getopts b:d:i:r:t:vw: opt do case "${opt}" in b) BRANCHTAG="${OPTARG}";; d) DIST="${OPTARG}";; i) IREV="${OPTARG}";; r) REPODIR="${OPTARG}";; t) THEMEDIR="${OPTARG}";; v) verbose=`expr ${verbose} + 1`;; w) WREV="${OPTARG}";; *) usage;; esac done shift `expr ${OPTIND} - 1` # case $# in 0) if [ -z "${REPODIR}" ] then echo "ERROR: Must provide a repository or directories" 1>&2 echo " " 1>&2 usage fi set -- "${REPODIR}"/*/trunk ;; esac # if [ -z "${BASENAME}" ] then BASENAME="wordpress" if [ -n "${BRANCHTAG}" ] then BASENAME="wordpress-${BRANCHTAG}" else BASENAME="latest" fi fi # CURDIR=`pwd` # case "${DIST}" in /*) ;; *) DIST="${CURDIR}/${DIST}" ;; esac # if [ ! -r "${DIST}" ] then echo "ERROR: Cannot read ${DIST}" 1>&2 exit 1 fi # if [ -z "${THEMEDIR}" ] then if [ -n "${REPODIR}" ] then if [ -d "${REPODIR}/theme/tags/${BRANCHTAG}" ] then THEMEDIR="${REPODIR}/theme/tags/${BRANCHTAG}" else THEMEDIR="${REPODIR}/theme/trunk" fi fi fi # umask 022 # for dir do case "${dir}" in /*) SRCDIR="${dir}" ;; *) SRCDIR="${CURDIR}/${dir}" ;; esac # case "${SRCDIR}" in */cy/*) LANG="cy" ;; */eo/*) LANG="eo" ;; */fa/*) LANG="fa" ;; */??_??*/*) LANG=`echo "${SRCDIR}" | sed -e 's,.*/\(.._..[^/]*\)/.*,\1,'` case "${LANG}" in */*) if [ ${verbose} -gt 0 ] then echo "Skipping ${SRCDIR}" fi continue ;; esac ;; *) if [ ${verbose} -gt 0 ] then echo "Skipping ${SRCDIR}" fi continue ;; esac # if [ -n "${BRANCHTAG}" ] then BDIR=`echo "${SRCDIR}" | sed -e "s,/trunk,/tags/${BRANCHTAG},"` if [ -d "${BDIR}" ] then SRCDIR="${BDIR}" echo "Processing ${LANG}/tags/${BRANCHTAG}" else echo "Processing ${LANG}/trunk" fi fi # for mpo in "${SRCDIR}/messages/"*.po do if [ ! -f "${mpo}" ] then continue fi # bf=`basename "${mpo}" .po` case "${bf}" in "${LANG}".*) charset=`echo "${bf}" | awk -F. '{print $NF}'` ;; "${LANG}") charset='' ;; theme-"${LANG}"*) # these are processed as needed continue ;; *) if [ ${verbose} -gt 0 ] then echo "* not processing ${mpo}" fi continue ;; esac # WRKDIR=`mktemp -d -t wp` # if [ ! -d "${WRKDIR}" ] then echo "ERROR: Creating work directory failed!" 1>&2 exit 1 fi # trap "rm -rf '${WRKDIR}'" 0 1 3 13 15 # cd "${WRKDIR}" || exit 1 # if [ -d "${DIST}" ] then mkdir wordpress || exit 1 copytree "${DIST}" wordpress else tar -xzf "${DIST}" fi # mkdir -p "wordpress/wp-includes/languages" msgfmt -o "wordpress/wp-includes/languages/${LANG}.mo" "${mpo}" # for i in \ "theme${charset:+/${charset}}" \ "theme${charset:+/${charset}}/default" do theme="${i}" if [ -f "${SRCDIR}/${i}/index.php" ] then break fi done # for pair in \ "${theme} wp-content/themes/default" \ "dist${charset:+/${charset}} ." do set -- ${pair} src="${SRCDIR}/${1}" dst="${WRKDIR}/wordpress/${2}" if [ -d "${src}" ] then if [ ${verbose} -gt 1 ] then echo "* ${1}" fi copytree "${src}" "${dst}" else case "${src}" in "${SRCDIR}/${theme}") if [ -d "${THEMEDIR}" ] then tpo=`echo ${mpo} | sed -e \ "s,/messages/${LANG},/messages/theme-${LANG},"` if [ -f "${tpo}" ] then if [ ${verbose} -gt 1 ] then echo '* gettext theme ('`basename "${tpo}"`')' fi msgfmt -o "${dst}/${LANG}.mo" "${tpo}" copytree "${THEMEDIR}" "${dst}" continue fi fi ;; esac echo "* WARNING: ${LANG}: ${1} is missing" fi done # chmod -R u=rwX,go=rX wordpress # pfile="`mkfilename`" for i in tar.gz zip do case "$i" in zip) cmd="zip -qr" ;; *) cmd="tar -czf" ;; esac eval $cmd "${pfile}.${i}" wordpress || rm -f "${pfile}.${i}" # if [ -f "${pfile}.${i}" ] then echo '* created' `basename "${pfile}.${i}"` fi done # cd "${CURDIR}" rm -rf "${WRKDIR}" done done