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

Add script for creating debian package #3189

Merged
merged 54 commits into from Sep 20, 2023
Merged

Conversation

silentninja
Copy link
Contributor

@silentninja silentninja commented Aug 29, 2023

Fixes #2765

This PR adds the release-scripts/build-debian.sh for generating a Debian package of Mathesar.
The generated Debian package is specific to the OS version it was generated on. So if it was generated on Debian bullseye, it can be installed only on machines running Debian bullseye and for example, cannot be installed on Debian buster.
We would be running this script on a build service like Open Build Service, it is provided here only for generating and testing manually.

The generated Debian package contains a virtualenv directory of all the dependencies of Mathesar and Mathesar Python modules. When the debian package is installed, the system python is symlinked to this virtual env. The systemd file then uses this virtual environment to start Mathesar.

The following changes are needed for the Debian package to function correctly

  • Removal of Python typings - This is needed for supporting various Python versions. We could use backports but I decided to remove it as we are not using typings in a lot of places.
  • Some non-python resources are referenced as Python modules instead of being referenced using the filesystem location - This is needed because Debian packages the files in the mathesar repository as Python modules.

Notes for the reviewer

  • The aim of this PR is to generate the debian package manually by running the release-scripts/build-debian.sh script and test the generated package on a Debian machine to see if the .deb file works as intended.
    In practice, the script will run a build service like Open Build Service which will download the release source code along with static assets, and use it for generating the Debian file.

  • Instructions for building the Debian image are in the Developer Guide

  • Before installing Mathesar, you need to install a Postgres server as we don't support SQLite as an internal database as of now

sudo apt install postgresql
sudo -u postgres psql
CREATE USER mathesar WITH SUPERUSER ENCRYPTED PASSWORD 'mathesar';
CREATE DATABASE mathesar_django;
  • Installing the Debian package can be done by
sudo apt install mathesar_0.1.3_amd64.deb
  • Check the status of mathesar by
systemctl status mathesar.service
  • If the mathesar service is installed on a remote server. You need to do the following

    • Add the IP address of the server to allowed hosts

      sudo nano /etc/mathesar/.env
      

      and add the IP address to the ALLOWED_HOSTS and restart the service

    • Since the mathesar server runs on port 8000 which is not exposed to the public. You would need to set up a reverse proxy to listen on port 80 or redirect the port 80 traffic to port 8000.

    sudo socat tcp-listen:80,reuseaddr,fork tcp:localhost:8000
    
  • Updating the debian package can be tested by making changes to the version number in pyproject.yaml and running the build script again. The generated debian package can be installed to update the existing Mathesar running on the OS

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the develop branch of the repository
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no
    visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@silentninja silentninja added this to the v0.1.4 milestone Aug 29, 2023
@silentninja silentninja marked this pull request as ready for review September 8, 2023 13:09
Copy link
Contributor

@mathemancer mathemancer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to get Mathesar running on a Debian (bullseye) machine as a .deb package! Nice work, @silentninja .

For future reference, the correct command to install the package is

sudo apt install ./mathesar_0.1.3_amd64.deb

I'm not sure why the ./ prefix is necessary, but it didn't work (on my test machine) without that. I assume it flags the installation package as existing on the local filesystem.

Moving forward, I think we should consider reorganizing the docs a bit, however I was able to use the ones added in this PR to build the package, so they suffice.

I think we should hold off on merging until #3206 is merged (via develop) into this branch, to make sure the python changes don't affect PG version compatibility.

@mathemancer mathemancer added pr-status: revision A PR awaiting follow-up work from its author after review and removed pr-status: review A PR awaiting review labels Sep 19, 2023
@silentninja silentninja added this pull request to the merge queue Sep 20, 2023
Merged via the queue into develop with commit f1fdbe4 Sep 20, 2023
18 checks passed
@silentninja silentninja deleted the add-deb-file-script branch September 20, 2023 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-status: revision A PR awaiting follow-up work from its author after review
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Create debian or flatpak images for Mathesar
2 participants