File: process_language_pages

package info (click to toggle)
moin 1.9.9-1+deb9u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 76,024 kB
  • sloc: python: 143,896; java: 10,704; php: 2,385; perl: 1,574; xml: 371; makefile: 214; sh: 81; sed: 5
file content (45 lines) | stat: -rwxr-xr-x 1,529 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/sh
# This script clean-up the underlay page. (contained in zip files).
# Copyright 2009, Frank lin Piat ; License GPL V2 or later.


# Strip these notes in underlay about editing only on moinmaster:
## Pour plus d'informations, consultez la page MoinMoin:MoinDev/Translation.
## Please edit system and help pages ONLY in the moinmaster wiki!
## Please edit system and help pages ONLY in the master wiki!
## For more information, please see MoinMoin:MoinDev/Translation.

set -e
set -x 
UNDERLAY_DIR=$1
[ ! -d "$UNDERLAY_DIR" ] && (echo "Error: argument isn't a directory" ; false)

find  $UNDERLAY_DIR -iname '*.zip' \
	| grep -E '[^[:alnum:]/_\.-]' \
	&& (echo "^^ Are the above filenames safe?"; exit 1)

BASE=$PWD
COUNT=0
for f in $(find  $BASE/$UNDERLAY_DIR -iname '*.zip') ; do
	echo "Cleaning comments in $f"
	tmp=`mktemp -d --tmpdir=$BASE` || exit 2
	cd $tmp
	TZ=UTC unzip -q $f
	chmod a+rw ./*
	egrep -r -l -Z '^## ' * \
		| xargs -r -0 -n 1 \
		  sed -i -e '1,8{/^## \(Please edit system\|For more information\|.*MoinMoin:MoinDev\/Translation\)/d}'
		# ^^ search and drop notes in the 8 first lines.
	chmod a-w ./*
	chmod a+w MOIN_PACKAGE
	# Fix files mtime before compressing to get reproducible results.
	find . -newermt "$(date -u -d @$SOURCE_DATE_EPOCH)" -print0 | \
		xargs -0r touch --no-dereference --date="$(date -u -d @$SOURCE_DATE_EPOCH)"
	rm $f
	TZ=UTC zip -X -q $f *
	cd $BASE
	rm -Rf $tmp
	COUNT=$(($COUNT + 1))
done

[ $COUNT -eq 0 ] && (echo "Error: No Zip (language pages) found" ; false) || true