davical/davical-setup.sh

Tue, 29 Mar 2011 20:04:34 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 29 Mar 2011 20:04:34 +0200
changeset 334
4a34d7a82eab
parent 295
adc4bc1f8985
child 396
610cba0674b9
permissions
-rw-r--r--

Rework package yet again, correcting and introducing new buildconf logic:
Conditionally disable bootstrap stage comparison correctly, correct
english grammar, better find system as(1) and ld(1), indotruce detailed
optimization option messages, more completely guess cpu types, allow
profiled bootstrapping without a preinstalled GCC because many other
compilers have long since implemented 64-bit arithmetic, instruct make
to build sequentially (not in sparallel) when building a profiled
bootstrap as GCC online documents recommend, and generally improve
comment blocks.

The single most important correction in this changeset relates to the
GCC changed optimization policy since at least GCC 4.5, in which -march
is always passed and not always correctly guessed. In the case of this
package, allowing GCC to guess the architecture leads to wild build
errors at various subcomponents (zlib, libgcc, libiberty...) and
bootstrap stages. It seems quite platform specific, and the safest
approach to correcting this seems to be explicitly always specifying the
-march argument when bootstrapping GCC. Because the best choice 'native'
is not available when bootstrapping using a foreign (non GCC) compiler,
a guess is made according to rpmmacros l_platform in that case.

It is questionable as to whether these recent optimization changes
on the part of GCC or this package are compatible with each other,
or if either are complete or correct at all. At least applying these
corrections allows this package to build again in most cases test.

