Racket distro packagers: please try building from a snapshot

Hello everyone. I'm the person behind the snap.

I started doing it for myself, since I wanted to play with racket and building it from source was a fun way to get started. The snap packaging is actually very simple (too simple in fact, it needs some improvements).

I started by cloning the GitHub - racket/racket: The Racket repository repo, then inside the new snap/ directory I've created the snapcraft.yaml file with the following contents:

# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Zygmunt Krynicki <me@zygoon.pl>

name: racket
title: Racket Language
base: core22
adopt-info: racket
summary: Racket Language
license: MIT
description: |
  Racket is a general-purpose programming language and an
  ecosystem for language-oriented programming.
confinement: strict

parts:
  racket:
    plugin: make
    source: .
    source-type: git
    build-packages:
      - gcc
      - libglib2.0-dev
      - libfontconfig-dev
      - libcairo2-dev
      - libpango1.0-dev
      - libjpeg-dev
    stage-packages:
      - libgtk2.0-0
      - libglib2.0-0
      - libglib2.0-bin
      - libglib2.0-data
      - libfontconfig
      - libcairo2
      - libpango1.0-0
      - libjpeg9
    override-pull: |
      craftctl default
      # Set defaults
      grade=devel
      tag="$(git describe --tags --abbrev=0)" || true
      hash="$(git rev-parse --short HEAD)"
      # Check for tagged version
      if [ -n "$tag" ]; then
        count="$(git rev-list "$tag".. --count)"
        if [ "$count" -eq 0 ]; then
          version="$tag"
          grade=stable
        else
          version="$tag+git$count.$hash"
        fi
      else
        count="$(git rev-list HEAD --count)"
        version="0+git$count.$hash"
      fi
      # Relay back to snapcraft
      craftctl set grade="$grade"
      craftctl set version="$version"
    override-build: |
      make -j$CRAFT_PARALLEL_BUILD_COUNT unix-style PREFIX=/snap/racket/current/usr DESTDIR=$CRAFT_PART_INSTALL
    organize:
        snap/racket/current/usr: usr

apps:
  racket:
    command: usr/bin/racket
    plugs: [home]
  drracket:
    command: usr/bin/drracket
    plugs: [home, desktop, x11, wayland, opengl]
  raco:
    command: usr/bin/raco
    plugs: [home, network, network-bind]

If you are not versed with snapcraft packaging, this effectively builds racket from source, using the project git repo as the starting point.

I was asked to use snapshots from https://www.cs.utah.edu/plt/snapshots/current/installers/racket-8.5.0.8-src-builtpkgs.tgz and this should be equally easy, with a different source: entry and some changes around how the build script tells snapcraft about the version.

I have not published the snap anywhere yet. I think the racket community should request the racket snap name and do that if there is desire to provide an official snap package. In the meantime I will explore racket, improve packaging and share updates once in a while.

I can be found on twitter (@zygoon), where I'm happy to respond to any questions in case I miss a notification from discourse.

5 Likes

Something appears to have gone wrong with the files in src/cs/c/ChezScheme/pb/boot/pb. Just deleting cs/c/ChezScheme/pb may solve the problem, or it may be that files in src/ChezScheme/boot/pb have gone wrong (where those files would be the starting content for src/cs/c/ChezScheme/pb/boot/pb).

Unfortunately it happens after running git clean -dfx on the whole repo. Maybe some prerequisite is not getting built?

Ah wait. There is a lurking git repo in there.

This issue is on master, and not in the snapshot. I'm guessing that the snapshot will not have these issues.

That said, the problem seems to be that the git repo in src/ChezScheme/boot/bp is somehow out of sync. I did git checkout master in that sub-repo which leaves only README.md, and I get the following error when running make cs: missing input file: "ChezScheme/boot/pb/petite.boot". IIRC this used to bootstrap from nothing?

That checkout need to be a different branch than master. The easiest solution is to delete src/ChezScheme/boot/bp and run make pb-fetch in the Racket checkout root.

That solves it. I'm not going to fiddle with trying to bootstrap pb using rktboot right now. Thanks!

FYI, if building for a distro, you can use rktboot to generate the native bootfiles directly, without going through pb. That's especially true if your bootstrapping policies (like Guix's) require self-hosting the bootstrap whenever possible, rather than cross-compiling from another architecture.

