Skip to content

Commit

Permalink
Added files and instructions for building a deb file
Browse files Browse the repository at this point in the history
Also upgraded to a modern 2.x version of stack which required
significant changes to the stack.yaml and addition of stack.yaml.lock
  • Loading branch information
dino- committed Jul 6, 2019
1 parent 4e6f4f1 commit c585551
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 32 deletions.
73 changes: 48 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,33 @@ Data downloader and parser for the KitchenSnitch project (Haskell)

## Installing

Installation is usually from a .deb file located on
[github](https://github.com/dino-/ks-download/releases)

Instructions for building the .deb file are below, under Building for
deployment.


## Configuration and execution

Make a directory for config files, and copy or link the conf files into
it, along with your Google API key in a file. The defaults are
expecting `$HOME/.config/kitchensnitch`
Make a directory for config files, and copy all the files from
`/usr/share/ks-download/resources` into it, along with your Google API key in a
file.

The key should be the only thing in the `GoogleAPIKey` file, on a
line by itself.

You will need to put real credentials in `monbodb.conf` as well.

The directory should look something like this:

$HOME/
.config/
kitchensnitch/
ksnitch/
GoogleAPIKey
ks-locate.conf
mongodb.conf

The key should be the only thing in the `GoogleAPIKey` file, on a
line by itself.
.. more conf files from share ..


### ks-locate - Google Places lookup utility
Expand All @@ -41,7 +52,7 @@ To run, have a directory structure like this:
Then, to run:

$ cd inspectionsToProcess
$ ks-locate -c $HOME/.config/kitchensnitch -s succ/ -f fail/ --delete insp | tee ks-locate.log
$ ks-locate -c $HOME/.config/ksnitch -s succ/ -f fail/ --delete insp | tee ks-locate.log

When it's finished:

Expand All @@ -66,38 +77,50 @@ job shoulld look something like this:

Put this in a cron job:

45 1 * * * /opt/ks-download/bin/ks-regionupd --log-priority=NOTICE $HOME/.config/kitchensnitch > /some/dir/ks-regionupd.log
45 1 * * * /opt/ks-download/bin/ks-regionupd --log-priority=NOTICE $HOME/.config/ksnitch > /some/dir/ks-regionupd.log


## Building from source

Follow the instructions on the wiki for setting up a sandbox for all KS development, in the section "Building the KitchenSnitch Haskell server-side components for deployment"


### Building for development

$ cabal sandbox init --sandbox=/home/USER/.cabal/sandbox/kitchensnitch
$ cabal install --only-dep --enable-tests
$ cabal configure --enable-tests
$ cabal build
$ cabal test

And you should be good for development from here.
$ stack build
$ stack exec BIN_NAME -- ARGS
$ stack test
$ stack clean


### Building for deployment

This will build everything into a deployable directory structure
that you can put somewhere like `/opt/` for instance.
Our production servers have so far been Ubuntu, so what follows are
instructions for building a .deb file which can be installed with dpkg.

You will need the [hsinstall](https://github.com/dino-/hsinstall/releases)
utility version 2.5 for this procedure.

Now, starting in the root of the project, do this, where VER is the version of
ks-download you are building:

$ hsinstall --prefix=ks-download/ks-download_VER
$ mkdir ks-download/ks-download_VER/DEBIAN
$ cp -t ks-download/ks-download_VER/DEBIAN util/resources/DEBIAN/control util/resources/DEBIAN/conffiles

Edit `ks-download/ks-download_VER/DEBIAN/control` to make sure the version
matches what you're building.

$ sudo chown -R root:root ks-download/ks-download_VER
$ dpkg-deb --build ks-download/ks-download_VER

$ cabal install --prefix=/tmp/ks-download-VER --datasubdir=.
$ pushd /tmp
$ tar czvf ks-download-VER.tgz ks-download-VER
$ popd
And you should see a `ks-download/ks-download_VER.deb` file. Check the contents
if you wish with `dpkg-deb -c ...` This file can be added to the ks-download
release page on github or distributed however you wish.

Some of these notes exist in a more detailed form on the developer wiki.

When you want to insert records into the database, make sure you do not forget to edit the `bin/ks-dl-nightly.sh` script. By default ks-dbinsert execution is commented out and fake one runs!
When you want to insert records into the database, make sure you do not forget
to edit the `PREFIX/bin/ks-dl-nightly-XXX.sh` scripts. By default ks-dbinsert
execution is commented out and a fake one runs!


## Contact
Expand Down
11 changes: 4 additions & 7 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
resolver: lts-11.10

packages:
- '.'
- location:
git: https://github.com/Palmik/bson-generic.git
commit: e078def65d0dee1ea7e3205f445e47d5937851f3
extra-dep: True
- location: ../ks-library
extra-dep: True
- .
- ../ks-library

extra-deps:
- git: https://github.com/Palmik/bson-generic.git
commit: e078def65d0dee1ea7e3205f445e47d5937851f3
- hcoord-1.0.0.0
- tce-conf-1.3
40 changes: 40 additions & 0 deletions stack.yaml.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This file was autogenerated by Stack.
# You should not edit this file by hand.
# For more information, please see the documentation at:
# https://docs.haskellstack.org/en/stable/lock_files

packages:
- completed:
cabal-file:
size: 784
sha256: 7e5ebe5df4574254c7e38d96bc116dce98d9cd7147c40c78371283071cc00191
name: bson-generic
version: 0.0.8
git: https://github.com/Palmik/bson-generic.git
pantry-tree:
size: 676
sha256: fb2999c6352fcf8719eaba010bfa4617fc60b7ece015dbb13c7474c7ef3b0915
commit: e078def65d0dee1ea7e3205f445e47d5937851f3
original:
git: https://github.com/Palmik/bson-generic.git
commit: e078def65d0dee1ea7e3205f445e47d5937851f3
- completed:
hackage: hcoord-1.0.0.0@sha256:8cf3030c7df35900770bfbf5c972880c550cba160497c09315f4084aba64b177,1595
pantry-tree:
size: 853
sha256: ea297cb8d110a1709281e5a31cc7755849d76100b4d3751e1257a2134f1f6d0d
original:
hackage: hcoord-1.0.0.0
- completed:
hackage: tce-conf-1.3@sha256:8dcdcd680215bff83e2033f7cf1b1c9257ea63328b4e2e81479b3fa892e9763d,2316
pantry-tree:
size: 1080
sha256: 17d2fff56342ea6bbc49dd3c764c0f9036badd331ce22387944d8d57a1308925
original:
hackage: tce-conf-1.3
snapshots:
- completed:
size: 507599
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/11/10.yaml
sha256: ebbaab4c207d9e1a83ff9e92557f692e41b07aa19280819de1ebc73b7b46c5ee
original: lts-11.10
Empty file added util/resources/DEBIAN/conffiles
Empty file.
7 changes: 7 additions & 0 deletions util/resources/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Package: ks-download
Architecture: all
Maintainer: Dino Morelli
Depends: debconf (>= 0.5.00)
Priority: optional
Version: 2.1
Description: Kitchen Snitch server inspection download software

0 comments on commit c585551

Please sign in to comment.