michael@290 1 #!/bin/sh
michael@290 2 ##
michael@290 3 ## davical-setup
michael@290 4 ##
michael@290 5
michael@290 6 # command line argument sanity check
michael@290 7 prg="$0"
michael@290 8 if [ $# -eq 0 ]; then
michael@290 9 echo "$prg:ERROR: invalid command line" 1>&2
michael@290 10 echo "$prg:USAGE: $prg install [<admin-password>]" 1>&2
michael@290 11 echo "$prg:USAGE: $prg uninstall" 1>&2
michael@290 12 echo "$prg:USAGE: $prg edit" 1>&2
michael@290 13 exit 1
michael@290 14 fi
michael@290 15
michael@290 16 # database configuration
michael@290 17 db_dir="@l_prefix@/var/davical/db"
michael@290 18 db_name="davical"
michael@290 19 db_user="davical"
michael@290 20 db_pass="davical"
michael@290 21 db_sname=`grep "^superuser_database" @l_prefix@/var/postgresql/db/pg_superuser.conf |\
michael@290 22 sed -e 's;^ *superuser_database="\(.*\)".*;\1;'`
michael@290 23 db_suser=`grep "^superuser_username" @l_prefix@/var/postgresql/db/pg_superuser.conf |\
michael@290 24 sed -e 's;^ *superuser_username="\(.*\)".*;\1;'`
michael@290 25 db_spass=`grep "^superuser_password" @l_prefix@/var/postgresql/db/pg_superuser.conf |\
michael@290 26 sed -e 's;^ *superuser_password="\(.*\)".*;\1;'`
michael@290 27
michael@290 28 # dispatch operation
michael@290 29 cmd="${1:-"install"}"
michael@290 30 shift
michael@290 31 case "$cmd" in
michael@290 32 install )
michael@290 33 # determine admin password
michael@290 34 admin_password="$1"
michael@290 35 if [ ".$admin_password" = . ]; then
michael@290 36 admin_password="`@l_prefix@/bin/apg -Mncl -a1 -m12 -n1`"
michael@290 37 echo "ATTENTION: using generated \"admin\" password: \"$admin_password\"" 1>&2
michael@290 38 fi
michael@290 39
michael@290 40 # create database
michael@290 41 ( echo "CREATE ROLE $db_user LOGIN ENCRYPTED PASSWORD '$db_pass' NOCREATEDB NOCREATEUSER;"
michael@290 42 echo "CREATE TABLESPACE $db_name OWNER $db_user LOCATION '$db_dir';"
michael@298 43 echo "CREATE DATABASE $db_name OWNER $db_user TABLESPACE $db_name ENCODING 'SQL_ASCII';"
michael@290 44 ) | PGPASSWORD="$db_spass" @l_prefix@/bin/psql -q -U "$db_suser" -d "$db_sname" -f-
michael@290 45 PGPASSWORD="$db_pass" @l_prefix@/bin/psql -q -U "$db_user" -d "$db_name" \
michael@290 46 -c "CREATE LANGUAGE plpgsql;"
michael@290 47
michael@290 48 # create schema 1/2 (from original "create_database" script)
michael@290 49 PGPASSWORD="$db_pass" @l_prefix@/bin/psql -q -U "$db_user" -d "$db_name" -A -t \
michael@290 50 -f "@l_prefix@/lib/davical/awl/dba/awl-tables.sql" 2>&1 | grep -v NOTICE
michael@290 51 PGPASSWORD="$db_pass" @l_prefix@/bin/psql -q -U "$db_user" -d "$db_name" -A -t \
michael@290 52 -f "@l_prefix@/lib/davical/awl/dba/schema-management.sql" 2>&1 | grep -v NOTICE
michael@290 53 PGPASSWORD="$db_pass" @l_prefix@/bin/psql -q -U "$db_user" -d "$db_name" -A -t \
michael@290 54 -f "@l_prefix@/lib/davical/davical/dba/davical.sql" 2>&1 | grep -v NOTICE
michael@290 55 PGPASSWORD="$db_pass" @l_prefix@/bin/psql -q -U "$db_user" -d "$db_name" -A -t \
michael@290 56 -f "@l_prefix@/lib/davical/davical/dba/base-data.sql" 2>&1 | grep -v NOTICE
michael@290 57
michael@290 58 # create schema 2/2 (from original "update-davical-database" script)
michael@290 59 PGPASSWORD="$db_pass" @l_prefix@/bin/psql -q -U "$db_user" -d "$db_name" -A -t \
michael@290 60 -f "@l_prefix@/lib/davical/davical/dba/supported_locales.sql" 2>&1 | grep -v NOTICE
michael@290 61 PGPASSWORD="$db_pass" @l_prefix@/bin/psql -q -U "$db_user" -d "$db_name" -A -t \
michael@290 62 -f "@l_prefix@/lib/davical/davical/dba/caldav_functions.sql" 2>&1 | egrep -v '(NOTICE|ERROR)'
michael@290 63 PGPASSWORD="$db_pass" @l_prefix@/bin/psql -q -U "$db_user" -d "$db_name" -A -t \
michael@290 64 -f "@l_prefix@/lib/davical/davical/dba/rrule_functions.sql" 2>&1 | egrep -v '(NOTICE|ERROR)'
michael@290 65 PGPASSWORD="$db_spass" @l_prefix@/bin/psql -q -U "$db_suser" -d "$db_name" -A -t \
michael@295 66 -f "/opmi/lib/davical/davical/dba/views/dav_principal.sql"
michael@295 67 PGPASSWORD="$db_spass" @l_prefix@/bin/psql -q -U "$db_suser" -d "$db_name" -A -t \
michael@290 68 -f "@l_prefix@/lib/davical/davical/dba/appuser_permissions.txt" 2>&1 | grep -v NOTICE
michael@290 69
michael@290 70 # set admin password
michael@290 71 PGPASSWORD="$db_pass" @l_prefix@/bin/psql -q -U "$db_user" -d "$db_name" \
michael@290 72 -c "UPDATE usr SET password = '**$admin_password' WHERE user_no = 1;"
michael@290 73 ;;
michael@290 74
michael@290 75 uninstall )
michael@290 76 PGPASSWORD="$db_pass" @l_prefix@/bin/psql -q -U "$db_user" -d "$db_name" \
michael@290 77 -c "DROP LANGUAGE plpgsql CASCADE;" 2>&1 | grep -v NOTICE
michael@290 78 ( echo "DROP DATABASE $db_name;"
michael@290 79 echo "DROP TABLESPACE $db_name;"
michael@290 80 echo "DROP ROLE $db_user;"
michael@290 81 ) | PGPASSWORD="$db_spass" @l_prefix@/bin/psql -q -U "$db_suser" -d "$db_sname" -f-
michael@290 82 ;;
michael@290 83
michael@290 84 edit )
michael@290 85 PGPASSWORD="$db_spass" @l_prefix@/bin/psql -U "$db_suser" -d "$db_name"
michael@290 86 ;;
michael@290 87 esac
michael@290 88

mercurial