At the moment, koha-create is hardcoded to do MARC21 installations.
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.
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.)
Created attachment 4649 [details] [review] Proposed patch This patch should make it possible to set ZEBRA_MARC_FORMAT and ZEBRA_LANGUAGE by way of /etc/koha/koha-sites.conf This patch does NOT create command line options for ZEBRA_MARC_FORMAT and ZEBRA_LANGUAGE - that seems to be beyond my shell scripting abilities at the moment, but hopefully it still a step in the right direction. Maybe koha-create would be a good candidate for rewriting as a Perl script anyway, as suggested by Bug 4876, and similar to what was done for build-git-snapshot by Bug 5602? To test: * Apply patch * Build packages with build-git-snapshot * Install your newly built koha-common * Set ZEBRA_MARC_FORMAT and ZEBRA_LANGUAGE to something other than the defaults in /etc/koha/koha-sites.conf: ZEBRA_MARC_FORMAT="unimarc|normarc" ZEBRA_LANGUAGE="fr|nb" * Create a new instance with koha-create * Check that the values you set are reflected in the "profilePath" line in the /etc/koha/sites/<yoursite>/zebra-* files that were created * Check that indexing and searching works as expected (Remember to change the example at http://wiki.koha-community.org/wiki/Debian#Quick_Start if this gets pushed.)
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".
Created attachment 4660 [details] [review] Followup - apply on top of the first one Ah, at first glance I got the impression that getopt only supported one character options... Apply this second patch on top of the first one, and koha-create should be able to interpret the --marcflavor and --zebralang options. I have also added short options: -c --create-db -r --request-db -p --populate-db -m --marcflavor -l --zebralang Usage: koha-create [--create-db|--request-db|--populate-db] [--marcflavor marc21|normarc|unimarc] [--zebralang en|fr|nb] instancename
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?
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.
Created attachment 4677 [details] [review] Followup - Add defaultsql command line option Apply on top of the first two. Changes are also pushed here: https://github.com/MagnusEnger/kohawork/tree/bug6540
Created attachment 4679 [details] [review] Followup - Add command line option for config file Makes it possible to point at an alternate configfile with --configfile 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 I hope this is ready for signoff now... Please yell at me if you want me to make a unified patch!
Naw, this should be fine. Looking into it now.
+[ $# -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?
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.
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.
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>
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>
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>
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>
Created attachment 4694 [details] [review] Bug 6540 - fix some command-line args issues
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.
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.
Patches for packages, pushed, please test
Created attachment 5016 [details] [review] Follow up - fix problem when --configfile is not set koha-create did not check that --configfile was actually set on the command line, before checking for the existence of a configfile and dying if it was not found. This patch should make sure a configfile is only looked for if --configfile is actually set.
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.
Follow up patch pushed, please test
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.