From a993c99d576cfef0798d2f69cb807bd8d08ced0a Mon Sep 17 00:00:00 2001 From: Jessica Tölke Date: Mon, 4 Jun 2012 21:08:22 +0200 Subject: Add a script to automatically format xml files. --- client/formatXML.sh | 13 +++++++++++++ client/indent.xsl | 7 +++++++ 2 files changed, 20 insertions(+) create mode 100755 client/formatXML.sh create mode 100644 client/indent.xsl diff --git a/client/formatXML.sh b/client/formatXML.sh new file mode 100755 index 0000000..c830f30 --- /dev/null +++ b/client/formatXML.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +cd .. + +for f in $(find -name "*.xml") +do + if [ ${f} != "./items.xml" ]; then + xsltproc tools/indent.xsl ${f} > ${f}__ + mv ${f}__ ${f} + fi +done +xmlindent items.xml > items.xml_ +sed 's/[[:space:]]*$//' items.xml_ > items.xml diff --git a/client/indent.xsl b/client/indent.xsl new file mode 100644 index 0000000..7d747ab --- /dev/null +++ b/client/indent.xsl @@ -0,0 +1,7 @@ + + + + + + + -- cgit v1.2.3-70-g09d2 From f4d40d38710743fa9f4f12ec035ac9b19e977253 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Fri, 20 Jul 2012 16:18:36 -0700 Subject: Canonicalize tileset names. Also remove some executable bits --- client/edit-map-tileset-names.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 client/edit-map-tileset-names.sh diff --git a/client/edit-map-tileset-names.sh b/client/edit-map-tileset-names.sh new file mode 100755 index 0000000..6c359e2 --- /dev/null +++ b/client/edit-map-tileset-names.sh @@ -0,0 +1,15 @@ +#!/bin/bash +for MAP in maps/*.tmx +do + grep ' Date: Fri, 20 Jul 2012 17:35:17 -0700 Subject: Canonicalize tileset order and use external tilesets --- client/add-git-attributes | 2 ++ client/edit-all-to-export-tilesets.sh | 19 +++++++++++++++++++ client/list-tileset-order | 15 +++++++++++++++ 3 files changed, 36 insertions(+) create mode 100755 client/add-git-attributes create mode 100755 client/edit-all-to-export-tilesets.sh create mode 100755 client/list-tileset-order diff --git a/client/add-git-attributes b/client/add-git-attributes new file mode 100755 index 0000000..80cc30c --- /dev/null +++ b/client/add-git-attributes @@ -0,0 +1,2 @@ +#!/bin/sh +git config diff.csv2tsv.textconv 'sed s/,/\\t/g' diff --git a/client/edit-all-to-export-tilesets.sh b/client/edit-all-to-export-tilesets.sh new file mode 100755 index 0000000..7be3411 --- /dev/null +++ b/client/edit-all-to-export-tilesets.sh @@ -0,0 +1,19 @@ +#!/bin/bash +for MAP in $(ls maps | grep '\.tmx$') +do + TILESETS=$( + grep ' Date: Sun, 20 Jan 2013 23:22:56 +0100 Subject: Add Client updates tools to generate zip updates. --- client/client-updates/.gitignore | 3 + client/client-updates/README | 69 ++++++++++++++++++++++ client/client-updates/release/news.txt | 0 client/client-updates/release/resources.xml | 3 + client/client-updates/release/resources2.txt | 0 client/client-updates/src/adler32.c | 68 +++++++++++++++++++++ client/client-updates/src/client-updates-gen | 68 +++++++++++++++++++++ client/client-updates/src/client-updates-inspect | 20 +++++++ client/client-updates/src/client-updates-news | 14 +++++ client/client-updates/src/client-updates-push | 8 +++ .../client-updates/src/client-updates.conf.example | 15 +++++ client/client-updates/src/makefile | 9 +++ 12 files changed, 277 insertions(+) create mode 100644 client/client-updates/.gitignore create mode 100644 client/client-updates/README create mode 100644 client/client-updates/release/news.txt create mode 100644 client/client-updates/release/resources.xml create mode 100644 client/client-updates/release/resources2.txt create mode 100644 client/client-updates/src/adler32.c create mode 100755 client/client-updates/src/client-updates-gen create mode 100755 client/client-updates/src/client-updates-inspect create mode 100755 client/client-updates/src/client-updates-news create mode 100755 client/client-updates/src/client-updates-push create mode 100644 client/client-updates/src/client-updates.conf.example create mode 100644 client/client-updates/src/makefile diff --git a/client/client-updates/.gitignore b/client/client-updates/.gitignore new file mode 100644 index 0000000..c369c66 --- /dev/null +++ b/client/client-updates/.gitignore @@ -0,0 +1,3 @@ +/src/adler32 +/src/client-updates.conf + diff --git a/client/client-updates/README b/client/client-updates/README new file mode 100644 index 0000000..56026b8 --- /dev/null +++ b/client/client-updates/README @@ -0,0 +1,69 @@ +######################################## +# How to use the client updates system # +######################################## + +# Initial setup + +1. compile adler32: Run 'make' in the src directory. +2. Copy example config and edit it to your needs: + $ cp client-updates.conf.example client-updates.conf +3. Optionally, put the client-update-{gen,news,inspect,push} in your PATH +4. Init a git repository for the client-updates dir, as zip updates will be committed. + $ git init + $ git add . + $ git commit -m 'Initial scripts' + +Now we have to generate the base update. +If you have already base zip files, you can include them in the release/ directory. +Fill properly the resources.xml and resources2.xml files. +Otherwise, run client-updates-gen with proper arguments. +1st arg is base commit, 2nd arg is final commit (HEAD if omitted). + +# Overview +The process to manage client updates is as follows: + +1. a developer needs to include new client data. +2. if not done already, he/she will set up a personal branch in the tmwa-client-data repo + and pull what is necessary. +3. the tmwa-client-data repo has a "testing" branch which is the reference for generating the updates. + there is also the "master" branch which is in sync with mainline. + the developer will perform a merge in the "testing" branch, and if necessary resolve the conflicts. +4. $ client-updates-gen + will generate if necessary a new zip and display its contents. +5. optionally, you can check the contents of the updates is correct: + $ client-updates-inspect + This will list the contents of all updates in a pager, from most recent to oldest. +6. $ client-updates-push + will sync the client updates to the local webserver directory + +As a general rule, never break the history of the "$CLIENT_DATA_BRANCH" branch of the tmwa-client-data repository. + +# Handling news -- only useful if not using the news of the server-data. + +1. $ client-updates-news + will open the news.txt for editing. +2. Publish these changes. + $ client-updates-push + +# Details on the client-updates-gen script + +This script analyses the client data repo and generates +a zip file with the files changed / added between 2 revisions. + +The script will check the differences between HEAD and the latest reference commit. +The reference commit is determined by the latest entry in $UPDATES_DIR/resources2.src.txt + +# Config file (client-updates.conf) + +Several variables for finding the UPDATES_DIR, the client data repository, +and ftp credentials. +Find it next to client-updates-* scripts. + +# Client updates repository + +A local git repository is used for managing these scripts. +This repository has 2 branches: master and updates +The repository should always be left on the branch "updates": most scripts will write commits +when updates are issued or when news.txt is updated. +When you need to change things in the core scripts, change to master, commit, then rebase the "updates" branch. + diff --git a/client/client-updates/release/news.txt b/client/client-updates/release/news.txt new file mode 100644 index 0000000..e69de29 diff --git a/client/client-updates/release/resources.xml b/client/client-updates/release/resources.xml new file mode 100644 index 0000000..faab981 --- /dev/null +++ b/client/client-updates/release/resources.xml @@ -0,0 +1,3 @@ + + + diff --git a/client/client-updates/release/resources2.txt b/client/client-updates/release/resources2.txt new file mode 100644 index 0000000..e69de29 diff --git a/client/client-updates/src/adler32.c b/client/client-updates/src/adler32.c new file mode 100644 index 0000000..5dd7e4c --- /dev/null +++ b/client/client-updates/src/adler32.c @@ -0,0 +1,68 @@ +/* + * adler32.c (c) 2006 Bjorn Lindeijer + * License: GPL, v2 or later + * + * Calculates Adler-32 checksums for all files passed as argument. + * + * Usage: adler32 [file]... + */ + +#include +#include +#include + +/** + * Calculates the Adler-32 checksum for the given file. + */ +unsigned long fadler32(FILE *file) +{ + // Obtain file size + fseek(file, 0, SEEK_END); + long fileSize = ftell(file); + rewind(file); + + // Calculate Adler-32 checksum + char *buffer = (char*) malloc(fileSize); + fread(buffer, 1, fileSize, file); + unsigned long adler = adler32(0L, Z_NULL, 0); + adler = adler32(adler, (Bytef*) buffer, fileSize); + free(buffer); + + return adler; +} + +/** + * Prints out usage and exists. + */ +void print_usage() +{ + printf("Usage: adler32 [file]...\n"); + exit(0); +} + +int main(int argc, char *argv[]) +{ + int i; /**< Loops through arguments. */ + + if (argc == 1) + { + print_usage(); + } + + for (i = 1; i < argc; ++i) + { + FILE *file = fopen(argv[i], "r"); + + if (!file) + { + printf("Error while opening '%s' for reading!\n", argv[i]); + exit(1); + } + + unsigned long adler = fadler32(file); + printf("%s %lx\n", argv[i], adler); + fclose(file); + } + + return 0; +} diff --git a/client/client-updates/src/client-updates-gen b/client/client-updates/src/client-updates-gen new file mode 100755 index 0000000..76c0ed3 --- /dev/null +++ b/client/client-updates/src/client-updates-gen @@ -0,0 +1,68 @@ +#!/bin/sh + +# config +SRC=$(dirname $(readlink -f "$0")) + +. ${SRC}/client-updates.conf + +# Check we are on the $CLIENT_DATA_BRANCH branch +git --git-dir "${CLIENT_DATA_DIR}/.git" branch | grep -q "^* $CLIENT_DATA_BRANCH" || { echo "The client-data repository is not on $CLIENT_DATA_BRANCH branch. Exiting"; exit 2; } + +# Unless specified on 1st argument, we'll use the latest revision that was +# included in updates, as starting revision. +# If this is the initial generation, this argument is mandatory. +if [ $# -gt 0 ]; then + OLD_CLIENT_DATA_HEAD="$1" +else + # Get the last commit sha where we generated an update + # This assumes the generated zip names follow the pattern: update-SHA1..SHA2.zip + OLD_CLIENT_DATA_HEAD=$(tail -n 1 ${UPDATES_DIR}/release/resources2.txt | cut -d . -f 3) +fi + +# Unless specified on 2nd argument, we'll use the HEAD as final revision. +if [ $# -gt 1 ]; then + NEW_CLIENT_DATA_HEAD="$2" +else + # get the commit SHA from the client data repo + NEW_CLIENT_DATA_HEAD=$(git --git-dir "${CLIENT_DATA_DIR}/.git" rev-parse HEAD | cut -c 1-7) +fi + +if [ "$OLD_CLIENT_DATA_HEAD" = "$NEW_CLIENT_DATA_HEAD" ]; then + echo "Everything is up-to-date." + exit 0 +fi + +update_basename="update-${OLD_CLIENT_DATA_HEAD}..${NEW_CLIENT_DATA_HEAD}" + +# generate a diff of files to package +cd ${CLIENT_DATA_DIR} +git --git-dir "${CLIENT_DATA_DIR}/.git" log --name-status ${OLD_CLIENT_DATA_HEAD}..${NEW_CLIENT_DATA_HEAD} | awk '/^(A|M)\t/ {print $2}' | sort | uniq | xargs zip -9 -r "${UPDATES_DIR}/${update_basename}.zip" > /dev/null +cd - > /dev/null + +if [ ! -f "${UPDATES_DIR}/${update_basename}.zip" ];then + echo "Error while generating ${update_basename}.zip. Exiting." > /dev/stderr + exit 1 +fi + +# package update +cd "${UPDATES_DIR}" +mkdir -p "release" +${SRC}/adler32 "${update_basename}.zip" >> "release/resources2.txt" +hash=$(tail -n 1 "release/resources2.txt" | awk '{ print $2; }') +# populate resources.xml as well +xmlentry="" + +sed -i '$d' 'release/resources.xml' +echo " $xmlentry" >> 'release/resources.xml' +echo '' >> 'release/resources.xml' + +echo "Adding ${update_basename}.zip:" +# Display the contents of the update +unzip -l ${update_basename}.zip +mv "${update_basename}.zip" "release/" +# Copy resources +git add 'release' +git commit -m "Updating resources to ${NEW_CLIENT_DATA_HEAD}" > /dev/null +cd - > /dev/null + +exit 0 diff --git a/client/client-updates/src/client-updates-inspect b/client/client-updates/src/client-updates-inspect new file mode 100755 index 0000000..03ae2d6 --- /dev/null +++ b/client/client-updates/src/client-updates-inspect @@ -0,0 +1,20 @@ +#!/bin/sh + +#config +SRC=$(dirname $(readlink -f "$0")) + +. ${SRC}/client-updates.conf + +DIRECTORY="${UPDATES_DIR}/release" +listing=$(mktemp) +IFS=' +' +for f in $(tac $DIRECTORY/resources2.txt); do + file=$(awk '{ print $1; }' <<< $f) + unzip -l "$DIRECTORY/$file" >> $listing +done + +if [ -f "$listing" ]; then + less "$listing" +fi +rm -f "$listing" diff --git a/client/client-updates/src/client-updates-news b/client/client-updates/src/client-updates-news new file mode 100755 index 0000000..bc78e4e --- /dev/null +++ b/client/client-updates/src/client-updates-news @@ -0,0 +1,14 @@ +#!/bin/sh + +# config +SRC=$(dirname $(readlink -f "$0")) + +. ${SRC}/client-updates.conf + +# Edit news.txt +nano "${UPDATES_DIR}"/release/news.txt + +# Commit if changed +cd "${UPDATES_DIR}" +git status | grep -q 'news.txt' && { git add release/news.txt; git commit -m 'Updating news.txt' > /dev/null; } +cd - > /dev/null diff --git a/client/client-updates/src/client-updates-push b/client/client-updates/src/client-updates-push new file mode 100755 index 0000000..edeae49 --- /dev/null +++ b/client/client-updates/src/client-updates-push @@ -0,0 +1,8 @@ +#!/bin/sh + +# config +SRC=$(dirname $(readlink -f "$0")) + +. ${SRC}/client-updates.conf + +rsync -av --delete "$UPDATES_DIR/release/" "$UPDATES_PUBLISH_DIR" diff --git a/client/client-updates/src/client-updates.conf.example b/client/client-updates/src/client-updates.conf.example new file mode 100644 index 0000000..8bdce43 --- /dev/null +++ b/client/client-updates/src/client-updates.conf.example @@ -0,0 +1,15 @@ +# The client-data directory +CLIENT_DATA_DIR="$HOME/tmwa-client-data" + +# The updates working directory +UPDATES_DIR="$HOME/client-updates" + +# The git branch used for generating the updates +# This allows for more complex setups, where e.g a branch is used for merging +# from various other branches. It's used on the testing server +# Defaults to master +CLIENT_DATA_BRANCH=master + +# Local directory served by the web server, +# where the update files will be copied +UPDATES_PUBLISH_DIR="$HOME/www/tmwupdate" diff --git a/client/client-updates/src/makefile b/client/client-updates/src/makefile new file mode 100644 index 0000000..00acaf0 --- /dev/null +++ b/client/client-updates/src/makefile @@ -0,0 +1,9 @@ +all: adler32 + +adler32: adler32.c + gcc -lz -o $@ $< + +clean: + rm -f adler32 + +.PHONY: clean -- cgit v1.2.3-70-g09d2 From c71b8b8db09b927251b1b77779740e9ef5e69ea9 Mon Sep 17 00:00:00 2001 From: Vincent Petithory Date: Mon, 11 Feb 2013 22:41:57 +0100 Subject: client-updates: add a verbose README explaining how to initialize the client updates --- client/client-updates/README.init.verbose.txt | 97 +++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 client/client-updates/README.init.verbose.txt diff --git a/client/client-updates/README.init.verbose.txt b/client/client-updates/README.init.verbose.txt new file mode 100644 index 0000000..a0d3374 --- /dev/null +++ b/client/client-updates/README.init.verbose.txt @@ -0,0 +1,97 @@ +$ ~/Desktop ➜ mkdir client-data-test +$ ~/Desktop ➜ cd client-data-test +$ ~/Desktop/client-data-test ➜ git clone git://github.com/themanaworld/tmwa-client-data.git +Cloning into 'tmwa-client-data'... +remote: Counting objects: 15162, done. +remote: Compressing objects: 100% (5452/5452), done. +remote: Total 15162 (delta 9679), reused 15083 (delta 9629) +Receiving objects: 100% (15162/15162), 58.81 MiB | 188 KiB/s, done. +Resolving deltas: 100% (9679/9679), done. +$ ~/Desktop/client-data-test ➜ ls +tmwa-client-data +$ ~/Desktop/client-data-test ➜ cp -a tmwa-client-data/tools/client-updates . +$ ~/Desktop/client-data-test ➜ ls +client-updates tmwa-client-data +$ ~/Desktop/client-data-test ➜ cd client-updates +$ ~/Desktop/client-data-test/client-updates ➜ ls +README release src +$ ~/Desktop/client-data-test/client-updates ➜ cd src +$ ~/Desktop/client-data-test/client-updates/src ➜ make +gcc -lz -o adler32 adler32.c +$ ~/Desktop/client-data-test/client-updates/src ➜ cp client-updates.conf.example client-updates.conf +$ ~/Desktop/client-data-test/client-updates/src ➜ vim client-updates.conf +$ ~/Desktop/client-data-test/client-updates/src ➜ cat client-updates.conf +# The client-data directory +CLIENT_DATA_DIR="$HOME/Desktop/client-data-test/tmwa-client-data" + +# The updates working directory +UPDATES_DIR="$HOME/Desktop/client-data-test/client-updates" + +# The git branch used for generating the updates +# This allows for more complex setups, where e.g a branch is used for merging +# from various other branches. It's used on the testing server +# Defaults to master +CLIENT_DATA_BRANCH=master + +# Local directory served by the web server, +# where the update files will be copied +UPDATES_PUBLISH_DIR="$HOME/Desktop/client-data-test/www" +$ ~/Desktop/client-data-test/client-updates/src ➜ cd .. +$ ~/Desktop/client-data-test/client-updates ➜ git init +Initialized empty Git repository in /home/vincent/Desktop/client-data-test/client-updates/.git/ +$ ~/Desktop/client-data-test/client-updates ➜ git add . +$ ~/Desktop/client-data-test/client-updates ➜ git commit -m 'Initial scripts' +[master (root-commit) 88b4d1f] Initial scripts + 12 files changed, 277 insertions(+) + create mode 100644 .gitignore + create mode 100644 README + create mode 100644 release/news.txt + create mode 100644 release/resources.xml + create mode 100644 release/resources2.txt + create mode 100644 src/adler32.c + create mode 100755 src/client-updates-gen + create mode 100755 src/client-updates-inspect + create mode 100755 src/client-updates-news + create mode 100755 src/client-updates-push + create mode 100644 src/client-updates.conf.example + create mode 100644 src/makefile +$ ~/Desktop/client-data-test/client-updates ➜ cd ../tmwa-client-data +$ ~/Desktop/client-data-test/tmwa-client-data ➜ git log --oneline | tail -n 1 +840c732 *** empty log message *** +$ ~/Desktop/client-data-test/tmwa-client-data ➜ cd .. +$ ~/Desktop/client-data-test ➜ mkdir www +$ ~/Desktop/client-data-test ➜ ls +client-updates tmwa-client-data www +$ ~/Desktop/client-data-test ➜ ./client-updates/src/client-updates-gen 840c732 +Adding update-840c732..15ff3ba.zip: +Archive: update-840c732..15ff3ba.zip + Length Date Time Name +--------- ---------- ----- ---- + 191 02-06-2013 17:22 charcreation.xml + 18009 02-06-2013 17:22 COPYING + 1657 02-06-2013 17:22 ea-skills.xml +.................. MORE FILES HERE +........ +........ +--------- ------- + 20138266 1793 files +$ ~/Desktop/client-data-test ➜ ls client-updates/release +news.txt resources2.txt resources.xml update-840c732..15ff3ba.zip +$ ~/Desktop/client-data-test ➜ cat client-updates/release/{news.txt,resources2.txt,resources.xml} +update-840c732..15ff3ba.zip 71aa03f0 + + + + +$ ~/Desktop/client-data-test ➜ ./client-updates/src/client-updates-push +sending incremental file list +./ +news.txt +resources.xml +resources2.txt +update-840c732..15ff3ba.zip + +sent 16973826 bytes received 91 bytes 33947834.00 bytes/sec +total size is 16971447 speedup is 1.00 +$ ~/Desktop/client-data-test ➜ ls www +news.txt resources2.txt resources.xml update-840c732..15ff3ba.zip -- cgit v1.2.3-70-g09d2 From 66a2e93d2910b15f847c2e2cb50f8ff74c3fe29b Mon Sep 17 00:00:00 2001 From: Vincent Petithory Date: Sat, 22 Sep 2012 21:51:03 +0200 Subject: Add a tool to visualize map differences between revisions --- client/map-diff.py | 188 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 188 insertions(+) create mode 100755 client/map-diff.py diff --git a/client/map-diff.py b/client/map-diff.py new file mode 100755 index 0000000..b872d47 --- /dev/null +++ b/client/map-diff.py @@ -0,0 +1,188 @@ +#!/usr/bin/env python +#-*- coding:utf-8 -*- + +import sys +import os +import subprocess +import re +import tempfile + +class MapDiff(object): + + @staticmethod + def check_programs(): + """ + Checks the require programs are available + """ + def which(program): + import os + def is_exe(fpath): + return os.path.isfile(fpath) and os.access(fpath, os.X_OK) + fpath, fname = os.path.split(program) + if fpath: + if is_exe(program): + return program + else: + for path in os.environ["PATH"].split(os.pathsep): + exe_file = os.path.join(path, program) + if is_exe(exe_file): + return exe_file + return None + + platform_programs = MapDiff.PROGRAMS.get(sys.platform, MapDiff.PROGRAMS.get('default')) + for program in platform_programs.values(): + if not which(program): + raise Exception('The required "%s" program is missing from your PATH.' % program) + + MAP_RE = re.compile(r'^\d{3}-\d{1}(\.tmx)?$') + PROGRAMS = { + 'default': { + 'tmxrasterizer': 'tmxrasterizer', + 'im_convert': 'convert', + 'im_display': 'display', + 'git': 'git', + }, + 'win32': { + 'tmxrasterizer': 'tmxrasterizer.exe', + 'im_convert': 'convert.exe', + 'im_display': 'display.exe', + 'git': 'git.exe', + }, + } + + def __init__(self): + self.platform_programs = MapDiff.PROGRAMS.get(sys.platform, MapDiff.PROGRAMS.get('default')) + + def _diffmaps(self, tmx1, tmx2, tmxdiffpath): + tmxraster1 = self._rastermap(tmx1) + tmxraster2 = self._rastermap(tmx2) + tmxf, tmxdiff = tempfile.mkstemp(suffix='.png') + subprocess.check_call([ + self.platform_programs.get('im_convert'), tmxraster1, tmxraster2, + '-compose', 'Difference', + '-auto-level', + '-composite', + tmxraster2, + '-compose', 'Screen', + '-composite', + tmxdiffpath + ]) + os.unlink(tmxdiff) + os.unlink(tmxraster1) + os.unlink(tmxraster2) + sys.stdout.write((u'Map diff written to %s\n' % tmxdiffpath).encode('utf-8')) + subprocess.check_call([self.platform_programs.get('im_display'), tmxdiffpath]) + + def _rastermap(self, tmx): + tmxf, tmxraster = tempfile.mkstemp(suffix='.png') + subprocess.check_call([self.platform_programs.get('tmxrasterizer'), tmx, tmxraster]) + if os.stat(tmxraster).st_size == 0: + # the image couldnt be rendered. The most probable reason is + # that the map was too big (e.g 024-4, 500x500 tiles) + raise Exception('Map too large to be rendered.') + return tmxraster + + +class MapGitRevDiff(MapDiff): + + def __init__(self, map_name): + super(MapGitRevDiff, self).__init__() + self.map_name = map_name + + def diff(self): + if not MapDiff.MAP_RE.match(self.map_name): + sys.stderr.write(u'Invalid map name: %s.\n' % self.map_name) + return 1 + if not self.map_name.endswith(u'.tmx'): + self.map_name = self.map_name+u'.tmx' + self.tmx_path = os.path.join(u'..', u'maps', self.map_name) + self.map_number = os.path.splitext(os.path.basename(self.map_name))[0] + p = subprocess.Popen([self.platform_programs.get('git'), '--no-pager', 'log', '-n', '2', '--oneline', '--follow', self.tmx_path], stdout=subprocess.PIPE) + log = p.communicate()[0].splitlines() + if not len(log) == 2: + raise Exception('This map has only one version') + c1 = log[0].split(' ')[0] + c2 = log[1].split(' ')[0] + + # We have the 2 revs to compare. Let's extract the related tmx file + p1 = self._mktmx_from_rev(c1) + p2 = self._mktmx_from_rev(c2) + difftmxpath = '%s_%s-%s.png' % (self.map_number, c1, c2) + self._diffmaps(p1, p2, difftmxpath) + os.unlink(p1) + os.unlink(p2) + + def _mktmx_from_rev(self, rev): + p = subprocess.Popen([self.platform_programs.get('git'), '--no-pager', 'show', '%s:%s' % (rev, self.tmx_path)], stdout=subprocess.PIPE) + contents = p.communicate()[0] + revtmx = '%s-%s.tmx' % (self.map_number, rev) + f = open(revtmx, 'w') + f.write(contents) + f.close() + return revtmx + + +class MapFileDiff(MapDiff): + + def __init__(self, map1, map2): + super(MapFileDiff, self).__init__() + self.map1 = map1 + self.map2 = map2 + + def diff(self): + b1 = os.path.splitext(os.path.basename(self.map1))[0] + b2 = os.path.splitext(os.path.basename(self.map2))[0] + difftmxpath = '%s__%s.png' % (b1, b2) + self._diffmaps(self.map1, self.map2, difftmxpath) + + +def usage(): + sys.stderr.write(u'''Usage: %s MAP_NAME + %s CHANGED_TMX REFERENCE_TMX + + Example: + $ ./map-diff.py 007-1 + will highlight the changes between the current 007-1 map and its previous version + + $ ./map-diff.py changes-made-by-someone-007-1.tmx ../maps-007-1.tmx + will highlight the changes between the two tmx maps. + Note that these 2 tmx to compare have to satisfy their dependancies, e.g tilesets. + Hence they should be in a sibling directory of the client-data/maps folder. + \n''' % (sys.argv[0], sys.argv[0])) + +def main(): + if not len(sys.argv) > 1: + usage() + return 127 + if not os.path.basename(os.path.dirname(os.getcwdu())) == u'client-data': + sys.stderr.write(u'This script must be run from client-data/tools.\n') + return 1 + try: + MapDiff.check_programs() + except Exception as e: + sys.stderr.write(u'%s\n' % e) + return 126 + if len(sys.argv) == 2: + map_name = sys.argv[1] + mapdiff = MapGitRevDiff(map_name) + try: + mapdiff.diff() + except Exception as e: + sys.stderr.write(u'\x1b[31m\x1b[1mError while generating the diff for map %s: %s\x1b[0m\n' % (map_name, e)) + return 1 + else: + return 0 + else: + map1 = sys.argv[1] + map2 = sys.argv[2] + mapdiff = MapFileDiff(map1, map2) + try: + mapdiff.diff() + except Exception as e: + sys.stderr.write(u'\x1b[31m\x1b[1mError while generating the diff for %s and %s: %s\x1b[0m\n' % (map1, map2, e)) + return 1 + else: + return 0 + +if __name__ == '__main__': + sys.exit(main()) -- cgit v1.2.3-70-g09d2 From 40623c146ac1e5210d20bcb47d313c2659c665f2 Mon Sep 17 00:00:00 2001 From: Vincent Petithory Date: Sat, 22 Sep 2012 21:51:47 +0200 Subject: Add a tool to render minimaps --- client/minimap-render.py | 148 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100755 client/minimap-render.py diff --git a/client/minimap-render.py b/client/minimap-render.py new file mode 100755 index 0000000..402630b --- /dev/null +++ b/client/minimap-render.py @@ -0,0 +1,148 @@ +#!/usr/bin/env python +#-*- coding:utf-8 -*- + +import sys +import os +import subprocess +import tempfile +import re + + +class MinimapRenderer(object): + + MAP_RE = re.compile(r'^\d{3}-\d{1}(\.tmx)?$') + PROGRAMS = { + 'default': { + 'tmxrasterizer': 'tmxrasterizer', + 'im_convert': 'convert', + }, + 'win32': { + 'tmxrasterizer': 'tmxrasterizer.exe', + 'im_convert': 'convert.exe', + }, + } + + def __init__(self, map_name, scale): + self.map_name = map_name + self.scale = scale + + def render(self): + """ + Processes a map + """ + if not MinimapRenderer.MAP_RE.match(self.map_name): + sys.stderr.write(u'Invalid map name: %s. Skipping.\n' % self.map_name) + return 1 + if not self.map_name.endswith(u'.tmx'): + self.map_name = self.map_name+u'.tmx' + + map_number = os.path.splitext(os.path.basename(self.map_name))[0] + tmx_file = os.path.normpath(os.path.join(os.getcwdu(), u'..', u'maps', self.map_name)) + minimap_file = os.path.normpath(os.path.join(os.getcwdu(), u'..', u'graphics', u'minimaps', map_number+u'.png')) + + prefix = os.path.commonprefix((tmx_file, minimap_file)) + sys.stdout.write(u'%s -> %s\n' % (os.path.relpath(tmx_file, prefix), os.path.relpath(minimap_file, prefix))) + + try: + self.do_render(tmx_file, minimap_file) + except Exception as e: + sys.stderr.write(u'\x1b[31m\x1b[1mError while rendering %s: %s\x1b[0m\n' % (self.map_name, e)) + return 1 + else: + return 0 + + def do_render(self, tmx_file, bitmap_file): + """ + The map rendering implementation + """ + platform_programs = MinimapRenderer.PROGRAMS.get(sys.platform, MinimapRenderer.PROGRAMS.get('default')) + # tmx rasterize + mrf, map_raster = tempfile.mkstemp(suffix='.png') + subprocess.check_call([platform_programs.get('tmxrasterizer'), '--scale', str(self.scale), tmx_file, map_raster]) + if os.stat(map_raster).st_size == 0: + # the image couldnt be rendered. The most probable reason is + # that the map was too big (e.g 024-4, 500x500 tiles) + raise Exception('Map too large to be rendered.') + # add cell-shading to the minimap to improve readability + ebf, edges_bitmap = tempfile.mkstemp(suffix='.png') + subprocess.check_call([ + platform_programs.get('im_convert'), map_raster, + '-set', 'option:convolve:scale', '-1!', + '-morphology', 'Convolve', 'Laplacian:0', + '-colorspace', 'gray', + '-auto-level', + '-threshold', '2.8%', + '-negate', + '-transparent', 'white', + edges_bitmap + ]) + subprocess.check_call([ + platform_programs.get('im_convert'), map_raster, edges_bitmap, + '-compose', 'Dissolve', + '-define', 'compose:args=35', + '-composite', + bitmap_file + ]) + os.unlink(map_raster) + os.unlink(edges_bitmap) + + @staticmethod + def check_programs(): + """ + Checks the require programs are available + """ + def which(program): + import os + def is_exe(fpath): + return os.path.isfile(fpath) and os.access(fpath, os.X_OK) + fpath, fname = os.path.split(program) + if fpath: + if is_exe(program): + return program + else: + for path in os.environ["PATH"].split(os.pathsep): + exe_file = os.path.join(path, program) + if is_exe(exe_file): + return exe_file + return None + + platform_programs = MinimapRenderer.PROGRAMS.get(sys.platform, MinimapRenderer.PROGRAMS.get('default')) + for program in platform_programs.values(): + if not which(program): + raise Exception('The required "%s" program is missing from your PATH.' % program) + +def usage(): + sys.stderr.write(u'''Usage: %s MAP_NAME... + + Example: + $ ./minimap-render.py 007-1 + will render the map at maps/007-1.tmx in the graphics/minimaps directory. + + For convenience, + $ ./minimap-render.py 007-1.tmx + is also acceptable, for e.g running things like, + $ ./minimap-render.py $(ls ../maps/) + that would render all existing maps. + \n''' % sys.argv[0]) + +def main(): + if not len(sys.argv) > 1: + usage() + return 127 + if not os.path.basename(os.path.dirname(os.getcwdu())) == u'client-data': + sys.stderr.write(u'This script must be run from client-data/tools.\n') + return 1 + try: + MinimapRenderer.check_programs() + except Exception as e: + sys.stderr.write(u'%s\n' % e) + return 126 + + status = 0 + for map_name in sys.argv[1:]: + map_renderer = MinimapRenderer(map_name, 0.03125) # this scale renders 1px for a tile of 32px + status += map_renderer.render() + return status + +if __name__ == '__main__': + sys.exit(main()) \ No newline at end of file -- cgit v1.2.3-70-g09d2 From 2daee52eec6ace68bf49779acba61056aeba11be Mon Sep 17 00:00:00 2001 From: Vincent Petithory Date: Mon, 18 Feb 2013 23:11:40 +0100 Subject: Map tools: use new --tilesize option of tmwrasterizer and update some things --- client/map-diff.py | 20 ++++++++++++-------- client/minimap-render.py | 23 +++++++++++++++-------- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/client/map-diff.py b/client/map-diff.py index b872d47..1da5cde 100755 --- a/client/map-diff.py +++ b/client/map-diff.py @@ -75,11 +75,13 @@ class MapDiff(object): def _rastermap(self, tmx): tmxf, tmxraster = tempfile.mkstemp(suffix='.png') - subprocess.check_call([self.platform_programs.get('tmxrasterizer'), tmx, tmxraster]) + subprocess.check_call([ + self.platform_programs.get('tmxrasterizer'), + '--scale', '1.0', + tmx, tmxraster + ]) if os.stat(tmxraster).st_size == 0: - # the image couldnt be rendered. The most probable reason is - # that the map was too big (e.g 024-4, 500x500 tiles) - raise Exception('Map too large to be rendered.') + raise Exception('A problem was encountered when rendering a map') return tmxraster @@ -107,10 +109,12 @@ class MapGitRevDiff(MapDiff): # We have the 2 revs to compare. Let's extract the related tmx file p1 = self._mktmx_from_rev(c1) p2 = self._mktmx_from_rev(c2) - difftmxpath = '%s_%s-%s.png' % (self.map_number, c1, c2) - self._diffmaps(p1, p2, difftmxpath) - os.unlink(p1) - os.unlink(p2) + try: + difftmxpath = '%s_%s-%s.png' % (self.map_number, c1, c2) + self._diffmaps(p1, p2, difftmxpath) + finally: + os.unlink(p1) + os.unlink(p2) def _mktmx_from_rev(self, rev): p = subprocess.Popen([self.platform_programs.get('git'), '--no-pager', 'show', '%s:%s' % (rev, self.tmx_path)], stdout=subprocess.PIPE) diff --git a/client/minimap-render.py b/client/minimap-render.py index 402630b..6b6b009 100755 --- a/client/minimap-render.py +++ b/client/minimap-render.py @@ -22,9 +22,10 @@ class MinimapRenderer(object): }, } - def __init__(self, map_name, scale): + def __init__(self, map_name, tilesize, useAntiAliasing): self.map_name = map_name - self.scale = scale + self.tilesize = tilesize + self.useAntiAliasing = useAntiAliasing def render(self): """ @@ -58,11 +59,16 @@ class MinimapRenderer(object): platform_programs = MinimapRenderer.PROGRAMS.get(sys.platform, MinimapRenderer.PROGRAMS.get('default')) # tmx rasterize mrf, map_raster = tempfile.mkstemp(suffix='.png') - subprocess.check_call([platform_programs.get('tmxrasterizer'), '--scale', str(self.scale), tmx_file, map_raster]) + tmxrasterizer_cmd = [ + platform_programs.get('tmxrasterizer'), + '--tilesize', str(self.tilesize), + ] + if self.useAntiAliasing: + tmxrasterizer_cmd.append('--anti-aliasing') + tmxrasterizer_cmd += [tmx_file, map_raster] + subprocess.check_call(tmxrasterizer_cmd) if os.stat(map_raster).st_size == 0: - # the image couldnt be rendered. The most probable reason is - # that the map was too big (e.g 024-4, 500x500 tiles) - raise Exception('Map too large to be rendered.') + raise Exception('A problem was encountered when rendering a map') # add cell-shading to the minimap to improve readability ebf, edges_bitmap = tempfile.mkstemp(suffix='.png') subprocess.check_call([ @@ -140,9 +146,10 @@ def main(): status = 0 for map_name in sys.argv[1:]: - map_renderer = MinimapRenderer(map_name, 0.03125) # this scale renders 1px for a tile of 32px + # Render tiles at 1 pixel size + map_renderer = MinimapRenderer(map_name, 1, True) status += map_renderer.render() return status if __name__ == '__main__': - sys.exit(main()) \ No newline at end of file + sys.exit(main()) -- cgit v1.2.3-70-g09d2 From 795fe02f1080ff254d279ae28187df8fb1beb78e Mon Sep 17 00:00:00 2001 From: Vincent Petithory Date: Wed, 27 Mar 2013 20:49:16 +0100 Subject: Minimap renderer: allow to run elsewhere than tools/ --- client/minimap-render.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/client/minimap-render.py b/client/minimap-render.py index 6b6b009..33917ee 100755 --- a/client/minimap-render.py +++ b/client/minimap-render.py @@ -7,6 +7,12 @@ import subprocess import tempfile import re +CLIENT_DATA_ROOT = os.path.realpath( + os.path.join( + os.path.dirname(__file__), + u'..', + ) +) class MinimapRenderer(object): @@ -38,8 +44,8 @@ class MinimapRenderer(object): self.map_name = self.map_name+u'.tmx' map_number = os.path.splitext(os.path.basename(self.map_name))[0] - tmx_file = os.path.normpath(os.path.join(os.getcwdu(), u'..', u'maps', self.map_name)) - minimap_file = os.path.normpath(os.path.join(os.getcwdu(), u'..', u'graphics', u'minimaps', map_number+u'.png')) + tmx_file = os.path.join(CLIENT_DATA_ROOT, u'maps', self.map_name) + minimap_file = os.path.join(CLIENT_DATA_ROOT, u'graphics', u'minimaps', map_number+u'.png') prefix = os.path.commonprefix((tmx_file, minimap_file)) sys.stdout.write(u'%s -> %s\n' % (os.path.relpath(tmx_file, prefix), os.path.relpath(minimap_file, prefix))) @@ -135,9 +141,6 @@ def main(): if not len(sys.argv) > 1: usage() return 127 - if not os.path.basename(os.path.dirname(os.getcwdu())) == u'client-data': - sys.stderr.write(u'This script must be run from client-data/tools.\n') - return 1 try: MinimapRenderer.check_programs() except Exception as e: -- cgit v1.2.3-70-g09d2 From 15257e49db8a6bfa383306c8ec35f60bfa354468 Mon Sep 17 00:00:00 2001 From: Vincent Petithory Date: Wed, 27 Mar 2013 21:00:47 +0100 Subject: Minimap renderer: add special args: * "all" to create minimaps of all existing maps * "update" to update all existing minimaps --- client/minimap-render.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/client/minimap-render.py b/client/minimap-render.py index 33917ee..c9cb4a1 100755 --- a/client/minimap-render.py +++ b/client/minimap-render.py @@ -129,12 +129,14 @@ def usage(): Example: $ ./minimap-render.py 007-1 will render the map at maps/007-1.tmx in the graphics/minimaps directory. + $ ./minimap-render.py all + will render all existing maps found in the maps directory. + $ ./minimap-render.py update + will update all existing minimaps found in the graphics/minimaps directory. For convenience, $ ./minimap-render.py 007-1.tmx - is also acceptable, for e.g running things like, - $ ./minimap-render.py $(ls ../maps/) - that would render all existing maps. + is also accepted. \n''' % sys.argv[0]) def main(): @@ -148,7 +150,14 @@ def main(): return 126 status = 0 - for map_name in sys.argv[1:]: + if sys.argv[1].lower() == 'all': + map_names = sorted([os.path.splitext(p)[0] for p in os.listdir(os.path.join(CLIENT_DATA_ROOT, u'maps'))]) + elif sys.argv[1].lower() == 'update': + map_names = sorted([os.path.splitext(p)[0] for p in os.listdir(os.path.join(CLIENT_DATA_ROOT, u'graphics', u'minimaps'))]) + else: + map_names = sys.argv[1:] + + for map_name in map_names: # Render tiles at 1 pixel size map_renderer = MinimapRenderer(map_name, 1, True) status += map_renderer.render() -- cgit v1.2.3-70-g09d2 From 42c28dae1dd895dab14f246ed2c78cbb1685819f Mon Sep 17 00:00:00 2001 From: Vincent Petithory Date: Thu, 28 Mar 2013 13:17:45 +0100 Subject: Add a tool to get data about the maps database. * Add a command to list maps that do not have a minimap --- client/map-db.py | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100755 client/map-db.py diff --git a/client/map-db.py b/client/map-db.py new file mode 100755 index 0000000..5215e72 --- /dev/null +++ b/client/map-db.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python +#-*- coding:utf-8 -*- + +import sys +import os +import subprocess +import tempfile +import re + +CLIENT_DATA_ROOT = os.path.realpath( + os.path.join( + os.path.dirname(__file__), + u'..', + ) +) + +MAP_RE = re.compile(r'^(\d{3})-(\d{1})$') + +def list_missing_minimaps(maps, minimaps): + def minimap_wanted(m): + match = MAP_RE.match(m) + if match: + d = match.group(2) + # We ignore indoor maps + if not d == '2': + return True + return False + + missing_minimaps = set([m for m in maps if minimap_wanted(m)]) - set(minimaps) + retcode = len(missing_minimaps) + print '\n'.join(sorted(missing_minimaps)) + return retcode + +def usage(): + sys.stderr.write(u'''Usage: %(prgm_name)s CMD + + Where CMD is one of: + list-missing-minimaps, lm: Lists all maps which do not + have a minimap. + + \n''' % {'prgm_name': sys.argv[0]}) + +def main(): + if not len(sys.argv) > 1: + usage() + return 127 + action = sys.argv[1].lower() + maps = [os.path.splitext(p)[0] for p in os.listdir(os.path.join(CLIENT_DATA_ROOT, u'maps'))] + minimaps = [os.path.splitext(p)[0] for p in os.listdir(os.path.join(CLIENT_DATA_ROOT, u'graphics', u'minimaps'))] + status = 0 + if action in ('list-missing-minimaps', 'lm'): + status = list_missing_minimaps(maps, minimaps) + else: + usage() + return 127 + return status + +if __name__ == '__main__': + sys.exit(main()) -- cgit v1.2.3-70-g09d2 From 4271bbbcf141d474048ac3b5e369b4ecbfb0aac6 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Mon, 22 Jul 2013 15:46:31 -0700 Subject: Add a new update generator that splits paths --- client/make-updates | 123 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100755 client/make-updates diff --git a/client/make-updates b/client/make-updates new file mode 100755 index 0000000..d4d29ce --- /dev/null +++ b/client/make-updates @@ -0,0 +1,123 @@ +#!/bin/bash -e +# This is a tool to automatically generate and ship client updates. +# It is entirely self-contained, storing its own state in the git repo. +# It is called by running 'make updates' in server-data. +# It also supports manually calls for maintenance work. +# TODO: make auto-mode work with music too. + +# local branch to keep update info on +# will be created on first run; updated thereafter +branch=update-zips +# must already exist +# must NOT be a relative path +output=~/www/updates + +function apply_function() +{ + $1 misc-xml charcreation.xml ea-skills.xml effects.xml emotes.xml hair.xml paths.xml settings.xml skills.xml status-effects.xml units.xml + $1 emotes graphics/emotes/ + $1 images graphics/images/ + $1 items graphics/items/ + $1 minimaps graphics/minimaps/ + $1 particles graphics/particles/ + $1 skills graphics/skills/ + $1 sprites graphics/sprites/ + $1 tiles graphics/tiles/ + $1 item-xml items.xml + $1 map-xml maps.xml + $1 maps maps/ + $1 mob-xml monsters.xml + $1 npc-xml npcs.xml + $1 sfx sfx/ + $1 tsx tilesets/ +} + +function add_resource() +{ + pushd $output >/dev/null + adler32 $1 | tee -a resources2.txt | { + read name hash + sed '/<\/updates>/i ' -i resources.xml + } + popd >/dev/null +} + +# TODO actually use this +function add_music() +{ + adler32 $1 | { + read name hash + sed '/<\/updates>/i ' -i resources.xml + } +} + +function do_initial_zip() +{ + zip=$1-$this_update.zip; shift + git ls-files --with-tree=HEAD -- "$@" \ + | zip -q $output/$zip -@ + add_resource $zip +} + +function git_diff_tree() +{ + git diff-tree -r --diff-filter=AM "$@" +} + +function do_delta_zip() +{ + zip=$1-$last_update..$this_update.zip; shift + if git_diff_tree --quiet $last_update $this_update -- "$@" + then + return + fi + git_diff_tree --name-only $last_update $this_update -- "$@" \ + | zip -q $output/$zip -@ + add_resource $zip +} + +function do_initial_zips() +{ + apply_function do_initial_zip +} + +function do_delta_zips() +{ + apply_function do_delta_zip +} + +function main() +{ + if ! test -d $output + then + echo 'Fatal error: output directory does not exist' + echo "$output" + return 1 + fi + + this_update=$(git rev-parse --short HEAD) + if ! last_update=$(git rev-parse --short $branch 2>/dev/null) + then + echo 'Doing initial updates' + do_initial_zips + elif test "$this_update" = "$last_update" + then + echo 'No commits since last update generation ...' + else + echo 'Doing incremental updates' + do_delta_zips + fi + git branch -f $branch +} + +if test "$0" = "$BASH_SOURCE" +then + echo 'Generating updates automatically' + main +elif test "$0" = 'bash' +then + echo 'sourcing detected - you can do manual updates' +else + echo 'How did you get here?' + exit 3 +fi -- cgit v1.2.3-70-g09d2 From 7b3fc1dbc951f8e49b06c95c6ed44f943ff4c6b3 Mon Sep 17 00:00:00 2001 From: Vincent Petithory Date: Tue, 24 Sep 2013 20:41:01 +0200 Subject: Remove deprecated client-updates --- client/client-updates/.gitignore | 3 - client/client-updates/README | 69 --------------- client/client-updates/README.init.verbose.txt | 97 ---------------------- client/client-updates/release/news.txt | 0 client/client-updates/release/resources.xml | 3 - client/client-updates/release/resources2.txt | 0 client/client-updates/src/adler32.c | 68 --------------- client/client-updates/src/client-updates-gen | 68 --------------- client/client-updates/src/client-updates-inspect | 20 ----- client/client-updates/src/client-updates-news | 14 ---- client/client-updates/src/client-updates-push | 8 -- .../client-updates/src/client-updates.conf.example | 15 ---- client/client-updates/src/makefile | 9 -- 13 files changed, 374 deletions(-) delete mode 100644 client/client-updates/.gitignore delete mode 100644 client/client-updates/README delete mode 100644 client/client-updates/README.init.verbose.txt delete mode 100644 client/client-updates/release/news.txt delete mode 100644 client/client-updates/release/resources.xml delete mode 100644 client/client-updates/release/resources2.txt delete mode 100644 client/client-updates/src/adler32.c delete mode 100755 client/client-updates/src/client-updates-gen delete mode 100755 client/client-updates/src/client-updates-inspect delete mode 100755 client/client-updates/src/client-updates-news delete mode 100755 client/client-updates/src/client-updates-push delete mode 100644 client/client-updates/src/client-updates.conf.example delete mode 100644 client/client-updates/src/makefile diff --git a/client/client-updates/.gitignore b/client/client-updates/.gitignore deleted file mode 100644 index c369c66..0000000 --- a/client/client-updates/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/src/adler32 -/src/client-updates.conf - diff --git a/client/client-updates/README b/client/client-updates/README deleted file mode 100644 index 56026b8..0000000 --- a/client/client-updates/README +++ /dev/null @@ -1,69 +0,0 @@ -######################################## -# How to use the client updates system # -######################################## - -# Initial setup - -1. compile adler32: Run 'make' in the src directory. -2. Copy example config and edit it to your needs: - $ cp client-updates.conf.example client-updates.conf -3. Optionally, put the client-update-{gen,news,inspect,push} in your PATH -4. Init a git repository for the client-updates dir, as zip updates will be committed. - $ git init - $ git add . - $ git commit -m 'Initial scripts' - -Now we have to generate the base update. -If you have already base zip files, you can include them in the release/ directory. -Fill properly the resources.xml and resources2.xml files. -Otherwise, run client-updates-gen with proper arguments. -1st arg is base commit, 2nd arg is final commit (HEAD if omitted). - -# Overview -The process to manage client updates is as follows: - -1. a developer needs to include new client data. -2. if not done already, he/she will set up a personal branch in the tmwa-client-data repo - and pull what is necessary. -3. the tmwa-client-data repo has a "testing" branch which is the reference for generating the updates. - there is also the "master" branch which is in sync with mainline. - the developer will perform a merge in the "testing" branch, and if necessary resolve the conflicts. -4. $ client-updates-gen - will generate if necessary a new zip and display its contents. -5. optionally, you can check the contents of the updates is correct: - $ client-updates-inspect - This will list the contents of all updates in a pager, from most recent to oldest. -6. $ client-updates-push - will sync the client updates to the local webserver directory - -As a general rule, never break the history of the "$CLIENT_DATA_BRANCH" branch of the tmwa-client-data repository. - -# Handling news -- only useful if not using the news of the server-data. - -1. $ client-updates-news - will open the news.txt for editing. -2. Publish these changes. - $ client-updates-push - -# Details on the client-updates-gen script - -This script analyses the client data repo and generates -a zip file with the files changed / added between 2 revisions. - -The script will check the differences between HEAD and the latest reference commit. -The reference commit is determined by the latest entry in $UPDATES_DIR/resources2.src.txt - -# Config file (client-updates.conf) - -Several variables for finding the UPDATES_DIR, the client data repository, -and ftp credentials. -Find it next to client-updates-* scripts. - -# Client updates repository - -A local git repository is used for managing these scripts. -This repository has 2 branches: master and updates -The repository should always be left on the branch "updates": most scripts will write commits -when updates are issued or when news.txt is updated. -When you need to change things in the core scripts, change to master, commit, then rebase the "updates" branch. - diff --git a/client/client-updates/README.init.verbose.txt b/client/client-updates/README.init.verbose.txt deleted file mode 100644 index a0d3374..0000000 --- a/client/client-updates/README.init.verbose.txt +++ /dev/null @@ -1,97 +0,0 @@ -$ ~/Desktop ➜ mkdir client-data-test -$ ~/Desktop ➜ cd client-data-test -$ ~/Desktop/client-data-test ➜ git clone git://github.com/themanaworld/tmwa-client-data.git -Cloning into 'tmwa-client-data'... -remote: Counting objects: 15162, done. -remote: Compressing objects: 100% (5452/5452), done. -remote: Total 15162 (delta 9679), reused 15083 (delta 9629) -Receiving objects: 100% (15162/15162), 58.81 MiB | 188 KiB/s, done. -Resolving deltas: 100% (9679/9679), done. -$ ~/Desktop/client-data-test ➜ ls -tmwa-client-data -$ ~/Desktop/client-data-test ➜ cp -a tmwa-client-data/tools/client-updates . -$ ~/Desktop/client-data-test ➜ ls -client-updates tmwa-client-data -$ ~/Desktop/client-data-test ➜ cd client-updates -$ ~/Desktop/client-data-test/client-updates ➜ ls -README release src -$ ~/Desktop/client-data-test/client-updates ➜ cd src -$ ~/Desktop/client-data-test/client-updates/src ➜ make -gcc -lz -o adler32 adler32.c -$ ~/Desktop/client-data-test/client-updates/src ➜ cp client-updates.conf.example client-updates.conf -$ ~/Desktop/client-data-test/client-updates/src ➜ vim client-updates.conf -$ ~/Desktop/client-data-test/client-updates/src ➜ cat client-updates.conf -# The client-data directory -CLIENT_DATA_DIR="$HOME/Desktop/client-data-test/tmwa-client-data" - -# The updates working directory -UPDATES_DIR="$HOME/Desktop/client-data-test/client-updates" - -# The git branch used for generating the updates -# This allows for more complex setups, where e.g a branch is used for merging -# from various other branches. It's used on the testing server -# Defaults to master -CLIENT_DATA_BRANCH=master - -# Local directory served by the web server, -# where the update files will be copied -UPDATES_PUBLISH_DIR="$HOME/Desktop/client-data-test/www" -$ ~/Desktop/client-data-test/client-updates/src ➜ cd .. -$ ~/Desktop/client-data-test/client-updates ➜ git init -Initialized empty Git repository in /home/vincent/Desktop/client-data-test/client-updates/.git/ -$ ~/Desktop/client-data-test/client-updates ➜ git add . -$ ~/Desktop/client-data-test/client-updates ➜ git commit -m 'Initial scripts' -[master (root-commit) 88b4d1f] Initial scripts - 12 files changed, 277 insertions(+) - create mode 100644 .gitignore - create mode 100644 README - create mode 100644 release/news.txt - create mode 100644 release/resources.xml - create mode 100644 release/resources2.txt - create mode 100644 src/adler32.c - create mode 100755 src/client-updates-gen - create mode 100755 src/client-updates-inspect - create mode 100755 src/client-updates-news - create mode 100755 src/client-updates-push - create mode 100644 src/client-updates.conf.example - create mode 100644 src/makefile -$ ~/Desktop/client-data-test/client-updates ➜ cd ../tmwa-client-data -$ ~/Desktop/client-data-test/tmwa-client-data ➜ git log --oneline | tail -n 1 -840c732 *** empty log message *** -$ ~/Desktop/client-data-test/tmwa-client-data ➜ cd .. -$ ~/Desktop/client-data-test ➜ mkdir www -$ ~/Desktop/client-data-test ➜ ls -client-updates tmwa-client-data www -$ ~/Desktop/client-data-test ➜ ./client-updates/src/client-updates-gen 840c732 -Adding update-840c732..15ff3ba.zip: -Archive: update-840c732..15ff3ba.zip - Length Date Time Name ---------- ---------- ----- ---- - 191 02-06-2013 17:22 charcreation.xml - 18009 02-06-2013 17:22 COPYING - 1657 02-06-2013 17:22 ea-skills.xml -.................. MORE FILES HERE -........ -........ ---------- ------- - 20138266 1793 files -$ ~/Desktop/client-data-test ➜ ls client-updates/release -news.txt resources2.txt resources.xml update-840c732..15ff3ba.zip -$ ~/Desktop/client-data-test ➜ cat client-updates/release/{news.txt,resources2.txt,resources.xml} -update-840c732..15ff3ba.zip 71aa03f0 - - - - -$ ~/Desktop/client-data-test ➜ ./client-updates/src/client-updates-push -sending incremental file list -./ -news.txt -resources.xml -resources2.txt -update-840c732..15ff3ba.zip - -sent 16973826 bytes received 91 bytes 33947834.00 bytes/sec -total size is 16971447 speedup is 1.00 -$ ~/Desktop/client-data-test ➜ ls www -news.txt resources2.txt resources.xml update-840c732..15ff3ba.zip diff --git a/client/client-updates/release/news.txt b/client/client-updates/release/news.txt deleted file mode 100644 index e69de29..0000000 diff --git a/client/client-updates/release/resources.xml b/client/client-updates/release/resources.xml deleted file mode 100644 index faab981..0000000 --- a/client/client-updates/release/resources.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/client/client-updates/release/resources2.txt b/client/client-updates/release/resources2.txt deleted file mode 100644 index e69de29..0000000 diff --git a/client/client-updates/src/adler32.c b/client/client-updates/src/adler32.c deleted file mode 100644 index 5dd7e4c..0000000 --- a/client/client-updates/src/adler32.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * adler32.c (c) 2006 Bjorn Lindeijer - * License: GPL, v2 or later - * - * Calculates Adler-32 checksums for all files passed as argument. - * - * Usage: adler32 [file]... - */ - -#include -#include -#include - -/** - * Calculates the Adler-32 checksum for the given file. - */ -unsigned long fadler32(FILE *file) -{ - // Obtain file size - fseek(file, 0, SEEK_END); - long fileSize = ftell(file); - rewind(file); - - // Calculate Adler-32 checksum - char *buffer = (char*) malloc(fileSize); - fread(buffer, 1, fileSize, file); - unsigned long adler = adler32(0L, Z_NULL, 0); - adler = adler32(adler, (Bytef*) buffer, fileSize); - free(buffer); - - return adler; -} - -/** - * Prints out usage and exists. - */ -void print_usage() -{ - printf("Usage: adler32 [file]...\n"); - exit(0); -} - -int main(int argc, char *argv[]) -{ - int i; /**< Loops through arguments. */ - - if (argc == 1) - { - print_usage(); - } - - for (i = 1; i < argc; ++i) - { - FILE *file = fopen(argv[i], "r"); - - if (!file) - { - printf("Error while opening '%s' for reading!\n", argv[i]); - exit(1); - } - - unsigned long adler = fadler32(file); - printf("%s %lx\n", argv[i], adler); - fclose(file); - } - - return 0; -} diff --git a/client/client-updates/src/client-updates-gen b/client/client-updates/src/client-updates-gen deleted file mode 100755 index 76c0ed3..0000000 --- a/client/client-updates/src/client-updates-gen +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/sh - -# config -SRC=$(dirname $(readlink -f "$0")) - -. ${SRC}/client-updates.conf - -# Check we are on the $CLIENT_DATA_BRANCH branch -git --git-dir "${CLIENT_DATA_DIR}/.git" branch | grep -q "^* $CLIENT_DATA_BRANCH" || { echo "The client-data repository is not on $CLIENT_DATA_BRANCH branch. Exiting"; exit 2; } - -# Unless specified on 1st argument, we'll use the latest revision that was -# included in updates, as starting revision. -# If this is the initial generation, this argument is mandatory. -if [ $# -gt 0 ]; then - OLD_CLIENT_DATA_HEAD="$1" -else - # Get the last commit sha where we generated an update - # This assumes the generated zip names follow the pattern: update-SHA1..SHA2.zip - OLD_CLIENT_DATA_HEAD=$(tail -n 1 ${UPDATES_DIR}/release/resources2.txt | cut -d . -f 3) -fi - -# Unless specified on 2nd argument, we'll use the HEAD as final revision. -if [ $# -gt 1 ]; then - NEW_CLIENT_DATA_HEAD="$2" -else - # get the commit SHA from the client data repo - NEW_CLIENT_DATA_HEAD=$(git --git-dir "${CLIENT_DATA_DIR}/.git" rev-parse HEAD | cut -c 1-7) -fi - -if [ "$OLD_CLIENT_DATA_HEAD" = "$NEW_CLIENT_DATA_HEAD" ]; then - echo "Everything is up-to-date." - exit 0 -fi - -update_basename="update-${OLD_CLIENT_DATA_HEAD}..${NEW_CLIENT_DATA_HEAD}" - -# generate a diff of files to package -cd ${CLIENT_DATA_DIR} -git --git-dir "${CLIENT_DATA_DIR}/.git" log --name-status ${OLD_CLIENT_DATA_HEAD}..${NEW_CLIENT_DATA_HEAD} | awk '/^(A|M)\t/ {print $2}' | sort | uniq | xargs zip -9 -r "${UPDATES_DIR}/${update_basename}.zip" > /dev/null -cd - > /dev/null - -if [ ! -f "${UPDATES_DIR}/${update_basename}.zip" ];then - echo "Error while generating ${update_basename}.zip. Exiting." > /dev/stderr - exit 1 -fi - -# package update -cd "${UPDATES_DIR}" -mkdir -p "release" -${SRC}/adler32 "${update_basename}.zip" >> "release/resources2.txt" -hash=$(tail -n 1 "release/resources2.txt" | awk '{ print $2; }') -# populate resources.xml as well -xmlentry="" - -sed -i '$d' 'release/resources.xml' -echo " $xmlentry" >> 'release/resources.xml' -echo '' >> 'release/resources.xml' - -echo "Adding ${update_basename}.zip:" -# Display the contents of the update -unzip -l ${update_basename}.zip -mv "${update_basename}.zip" "release/" -# Copy resources -git add 'release' -git commit -m "Updating resources to ${NEW_CLIENT_DATA_HEAD}" > /dev/null -cd - > /dev/null - -exit 0 diff --git a/client/client-updates/src/client-updates-inspect b/client/client-updates/src/client-updates-inspect deleted file mode 100755 index 03ae2d6..0000000 --- a/client/client-updates/src/client-updates-inspect +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -#config -SRC=$(dirname $(readlink -f "$0")) - -. ${SRC}/client-updates.conf - -DIRECTORY="${UPDATES_DIR}/release" -listing=$(mktemp) -IFS=' -' -for f in $(tac $DIRECTORY/resources2.txt); do - file=$(awk '{ print $1; }' <<< $f) - unzip -l "$DIRECTORY/$file" >> $listing -done - -if [ -f "$listing" ]; then - less "$listing" -fi -rm -f "$listing" diff --git a/client/client-updates/src/client-updates-news b/client/client-updates/src/client-updates-news deleted file mode 100755 index bc78e4e..0000000 --- a/client/client-updates/src/client-updates-news +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -# config -SRC=$(dirname $(readlink -f "$0")) - -. ${SRC}/client-updates.conf - -# Edit news.txt -nano "${UPDATES_DIR}"/release/news.txt - -# Commit if changed -cd "${UPDATES_DIR}" -git status | grep -q 'news.txt' && { git add release/news.txt; git commit -m 'Updating news.txt' > /dev/null; } -cd - > /dev/null diff --git a/client/client-updates/src/client-updates-push b/client/client-updates/src/client-updates-push deleted file mode 100755 index edeae49..0000000 --- a/client/client-updates/src/client-updates-push +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -# config -SRC=$(dirname $(readlink -f "$0")) - -. ${SRC}/client-updates.conf - -rsync -av --delete "$UPDATES_DIR/release/" "$UPDATES_PUBLISH_DIR" diff --git a/client/client-updates/src/client-updates.conf.example b/client/client-updates/src/client-updates.conf.example deleted file mode 100644 index 8bdce43..0000000 --- a/client/client-updates/src/client-updates.conf.example +++ /dev/null @@ -1,15 +0,0 @@ -# The client-data directory -CLIENT_DATA_DIR="$HOME/tmwa-client-data" - -# The updates working directory -UPDATES_DIR="$HOME/client-updates" - -# The git branch used for generating the updates -# This allows for more complex setups, where e.g a branch is used for merging -# from various other branches. It's used on the testing server -# Defaults to master -CLIENT_DATA_BRANCH=master - -# Local directory served by the web server, -# where the update files will be copied -UPDATES_PUBLISH_DIR="$HOME/www/tmwupdate" diff --git a/client/client-updates/src/makefile b/client/client-updates/src/makefile deleted file mode 100644 index 00acaf0..0000000 --- a/client/client-updates/src/makefile +++ /dev/null @@ -1,9 +0,0 @@ -all: adler32 - -adler32: adler32.c - gcc -lz -o $@ $< - -clean: - rm -f adler32 - -.PHONY: clean -- cgit v1.2.3-70-g09d2 From 90c62e0a3a8679d53e42049a308833a539e64aec Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Tue, 1 Oct 2013 15:07:37 -0700 Subject: Fix permissions on generated updates --- client/make-updates | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/make-updates b/client/make-updates index d4d29ce..aef0aaf 100755 --- a/client/make-updates +++ b/client/make-updates @@ -37,6 +37,7 @@ function add_resource() pushd $output >/dev/null adler32 $1 | tee -a resources2.txt | { read name hash + chmod a+r $name sed '/<\/updates>/i ' -i resources.xml } popd >/dev/null @@ -47,6 +48,7 @@ function add_music() { adler32 $1 | { read name hash + chmod a+r $name sed '/<\/updates>/i ' -i resources.xml } } -- cgit v1.2.3-70-g09d2 From 709373a850e6c96aa03b56c8e0865a09db91b341 Mon Sep 17 00:00:00 2001 From: wushin Date: Mon, 7 Oct 2013 10:43:38 -0500 Subject: Restore adler32, which is not deprecated This reverts part of commit 0938aa15367caa3332d0b812b6e4514d14772e0d Closes #27 --- client/adler32/.gitignore | 1 + client/adler32/Makefile | 16 +++++++++++ client/adler32/adler32.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 client/adler32/.gitignore create mode 100644 client/adler32/Makefile create mode 100644 client/adler32/adler32.c diff --git a/client/adler32/.gitignore b/client/adler32/.gitignore new file mode 100644 index 0000000..cfcde45 --- /dev/null +++ b/client/adler32/.gitignore @@ -0,0 +1 @@ +/adler32 diff --git a/client/adler32/Makefile b/client/adler32/Makefile new file mode 100644 index 0000000..42f101a --- /dev/null +++ b/client/adler32/Makefile @@ -0,0 +1,16 @@ +prefix=/usr/local +bindir=${prefix}/bin + +LDLIBS=-lz + +all: adler32 + +adler32: adler32.c + +clean: + rm -f adler32 + +install: + install -D adler32 ${bindir}/ + +.PHONY: clean install diff --git a/client/adler32/adler32.c b/client/adler32/adler32.c new file mode 100644 index 0000000..5dd7e4c --- /dev/null +++ b/client/adler32/adler32.c @@ -0,0 +1,68 @@ +/* + * adler32.c (c) 2006 Bjorn Lindeijer + * License: GPL, v2 or later + * + * Calculates Adler-32 checksums for all files passed as argument. + * + * Usage: adler32 [file]... + */ + +#include +#include +#include + +/** + * Calculates the Adler-32 checksum for the given file. + */ +unsigned long fadler32(FILE *file) +{ + // Obtain file size + fseek(file, 0, SEEK_END); + long fileSize = ftell(file); + rewind(file); + + // Calculate Adler-32 checksum + char *buffer = (char*) malloc(fileSize); + fread(buffer, 1, fileSize, file); + unsigned long adler = adler32(0L, Z_NULL, 0); + adler = adler32(adler, (Bytef*) buffer, fileSize); + free(buffer); + + return adler; +} + +/** + * Prints out usage and exists. + */ +void print_usage() +{ + printf("Usage: adler32 [file]...\n"); + exit(0); +} + +int main(int argc, char *argv[]) +{ + int i; /**< Loops through arguments. */ + + if (argc == 1) + { + print_usage(); + } + + for (i = 1; i < argc; ++i) + { + FILE *file = fopen(argv[i], "r"); + + if (!file) + { + printf("Error while opening '%s' for reading!\n", argv[i]); + exit(1); + } + + unsigned long adler = fadler32(file); + printf("%s %lx\n", argv[i], adler); + fclose(file); + } + + return 0; +} -- cgit v1.2.3-70-g09d2