Bug 241655 - net-mgmt/semaphore: Incomplete file list and wrong search path
Summary: net-mgmt/semaphore: Incomplete file list and wrong search path
Status: In Progress
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Vinícius Zavam
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-11-02 00:21 UTC by marek
Modified: 2020-02-11 09:42 UTC (History)
1 user (show)

See Also:
egypcio: maintainer-feedback+


Attachments
241655.diff (1.90 KB, patch)
2019-11-06 17:16 UTC, Vinícius Zavam
no flags Details | Diff
241655: Working Diff (1.92 KB, patch)
2020-02-10 17:57 UTC, Vinícius Zavam
no flags Details | Diff
[PATCH] net-mgmt/semaphore: fix DB migration files path (2.94 KB, patch)
2020-02-11 09:42 UTC, Vinícius Zavam
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description marek 2019-11-02 00:21:22 UTC
The latest version of the port has missed some files for work properly. For example, first run of semaphore wants to create database from sql files:

# semaphore
Using config file: /usr/local/etc/semaphore/config.json
Semaphore 2.5.1
Port :3000
MySQL semaphore@127.0.0.1:3306 semaphore
Tmp Path (projects home) /tmp/semaphore
Checking DB migrations
Creating migrations table
Executing migration v0.0.0 (at 2019-11-01 21:19:23.778424681 +0100 CET m=+0.224762334)...
panic: stat /wrkdirs/usr/ports/net-mgmt/semaphore/work/src/github.com/ansible-semaphore/semaphore/db/migrations/v0.0.0.sql: no such file or directory

goroutine 1 [running]:
github.com/ansible-semaphore/semaphore/db.(*Version).GetSQL(0xc000069840, 0xc00012e350, 0xa, 0xaa7cb5, 0x4, 0xc00012e350)
        /wrkdirs/usr/ports/net-mgmt/semaphore/work/src/github.com/ansible-semaphore/semaphore/db/version.go:60 +0x176
github.com/ansible-semaphore/semaphore/db.(*Version).Run(0xc000069840, 0xc000010000, 0x0)
        /wrkdirs/usr/ports/net-mgmt/semaphore/work/src/github.com/ansible-semaphore/semaphore/db/migrations.go:49 +0x272
github.com/ansible-semaphore/semaphore/db.MigrateAll(0xc000113e18, 0x0)
        /wrkdirs/usr/ports/net-mgmt/semaphore/work/src/github.com/ansible-semaphore/semaphore/db/migrations.go:118 +0x13b
main.main()
        /wrkdirs/usr/ports/net-mgmt/semaphore/work/src/github.com/ansible-semaphore/semaphore/cli/main.go:51 +0x406

The binary expects to exist in the location started by /wrkdirs/... 

The similar issue is when the semaphore wants to serve web content (output from truss):

fstatat(AT_FDCWD,"/wrkdirs/usr/ports/net-mgmt/semaphore/work/src/github.com/ansible-semaphore/semaphore/web/public/html/index.html",0xc0002d2038,0x0) ERR#2 'No such file or directory'
Comment 1 marek 2019-11-02 00:22:41 UTC
The list of installed files from the package:

# pkg info -l semaphore
semaphore-2.5.1:
        /usr/local/bin/semaphore
        /usr/local/etc/rc.d/semaphore
        /usr/local/etc/semaphore/semaphore_config.json.sample
        /usr/local/share/licenses/semaphore-2.5.1/LICENSE
        /usr/local/share/licenses/semaphore-2.5.1/MIT
        /usr/local/share/licenses/semaphore-2.5.1/catalog.mk
Comment 2 Vinícius Zavam freebsd_committer 2019-11-06 16:39:35 UTC
ACK; thanks for reporting it. already part of my 'TODO' since r516887
Comment 3 Vinícius Zavam freebsd_committer 2019-11-06 17:16:27 UTC
Created attachment 208916 [details]
241655.diff

could please try this one, passing the .sql file you need (that should correspond to your previous semaphore version)?

