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

Refactor make install rules #373

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

tomodachi94
Copy link
Contributor

@tomodachi94 tomodachi94 commented Sep 2, 2024

This refactor aims to reduce the amount of duplicated Bash code that is
used in all of the distribution packages (dpkg, AUR, COPR, and Nixpkgs), since the code is the same across all packages (with some minor variations to account for the customs of the distributions).

This PR is definitely easier to review by viewing the commits step-by-step. I tried to explain the rationale for all of my changes.

I would definitely appreciate a review from @LeMoonStar and @MCJack123, who maintain the COPR and AUR+dpkg packages, respectively.

Migration guide

This is based on a private conversation between myself and @LeMoonStar.

  1. Remove the following "build code":
    • Unzipping the Linux icons
    • The build-time dependency on unzip or similar tool
  2. Remove the following pieces of installation code:
    • Binary installation
    • Installing liblua.so, including the patchelf invocation(s).
      • liblua.so is now installed to libcraftos2-liblua$(LIBEXT); make sure to add a symlink to that location from non-standard locations if you your distribution has stability guarantees
    • Icons and .desktop file installation
    • Headers installation (make sure to do make extra-install-headers if you want them in the main package)
    • Installing the ccemux plugin (make sure to do make extra-install-linux-plugin if you want it in the main package)
    • Installing Apport configuration (Ubuntu only; make sure to do extra-install-apport if you want it)
  3. Invoke make install in the package, possibly with some additional extra-install-* invocations depending on your preferences and the preferences of your distribution.
  4. Leave a comment on this PR if you have any code that should be included in the Makefile.

@tomodachi94
Copy link
Contributor Author

I'm not quite satisfied with the platform detection; please let me know if there is a better way.

@tomodachi94 tomodachi94 marked this pull request as ready for review September 2, 2024 06:56
@tomodachi94 tomodachi94 marked this pull request as draft September 2, 2024 07:50
@tomodachi94 tomodachi94 force-pushed the refactor-make-install branch 4 times, most recently from 1196a36 to 9c32462 Compare September 2, 2024 22:34
@tomodachi94 tomodachi94 marked this pull request as ready for review September 2, 2024 22:35
@tomodachi94
Copy link
Contributor Author

tomodachi94 commented Sep 2, 2024

I haven't tested the new rules on Darwin, but they should work almost the same if they are POSIX-compliant. I am unable to test that macapp does as expected, but there is no reason it shouldn't.

@tomodachi94 tomodachi94 force-pushed the refactor-make-install branch from 9c32462 to d1fe216 Compare September 2, 2024 22:50
@tomodachi94 tomodachi94 marked this pull request as draft September 2, 2024 23:58
@tomodachi94
Copy link
Contributor Author

Marking as a draft, since there is some logic included in the dpkg packages that isn't included anywhere else.

@tomodachi94 tomodachi94 force-pushed the refactor-make-install branch from d1fe216 to 54ae56e Compare September 3, 2024 01:27
@tomodachi94 tomodachi94 marked this pull request as ready for review September 3, 2024 01:28
@tomodachi94
Copy link
Contributor Author

tomodachi94 commented Sep 3, 2024

The install target now has parity with the dpkg package except for installing configuration for the Apport crash reporting system.

I have a variant of this branch that we could incorporate into this one. It:

  • Moves the Apport configuration into the main craftos2 repository, and
  • Installs it with an install-extra-apport rule upon request (e.g. it is not part of the default install rule)

if @MCJack123 wants that (I didn't want to include it in this PR without asking him first, since it looks distro-specific).

@tomodachi94 tomodachi94 force-pushed the refactor-make-install branch from 54ae56e to 5808e90 Compare September 3, 2024 01:35
@MCJack123
Copy link
Owner

Frankly, I'm scared to touch any of the release code because it's a hassle to test properly, and any singular issue means I have to either a) delete the tag, fix the issue, and re-release (bad), b) do the work for whatever was missed myself (annoying), or c) ignore it and move on (very bad). It's working, so I don't really want to mess with it in such a significant way.

This isn't an outright denial, but I'm not going to make a decision on it until I'm ready to dig down and get dirty in testing releases. If you want to help speed it up a bit, I'd appreciate a PR to https://github.com/MCJack123/craftos2-release-resources to update those scripts to work with this new process as well. You could also try testing releases in your own fork to really help me out - just mind the missing secrets and upload build steps that you'd have to remove.

