Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using . for parent_dir causes issues #57

Open
daenney opened this issue Jun 19, 2023 · 8 comments
Open

Using . for parent_dir causes issues #57

daenney opened this issue Jun 19, 2023 · 8 comments

Comments

@daenney
Copy link

daenney commented Jun 19, 2023

When I try to use --parent_dir . things go wrong for ExtraFilePaths. At that point it no longer resolves relative paths by the instance/next to the config.json, but seems to use the build directory instead.

I suspect this is in the same ballpark as #50?

~/D/g/gotopi  (main) ❯❯❯ gok --version
https://github.com/gokrazy/tools/commit/cd4073ee8575

config.json:

{
    "Hostname": "gotosocial",
    "Packages": [
...
        "github.com/superseriousbusiness/gotosocial/cmd/gotosocial"
    ],
    "PackageConfig": {
...
        "github.com/superseriousbusiness/gotosocial/cmd/gotosocial": {
            "ExtraFilePaths": {
                "/usr/share/gotosocial/web": "assets/web"
            },
...
        }
    },
    "SerialConsole": "disabled",
    "InternalCompatibilityFlags": {}
}
Filesystem layout
~/D/g/gotopi  (main) ❯❯❯ pwd
/home/daenney/Development/github.com/gotopi

~/D/g/gotopi  (main) ❯❯❯ tree
.
├── gotosocial
│   ├── assets
│   │   ├── LICENSE
│   │   └── web
│   │       ├── assets
│   │       │   ├── default_avatars
│   │       │   │   ├── GoToSocial_icon1.png
│   │       │   │   ├── GoToSocial_icon2.png
│   │       │   │   ├── GoToSocial_icon3.png
│   │       │   │   ├── GoToSocial_icon4.png
│   │       │   │   ├── GoToSocial_icon5.png
│   │       │   │   └── GoToSocial_icon6.png
│   │       │   ├── default_header.png
│   │       │   ├── dist
│   │       │   │   ├── base.css
│   │       │   │   ├── _colors.css
│   │       │   │   ├── frontend.js
│   │       │   │   ├── index.css
│   │       │   │   ├── profile.css
│   │       │   │   ├── settings.js
│   │       │   │   ├── settings-style.css
│   │       │   │   └── status.css
│   │       │   ├── fonts
│   │       │   │   ├── noto-sans-v27-latin-700.woff
│   │       │   │   ├── noto-sans-v27-latin-700.woff2
│   │       │   │   ├── noto-sans-v27-latin-regular.woff
│   │       │   │   ├── noto-sans-v27-latin-regular.woff2
│   │       │   │   └── OFL.txt
│   │       │   ├── Fork-Awesome
│   │       │   │   ├── CONTRIBUTORS.md
│   │       │   │   ├── css
│   │       │   │   │   ├── fork-awesome.css
│   │       │   │   │   ├── fork-awesome.min.css
│   │       │   │   │   ├── fork-awesome.min.css.map
│   │       │   │   │   ├── v5-compat.css
│   │       │   │   │   ├── v5-compat.min.css
│   │       │   │   │   └── v5-compat.min.css.map
│   │       │   │   ├── fonts
│   │       │   │   │   ├── forkawesome-webfont.eot
│   │       │   │   │   ├── forkawesome-webfont.svg
│   │       │   │   │   ├── forkawesome-webfont.ttf
│   │       │   │   │   ├── forkawesome-webfont.woff
│   │       │   │   │   └── forkawesome-webfont.woff2
│   │       │   │   └── LICENSES
│   │       │   ├── LICENSE
│   │       │   ├── logo.png
│   │       │   ├── logo.svg
│   │       │   ├── mastodon.svg
│   │       │   ├── plyr.svg
│   │       │   ├── swagger.yaml
│   │       │   └── tusky.svg
│   │       └── template
│   │           ├── 404.tmpl
│   │           ├── about.tmpl
│   │           ├── authorize.tmpl
│   │           ├── confirmed.tmpl
│   │           ├── domain-blocklist.tmpl
│   │           ├── email_confirm.tmpl
│   │           ├── email_new_report.tmpl
│   │           ├── email_report_closed.tmpl
│   │           ├── email_reset.tmpl
│   │           ├── email_test.tmpl
│   │           ├── error.tmpl
│   │           ├── finalize.tmpl
│   │           ├── footer.tmpl
│   │           ├── frontend.tmpl
│   │           ├── header.tmpl
│   │           ├── index.tmpl
│   │           ├── oob.tmpl
│   │           ├── profile.tmpl
│   │           ├── sign-in.tmpl
│   │           ├── status.tmpl
│   │           └── thread.tmpl
│   ├── breakglass.authorized_keys
│   ├── builddir
│   │   ├── github.com
│   │   │   ├── gokrazy
│   │   │   │   ├── breakglass
│   │   │   │   │   ├── go.mod
│   │   │   │   │   └── go.sum
│   │   │   │   ├── fbstatus
│   │   │   │   │   ├── go.mod
│   │   │   │   │   └── go.sum
│   │   │   │   ├── firmware
│   │   │   │   │   ├── go.mod
│   │   │   │   │   └── go.sum
│   │   │   │   ├── gokrazy
│   │   │   │   │   ├── cmd
│   │   │   │   │   │   ├── dhcp
│   │   │   │   │   │   │   ├── go.mod
│   │   │   │   │   │   │   └── go.sum
│   │   │   │   │   │   ├── heartbeat
│   │   │   │   │   │   │   ├── go.mod
│   │   │   │   │   │   │   └── go.sum
│   │   │   │   │   │   ├── ntp
│   │   │   │   │   │   │   ├── go.mod
│   │   │   │   │   │   │   └── go.sum
│   │   │   │   │   │   └── randomd
│   │   │   │   │   │       ├── go.mod
│   │   │   │   │   │       └── go.sum
│   │   │   │   │   ├── go.mod
│   │   │   │   │   └── go.sum
│   │   │   │   ├── hello
│   │   │   │   │   ├── go.mod
│   │   │   │   │   └── go.sum
│   │   │   │   ├── kernel
│   │   │   │   │   ├── go.mod
│   │   │   │   │   └── go.sum
│   │   │   │   ├── rpi-eeprom
│   │   │   │   │   ├── go.mod
│   │   │   │   │   └── go.sum
│   │   │   │   ├── serial-busybox
│   │   │   │   │   ├── go.mod
│   │   │   │   │   └── go.sum
│   │   │   │   └── wifi
│   │   │   │       ├── go.mod
│   │   │   │       └── go.sum
│   │   │   └── superseriousbusiness
│   │   │       └── gotosocial
│   │   │           └── cmd
│   │   │               └── gotosocial
│   │   │                   ├── go.mod
│   │   │                   └── go.sum
│   │   └── init
│   │       ├── go.mod
│   │       └── go.sum
│   └── config.json
└── README.md