3 Likes

This looks great! What would it take to request the racket name?

You want to go to Snapcraft - Snaps are universal Linux packages and also read https://snapcraft.io/docs/registering-your-app-name

You will find that the name is reserved, because snapcraft auto-reserved names related to package names and popular git repositories, to avoid confusion and name squatting.

Let me know if you need help.

Registering the name does not make the package available, so you can safely do that now.

Thanks! I've submitted the request.

1 Like

Registering the name racket gives you a top-level application under the same name. To have other top-level names related to racket apps like raco, you have to follow a different process (automatic aliases). This will make snapd install an alias raco that points to racket.raco and really runs raco. Since those share the same top-level namespace of all command line apps, this process requires a request on the snapcraft forum, community vote and clash check. This only affects automatically providing the aliases, you can have any number of apps under the racket snap name, but they are all called racket.$app-name. Users can set up any aliases they want locally with snap alias, the forum process just makes this automatic upon installation.

Cool, let me know if you want to try the build process.

You can stick the file I've pasted in the earlier post in this thread, install snapcraft (sudo snap install --classic --candidate snapcraft and then just run snapcraft. I made the packaging to use snapcraft 7.x features and snapcraft 7 is still in the candidate release phase.

Let me know if you want to give this a try or if you get stuck on anything.

You can see my request to get aliases for the hare toolchain here: Request for aliases for hare snap - store-requests - snapcraft.io -- if you make one you just want to use the store-requests category on the forum.

Update.

New issue when building against the latest snapshot. The issue happens during make install-bc and I'm 99% sure that it is due to the fact that DESTDIR is different than the configured prefix. It also may be the case that this is an interaction with --enable-shared. I can reproduce the issue on master by running the following:

pushd racket/src
./configure --enable-bc --enable-shared --prefix=/usr
make bc
make install-bc DESTDIR=/tmp/test-racket-destdir

For reference the configure is run with the following options.