(Actually, thinking about it, I just barely was able to get macOS built last version by the skin of my teeth, so I have to rebuild all the macOS stuff anyway. I guess I can merge this once I work on that too.)

@tomodachi94
Copy link
Contributor Author

Frankly, I'm scared to touch any of the release code

Very understandable :)

I'd appreciate a PR to <URL>

Done at MCJack123/craftos2-release-resources#1.

You could also try testing releases in your own fork to really help me out - just mind the missing secrets and upload build steps that you'd have to remove.

I have been testing the entire build -> install workflow through the Nix package. It appears to work, but I can't speak for other distributions (or MacOS):

Tree output of Nix package output

./result ├── bin │ └── craftos ├── include │ └── CraftOS-PC │ ├── Computer.hpp │ ├── configuration.hpp │ ├── CraftOS-PC.hpp │ ├── FileEntry.hpp │ ├── generic_peripheral │ │ ├── energy_storage.hpp │ │ ├── fluid_storage.hpp │ │ └── inventory.hpp │ ├── lib.hpp │ ├── peripheral.hpp │ └── Terminal.hpp ├── lib │ └── libcraftos2-liblua.so └── share ├── applications │ └── CraftOS-PC.desktop ├── craftos │ ├── bios.lua │ ├── debug │ │ ├── adapter.lua │ │ ├── bios.lua │ │ ├── console.lua │ │ ├── debugger.lua │ │ ├── profiler.lua │ │ ├── releasenotes.lua │ │ ├── showfile.lua │ │ └── startup.lua │ ├── hdfont.bmp │ ├── README.md │ └── rom │ ├── apis │ │ ├── colors.lua │ │ ├── colours.lua │ │ ├── command │ │ │ └── commands.lua │ │ ├── disk.lua │ │ ├── fs.lua │ │ ├── gps.lua │ │ ├── help.lua │ │ ├── http │ │ │ └── http.lua │ │ ├── io.lua │ │ ├── keys.lua │ │ ├── paintutils.lua │ │ ├── parallel.lua │ │ ├── peripheral.lua │ │ ├── rednet.lua │ │ ├── settings.lua │ │ ├── term.lua │ │ ├── textutils.lua │ │ ├── turtle │ │ │ └── turtle.lua │ │ ├── vector.lua │ │ └── window.lua │ ├── autorun │ ├── help │ │ ├── adventure.txt │ │ ├── alias.txt │ │ ├── apis.txt │ │ ├── attach.txt │ │ ├── bg.txt │ │ ├── bit.txt │ │ ├── bundled.txt │ │ ├── cash.txt │ │ ├── cd.txt │ │ ├── changelog.md │ │ ├── chat.txt │ │ ├── clear.txt │ │ ├── colors.txt │ │ ├── colours.txt │ │ ├── commands.txt │ │ ├── commandsapi.txt │ │ ├── config.txt │ │ ├── copy.txt │ │ ├── coroutine.txt │ │ ├── craft.txt │ │ ├── credits.txt │ │ ├── dance.txt │ │ ├── delete.txt │ │ ├── demos.txt │ │ ├── detach.txt │ │ ├── disk.txt │ │ ├── dj.txt │ │ ├── drive.txt │ │ ├── drives.txt │ │ ├── earth.txt │ │ ├── edit.txt │ │ ├── eject.txt │ │ ├── equip.txt │ │ ├── events.txt │ │ ├── excavate.txt │ │ ├── exec.txt │ │ ├── exit.txt │ │ ├── falling.txt │ │ ├── fg.txt │ │ ├── fs.txt │ │ ├── gestures.md │ │ ├── gist.txt │ │ ├── go.txt │ │ ├── gps.txt │ │ ├── gpsapi.txt │ │ ├── hello.txt │ │ ├── help.txt │ │ ├── helpapi.txt │ │ ├── http.txt │ │ ├── id.txt │ │ ├── intro.txt │ │ ├── io.txt │ │ ├── keys.txt │ │ ├── label.txt │ │ ├── list.txt │ │ ├── lua.txt │ │ ├── math.txt │ │ ├── mkdir.txt │ │ ├── modems.txt │ │ ├── monitor.txt │ │ ├── monitors.txt │ │ ├── mount.txt │ │ ├── move.txt │ │ ├── multishell.txt │ │ ├── os.txt │ │ ├── paint.txt │ │ ├── paintutils.txt │ │ ├── parallel.txt │ │ ├── pastebin.txt │ │ ├── peripheral.txt │ │ ├── peripherals.txt │ │ ├── pocket.txt │ │ ├── printers.txt │ │ ├── programming.txt │ │ ├── programs.txt │ │ ├── reboot.txt │ │ ├── redirection.txt │ │ ├── rednet.txt │ │ ├── redstone.txt │ │ ├── redstoneapi.txt │ │ ├── refuel.txt │ │ ├── rename.txt │ │ ├── repeat.txt │ │ ├── rs.txt │ │ ├── set.txt │ │ ├── settings.txt │ │ ├── shell.txt │ │ ├── shellapi.txt │ │ ├── shutdown.txt │ │ ├── speaker.md │ │ ├── speakers.txt │ │ ├── string.txt │ │ ├── table.txt │ │ ├── term.txt │ │ ├── textutils.txt │ │ ├── time.txt │ │ ├── tunnel.txt │ │ ├── turn.txt │ │ ├── turtle.txt │ │ ├── type.txt │ │ ├── unequip.txt │ │ ├── unmount.txt │ │ ├── vector.txt │ │ ├── wget.txt │ │ ├── whatsnew.md │ │ ├── window.txt │ │ ├── workbench.txt │ │ └── worm.txt │ ├── modules │ │ ├── command │ │ ├── main │ │ │ └── cc │ │ │ ├── audio │ │ │ │ └── dfpwm.lua │ │ │ ├── completion.lua │ │ │ ├── expect.lua │ │ │ ├── http │ │ │ │ └── gist.lua │ │ │ ├── image │ │ │ │ └── nft.lua │ │ │ ├── internal │ │ │ │ ├── error_printer.lua │ │ │ │ ├── event.lua │ │ │ │ ├── exception.lua │ │ │ │ ├── import.lua │ │ │ │ └── syntax │ │ │ │ ├── errors.lua │ │ │ │ ├── init.lua │ │ │ │ ├── lexer.lua │ │ │ │ └── parser.lua │ │ │ ├── pretty.lua │ │ │ ├── require.lua │ │ │ ├── shell │ │ │ │ └── completion.lua │ │ │ └── strings.lua │ │ └── turtle │ ├── motd.txt │ ├── programs │ │ ├── about.lua │ │ ├── advanced │ │ │ ├── bg.lua │ │ │ ├── fg.lua │ │ │ └── multishell.lua │ │ ├── alias.lua │ │ ├── apis.lua │ │ ├── attach.lua │ │ ├── cash.lua │ │ ├── cd.lua │ │ ├── clear.lua │ │ ├── command │ │ │ ├── commands.lua │ │ │ └── exec.lua │ │ ├── config.lua │ │ ├── copy.lua │ │ ├── delete.lua │ │ ├── detach.lua │ │ ├── drive.lua │ │ ├── edit.lua │ │ ├── eject.lua │ │ ├── env.lua │ │ ├── exit.lua │ │ ├── fun │ │ │ ├── advanced │ │ │ │ ├── gfxpaint.lua │ │ │ │ ├── levels │ │ │ │ │ ├── 0.dat │ │ │ │ │ ├── 1.dat │ │ │ │ │ ├── 2.dat │ │ │ │ │ ├── 3.dat │ │ │ │ │ ├── 4.dat │ │ │ │ │ ├── 5.dat │ │ │ │ │ ├── 6.dat │ │ │ │ │ ├── 7.dat │ │ │ │ │ ├── 8.dat │ │ │ │ │ ├── 9.dat │ │ │ │ │ ├── 10.dat │ │ │ │ │ ├── 11.dat │ │ │ │ │ └── 12.dat │ │ │ │ ├── paint.lua │ │ │ │ ├── pngview.lua │ │ │ │ ├── raycast.lua │ │ │ │ └── redirection.lua │ │ │ ├── adventure.lua │ │ │ ├── dj.lua │ │ │ ├── hello.lua │ │ │ ├── speaker.lua │ │ │ └── worm.lua │ │ ├── gps.lua │ │ ├── help.lua │ │ ├── http │ │ │ ├── gist.lua │ │ │ ├── pastebin.lua │ │ │ └── wget.lua │ │ ├── id.lua │ │ ├── import.lua │ │ ├── label.lua │ │ ├── list.lua │ │ ├── lua.lua │ │ ├── mkdir.lua │ │ ├── mobile │ │ │ ├── motd.txt │ │ │ └── onboarding.lua │ │ ├── monitor.lua │ │ ├── motd.lua │ │ ├── mount.lua │ │ ├── move.lua │ │ ├── peripherals.lua │ │ ├── pocket │ │ │ ├── equip.lua │ │ │ ├── falling.lua │ │ │ └── unequip.lua │ │ ├── programs.lua │ │ ├── reboot.lua │ │ ├── rednet │ │ │ ├── chat.lua │ │ │ └── repeat.lua │ │ ├── redstone.lua │ │ ├── rename.lua │ │ ├── screenfetch.lua │ │ ├── set.lua │ │ ├── shell.lua │ │ ├── shutdown.lua │ │ ├── time.lua │ │ ├── turtle │ │ │ ├── craft.lua │ │ │ ├── dance.lua │ │ │ ├── equip.lua │ │ │ ├── excavate.lua │ │ │ ├── go.lua │ │ │ ├── refuel.lua │ │ │ ├── tunnel.lua │ │ │ ├── turn.lua │ │ │ └── unequip.lua │ │ ├── type.lua │ │ └── unmount.lua │ └── startup.lua └── icons └── hicolor ├── 16x16 │ └── apps │ └── craftos.png ├── 24x24 │ └── apps │ └── craftos.png ├── 32x32 │ └── apps │ └── craftos.png ├── 48x48 │ └── apps │ └── craftos.png ├── 64x64 │ └── apps │ └── craftos.png ├── 96x96 │ └── apps │ └── craftos.png ├── 128x128 │ └── apps │ └── craftos.png ├── 256x256 │ └── apps │ └── craftos.png └── 1024x1024 └── apps └── craftos.png

