Bug 184203 - [NEW PORT] net/motsognir: an ANSI C gopher server
Summary: [NEW PORT] net/motsognir: an ANSI C gopher server
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Bartek Rutkowski
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-24 00:20 UTC by Mateusz Viste
Modified: 2014-10-31 12:38 UTC (History)
2 users (show)

See Also:


Attachments
file.shar (2.25 KB, text/plain)
2013-11-24 00:20 UTC, Mateusz Viste
no flags Details
Motsognir port working on FreeBSD 10.0 (2.38 KB, application/x-shar)
2014-08-16 13:56 UTC, Mateusz Viste
no flags Details
Motsognir port working on FreeBSD 10.0 (2.35 KB, text/plain)
2014-08-16 14:26 UTC, Mateusz Viste
no flags Details
staged port for motsognir 1.0.5 (3.06 KB, text/plain)
2014-10-24 21:08 UTC, kaltheat
no flags Details
staged port for motsognir 1.0.5 (3.04 KB, text/plain)
2014-10-24 21:33 UTC, kaltheat
no flags Details
some test results (3.12 KB, text/plain)
2014-10-24 21:34 UTC, kaltheat
no flags Details
staged port for motsognir 1.0.5 w/o motsognir.c config file location patching (2.39 KB, text/plain)
2014-10-25 21:33 UTC, kaltheat
no flags Details
staged port for motsognir 1.0.5 (3.27 KB, text/plain)
2014-10-26 10:23 UTC, kaltheat
no flags Details
improved port with included man page (3.47 KB, application/x-shar)
2014-10-28 15:03 UTC, Mateusz Viste
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mateusz Viste 2013-11-24 00:20:00 UTC
This is the port of Motsognir. A gopher server written in ANSI C.