./configure --prefix=/usr --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --libdir=/usr/lib64 --docdir=/usr/share/doc/racket-8.6_pre1 --collectsdir=/usr/share/racket/collects --pkgsdir=/usr/share/racket/pkgs --enable-postlink="big nasty multiline hackery" --enable-shared --enable-float --enable-libffi --enable-foreign --disable-libs --disable-strip --enable-useprefix --disable-cgcdefault --disable-bcdefault --disable-csdefault --enable-bc --disable-cs --enable-gracket --enable-docs --enable-jit --enable-places --enable-futures --enable-pthread
make -j73 -l8 DESTDIR=/var/tmp/portage/dev-scheme/racket-8.6_pre1/bc/image/ install-bc 
bin/zuo . install-bc DESTDIR="/var/tmp/portage/dev-scheme/racket-8.6_pre1/bc/image/"
bc/racket3m -O info'@'compiler/cm -l- setup --boot setup-go.rkt bc/compiled ignored bc/ignored.d bc/mksystem.rkt bc/system.rktd
compiler/cm:   start-compile: /var/tmp/portage/dev-scheme/racket-8.6_pre1/work/racket-8.5.0.8/src/bc/mksystem.rkt
compiler/cm:   finish-compile: /var/tmp/portage/dev-scheme/racket-8.6_pre1/work/racket-8.5.0.8/src/bc/mksystem.rkt
bc/racket3m -O info'@'compiler/cm -l- setup --boot setup-go.rkt bc/compiled ignored bc/ignored.d bc/mkincludes.rkt /var/tmp/portage/dev-scheme/racket-8.6_pre1/bc/image/usr/include/racket bc/ bc
compiler/cm:   start-compile: /var/tmp/portage/dev-scheme/racket-8.6_pre1/work/racket-8.5.0.8/src/bc/mkincludes.rkt
compiler/cm:   finish-compile: /var/tmp/portage/dev-scheme/racket-8.6_pre1/work/racket-8.5.0.8/src/bc/mkincludes.rkt
Making /var/tmp/portage/dev-scheme/racket-8.6_pre1/bc/image/usr/include/racket
Done.
libtool --mode=install cp bc/racket3m /var/tmp/portage/dev-scheme/racket-8.6_pre1/bc/image/usr/bin/racketbc
libtool: warning: 'bc/libracket3m.la' has not been installed in '/usr/lib64'
libtool: install: cp bc/.libs/racket3m /var/tmp/portage/dev-scheme/racket-8.6_pre1/bc/image/usr/bin/racketbc
: /var/tmp/portage/dev-scheme/racket-8.6_pre1/bc/image/usr/bin/racketbc
bc/racket3m -O info'@'compiler/cm -l- setup --boot setup-go.rkt bc/compiled ignored bc/ignored.d start/collects-path.rkt . /var/tmp/portage/dev-scheme/racket-8.6_pre1/bc/image/usr/bin/racketbc /usr/share/racket/collects /etc/racket
compiler/cm:   start-compile: /var/tmp/portage/dev-scheme/racket-8.6_pre1/work/racket-8.5.0.8/src/start/collects-path.rkt
compiler/cm:   finish-compile: /var/tmp/portage/dev-scheme/racket-8.6_pre1/work/racket-8.5.0.8/src/start/collects-path.rkt
libtool --mode=install cp bc/gracket3m /var/tmp/portage/dev-scheme/racket-8.6_pre1/bc/image/usr/lib64/racket/gracketbc
libtool: warning: 'bc/libracket3m.la' has not been installed in '/usr/lib64'
libtool: install: cp bc/.libs/gracket3m /var/tmp/portage/dev-scheme/racket-8.6_pre1/bc/image/usr/lib64/racket/gracketbc
: /var/tmp/portage/dev-scheme/racket-8.6_pre1/bc/image/usr/lib64/racket/gracketbc
bc/racket3m -O info'@'compiler/cm -l- setup --boot setup-go.rkt bc/compiled ignored bc/ignored.d start/collects-path.rkt . /var/tmp/portage/dev-scheme/racket-8.6_pre1/bc/image/usr/lib64/racket/gracketbc /usr/share/racket/collects /etc/racket
: /var/tmp/portage/dev-scheme/racket-8.6_pre1/bc/image/usr/lib64/racket/starter
bc/racket3m -O info'@'compiler/cm -l- setup --boot setup-go.rkt bc/compiled ignored bc/ignored.d start/collects-path.rkt . /var/tmp/portage/dev-scheme/racket-8.6_pre1/bc/image/usr/lib64/racket/starter /usr/share/racket/collects /etc/racket
libtool --mode=install install bc/libracket3m.la /var/tmp/portage/dev-scheme/racket-8.6_pre1/bc/image/usr/lib64/libracket3m.la
libtool: install: install bc/.libs/libracket3m-8.5.0.8.so /var/tmp/portage/dev-scheme/racket-8.6_pre1/bc/image/usr/lib64/libracket3m-8.5.0.8.so
libtool: install: (cd /var/tmp/portage/dev-scheme/racket-8.6_pre1/bc/image/usr/lib64 && { ln -s -f libracket3m-8.5.0.8.so libracket3m.so || { rm -f libracket3m.so && ln -s libracket3m-8.5.0.8.so libracket3m.so; }; })
libtool: install: install bc/.libs/libracket3m.lai /var/tmp/portage/dev-scheme/racket-8.6_pre1/bc/image/usr/lib64/libracket3m.la
libtool: install: install bc/.libs/libracket3m.a /var/tmp/portage/dev-scheme/racket-8.6_pre1/bc/image/usr/lib64/libracket3m.a
libtool: install: chmod 644 /var/tmp/portage/dev-scheme/racket-8.6_pre1/bc/image/usr/lib64/libracket3m.a
libtool: install: x86_64-pc-linux-gnu-ranlib /var/tmp/portage/dev-scheme/racket-8.6_pre1/bc/image/usr/lib64/libracket3m.a
libtool: warning: remember to run 'libtool --finish /usr/lib64'
: /var/tmp/portage/dev-scheme/racket-8.6_pre1/bc/image/usr/lib64/libracket3m.la
/var/tmp/portage/dev-scheme/racket-8.6_pre1/bc/image/usr/bin/racketbc -X ../collects -G ../etc -O info'@'compiler/cm -l- setup --boot setup-go.rkt bc/compiled ignored bc/ignored.d ../collects/setup/unixstyle-install.rkt make-install-copytree .. /var/tmp/portage/dev-scheme/racket-8.6_pre1/bc/image/usr/bin /var/tmp/portage/dev-scheme/racket-8.6_pre1/bc/image/usr/share/racket/collects /var/tmp/portage/dev-scheme/racket-8.6_pre1/bc/image/usr/share/racket/pkgs /var/tmp/portage/dev-scheme/racket-8.6_pre1/bc/image/usr/share/doc/racket-8.6_pre1 /var/tmp/portage/dev-scheme/racket-8.6_pre1/bc/image/usr/lib64 /var/tmp/portage/dev-scheme/racket-8.6_pre1/bc/image/usr/include/racket /var/tmp/portage/dev-scheme/racket-8.6_pre1/bc/image/usr/lib64/racket /var/tmp/portage/dev-scheme/racket-8.6_pre1/bc/image/usr/share/racket /var/tmp/portage/dev-scheme/racket-8.6_pre1/bc/image/etc/racket /var/tmp/portage/dev-scheme/racket-8.6_pre1/bc/image/usr/share/applications /var/tmp/portage/dev-scheme/racket-8.6_pre1/bc/image/usr/share/man no
/var/tmp/portage/dev-scheme/racket-8.6_pre1/bc/image/usr/bin/racketbc: error while loading shared libraries: libracket3m-8.5.0.8.so: cannot open shared object file: No such file or directory
failed
 in build-one
 in loop
 in module->hash
make: *** [Makefile:36: install-bc] Error 1

The snaphot builds on x86 succeeded on opensuse tumbleweed.

see Show home:capfredf:branches:devel:languages:misc / racket - openSUSE Build Service

I've pushed a repair for --enable-shared plus DESTDIR.

1 Like

Just to confirm, I've now built Racket from 71772696941191c7d231d0ea8daf51e58801aeaa on top of current Guix and all is well. I haven't tried cross-compilation or platforms without native code backends yet: I hope to soon, but I didn't have that working with the old build scripts, either, so it's not a regression in any case.

Everything working on my end as of the latest snapshot.

I am also testing the main tree ebuild (@xgqt is not on racket discourse yet apparently, will ping separately) and I'm seeing an error related to missing install option for the chez boot files when calling make unix-install-boot-files in src/cs/c. I'm not sure what the importance of this is but it breaks the build. Looking at build.zuo it seems that this operation may be done by default now and only blocked if no-install is enabled?

make: Entering directory '/var/tmp/portage/dev-scheme/racket-8.6/work/racket-8.5.0.8/src/cs/c'
make: *** No rule to make target 'unix-install-boot-files'.  Stop.
make: Leaving directory '/var/tmp/portage/dev-scheme/racket-8.6/work/racket-8.5.0.8/src/cs/c'

Hi!

I have registered just now.

Racket version <= 8.5 by default was not installing Chez boot files.
As far as I remember I think I needed them for embedding Racket in one of my personal projects and when I found out that wasn't the default I patched the install script (ebuild) adding a command to install boot files when building the Chez Scheme Racket version (ref: repo/gentoo.git - Official Gentoo ebuild repository).

If Racket now installs Chez boot files by default this step (ref: racket-8.5.ebuild « racket « dev-scheme - repo/gentoo.git - Official Gentoo ebuild repository) can be removed.

If Racket still does not install Chez's boot files by default could anybody tell if there is a method to install them via make somehow still of if they have to be copied "manually"?
Because as @tgbugs pointed out the make call (make -C "${S}"/cs/c DESTDIR="${ED}" unix-install-boot-files) does not seem to work.

Also, minor correction, this is on installation (src_install) step, so compile step (src_compile) including the installation of compiled Racket (to DESTDIR, ref: racket-8.5.ebuild « racket « dev-scheme - repo/gentoo.git - Official Gentoo ebuild repository) should work.

Btw, if anybody wonders the default function in ebuild scripts calls looks something like this: make --jobs=7 --load-average=6 DESTDIR=/var/tmp/portage/dev-scheme/racket-8.5/image install, where jobs and load-average are controlled by user's configuration and the DESTDIR variable contains a temporary directory which is copied onto the running system after src_install is done.

1 Like

Initial snapshot ebuild of Racket 8.5.0.8: dev-scheme/racket/racket-8.5_p20220609.ebuild · b92ed9fbddade88decc08d3615ad324227ec06e6 · src_prepare / Racket / Racket Gentoo Overlay · GitLab

Zuo installation needs some work.