janet-lang / jpm

Janet Project Manager
MIT License
68 stars 22 forks source link

jpm self install to a custom DESTDIR doesn't work #19

Closed kodiak22 closed 2 years ago

kodiak22 commented 2 years ago

Hi, I'm trying to make a working janet-lang package for arch linux, because the packages in AUR are not really working, and unnecessarily complex. In theory the Makefile in the janet git repo should be able to install everything including the latest jpm from github. The problem is, the jpm bootstrap only partially takes notice of the PREFIX and DESTDIR Makefile variables.

The janet install is OK, all artifacts are installed under ~/Tmp/targetdir/usr/...

$ DESTDIR=~/Tmp/targetdir PREFIX=/usr make install --[OK]

But the jpm install doesn't work as expected, it only installs the man page and the jpm main script under $DESTDIR/$PREFIX and tries to put everything else under /usr/local/... as if DESTDIR and PREFIX were not defined.

$ DESTDIR=~/Tmp/targetdir PREFIX=/usr make install-jpm-git mkdir -p build rm -rf build/jpm git clone --depth=1 https://github.com/janet-lang/jpm.git build/jpm Cloning into 'build/jpm'... remote: Enumerating objects: 57, done. remote: Counting objects: 100% (57/57), done. remote: Compressing objects: 100% (40/40), done. remote: Total 57 (delta 16), reused 35 (delta 14), pack-reused 0 Receiving objects: 100% (57/57), 37.51 KiB | 1.25 MiB/s, done. Resolving deltas: 100% (16/16), done. cd build/jpm && PREFIX='/home/kodiak/Tmp/targetdir/usr' \ JANET_MANPATH='/home/kodiak/Tmp/targetdir/usr/share/man/man1/' \ JANET_HEADERPATH='/home/kodiak/Tmp/targetdir/usr/include/janet' \ JANET_BINPATH='/home/kodiak/Tmp/targetdir/usr/bin' \ JANET_LIBPATH='/home/kodiak/Tmp/targetdir/usr/lib' \ ../../build/janet ./bootstrap.janet

Using install prefix: /home/kodiak/Tmp/targetdir/usr binpath: /home/kodiak/Tmp/targetdir/usr/bin libpath: /home/kodiak/Tmp/targetdir/usr/lib manpath: /home/kodiak/Tmp/targetdir/usr/share/man/man1/ headerpath: /home/kodiak/Tmp/targetdir/usr/include/janet modpath: (default to JANET_PATH at runtime) Setting package listing: https://github.com/janet-lang/pkgs.git

Running jpm to self install... removing /usr/local/lib/janet/jpm/cc.janet removing /usr/local/lib/janet/jpm/cli.janet removing /usr/local/lib/janet/jpm/commands.janet removing /usr/local/lib/janet/jpm/config.janet removing /usr/local/lib/janet/jpm/dagbuild.janet removing /usr/local/lib/janet/jpm/declare.janet removing /usr/local/lib/janet/jpm/init.janet removing /usr/local/lib/janet/jpm/pm.janet removing /usr/local/lib/janet/jpm/rules.janet removing /usr/local/lib/janet/jpm/shutil.janet removing /usr/local/lib/janet/jpm/cgen.janet removing /usr/local/lib/janet/jpm/default-config.janet removing /home/kodiak/Tmp/targetdir/usr/local/share/man/man1//jpm.1 removing /home/kodiak/Tmp/targetdir/usr/local/bin/jpm removing manifest /usr/local/lib/janet/.manifests/jpm.jdn Uninstalled. generating /usr/local/lib/janet/.manifests/jpm.jdn... Installed as 'jpm'. copying jpm/cc.janet to /usr/local/lib/janet/jpm... copying jpm/cli.janet to /usr/local/lib/janet/jpm... copying jpm/commands.janet to /usr/local/lib/janet/jpm... copying jpm/config.janet to /usr/local/lib/janet/jpm... copying jpm/dagbuild.janet to /usr/local/lib/janet/jpm... copying jpm/declare.janet to /usr/local/lib/janet/jpm... copying jpm/init.janet to /usr/local/lib/janet/jpm... copying jpm/pm.janet to /usr/local/lib/janet/jpm... copying jpm/rules.janet to /usr/local/lib/janet/jpm... copying jpm/shutil.janet to /usr/local/lib/janet/jpm... copying jpm/cgen.janet to /usr/local/lib/janet/jpm... copying file ./temp-config.janet to /usr/local/lib/janet/jpm/default-config.janet... copying jpm.1 to /home/kodiak/Tmp/targetdir/usr/share/man/man1/...

And even though the jpm main script is installed in the correct location, the script itself is wrong: $ cat jpm

!/home/kodiak/Tmp/targetdir/usr/bin/janet

!/usr/bin/env janet

(put root-env :syspath "/usr/local/lib/janet") (import jpm/cli) (defn main [& argv] (cli/main ;argv))

The first shebang line is unnecessary and the :syspath should point to "/usr/lib/janet" as was given in the PREFIX variable.

bakpakin commented 2 years ago

Yeah, this looks liek a double whammy - in the janet project's Makefile utility, we should probably not mangle the input paths and pass destdir in directly. And jpm itslef should be able to handle destdir when bootstrapping or installing.

kodiak22 commented 2 years ago

@bakpakin Thanks for the really quick fix, tested it, and everything seems to work. I've made an AUR package that really works and is much simpler.

One minor thing: The first shebang line in the jpm script is still there, and unnecessary, but works non the less. $ cat jpm

!/usr/bin/janet

!/usr/bin/env janet

(put root-env :syspath "/usr/lib/janet") (import jpm/cli) (defn main [& argv] (cli/main ;argv))

Now that the jpm lives in its own github repo, do you plan to make releases?

sogaiu commented 2 years ago

@kodiak22 It looks like there is a tag for 0.0.1 now: https://github.com/janet-lang/jpm/releases

kodiak22 commented 2 years ago

@sogaiu I haven't noticed that, thanks.