Bug 6540 - Add more options to koha-create
Summary: Add more options to koha-create
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Packaging (show other bugs)
Version: 3.6
Hardware: All All
: PATCH-Sent (DO NOT USE) enhancement (vote)
Assignee: Magnus Enger
QA Contact: Bugs List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-29 11:23 UTC by Magnus Enger
Modified: 2012-10-25 23:09 UTC (History)
2 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Bot Control: ---
When did the bot last check this:
Who signed the patch off:
Text to go in the release notes:


Attachments
Proposed patch (3.62 KB, patch)
2011-07-17 21:49 UTC, Magnus Enger
Details | Diff | Splinter Review
Followup - apply on top of the first one (2.11 KB, patch)
2011-07-18 13:52 UTC, Magnus Enger
Details | Diff | Splinter Review
Followup - Add defaultsql command line option (848 bytes, patch)
2011-07-20 14:19 UTC, Magnus Enger
Details | Diff | Splinter Review
Followup - Add command line option for config file (2.86 KB, patch)
2011-07-20 17:13 UTC, Magnus Enger
Details | Diff | Splinter Review
Bug 6540 - Make ZEBRA_MARC_FORMAT and ZEBRA_LANGUAGE configurable for koha-create (3.67 KB, patch)
2011-07-21 05:38 UTC, Robin Sheat
Details | Diff | Splinter Review
Bug 6540 - Followup patch adding command line options (2.15 KB, patch)
2011-07-21 05:38 UTC, Robin Sheat
Details | Diff | Splinter Review
Bug 6540 - Add defaultsql command line option (894 bytes, patch)
2011-07-21 05:38 UTC, Robin Sheat
Details | Diff | Splinter Review
Bug 6540 - Add config file as command line option for koha-create (2.90 KB, patch)
2011-07-21 05:39 UTC, Robin Sheat
Details | Diff | Splinter Review
Bug 6540 - fix some command-line args issues (1.51 KB, patch)
2011-07-21 05:39 UTC, Robin Sheat
Details | Diff | Splinter Review
Signed-off Robin's patch (1.58 KB, patch)
2011-07-21 09:09 UTC, Magnus Enger
Details | Diff | Splinter Review
Follow up - fix problem when --configfile is not set (1.15 KB, patch)
2011-08-15 07:05 UTC, Magnus Enger
Details | Diff | Splinter Review
Bug 6540 - Followup - koha-create would die without --configfile (1.24 KB, patch)
2011-08-23 03:46 UTC, Robin Sheat
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Magnus Enger 2011-06-29 11:23:00 UTC
At the moment, koha-create is hardcoded to do MARC21 installations.
Comment 1 Robin Sheat 2011-06-29 12:31:20 UTC
Strictly speaking, koha-create is MARC flavour agnostic. It's the packages that are generating MARC21 (as that's the default.) What we should do is take the zebra config templates that the koha installer uses (or however it does it) and make one for each flavour. Then make koha-create know about these and it can choose which one to install.
Comment 2 Magnus Enger 2011-06-29 12:44:06 UTC
Hm, my guess would be that it should be possible to alter debian/templates/zebra-biblios-site.cfg.in which now has this: 

5 # Where are the config files located?
6 profilePath:/etc/koha/zebradb/biblios/etc:/etc/koha/zebradb/etc:/etc/koha/zebradb/marc_defs/marc21/biblios:/etc/koha/zebradb/lang_defs/en
7 # modulePath - where to look for loadable zebra modules
8 modulePath: /usr/lib/idzebra-2.0/modules

and turn line 6 into something like this: 

profilePath:/etc/koha/zebradb/biblios/etc:/etc/koha/zebradb/etc:/etc/koha/zebradb/marc_defs/__ZEBRA_MARC_FORMAT__/biblios:/etc/koha/zebradb/lang_defs/__ZEBRA_LANGUAGE__

and have koha-create replace the variables, similar to other settings in the same file?

(This would mean turning the zebra language into an option, not just the marcflavor, which would be a good thing.)
Comment 3 Magnus Enger 2011-07-17 21:49:06 UTC Comment hidden (obsolete)
Comment 4 Robin Sheat 2011-07-17 22:03:36 UTC
I think that adding the ability to set this is a good start. Adding the command line options isn't hard, the magic you need is "getopt".
Comment 5 Magnus Enger 2011-07-18 13:52:02 UTC Comment hidden (obsolete)
Comment 6 Magnus Enger 2011-07-18 14:05:28 UTC
Hm, now that I think about it... If you create an instance with a marcflavor other then the one you usually use, you probably do not want to use your standard SQL file either, right? Because you want to have an SQL file that has the frameworks for the marcflavor you are choosing... So maybe the SQL file should be a command line option too? 

