haikuports / haikuporter

The tool that builds HaikuPorts recipes.
MIT License
40 stars 44 forks source link

Uses the port name as the port directory in -o/--location #175

Open Crestwave opened 6 years ago

Crestwave commented 6 years ago

Dashes are substituted with underscores in port names, while directory names are kept as is, which can cause some mismatches, e.g., ls $(haikuporter -o speedtest_cli). Also, is it intended that all the recipe locations are listed if nothing is specified (e.g., haikuporter -o "")?

fbrosson commented 6 years ago

In most cases the directory names we use are those from the Gentoo layout. A long time ago someone made a huge commit to replace the dashes by underscores in the directory names. I don't know if this was really needed at that time. All I know is that since I've been using haikuporter it has never had any issue with dashes in directory names. BTW, it does not even care about the name of the directory. But we try to stick to the directory tree used by Gentoo. Of course, we do use underscores when appropriate. For instance, with sg3_utils.

Regarding your question about the output of haikuporter -o "" I believe this is the intended behaviour and I think this is better than getting no output :)

If we changed haikuporter to make haikuporter -o ""output nothing then we would be reducing its functionality. We could add it back with another syntax, say, by passing \*, but I don't think this would be an improvement.

alaviss commented 6 years ago

Regarding your question about the output of haikuporter -o "" I believe this is the intended behaviour and I think this is better than getting no output :)

If we changed haikuporter to make haikuporter -o ""output nothing then we would be reducing its functionality. We could add it back with another syntax, say, by passing \*, but I don't think this would be an improvement.

Document it and it becomes a feature ;)

fbrosson commented 6 years ago

--location and -o are already documented:

hp --help
Usage: haikuporter [options] portname[-portversion]

...

  -s, --search          search for a port (regex)
  --search-packages     search for a package (regex)
  -o, --location        print out the location of a recipe (via search, for
                        scripted editing)
...

The only change one might wish to add is:

-Usage: haikuporter [options] portname[-portversion]
+Usage: haikuporter [options] [portname[-portversion]]

But I think it is better the way it is right now :)

alaviss commented 6 years ago

I mean documenting the special "" query.

Crestwave commented 6 years ago

In most cases the directory names we use are those from the Gentoo layout. A long time ago someone made a huge commit to replace the dashes by underscores in the directory names. I don't know if this was really needed at that time. All I know is that since I've been using haikuporter it has never had any issue with dashes in directory names. BTW, it does not even care about the name of the directory. But we try to stick to the directory tree used by Gentoo. Of course, we do use underscores when appropriate. For instance, with sg3_utils.

HaikuPorter itself does not care about the name of the directory; I've never had an issue with the ports' directory names when building with it either. But if you try to use it as in my example ls $(haikuporter -o speedtest_cli), you will find that the directory it outputs does not exist, as it will use the package's underscore when the directory actually uses a dash.

Perhaps this is why they did that change, although it would be a much cleaner solution in my opinion to fix it in HaikuPorter. I currently have to do the following to work around it in a bash script because of the mix of dashes and underscores (I have die as a function):

directory=$(haikuporter -o "$1")
cd '$directory" ||
    { directory=$(sed 's/_/-/g' <<< "$directory") && cd "$directory"; } ||
        die "Invalid recipe location."

Regarding your question about the output of haikuporter -o "" I believe this is the intended behaviour and I think this is better than getting no output :)

If we changed haikuporter to make haikuporter -o ""output nothing then we would be reducing its functionality. We could add it back with another syntax, say, by passing \*, but I don't think this would be an improvement.

Yeah, it seems like it could be useful. I was just asking since I didn't expect it (hence my not opening another issue), and I also think that it should be documented.

fbrosson commented 6 years ago

You are right. haikuporter does not work the way it should for ports which reside in directories with dashes. I had never noticed it because I don't use that feature. BTW, on hybrid systems which have e.g. SECONDARY_TARGET_ARCHITECTURES="x86" the output is even more surprising:

hp -o speedtest_cli
/boot/home/haikuports/net-analyzer/speedtest_cli
/boot/home/haikuports/net-analyzer/speedtest_cli_x86

What's even more surprising here is that we get a second line with the "_x86", although speedtest-cli is any-arch. So I tried it with a recipe which is not any-arch, does not support secondary arches, has a dash in its directory and an underscore in its name: app-mobilephone/dfu-util/dfu_util-0.9.recipe

hp -o dfu_util
/boot/home/haikuports/app-mobilephone/dfu_util
/boot/home/haikuports/app-mobilephone/dfu_util_x86

So yes, haikuporter's -o is really not working as expected. Thanks for having reported this!

Perhaps this is why they did that change, although it would be a much cleaner solution in my opinion to fix it in HaikuPorter.

:+1: