Project

General

Profile

« Previous | Next » 

Revision 4094

input.Makefile: Removed no longer used DB inputs section, because all of our inputs are either CSV or (rarely) XML. This removes a significant amount of dead code that will make it easier to refactor input.Makefile to use custom CSV import orders.

View differences:

input.Makefile
106 106
##### Existing maps discovery
107 107

  
108 108
inputFiles := $(wildcard $(exts:%=src/*.%))
109
ifeq ($(inputFiles),)
110
dbExport := $(firstword $(wildcard src/db.*.sql))
111
endif
112 109

  
113 110
srcMaps := $(wildcard maps/src.*.csv)
114 111
srcRoots := $(srcMaps:maps/src.%.csv=$(mappings)/roots/%.sh)
......
156 153

  
157 154
##### Installation
158 155

  
159
install: _always src/install import/install ;
156
install: _always import/install ;
160 157

  
161
uninstall: _always import/uninstall src/uninstall ;
158
uninstall: _always import/uninstall ;
162 159

  
163 160
reinstall: _always uninstall install ;
164 161

  
......
274 271

  
275 272
##### Import to VegBIEN
276 273

  
277
ifneq ($(dbExport)$(inputFiles),)
274
ifneq ($(inputFiles),)
278 275

  
279 276
profileTest = $(if $(profile),$(if $(test),1))
280 277
profileOnly = -env profile_to=/dev/fd/3 $(map2db) 3>&1 1>&2|\
......
328 325

  
329 326
all += $(wildcard verify/*.out)
330 327

  
331
ifneq ($(dbExport),)
332
%.ref: %.ref.sql
333
	$(dbAsBien) $(db) <$< >$@
334
endif
335

  
336 328
##### Editing import
337 329

  
338 330
import/rotate: _always
......
410 402

  
411 403
import/steps.by_col.sql: _always
412 404
	+$(steps)
413

  
414
##### Input-type-specific
415

  
416
# Each input type needs var $(mapEnv) and targets src/install, src/uninstall
417

  
418
#### DB export
419

  
420
ifneq ($(dbExport),)
421

  
422
dbEngineExt := $(subst .,,$(suffix $(basename $(notdir $(dbExport)))))
423
db := $(datasrc)
424

  
425
### Installation
426

  
427
src/install: _always db ;
428

  
429
src/uninstall: _always rm_db ;
430

  
431
### DB-engine-specific
432

  
433
# Each DB engine needs vars $(dbEngine), $(dbAsBien) and targets db, rm_db
434

  
435
ifeq ($(dbEngineExt),my)
436

  
437
dbEngine := MySQL
438

  
439
bienPassword := $(shell cat $(root)/config/bien_password)
440
mysqlAs = mysql --user=$(1) --password='$(bienPassword)'
441
mysqlAsRoot := $(call mysqlAs,root)
442
dbAsBien := $(call mysqlAs,bien)
443

  
444
dbExists = $(shell echo "SHOW DATABASES LIKE '$(db)';"|$(mysqlAsRoot))
445

  
446
define createDb
447
echo "CREATE DATABASE $(db) DEFAULT CHARACTER SET latin1;"|$(mysqlAsRoot)
448
-$(mysqlAsRoot) --database=$(db) <$<
449
endef
450
# ignore errors in db import so that GRANT will still be run
451

  
452
db: $(dbExport) _always
453
	$(if $(dbExists),,$(createDb))
454
	echo "GRANT SELECT ON $(db).* TO 'bien'@'localhost';"|$(mysqlAsRoot)
455

  
456
rm_db: _always
457
	-echo "REVOKE ALL ON $(db).* FROM 'bien'@'localhost';"|$(mysqlAsRoot)
458
	echo "DROP DATABASE IF EXISTS $(db);"|$(mysqlAsRoot)
459
# ignore errors if grant not defined
460

  
461
## Unrecognized DB engine
462

  
463
else
464
$(error The DB filename $(dbExport) must be db.my.sql)
465
endif
466

  
467
### Other input types
468

  
469
else
470

  
471
src/install: _always ;
472
src/uninstall: _always ;
473

  
474
endif
475

  
476
#### DB connection info
477

  
478
ifneq ($(dbEngine),)
479
# Must come after dbEngine is set
480
mapEnv := in_engine=$(dbEngine) in_database=$(db)
481
endif

Also available in: Unified diff