[GRASS-dev] Re: [GRASS-CVS] hamish: grass6/lib/init init.sh, 1.119, 1.120

On Sat, Oct 06, 2007 at 07:05:00AM +0200, grass@intevation.de wrote:

Author: hamish

Update of /grassrepository/grass6/lib/init
In directory doto:/tmp/cvs-serv6411

Modified Files:
        init.sh
Log Message:
add test so don't overwrite VAR file without testing. I just commented the whole
thing out though after fixing it, as the VAR and $MAPSET/dbf/ should be
created on demand. To a raster-only or postgres-only user they are just
file pollution. code bug #502

Index: init.sh

RCS file: /grassrepository/grass6/lib/init/init.sh,v
retrieving revision 1.119
retrieving revision 1.120
diff -u -d -r1.119 -r1.120
--- init.sh 3 Oct 2007 08:30:48 -0000 1.119
+++ init.sh 6 Oct 2007 05:04:58 -0000 1.120
@@ -495,9 +495,10 @@
                        cp "$GISDBASE/$LOCATION_NAME/PERMANENT/WIND" "$LOCATION/WIND"
                        echo "Missing WIND file fixed"
                        # predefine DBF driver
- echo "DB_DRIVER: dbf" > "$LOCATION/VAR"
- echo "DB_DATABASE: \$GISDBASE/\$LOCATION_NAME/\$MAPSET/dbf/" >> "$LOCATION/VAR"
- mkdir "$LOCATION"/dbf
+ # why is this needed ??
+ #echo "DB_DRIVER: dbf" > "$LOCATION/VAR"
+ #echo "DB_DATABASE: \$GISDBASE/\$LOCATION_NAME/\$MAPSET/dbf/" >> "$LOCATION/VAR"
+ #mkdir "$LOCATION"/dbf

This is needed, if you start GRASS from CMD line with
full path to a non-existing mapset (which is then created).
So this should be restored somehow.

Above was there for many months without problems. The recent
problem seems to arise from a different modification.

Markus

PS: I find init.sh rather overloaded and hard to understand.

------------------
ITC -> dall'1 marzo 2007 Fondazione Bruno Kessler
ITC -> since 1 March 2007 Fondazione Bruno Kessler
------------------

On Sat, October 6, 2007 09:53, Markus Neteler wrote:

On Sat, Oct 06, 2007 at 07:05:00AM +0200, grass@intevation.de wrote:

Author: hamish

Update of /grassrepository/grass6/lib/init
In directory doto:/tmp/cvs-serv6411

Modified Files:
        init.sh
Log Message:
add test so don't overwrite VAR file without testing. I just commented
the whole
thing out though after fixing it, as the VAR and $MAPSET/dbf/ should be
created on demand. To a raster-only or postgres-only user they are just
file pollution. code bug #502

Index: init.sh

RCS file: /grassrepository/grass6/lib/init/init.sh,v
retrieving revision 1.119
retrieving revision 1.120
diff -u -d -r1.119 -r1.120
--- init.sh 3 Oct 2007 08:30:48 -0000 1.119
+++ init.sh 6 Oct 2007 05:04:58 -0000 1.120
@@ -495,9 +495,10 @@
                        cp "$GISDBASE/$LOCATION_NAME/PERMANENT/WIND"
"$LOCATION/WIND"
                        echo "Missing WIND file fixed"
                        # predefine DBF driver
- echo "DB_DRIVER: dbf" > "$LOCATION/VAR"
- echo "DB_DATABASE:
\$GISDBASE/\$LOCATION_NAME/\$MAPSET/dbf/" >> "$LOCATION/VAR"
- mkdir "$LOCATION"/dbf
+ # why is this needed ??
+ #echo "DB_DRIVER: dbf" > "$LOCATION/VAR"
+ #echo "DB_DATABASE:
\$GISDBASE/\$LOCATION_NAME/\$MAPSET/dbf/" >> "$LOCATION/VAR"
+ #mkdir "$LOCATION"/dbf

This is needed, if you start GRASS from CMD line with
full path to a non-existing mapset (which is then created).

Why is the dbf path creation needed ? You might never want to use dbf on
this new mapset...

I guess the automatic dbf path creation should be part of db.connect...

Above was there for many months without problems. The recent
problem seems to arise from a different modification.