quick fix solution so far.
Comment 4 marek 2019-11-08 12:26:15 UTC
(In reply to Vinícius Zavam from comment #3)

i!

I made a clean jail for tests. This patch add only db files to package, but the semaphore still expects these files in /usr/ports tree instead of /usr/local:

root@semtest:/usr/local/etc/semaphore # semaphore 
Using config file: /usr/local/etc/semaphore/config.json
Semaphore 2.5.1
Port :3000
MySQL semaphore@127.0.0.1:3306 sem_db
Tmp Path (projects home) /tmp/semaphore
Checking DB migrations
Executing migration v0.0.0 (at 2019-11-08 13:16:09.513075602 +0100 CET m=+0.028127598)...
panic: stat /usr/ports/net-mgmt/semaphore/work/src/github.com/ansible-semaphore/semaphore/db/migrations/v0.0.0.sql: no such file or directory

goroutine 1 [running]:
github.com/ansible-semaphore/semaphore/db.(*Version).GetSQL(0xc0000cb7c0, 0xc0000ab1d0, 0xa, 0xaa7cb5, 0x4, 0xc0000ab1d0)
	/usr/ports/net-mgmt/semaphore/work/src/github.com/ansible-semaphore/semaphore/db/version.go:60 +0x176
github.com/ansible-semaphore/semaphore/db.(*Version).Run(0xc0000cb7c0, 0xc0000b0000, 0x0)
	/usr/ports/net-mgmt/semaphore/work/src/github.com/ansible-semaphore/semaphore/db/migrations.go:49 +0x272
github.com/ansible-semaphore/semaphore/db.MigrateAll(0xc00012fe18, 0x0)
	/usr/ports/net-mgmt/semaphore/work/src/github.com/ansible-semaphore/semaphore/db/migrations.go:118 +0x13b
main.main()
	/usr/ports/net-mgmt/semaphore/work/src/github.com/ansible-semaphore/semaphore/cli/main.go:51 +0x406
root@semtest:/usr/local/etc/semaphore # pkg info -l semaphore
semaphore-2.5.1_1:
	/usr/local/bin/semaphore
	/usr/local/etc/rc.d/semaphore
	/usr/local/etc/semaphore/semaphore_config.json.sample
	/usr/local/share/licenses/semaphore-2.5.1_1/LICENSE
	/usr/local/share/licenses/semaphore-2.5.1_1/MIT
	/usr/local/share/licenses/semaphore-2.5.1_1/catalog.mk
	/usr/local/share/semaphore/v0.0.0.sql
	/usr/local/share/semaphore/v0.1.0.sql
	/usr/local/share/semaphore/v1.0.0.sql
	/usr/local/share/semaphore/v1.1.0.sql
	/usr/local/share/semaphore/v1.2.0.sql
	/usr/local/share/semaphore/v1.3.0.sql
	/usr/local/share/semaphore/v1.4.0.sql
	/usr/local/share/semaphore/v1.5.0.sql
	/usr/local/share/semaphore/v1.6.0.sql
	/usr/local/share/semaphore/v1.7.0.sql
	/usr/local/share/semaphore/v1.8.0.sql
	/usr/local/share/semaphore/v1.9.0.sql
	/usr/local/share/semaphore/v2.2.1.sql
	/usr/local/share/semaphore/v2.3.0.sql
	/usr/local/share/semaphore/v2.3.1.sql
	/usr/local/share/semaphore/v2.3.2.sql
	/usr/local/share/semaphore/v2.4.0.sql
	/usr/local/share/semaphore/v2.5.0.sql
Comment 5 marek 2019-11-08 12:27:59 UTC
There is another interesting thing in the semaphore binary from Github releases:
https://github.com/ansible-semaphore/semaphore/releases/download/v2.5.1/semaphore_2.5.1_freebsd_amd64.tar.gz

This is standalone binary that don't need SQL files and works. I suspect that these files are included in the whole binary, but I have no knowledge about building go binaries.
Comment 6 Vinícius Zavam freebsd_committer 2019-11-14 10:45:15 UTC
ty for reporting it back; looks like I should change all the building stage for this particular port.

PS: did you try to specify the .sql file you need using the '-migrate' parameter?
Comment 7 marek 2019-11-15 16:24:37 UTC
Hi!

It doesn't work:

root@semtest:/usr/local/etc/semaphore # pkg info -l semaphore
semaphore-2.5.1_1:
	/usr/local/bin/semaphore
	/usr/local/etc/rc.d/semaphore
	/usr/local/etc/semaphore/semaphore_config.json.sample
	/usr/local/share/licenses/semaphore-2.5.1_1/LICENSE
	/usr/local/share/licenses/semaphore-2.5.1_1/MIT
	/usr/local/share/licenses/semaphore-2.5.1_1/catalog.mk
	/usr/local/share/semaphore/v0.0.0.sql
	/usr/local/share/semaphore/v0.1.0.sql
	/usr/local/share/semaphore/v1.0.0.sql
	/usr/local/share/semaphore/v1.1.0.sql
	/usr/local/share/semaphore/v1.2.0.sql
	/usr/local/share/semaphore/v1.3.0.sql
	/usr/local/share/semaphore/v1.4.0.sql
	/usr/local/share/semaphore/v1.5.0.sql
	/usr/local/share/semaphore/v1.6.0.sql
	/usr/local/share/semaphore/v1.7.0.sql
	/usr/local/share/semaphore/v1.8.0.sql
	/usr/local/share/semaphore/v1.9.0.sql
	/usr/local/share/semaphore/v2.2.1.sql
	/usr/local/share/semaphore/v2.3.0.sql
	/usr/local/share/semaphore/v2.3.1.sql
	/usr/local/share/semaphore/v2.3.2.sql
	/usr/local/share/semaphore/v2.4.0.sql
	/usr/local/share/semaphore/v2.5.0.sql

root@semtest:/usr/local/etc/semaphore # semaphore -migrate /usr/local/share/semaphore/v0.0.0.sql
Using config file: /usr/local/etc/semaphore/config.json
Semaphore 2.5.1
Port :3000
MySQL semaphore@127.0.0.1:3306 sem_db
Tmp Path (projects home) /tmp/semaphore
Checking DB migrations
Executing migration v0.0.0 (at 2019-11-15 17:22:59.839221915 +0100 CET m=+0.054748835)...
panic: stat /usr/ports/net-mgmt/semaphore/work/src/github.com/ansible-semaphore/semaphore/db/migrations/v0.0.0.sql: no such file or directory

goroutine 1 [running]:
github.com/ansible-semaphore/semaphore/db.(*Version).GetSQL(0xc000081840, 0xc0000a51d0, 0xa, 0xaa7cb5, 0x4, 0xc0000a51d0)
	/usr/ports/net-mgmt/semaphore/work/src/github.com/ansible-semaphore/semaphore/db/version.go:60 +0x176
github.com/ansible-semaphore/semaphore/db.(*Version).Run(0xc000081840, 0xc0000aa000, 0x0)
	/usr/ports/net-mgmt/semaphore/work/src/github.com/ansible-semaphore/semaphore/db/migrations.go:49 +0x272
github.com/ansible-semaphore/semaphore/db.MigrateAll(0xc000125e18, 0x0)
	/usr/ports/net-mgmt/semaphore/work/src/github.com/ansible-semaphore/semaphore/db/migrations.go:118 +0x13b
main.main()
	/usr/ports/net-mgmt/semaphore/work/src/github.com/ansible-semaphore/semaphore/cli/main.go:51 +0x406
Comment 8 Vinícius Zavam freebsd_committer 2019-11-21 09:11:22 UTC
it does seems to be an upstream issue, right?
Comment 9 Vinícius Zavam freebsd_committer 2019-11-21 09:19:20 UTC
I mean: somehow parsing a false path used by the '-migrate' parameter during build process or something similar.
Comment 10 marek 2019-11-25 10:05:50 UTC
I am not sure is it a bug. A help message does not define a parameter to -migrate option:

root@semtest:~ # semaphore -help
Usage of semaphore:
  -config string
        config path
  -hash string
        generate hash of given password
  -migrate
        execute migrations
  -printConfig
        print example configuration
  -setup
        perform interactive setup
  -upgrade
        upgrade semaphore
  -version
        print the semaphore version

Without the path as the parameter to the -migrate option the result is the same as shown in the 7th comment.

Currently, I try to build semaphore manually, using this instruction:
https://github.com/ansible-semaphore/semaphore/blob/develop/CONTRIBUTING.md

It seems that semaphore requires the goreleaser (https://github.com/goreleaser/goreleaser) in the build process. This binary is not present in the ports tree, so first I need to built it, then try to build semaphore.
Comment 11 Vinícius Zavam freebsd_committer 2020-02-06 14:08:48 UTC
pong! I did not forget about this one. still on my TODO list, but patches would be appreciated.
Comment 12 Vinícius Zavam freebsd_committer 2020-02-10 17:57:16 UTC
Created attachment 211543 [details]
241655: Working Diff

after running `semaphore -setup` this pops out:



 Running: mkdir -p /tmp..
 Configuration written to /tmp/config.json..
 Pinging db..

 Running DB Migrations..
Checking DB migrations
Creating migrations table
Executing migration v0.0.0 (at 2020-02-10 17:53:32.886096512 +0000 UTC m=+16.787054473)...
 [11/11]
Executing migration v1.0.0 (at 2020-02-10 17:53:32.894752455 +0000 UTC m=+16.795710397)...
 [7/7]
Executing migration v1.1.0 (at 2020-02-10 17:53:32.906538822 +0000 UTC m=+16.807496780)...
 [1/1]
Executing migration v1.2.0 (at 2020-02-10 17:53:32.909106257 +0000 UTC m=+16.810064211)...
 [1/1]
Executing migration v1.3.0 (at 2020-02-10 17:53:32.910808433 +0000 UTC m=+16.811766407)...
 [3/3]
Executing migration v1.4.0 (at 2020-02-10 17:53:32.916274016 +0000 UTC m=+16.817231971)...
 [2/2]
Executing migration v1.5.0 (at 2020-02-10 17:53:32.918948867 +0000 UTC m=+16.819906817)...
 [1/1]
Executing migration v0.1.0 (at 2020-02-10 17:53:32.920151108 +0000 UTC m=+16.821109053)...
 [6/6]
Executing migration v1.6.0 (at 2020-02-10 17:53:32.925867313 +0000 UTC m=+16.826825264)...
 [4/4]
Executing migration v1.7.0 (at 2020-02-10 17:53:32.9326 +0000 UTC m=+16.833557951)...
 [1/1]
Executing migration v1.8.0 (at 2020-02-10 17:53:32.934491147 +0000 UTC m=+16.835449091)...
 [2/2]
Executing migration v1.9.0 (at 2020-02-10 17:53:32.936282836 +0000 UTC m=+16.837240799)...
 [2/2]
Executing migration v2.2.1 (at 2020-02-10 17:53:32.938779866 +0000 UTC m=+16.839737824)...
 [2/2]
Executing migration v2.3.0 (at 2020-02-10 17:53:32.94349882 +0000 UTC m=+16.844456774)...
 [3/3]
Executing migration v2.3.1 (at 2020-02-10 17:53:32.948334281 +0000 UTC m=+16.849292231)...
 [1/1]
Executing migration v2.3.2 (at 2020-02-10 17:53:32.949228162 +0000 UTC m=+16.850186125)...
 [1/1]
Executing migration v2.4.0 (at 2020-02-10 17:53:32.949935142 +0000 UTC m=+16.850893080)...
 [1/1]
Executing migration v2.5.0 (at 2020-02-10 17:53:32.951488565 +0000 UTC m=+16.852446515)...
 [1/1]
Migrations Finished


 > Username: root
 > Email: root@localhost
WARN[0045] sql: no rows in result set                    level=Warn
 > Your name: jose
 > Password: 123

 You are all setup jose!
 Re-launch this program pointing to the configuration file
Comment 13 Vinícius Zavam freebsd_committer 2020-02-11 09:42:05 UTC
Created attachment 211555 [details]
[PATCH] net-mgmt/semaphore: fix DB migration files path

updated patch, with proposed changes to one of the source files