@tomodachi94 tomodachi94 force-pushed the refactor-make-install branch 6 times, most recently from 1804909 to c35ff09 Compare September 3, 2024 19:48
@tomodachi94
Copy link
Contributor Author

tomodachi94 commented Sep 3, 2024

The Apport code and configuration is now included here and is installable with the extra-install-apport rule (Jack: please let me know if you don't want this; it's trivial for me to remove).

LeMoonStar added a commit to LeMoonStar/craftos2-rpm that referenced this pull request Sep 3, 2024
@tomodachi94 tomodachi94 force-pushed the refactor-make-install branch 2 times, most recently from da3f237 to 383328d Compare September 4, 2024 06:09
@tomodachi94 tomodachi94 force-pushed the refactor-make-install branch 2 times, most recently from 47d87a7 to eb4bb9c Compare September 5, 2024 23:49
Icons ended up in ``resources/linux-icons``. CraftOS-PC.desktop is in
``resources`` since it's not an icon.

The appimage workflow has been updated to accomodate this new change.

Discussion: https://discord.com/channels/795376232958656564/796330457502580746/1280733785570410497
This is extremely useful for debugging problems in Makefiles.
This refactor aims to reduce the amount of duplicated Bash code that is
used in all of the distribution packages (dpkg, AUR, COPR, and Nixpkgs).

