summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-01-08 14:58:54 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-01-08 15:04:27 -0500
commitf9d4a992d0fa722b53a269532456b8b41fe428bf (patch)
tree915eea9ebd8f88bef77902b3022c2d795b163814
parent7485bf9277afa53158672dca08a022630ff1d748 (diff)
fix tempdir in -PKGBUILD, write -mozconfig
-rwxr-xr-xmoz-normalize-PKGBUILD2
-rwxr-xr-x[-rw-r--r--]moz-normalize-mozconfig129
2 files changed, 130 insertions, 1 deletions
diff --git a/moz-normalize-PKGBUILD b/moz-normalize-PKGBUILD
index f56639c..930c47b 100755
--- a/moz-normalize-PKGBUILD
+++ b/moz-normalize-PKGBUILD
@@ -1,6 +1,6 @@
#!/bin/bash
-tempdir="$(mktemp -d --tmpdir mozilla-normalize.XXXXXXXXXXX)"
+tempdir="$(mktemp -d --tmpdir ${0##*/}.XXXXXXXXXXX)"
################################################################################
diff --git a/moz-normalize-mozconfig b/moz-normalize-mozconfig
index e69de29..62cce3f 100644..100755
--- a/moz-normalize-mozconfig
+++ b/moz-normalize-mozconfig
@@ -0,0 +1,129 @@
+#!/bin/bash
+
+tempdir="$(mktemp -d --tmpdir ${0##*/}.XXXXXXXXXXX)"
+
+urlencode() {
+ perl -MURI::Escape -e 'print uri_escape($ARGV[0]);' "$1"
+}
+
+# outputs in the format
+# class-id:line
+classify-lines() {
+ while read line; do
+ _line="$(printf '%s' "$line"|sed -r 's/^#(\S)/\1/')"
+ class='other'
+ case "$_line" in
+ ac_add_options\ --enable-application=*) class=setapp;;
+ .\ *mozconfig) class=setapp;;
+
+ *optimiz*) class=vendor;;
+
+ ac_add_options\ --*-dirs) class=vendor;;
+ ac_add_options\ --*-home=*) class=vendor;;
+ ac_add_options\ --libdir=*) class=vendor;;
+ ac_add_options\ --prefix=*) class=vendor;;
+ *OFFICIAL*) class=vendor;;
+
+ ac_add_options\ --with-*=*) class=appsetting;;
+ *MOZ_PHOENIX*) class=appsetting;;
+
+ ac_add_options\ --*-system-*) class=system;;
+ ac_add_options\ --with-pthreads) class=system;;
+
+ ac_add_options\ --build=*) class=platform;;
+ ac_add_options\ --host=*) class=platform;;
+ *SHORT_LIBNAME*) class=platform;;
+
+ ac_add_options\ --*=*) class=other;;
+ ac_add_options\ --enable-toolkit-*) class=other;;
+
+ ac_add_options\ --enable-*) class=feature;;
+ ac_add_options\ --disable-*) class=feature;;
+ ac_add_options\ --with-*) class=feature;;
+
+ '# '*)
+ class=comment
+ echo "$line" >> "$tempdir/comments"
+ ;;
+ esac
+ if [[ $class != comment ]]; then
+ ci="$tempdir/comments"
+ co="$tempdir/comments-$(urlencode "$line")"
+ [[ -f $ci ]] && mv "$ci" "$co"
+
+ class_id=''
+ case "$class" in
+ setapp) class_id=0;;
+ system) class_id=1;;
+ feature) class_id=2;;
+ vendor) class_id=3;;
+ platform) class_id=4;;
+ appsetting) class_id=5;;
+ other) class_id=6;;
+ *) libremessages error "INVALID CLASS: $class"; exit 1;;
+ esac
+ printf '%s:%s\n' "$class_id" "$line"
+ fi
+ done
+}
+
+format-classes() (
+ echo 0 > "$tempdir/prev_id"
+ IFS=:
+ while read class_id line; do
+ prev_id=$(cat "$tempdir/prev_id")
+ if [[ "$class_id" != "$prev_id" ]]; then
+ echo ''
+ case "$class_id" in
+ 0) echo '# Set the application';;
+ 1) echo '# System libraries';;
+ 2) echo '# Features';;
+ 3) echo '# Vendor settings';;
+ 4) echo '# Platform settings';;
+ 5) echo '# Application settings';;
+ 6) echo '# Other';;
+ esac
+ fi
+ printf '%s\n' "$line"
+ echo "$class_id" > "$tempdir/prev_id"
+ done
+ echo ''
+ echo '# Build-generated'
+)
+
+add-comments() {
+ while read line; do
+ file="$tempdir/comments-$(urlencode "$line")"
+ if [[ -f $file ]]; then
+ cat "$file"
+ fi
+ echo "$line"
+ done
+ file="$tempdir/comments"
+ if [[ -f $file ]]; then
+ cat "$file"
+ fi
+}
+
+hack() {
+ sed -r \
+ -e '/^\s*$/d' \
+ -e '/#\s*(System libraries|Features|Optimization|Build-generated)/d' \
+ -e '/#\s*(Icecat|IceWeasel)/d' \
+ -e '/#\s*(ConnochaetOS|Parabola)/d' \
+ -e 's/# (ac_add_options)/#\1/'
+}
+
+main() {
+ cat \
+ | hack \
+ | classify-lines "$file" \
+ | sort \
+ | format-classes \
+ | add-comments \
+
+ # above line intentionally left blank
+ rm -rf "$tempdir"
+}
+
+main "$@"