Yes, the revision just before
(http://freegis.org/cgi-bin/viewcvs.cgi/grass6/lib/init/init.sh.diff?r1=1.118&r2=1.119):

===================================================================
RCS file: /home/grass/grassrepository/grass6/lib/init/init.sh,v
retrieving revision 1.118
retrieving revision 1.119
diff -u -r1.118 -r1.119
--- grass6/lib/init/init.sh 2007/09/20 14:18:01 1.118
+++ grass6/lib/init/init.sh 2007/10/03 08:30:48 1.119
@@ -1,7 +1,7 @@
#!/bin/sh
#############################################################################
#
-# $Id: init.sh,v 1.118 2007/09/20 14:18:01 moritz Exp $
+# $Id: init.sh,v 1.119 2007/10/03 08:30:48 markus Exp $
#
# MODULE: GRASS Initialization
# AUTHOR(S): Original author unknown - probably CERL
@@ -685,6 +685,11 @@
   echo "Building user fontcap ..."
   g.mkfontcap
fi
+
+# predefine DBF driver if DB connection not defined
+echo "DB_DRIVER: dbf" > "$LOCATION/VAR"
+echo "DB_DATABASE: \$GISDBASE/\$LOCATION_NAME/\$MAPSET/dbf/" >>
"$LOCATION/VAR"
+mkdir "$LOCATION"/dbf

trap "" 2 3 15

Moritz

Markus:

> Above was there for many months without problems. The recent
> problem seems to arise from a different modification.

Moritz:

Yes, the revision just before

(http://freegis.org/cgi-bin/viewcvs.cgi/grass6/lib/init/init.sh.diff?r1=1.118&r2=1.119):

ie the missing check for the existence of VAR before overwriting the file.

H

____________________________________________________________________________________
Be a better Globetrotter. Get better travel answers from someone who knows. Yahoo! Answers - Check it out.
http://answers.yahoo.com/dir/?link=list&sid=396545469

HamishB wrote:

Markus:

> Above was there for many months without problems. The recent
> problem seems to arise from a different modification.

Moritz:

Yes, the revision just before

(http://freegis.org/cgi-bin/viewcvs.cgi/grass6/lib/init/init.sh.diff?r1=1.118&r2=1.119):

ie the missing check for the existence of VAR before overwriting the file.

Would like to check that but...:

Python Exception Occurred
Traceback (most recent call last):
  File "/home/www/viewcvs/lib/viewcvs.py", line 2630, in run_cgi
    main()
  File "/home/www/viewcvs/lib/viewcvs.py", line 2608, in main
    view_diff(request, full_name[:-5])
  File "/home/www/viewcvs/lib/viewcvs.py", line 2335, in view_diff
    if revcmp(rev1, rev2) > 0:
  File "/home/www/viewcvs/lib/viewcvs.py", line 1098, in revcmp
    rev2 = map(int, string.split(rev2, '.'))
ValueError: invalid literal for int(): 119)

Ouch?

Markus

PS: Martin has prepared a CVS backup via rsync and with viewCVS:
http://josef.fsv.cvut.cz/cgi-bin/viewcvs.cgi/grass6/lib/init/init.sh?root=grass&r1=1.118&r2=1.119
So, seems to be my fault (the overwrite, not that the VAR file disappears!)
--
View this message in context: http://www.nabble.com/Re%3A--GRASS-CVS--hamish%3A-grass6-lib-init-init.sh%2C-1.119%2C-1.120-tf4579018.html#a13078288
Sent from the Grass - Dev mailing list archive at Nabble.com.

Markus Neteler wrote:

> Author: hamish

..

> Modified Files:
> init.sh
> Log Message:
> add test so don't overwrite VAR file without testing. I just
> commented the whole thing out though after fixing it, as the VAR and
> $MAPSET/dbf/ should be created on demand. To a raster-only or
> postgres-only user they are just file pollution. code bug #502
>
> Index: init.sh
> ===================================================================
> RCS file: /grassrepository/grass6/lib/init/init.sh,v
> retrieving revision 1.119
> retrieving revision 1.120
> diff -u -d -r1.119 -r1.120
> --- init.sh 3 Oct 2007 08:30:48 -0000 1.119
> +++ init.sh 6 Oct 2007 05:04:58 -0000 1.120
> @@ -495,9 +495,10 @@
> cp "$GISDBASE/$LOCATION_NAME/PERMANENT/WIND"
> "$LOCATION/WIND" echo "Missing WIND file fixed"
> # predefine DBF driver
> - echo "DB_DRIVER: dbf" > "$LOCATION/VAR"
> - echo "DB_DATABASE: \$GISDBASE/\
> $LOCATION_NAME/\$MAPSET/dbf/" >> "$LOCATION/VAR"
> - mkdir "$LOCATION"/dbf
> + # why is this needed ??
> + #echo "DB_DRIVER: dbf" > "$LOCATION/VAR"
> + #echo "DB_DATABASE: \$GISDBASE/\
> $LOCATION_NAME/\$MAPSET/dbf/" >> "$LOCATION/VAR"
> + #mkdir "$LOCATION"/dbf

Markus:

This is needed, if you start GRASS from CMD line with
full path to a non-existing mapset (which is then created).
So this should be restored somehow.

so

#typo
user:~ $ grass63 grassdata/spearfish60/user11

Is meant to create:
grassdata/spearfish60/user11/VAR
grassdata/spearfish60/user11/WIND
grassdata/spearfish60/user11/dbf/

(current CVS makes the new mapset but not the VAR and dbf/)

?
I would think we should throw an error if the mapset doesn't exist
(typo), and some '-n' flag is needed to create a new mapset from the
command line.
?

And don't create the VAR and dbf/ until needed. (why do those need to
exist before any vector maps with tables are created?)
?

Hamish

HamishB wrote:

Markus Neteler wrote:

> Author: hamish

..

> Modified Files:
> init.sh
> Log Message:
> add test so don't overwrite VAR file without testing. I just
> commented the whole thing out though after fixing it, as the VAR and
> $MAPSET/dbf/ should be created on demand. To a raster-only or
> postgres-only user they are just file pollution. code bug #502
>
> Index: init.sh
> ===================================================================
> RCS file: /grassrepository/grass6/lib/init/init.sh,v
> retrieving revision 1.119
> retrieving revision 1.120
> diff -u -d -r1.119 -r1.120
> --- init.sh 3 Oct 2007 08:30:48 -0000 1.119
> +++ init.sh 6 Oct 2007 05:04:58 -0000 1.120
> @@ -495,9 +495,10 @@
> cp "$GISDBASE/$LOCATION_NAME/PERMANENT/WIND"
> "$LOCATION/WIND" echo "Missing WIND file fixed"
> # predefine DBF driver
> - echo "DB_DRIVER: dbf" > "$LOCATION/VAR"
> - echo "DB_DATABASE: \$GISDBASE/\
> $LOCATION_NAME/\$MAPSET/dbf/" >> "$LOCATION/VAR"
> - mkdir "$LOCATION"/dbf
> + # why is this needed ??
> + #echo "DB_DRIVER: dbf" > "$LOCATION/VAR"
> + #echo "DB_DATABASE: \$GISDBASE/\
> $LOCATION_NAME/\$MAPSET/dbf/" >> "$LOCATION/VAR"
> + #mkdir "$LOCATION"/dbf

Markus:

This is needed, if you start GRASS from CMD line with
full path to a non-existing mapset (which is then created).
So this should be restored somehow.

so

#typo
user:~ $ grass63 grassdata/spearfish60/user11

Is meant to create:
grassdata/spearfish60/user11/VAR
grassdata/spearfish60/user11/WIND
grassdata/spearfish60/user11/dbf/

(current CVS makes the new mapset but not the VAR and dbf/)

?

Yes, because only then it becomes a valid mapset without subsequent
errors.

HamishB wrote:

I would think we should throw an error if the mapset doesn't exist
(typo), and some '-n' flag is needed to create a new mapset from the
command line.
?

OK, sounds reasonable to me (less surprises in the script behaviour).

HamishB wrote:

And don't create the VAR and dbf/ until needed. (why do those need to
exist before any vector maps with tables are created?)
?

Because any db./v. command will fail if those aren't present. DBF is the
default (still). Costs only a very few bytes.

Alternatively, fix all commands to auto-create when VAR and dbf/ are needed
but I suspect that this would be lots of work. Better do it in one place
right
at the beginning (then we can also easily switch to SQLite as default DB
driver
in future.

Markus
--
View this message in context: http://www.nabble.com/Re%3A--GRASS-CVS--hamish%3A-grass6-lib-init-init.sh%2C-1.119%2C-1.120-tf4579018.html#a13103885
Sent from the Grass - Dev mailing list archive at Nabble.com.