And how about just having the config file as a command line option as well (with /etc/koha/koha-sites.conf as the default)? That way I could have my standard config file set up to create NORMARC instances, but I could have an alternate config file lying around for the odd occasions when I want to create e.g. a MARC21 instance?
Comment 7 Robin Sheat 2011-07-19 04:58:07 UTC
Having a separate config option seems to be a good idea, although perhaps also allowing the SQL path to be overridden on the command line. This allows you to make all sorts of exceptions, but still basing off a file. Seems to me that's the best approach.
Comment 8 Magnus Enger 2011-07-20 14:19:09 UTC Comment hidden (obsolete)
Comment 9 Magnus Enger 2011-07-20 17:13:16 UTC Comment hidden (obsolete)
Comment 10 Robin Sheat 2011-07-20 23:50:32 UTC
Naw, this should be fine. Looking into it now.
Comment 11 Robin Sheat 2011-07-21 04:53:12 UTC
+[ $# -ge 2 ] && [ $# -le 6 ] || 
+    die "Usage: $0 [--create-db|--request-db|--populate-db] \
+[--marcflavor marc21|normarc|unimarc] \
+[--zebralang en|fr|nb] instancename"

should that language be 'nb' or 'no' or...? Where do those values come from?
Comment 12 Robin Sheat 2011-07-21 05:03:46 UTC
nvm the above, I worked that out.

Found a minor bug:

-TEMP=`getopt -o crpm:l: -l create-db,request-db,populate-db,marcflavor:,zebralang: \
+TEMP=`getopt -o crpm:l: -l create-db,request-db,populate-db,marcflavor:,zebralang:,configfile: \
      -n "$0" -- "$@"`

+		-f|--configfile) configfile="$2" ; shift 2 ;;

-f isn't picked up in the command line.
Comment 13 Robin Sheat 2011-07-21 05:17:35 UTC
Same with --defaultsql and -d

Also, the 'internal error' bit is actually correct, as if it ends up in that state, it is an internal error to do with the command line parsing, not an error with the provided options.

I'll fix these in a patch on top of this and sign your ones off.
Comment 14 Robin Sheat 2011-07-21 05:38:53 UTC
Created attachment 4690 [details] [review]
Bug 6540 - Make ZEBRA_MARC_FORMAT and ZEBRA_LANGUAGE configurable for koha-create

Signed-off-by: Robin Sheat <robin@catalyst.net.nz>
Comment 15 Robin Sheat 2011-07-21 05:38:56 UTC
Created attachment 4691 [details] [review]
Bug 6540 - Followup patch adding command line options

This adds the --marcflavor and --zebralang commandline options, as
well as short versions of all options.

Signed-off-by: Robin Sheat <robin@catalyst.net.nz>
Comment 16 Robin Sheat 2011-07-21 05:38:58 UTC
Created attachment 4692 [details] [review]
Bug 6540 - Add defaultsql command line option

This will override the setting in /etc/koha/koha-sites.conf.

Signed-off-by: Robin Sheat <robin@catalyst.net.nz>
Comment 17 Robin Sheat 2011-07-21 05:39:00 UTC
Created attachment 4693 [details] [review]
Bug 6540 - Add config file as command line option for koha-create

Order of precedence for config options, from lowest to highest:

1. The defaults set in koha-create itself
2. /etc/koha/koha-sites.conf
3. Config file specified with --configfile
4. Individual options set with --marcflavor, --zebralang, --defaultsql

Signed-off-by: Robin Sheat <robin@catalyst.net.nz>
Comment 18 Robin Sheat 2011-07-21 05:39:02 UTC Comment hidden (obsolete)
Comment 19 Robin Sheat 2011-07-21 05:42:33 UTC
Note that my patch (att#4694) hasn't been signed off, but as the core stuff has been, I'll mark this bug signed off. Magnus, if you get the time, double checking my changes would be handy.
Comment 20 Magnus Enger 2011-07-21 09:09:37 UTC
Created attachment 4696 [details] [review]
Signed-off Robin's patch

Thanks for fixing my mistakes and signing off, Robin. I'm signing off on your followup patch, so it should all be signed off now.
Comment 21 Chris Cormack 2011-07-28 02:27:00 UTC
Patches for packages, pushed, please test
Comment 22 Magnus Enger 2011-08-15 07:05:56 UTC Comment hidden (obsolete)
Comment 23 Robin Sheat 2011-08-23 03:46:25 UTC
Created attachment 5100 [details] [review]
Bug 6540 - Followup - koha-create would die without --configfile

koha-create would fail to check that --configfile was set on the
commandline, before either including it if it existed or dying if
it did not. This patch should make sure the existence of a
configfile is only tested if --config is set.

Signed-off-by: Robin Sheat <robin@catalyst.net.nz>

This should apply against 3.4 and master.
Comment 24 Chris Cormack 2011-08-23 03:53:11 UTC
Follow up patch pushed, please test
Comment 25 Chris Nighswonger 2011-10-26 18:02:13 UTC
The fix for this bug was published in the 3.4.5 release. If you were the reporter of this bug, please take time to verify the fix and update the status of this bug report accordingly. If the bug is fixed to your satisfaction, please close this report.