Fix: Patch attached with submission follows:
Comment 1 kaltheat 2014-06-27 11:37:42 UTC
I would be glad to see Motsognir in portstree!
Have there been recent tests if Motsognir works on FreeBSD 10?
Comment 2 kaltheat 2014-06-27 11:54:10 UTC
(In reply to kaltheat from comment #1)
> I would be glad to see Motsognir in portstree!
> Have there been recent tests if Motsognir works on FreeBSD 10?

just wanted to point to some urls:

svn repo on sf.net: http://svn.code.sf.net/p/motsognir/code/
(contains freebsd-port)

project site: http://gopherproxy.meulie.net/gopher.viste-family.net/1/projects/motsognir/
Comment 3 Mateusz Viste 2014-06-27 12:35:45 UTC
Hi,

Thank you for your answer, I wasn't expecting any feedback that fast ;)

There's no reason why motsognir wouldn't work on FreeBSD 10.x since it's a standard socket application without any kernel implications, but I will specifically test it to be sure 100% (strange things happen in life, so better to double-check everything) :)

I'll install some fresh FreeBSD 10 VM this weekend and test it out - will get back to you then.
Comment 4 Mateusz Viste 2014-06-28 18:21:01 UTC
Hi again,

I tested the *.shar file on a freshly installed FreeBSD 10.0 and... it doesn't install correctly. I have no idea what's wrong.. it seems that the packaging mechanism is not the same in version 10.0. The program have been fetched from sourceforge correctly, compiled without any problem, but 'make install' failed with some errors I don't understand:

root@bsd:/usr/ports/net/motsognir # make
===>  License GPLv3 accepted by the user
===>   motsognir-1.0.3 depends on file: /usr/local/sbin/pkg - found
===> Fetching all distfiles required by motsognir-1.0.3 for building
===>  Extracting for motsognir-1.0.3
=> SHA256 Checksum OK for motsognir-1.0.3.tar.gz.
===>  Patching for motsognir-1.0.3
===>  Configuring for motsognir-1.0.3
===>  Building for motsognir-1.0.3
cc -c motsognir.c -o motsognir.o -O2 -pipe -fno-strict-aliasing  -Wall -Wextra -O3 -std=gnu89 -pedantic
cc motsognir.o -o motsognir -O2 -pipe -fno-strict-aliasing  -Wall -Wextra -O3 -std=gnu89 -pedantic
root@bsd:/usr/ports/net/motsognir # make install
===>  Staging for motsognir-1.0.3
===>   Generating temporary packing list
mkdir -p /usr/local//usr/ports/net/motsognir/work/stage/usr/sbin/
mkdir -p /usr/local//usr/ports/net/motsognir/work/stage/etc/init.d/
mkdir -p /usr/local//usr/ports/net/motsognir/work/stage/usr/share/doc/motsognir/
cp motsognir /usr/local//usr/ports/net/motsognir/work/stage/usr/sbin/
cp motsognir.conf /usr/local//usr/ports/net/motsognir/work/stage/etc/
cp changes.txt manual.pdf /usr/local//usr/ports/net/motsognir/work/stage/usr/share/doc/motsognir/
====> Compressing man pages (compress-man)
===>  Installing for motsognir-1.0.3
===>  Checking if net/motsognir already installed
===>   Registering installation for motsognir-1.0.3
pkg-static: lstat(/usr/ports/net/motsognir/work/stage/usr/local/usr/sbin/motsognir): No such file or directory
pkg-static: lstat(/usr/ports/net/motsognir/work/stage/usr/local/etc/motsognir.conf): No such file or directory
pkg-static: lstat(/usr/ports/net/motsognir/work/stage/usr/local/usr/share/doc/motsognir/changes.txt): No such file or directory
pkg-static: lstat(/usr/ports/net/motsognir/work/stage/usr/local/usr/share/doc/motsognir/manual.pdf): No such file or directory
pkg-static: lstat(/usr/ports/net/motsognir/work/stage/usr/local/usr/share/doc/motsognir/): No such file or directory
*** Error code 74

Stop.
make: stopped in /usr/ports/net/motsognir
root@bsd:/usr/ports/net/motsognir #


I have no clue what's going on (but I am a total newbie when it comes to packagind FreeBSD stuff). I will try to redo the package from scratch on FreeBSD 10.0, maybe packages created on 9.x are not compatible with 10.0 (?). We'll see.
Comment 5 Mateusz Viste 2014-06-28 18:40:26 UTC
I see that FreeBSD requires now some special configuration in the 'install' target of the Makefile (specifically that stuff is installed into ${STAGEDIR}) and this is probably what is missing. I will have to study how the FreeBSD packaging works in 10.0 and I will redo a new Makefile..
Comment 6 kaltheat 2014-07-01 12:10:02 UTC
Thank you for your effort!
Once you've finished porting I think you need to talk to portmgr[1] to get the port in portstree[2].

Currently I've tested GoFish, but it seems to be stale and seems to have some issues with UTF-8.

[1] http://www.freebsd.org/portmgr/
[2] http://www.freebsd.org/portmgr/policies.html   see: "Manage Commit Access To The Ports Tree"
Comment 7 Mateusz Viste 2014-07-01 18:13:48 UTC
(In reply to kaltheat from comment #6)
> Once you've finished porting I think you need to talk to portmgr[1] to get
> the port in portstree[2].

It's not really "porting", since the only thing that I need to figure out is how to write a simple Makefile that will make the freebsd packager happy, but the way freebsd uses the makefile is still a bit confusing to me. Anyway, once I get the right Makefile that works on FreeBSD 10.x, I will post it here and check out the portmgr thing. Thanks for the hint!
Comment 8 John Marino freebsd_committer freebsd_triage 2014-08-11 10:45:30 UTC
what's the status with this PR?  I'm asking the submitter (Mateusz Viste)
Comment 9 Mateusz Viste 2014-08-11 18:27:44 UTC
(In reply to John Marino from comment #8)
> what's the status with this PR?  I'm asking the submitter (Mateusz Viste)

Hi John, I hadn't much time lately to investigate - last time I did I was quite confused about what the FreeBSD 10 packaging scripts need.. It's only about writing a few lines of Makefile, so it shouldn't be that hard (I just have to find out what the "good" lines are). I will look into the matter this weekend, and will get back to you guys then. Sorry for the delay!
Comment 10 Mateusz Viste 2014-08-16 13:56:22 UTC
Created attachment 145871 [details]
Motsognir port working on FreeBSD 10.0

Hi, sorry for the delay. I finally got the port working on FreeBSD 10.0. Here is attached the "shar" file. I tested it successfully under a fresh install of FreeBSD 10.0: compiled, installed, started, stopped, deinstalled..
Comment 11 John Marino freebsd_committer freebsd_triage 2014-08-16 14:04:38 UTC
Thanks!  Do you have any verification available?  In order of preference, examples of what I'm looking for are:

1) "poudriere testport" or "poudriere bulk -t" logs
2) Redports or tinderbox logs
3) "make check-plist" followed by "make stage-qa" output  (https://www.freebsd.org/doc/en/books/porters-handbook/porting-testing.html)

Also, please run "portlint" and paste the output.
Comment 12 Mateusz Viste 2014-08-16 14:26:19 UTC
Created attachment 145872 [details]
Motsognir port working on FreeBSD 10.0
Comment 13 Mateusz Viste 2014-08-16 14:47:22 UTC
Hi,

I fear most of the things you listed are black magic to me.

I installed the "poudriere" system, but it only says "Error: Unable to find /usr/local/share/poudriere/../../etc/poudriere.conf", so I obviously missed something obvious.

"make check-plist" says: "make: don't know how to make check-plist. Stop", which I am not sure is abnormal, since I have the same result on all existing ports I tested.

Tinderbox wasn't able to install on my system, failing to fetch some required file:

  fetch: ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/distfiles/cmake-2.8.12.1.tar.gz: File unavailable (e.g., file not found, no access)

Portlint is one thing that I was able to use out of the box. It generated a few fatal errors at first, but I fixed them all by fiddling with the Makefile. Now it only says this:

  root@bsd:/usr/ports/net/motsognir # portlint
  WARN: Makefile: Consider adding STAGE support.
  0 fatal errors and 1 warning found.
  root@bsd:/usr/ports/net/motsognir #

To be honest, I wasn't expecting the FreeBSD port system to be that sophisticated (which translates to 'complex' to someone not used to FreeBSD porting - like me). I see that the "poudriere", "tinderbox", etc seem to be really powerful tools, but they don't work out of the box, and although I'd love to say I will make the motsognir port work on them, I know I won't have the time for it.. :/

I attached here the latest version of my ("un-poudriered") port, just in case someone, some time in the future, would like to take it to the next level. I am quite confident now that porting stuff to BSD should be done only by people used to it (or smarter than me, maybe). I will get back to writing C, it's way easier than BSD porting, apparently :)

Anyway, as of now, I think it will be best you just reject this bug report, as its unlikely to evolve in any near future. I am really sorry for having wasted your time on this.

best regards,
Mateusz
Comment 14 John Marino freebsd_committer freebsd_triage 2014-08-16 18:27:36 UTC
(In reply to Mateusz Viste from comment #13)
> Hi,
> 
> I fear most of the things you listed are black magic to me.
> 
> I installed the "poudriere" system, but it only says "Error: Unable to find
> /usr/local/share/poudriere/../../etc/poudriere.conf", so I obviously missed
> something obvious.

Yes, you have to configure it, build a jail, and install a ports tree.  It's like a computer with an OS and a mostly empty hard-driver.  It works "out of the box" but there's not much to do until you install other stuff.  Basically your issue is you don't know know to how to use poudriere.  moving on...


 
> "make check-plist" says: "make: don't know how to make check-plist. Stop",
> which I am not sure is abnormal, since I have the same result on all
> existing ports I tested.

Maybe because of this: "NO_STAGE= yes"

 
> Tinderbox wasn't able to install on my system, failing to fetch some
> required file:

Poudriere > tinderbox.  If you are going to start from scratch, stick with poudriere and forget tinderbox.

 
> Portlint is one thing that I was able to use out of the box. It generated a
> few fatal errors at first, but I fixed them all by fiddling with the
> Makefile. Now it only says this:
> 
>   root@bsd:/usr/ports/net/motsognir # portlint
>   WARN: Makefile: Consider adding STAGE support.


^^^^^^^^^^^^^^^^  that's not warning, that FATAL
It means your portlink is out of date too, you should update that.



 
> I attached here the latest version of my ("un-poudriered") port, just in
> case someone, some time in the future, would like to take it to the next
> level. I am quite confident now that porting stuff to BSD should be done
> only by people used to it (or smarter than me, maybe). I will get back to
> writing C, it's way easier than BSD porting, apparently :)

There are hundreds of people that do porting, it's not that exclusive a club or really any kind of special talent...


> Anyway, as of now, I think it will be best you just reject this bug report,
> as its unlikely to evolve in any near future. I am really sorry for having
> wasted your time on this.

If it's unstaged (and it is) and there's no update coming, I have no choice but to close the PR.  You didn't waste my time.

Thanks,
John
Comment 15 John Marino freebsd_committer freebsd_triage 2014-08-16 20:06:56 UTC
Closing per request of submitter.

If something changes (e.g. you succeed in getting the port staged) feel free to reopen the PR with an updated shar.  Or ask on ports@ mailing list, maybe somebody can help you.
Comment 16 kaltheat 2014-10-24 21:08:10 UTC
Created attachment 148626 [details]
staged port for motsognir 1.0.5

Here I submit a staged version of this port.
Beside "staging" this new version fixes pkg-plist and patches motsognir.c to use a FreeBSD specific default config file. And it uses recent version of motsognir (1.0.5). I tested this port version on FreeBSD 10.0 amd64 using this test[1] without poudriere or tinderbox. Motsognir 1.0.5 seems to run fine too.

[1] https://www.freebsd.org/doc/en/books/porters-handbook/porting-testing.html
Comment 17 kaltheat 2014-10-24 21:33:35 UTC
Created attachment 148627 [details]
staged port for motsognir 1.0.5

Sorry for the noise. I did some tests and my previous submit had some portlint issues. I fixed them...
Comment 18 kaltheat 2014-10-24 21:34:51 UTC
Created attachment 148628 [details]
some test results

Here are some test results.
I did
  portlint
  make stage
  make check-orphans
  make package
  make install
  make deinstall
  pkg add ...
without issues.
Comment 19 John Marino freebsd_committer freebsd_triage 2014-10-24 22:20:24 UTC
moving to open.

This line isn't right:
X+  char *configfile = "/usr/local/etc/motsognir.conf";

You don't know that it's "/usr/local", it can be anything.  You need to replace the old value with the value of ${PREFIX} in post-patch or something like that.

e.g. check it to 
X+  char *configfile = "@@PREFIX@@/etc/motsognir.conf";
and replace @@PREFIX@@ with prefix in post patch

(you can probably do the replacement without using a patch too)
Comment 20 Mateusz Viste 2014-10-25 07:26:17 UTC
Hello,

Just a loose idea -- would it be okay to simply call motsognir from the rc.d/motsognir shell script always using the --config parameter to specify the config file location? This way, there would be no necessity to patch anything, only adapt the rc.d starting file.
Comment 21 Mateusz Viste 2014-10-25 08:02:27 UTC
also, I commited to motsognir's SVN a new "mini-feature" in code, to allow one to set the default location of motsognir.conf at compile time using a command-line define, for example: -DCONFIGFILE=/usr/local/etc/motsognir.conf

no idea if it helps, but it's here now...
Comment 22 kaltheat 2014-10-25 21:25:21 UTC
Ah, I see that the rc-script calls motsognir with the right config file parameter. So patching of motsognir.c to use the right config file localtion seems to be obsolete, right?
Comment 23 kaltheat 2014-10-25 21:33:11 UTC
Created attachment 148650 [details]
staged port for motsognir 1.0.5 w/o motsognir.c config file location patching

This is the version without config file location patching of motsognir.c (because rc-script already seems to do the right thing).
Comment 24 Mateusz Viste 2014-10-25 21:34:45 UTC
(In reply to kaltheat from comment #22)
> Ah, I see that the rc-script calls motsognir with the right config file
> parameter. So patching of motsognir.c to use the right config file localtion
> seems to be obsolete, right?

Yes, that's what I think. Anyway, now there are two ways to solve the problem:

1. using the --config parameter from within the rc script

OR

2. compile motsognir with -DCONFIGFILE=xxx to modify the default config file location

In both cases, patching anything is not necessary. However, in both cases the problem mentioned by John is still present (using ${PREFIX} instead of /usr/local).
Comment 25 kaltheat 2014-10-26 10:23:14 UTC
Created attachment 148658 [details]
staged port for motsognir 1.0.5

Sorry for the noise, folks. Now, I come up with a version using a rc script feature of the portstree as described here[1]. It seems to be much cleaner now ...

[1] https://www.freebsd.org/doc/en/books/porters-handbook/rc-scripts.html
Comment 26 John Marino freebsd_committer freebsd_triage 2014-10-27 15:11:57 UTC
This looks reasonably with a quick review.  I'll move it over the patch-ready pool for a final review / commit.
Comment 27 Mateusz Viste 2014-10-28 15:03:45 UTC
Created attachment 148735 [details]
improved port with included man page

Hi all, here is a very slight improvement over Kaltheat's port, where we included the motsognir man page into the port.
Comment 28 commit-hook freebsd_committer freebsd_triage 2014-10-31 09:13:50 UTC
A commit references this bug:

Author: robak
Date: Fri Oct 31 09:13:11 UTC 2014
New revision: 371787
URL: https://svnweb.freebsd.org/changeset/ports/371787

Log:
  net/motsognir: NEW PORT - Full-featured gopher server without dependencies

  Motsognir is a robust, reliable and easy to install open-source gopher server
  for Unix-like systems (Linux, BSD, and anything else POSIX-compliant).

  The Motsognir gopher server is meant to be used for small projects (like home
  servers), but should scale well on bigger architectures as well. All the
  configuration is done via a single configuration file, which has very
  reasonable defaults. That makes Motsognir easily maintainable, and allows the
  administrator to have a full knowledge of what features are allowed/enabled on
  the server. Motsognir supports server-side CGI applications and PHP scripts, is
  plainly compatible with UTF-8 filesystems, and is entirely written in ANSI C
  without external dependencies.

  WWW: http://sourceforge.net/projects/motsognir

  PR:		184203
  Submitted by:	Mateusz Viste <mateusz@viste.fr>
  Approved by:	mentors (implicit)

Changes:
  head/net/Makefile
  head/net/motsognir/
  head/net/motsognir/Makefile
  head/net/motsognir/distinfo
  head/net/motsognir/files/
  head/net/motsognir/files/motsognir.in
  head/net/motsognir/pkg-descr
Comment 29 Bartek Rutkowski freebsd_committer freebsd_triage 2014-10-31 09:20:05 UTC
Committed with minor changes (replacing spaces to tabs, changing pkg-plist to PLIST_FILES when there's less than 6 items on it), thanks for your work!
Comment 30 Mateusz Viste 2014-10-31 12:38:24 UTC
(In reply to Bartek Rutkowski from comment #29)
> Committed with minor changes (replacing spaces to tabs, changing pkg-plist
> to PLIST_FILES when there's less than 6 items on it), thanks for your work!

Perfect. Thank you!