* Introduce install-linux and install-darwin targets, which are
  automatically selected by make where appropriate.
    * install-linux installs icons and the CraftOS-PC.desktop file.
    * install-darwin installs CraftOS-PC.app to /Applications.
* Introduce install-bin, install-liblua, extra-install-headers, and
  extra-install-linux-plugin targets, which install the respective
  components.
* Introduce fixup-liblua-path target, which uses patchelf to change the
  name of liblua.so (this patching appears to be common across all packages).
* Significantly change the DESTDIR variable. It is now used as a prefix
  for everything, instead of just the binary.
* Introduce the INSTALL_TARGETS variable, which is used to control what
  dependencies the install rule has.
* Introduce the EXTRA_PLATFORM_INSTALL_TARGETS variable, which is
  conditionally set depending on the platform.
* Introduce the LIBLUA_NAME variable, which is used to control what file
  patchelf changes liblua.so from.

This refactor **does not** include code to install craftos2-rom, since
that appears to be out-of-scope.

[1]: https://www.gnu.org/software/autoconf/manual/autoconf-2.63/html_node/Installation-Directory-Variables.html
This is part of the AppImage build workflow, but it has been turned into
a generic Make rule in case a package wants the AppStream-friendly
files.
@tomodachi94 tomodachi94 force-pushed the refactor-make-install branch from eb4bb9c to fb89079 Compare September 7, 2024 21:54
@tomodachi94
Copy link
Contributor Author

REUSE headers have been added to all files that are created in this PR, to make integrating with #374 easier.

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

Successfully merging this pull request may close these issues.

2 participants