34 directories, 96 files

Building with: gok --parent_dir /home/daenney/Development/github.com/gotopi -i gotosocial overwrite --root root.squashfs succeeds.

Building with gok --parent_dir . -i gotosocial overwrite --root root.squashfs fails with:

2023/06/19 13:49:53 open /home/daenney/Development/github.com/gotopi/gotosocial/builddir/github.com/superseriousbusiness/gotosocial/cmd/gotosocial/assets/web/assets/LICENSE: no such file or directory
@stapelberg
Copy link
Contributor

Quick note: the expectation is that you use --parent_dir=.., but not --parent_dir=., which doesn’t make sense to me. I’ll need to read your message in more detail to better understand what you’re trying to do.

@daenney
Copy link
Author

daenney commented Jun 19, 2023

Mmm right, maybe my setup is weird.

I'm working on something reproducible for others, so I don't want things in ~/gokrazy/.... The --parent_dir seemed to be the right thing for that, and since I'm cded into that repository --parent-dir . made the most sense to me.

@stapelberg
Copy link
Contributor

parent_dir is the right flag for it, just use --parent_dir=.. and -i matching the name of the current directory.

@daenney
Copy link
Author

daenney commented Jun 19, 2023

I'm not quite sure I follow. . is current directory, which is what I wanted.

