From 6bf89972c8ce00d92d3aafd0c7785554d7c09420 Mon Sep 17 00:00:00 2001
From: Daniel <d.hornung@indiscale.com>
Date: Fri, 9 Jul 2021 12:28:22 +0200
Subject: [PATCH] WIP: Octave packaging.

---
 .gitignore                              |  5 ++++-
 Makefile                                |  5 +++++
 pkg/.miss_hit                           |  7 +++++++
 pkg/CITATION                            |  1 +
 src/Example.m => pkg/COPYING            | 15 +++------------
 pkg/ChangeLog                           |  1 +
 pkg/DESCRIPTION                         | 12 ++++++++++++
 pkg/LICENSE.md                          |  1 +
 {src => pkg}/doc/Gen_HTML.m             |  4 ++--
 {src => pkg}/doc/Makefile               |  0
 {src => pkg}/doc/conf.py                |  0
 {src => pkg}/doc/index.rst              |  0
 {src/dummy => pkg/inst}/some_function.m |  0
 pkg/src/configure                       |  5 +++++
 src/Run_Test.m                          |  6 +++---
 15 files changed, 44 insertions(+), 18 deletions(-)
 create mode 100644 pkg/.miss_hit
 create mode 100644 pkg/CITATION
 rename src/Example.m => pkg/COPYING (65%)
 create mode 120000 pkg/ChangeLog
 create mode 100644 pkg/DESCRIPTION
 create mode 120000 pkg/LICENSE.md
 rename {src => pkg}/doc/Gen_HTML.m (92%)
 rename {src => pkg}/doc/Makefile (100%)
 rename {src => pkg}/doc/conf.py (100%)
 rename {src => pkg}/doc/index.rst (100%)
 rename {src/dummy => pkg/inst}/some_function.m (100%)
 create mode 100755 pkg/src/configure

diff --git a/.gitignore b/.gitignore
index 51f3702..557180d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,9 @@
 # General
 build/
-include/libcaosdbConfig.h
+*.tar.gz
+
+# Caches
+.*cache
 
 # CMake
 CMakeLists.txt.user
diff --git a/Makefile b/Makefile
index 1d5197b..2d5cb2a 100644
--- a/Makefile
+++ b/Makefile
@@ -32,7 +32,12 @@ doc:
 .PHONY: style
 style:
 	mh_style --octave src
+	mh_style --octave pkg
 
 .PHONY: test
 test:
 	cd src && octave Run_Test.m
+
+.PHONY: pkg
+pkg:
+	tar -czf caosdb.tar.gz --exclude-from=.gitignore pkg
diff --git a/pkg/.miss_hit b/pkg/.miss_hit
new file mode 100644
index 0000000..f15ccfe
--- /dev/null
+++ b/pkg/.miss_hit
@@ -0,0 +1,7 @@
+# -*- mode:conf; -*-
+# See https://florianschanda.github.io/miss_hit/style_checker.html
+
+line_length: 100
+regex_function_name: "[a-z]+(_[a-z]+)*"
+suppress_rule: "whitespace_comments"
+tab_width: 2
diff --git a/pkg/CITATION b/pkg/CITATION
new file mode 100644
index 0000000..cc9f500
--- /dev/null
+++ b/pkg/CITATION
@@ -0,0 +1 @@
+caosdb-octavelib, an Octave library for CaosDB. IndiScale GmbH (2021)
diff --git a/src/Example.m b/pkg/COPYING
similarity index 65%
rename from src/Example.m
rename to pkg/COPYING
index 6b6abe1..fdc78ab 100644
--- a/src/Example.m
+++ b/pkg/COPYING
@@ -1,8 +1,8 @@
-% (C) Copyright 2021 IndiScale GmbH <info@indiscale.com>
-% (C) Copyright 2021 Daniel Hornung <d.hornung@indiscale.com>
-%
 % This file is a part of the CaosDB Project.
 %
+% Copyright (C) 2021 IndiScale GmbH <info@indiscale.com>
+% Copyright (C) 2021 Daniel Hornung <d.hornung@indiscale.com>
+%
 % This program is free software: you can redistribute it and/or modify
 % it under the terms of the GNU Affero General Public License as
 % published by the Free Software Foundation, either version 3 of the
@@ -15,12 +15,3 @@
 %
 % You should have received a copy of the GNU Affero General Public License
 % along with this program. If not, see <https://www.gnu.org/licenses/>.
-
-%% Example file with dummy code from https://www.gnu.org/software/octave/
-
-x = -10:0.1:10;  % Create an evenly-spaced vector from -10..10
-y = sin(x);      % y is also a vector
-plot (x, y);
-title ("Simple 2-D Plot");
-xlabel ("x");
-ylabel ("sin (x)");
diff --git a/pkg/ChangeLog b/pkg/ChangeLog
new file mode 120000
index 0000000..699cc9e
--- /dev/null
+++ b/pkg/ChangeLog
@@ -0,0 +1 @@
+../../CHANGELOG.md
\ No newline at end of file
diff --git a/pkg/DESCRIPTION b/pkg/DESCRIPTION
new file mode 100644
index 0000000..d34b56b
--- /dev/null
+++ b/pkg/DESCRIPTION
@@ -0,0 +1,12 @@
+# See https://octave.org/doc/interpreter/The-DESCRIPTION-File.html
+Name: caosdb
+Version: 0.1.0
+Date: 2021-07-09
+Author: Daniel Hornung <d.hornung@indiscale.com>
+Maintainer: Daniel Hornung <d.hornung@indiscale.com>
+Title: Octave and Matlab library for CaosDB
+Description: This package contains utility functions to interact with CaosDB.
+License: AGPLv3
+Categories: data management
+Url: https://gitlab.com/caosdb/caosdb-octavelib
+BuildRequires: libcaosdb
diff --git a/pkg/LICENSE.md b/pkg/LICENSE.md
new file mode 120000
index 0000000..f0608a6
--- /dev/null
+++ b/pkg/LICENSE.md
@@ -0,0 +1 @@
+../../LICENSE.md
\ No newline at end of file
diff --git a/src/doc/Gen_HTML.m b/pkg/doc/Gen_HTML.m
similarity index 92%
rename from src/doc/Gen_HTML.m
rename to pkg/doc/Gen_HTML.m
index 062322d..ac9fe83 100644
--- a/src/doc/Gen_HTML.m
+++ b/pkg/doc/Gen_HTML.m
@@ -19,5 +19,5 @@
 % ------------------------------------------------------------------------
 % Build the HTML documentation.
 
-pkg load generate_doc
-generate_package_html("caosdb", "_build_octave/")
+pkg load generate_doc;
+generate_package_html("caosdb", "_build_octave/");
diff --git a/src/doc/Makefile b/pkg/doc/Makefile
similarity index 100%
rename from src/doc/Makefile
rename to pkg/doc/Makefile
diff --git a/src/doc/conf.py b/pkg/doc/conf.py
similarity index 100%
rename from src/doc/conf.py
rename to pkg/doc/conf.py
diff --git a/src/doc/index.rst b/pkg/doc/index.rst
similarity index 100%
rename from src/doc/index.rst
rename to pkg/doc/index.rst
diff --git a/src/dummy/some_function.m b/pkg/inst/some_function.m
similarity index 100%
rename from src/dummy/some_function.m
rename to pkg/inst/some_function.m
diff --git a/pkg/src/configure b/pkg/src/configure
new file mode 100755
index 0000000..0a272ab
--- /dev/null
+++ b/pkg/src/configure
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+echo "Nothing is implemented yet."
+
+# See https://octave.org/doc/interpreter/Creating-Packages.html
diff --git a/src/Run_Test.m b/src/Run_Test.m
index 6854f19..b70b918 100644
--- a/src/Run_Test.m
+++ b/src/Run_Test.m
@@ -19,12 +19,12 @@
 % ------------------------------------------------------------------------
 % Run the tests, exit with their value.
 
-addpath("dummy");
+addpath('../pkg/inst/');
 
 [n, nmax, nxfail, nbug, nskip, nrtskip, nregression] = ...
-  test("some_function.m", "verbose");
+  test('some_function.m', 'verbose');
 
-disp(["Passed " num2str(n) " out of " num2str(nmax) " tests."]);
+disp(['Passed ' num2str(n) ' out of ' num2str(nmax) ' tests.']);
 if n == nmax
   exit(0);
 end
-- 
GitLab