My steps were basically this:

  • git init repo
  • cd repo
  • gok --parent_dir . new -i instance

That in return created repo/instance for me, and within instance lives config.json.

If I'm standing at repo, I would expect gok --parent_dir . -i instance edit to work, and indeed it does, it opens repo/instance/config.json.

However, when I build the rootfs, the . seems to cause confusion for the builder, at least when resolving ExtraFilePaths. Whereas if I replace it with the absolute path to repo instead, it works. Both of these should be the same, so I'm not sure why it behaves differently?

@stapelberg
Copy link
Contributor

However, when I build the rootfs, the . seems to cause confusion for the builder, at least when resolving ExtraFilePaths.

That might just be a bug. Relative paths should be resolved to absolute quite early, but maybe not everywhere/not correctly.

@stapelberg
Copy link
Contributor

Maybe using --parent_dir $PWD unblocks you for now?

@daenney
Copy link
Author

daenney commented Jun 22, 2023

Yes, using the absolute paths seems to always work reliably. I'll do that for now and take a look at how the paths are resolved internally.

@stapelberg
Copy link
Contributor

I can’t reproduce the issue:

% pwd
/tmp

% rm -rf parent
% mkdir parent
% cat > parent/config.json <<'EOT'
{
    "Hostname": "parent",
    "Update": {
        "HTTPPassword": "2tXVASTRRuI1ywgK5NS2"
    },
    "Packages": [
        "github.com/gokrazy/fbstatus",
        "github.com/gokrazy/hello",
        "github.com/gokrazy/serial-busybox",
        "github.com/gokrazy/breakglass",
	"github.com/superseriousbusiness/gotosocial/cmd/gotosocial"
    ],
    "PackageConfig": {
    "github.com/superseriousbusiness/gotosocial/cmd/gotosocial": {
            "ExtraFilePaths": {
                "/usr/share/gotosocial/web": "assets/web"
            }
        },
        "github.com/gokrazy/gokrazy/cmd/randomd": {
            "ExtraFileContents": {
                "/etc/machine-id": "a23b1f168437443aafb66b3ff4a834be\n"
            }
        }
    },
    "SerialConsole": "disabled"
}
EOT

% gok --parent_dir . -i parent overwrite --root /tmp/root.squashfs
gokrazy gok gcd4073+ on GOARCH=amd64 GOOS=linux
 
Build target: CGO_ENABLED=0 GOARCH=arm64 GOOS=linux
Build timestamp: 2023-06-24T19:27:02+02:00
Loading system CA certificates from /etc/ssl/certs/ca-certificates.crt
Building 5 Go packages:

  github.com/gokrazy/fbstatus

  github.com/gokrazy/hello

  github.com/gokrazy/serial-busybox

  github.com/gokrazy/breakglass

  github.com/superseriousbusiness/gotosocial/cmd/gotosocial

[done] in 2.87s                        

Including extra files for Go packages:

Including loadable kernel modules from:
/home/michael/go/pkg/mod/github.com/gokrazy/[email protected]/lib/modules

Feature summary:
  use GPT: true
  use PARTUUID: true
  use GPT PARTUUID: true

Creating root file system
[done] in 0.82s                           

Build complete!

To interact with the device, gokrazy provides a web interface reachable at:

	http://gokrazy:2tXVASTRRuI1ywgK5NS2@parent/

In addition, the following Linux consoles are set up:

	1. foreground Linux framebuffer console on HDMI


% unsquashfs -ll /tmp/root.squashfs|grep web
dr-xr-xr-x root/root                 3 2023-06-24 19:26 squashfs-root/usr/share/gotosocial/web

Can you provide updated steps to reproduce, ideally with a similarly self-contained transcript?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants