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

First working Makefile for generating a Debian package. #57

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@ ignore/
__pycache__/
.mypy_cache/
.idea

# Generated by Makefile
pxl.deb
package/usr/
package/usr/
package/usr/
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Builds the pxl package with dpkg-deb from the /package directory to pxl.deb

SHELL := /bin/bash
build:
rm -rf package/usr/lib/pxl
mkdir -p package/usr/lib/pxl
cp main.py package/usr/lib/pxl/
cp -r pxl package/usr/lib/pxl/
cp -r design package/usr/lib/pxl/
python3.7 -m venv package/usr/lib/pxl/venv;
Copy link
Member

Choose a reason for hiding this comment

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

Error: Command '['/home/rick/projects/itcrowd/pxl/package/usr/lib/pxl/venv/bin/python3.7', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.

\
source package/usr/lib/pxl/venv/bin/activate; \
pipenv sync; \
deactivate; \
\
dpkg-deb -b package/ pxl.deb
@echo "You can now install pxl by running 'sudo dpkg -i pxl.deb'"

clean:
rm -rf package/usr/lib/pxl



Empty file removed ignore/.gitkeep
Empty file.
5 changes: 5 additions & 0 deletions package/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Package: pxl
Version: 0
Architecture: all
Maintainer: IT Crowd <[email protected]>
Description: Manage photo albums on S3 buckets
4 changes: 4 additions & 0 deletions package/DEBIAN/prerm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

# Remove generate files (forced to ignore non 0 exit code when folder does not exist)
rm -rf /usr/lib/pxl/ignore
3 changes: 3 additions & 0 deletions package/usr/bin/pxl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
/usr/lib/pxl/venv/bin/python /usr/lib/pxl/main.py "$@"

15 changes: 10 additions & 5 deletions pxl/cli.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __main__ import __file__ as entrypoint_file # type: ignore
import click
import datetime
import functools
Expand All @@ -17,6 +18,8 @@
import pxl.state as state
import pxl.upload as upload

entrypoint = Path(entrypoint_file).parent


@click.group(name="pxl")
def cli() -> None:
Expand Down Expand Up @@ -134,9 +137,11 @@ def upload_cmd(dir_name: str, force: bool) -> None:
@cli.command("build")
def build_cmd() -> None:
"""Build a static site based on current state."""
click.echo("Building site...", err=True)
output_dir = Path.cwd() / "ignore" / "build"
design_dir = Path.cwd() / "design"
output_dir = Path(entrypoint) / "ignore" / "build"
output_dir.mkdir(parents=True, exist_ok=True)

click.echo(f"Building site to {output_dir}...", err=True)
design_dir = Path(entrypoint) / "design"

cfg = config.load()
with upload.client(cfg) as client:
Expand Down Expand Up @@ -170,7 +175,7 @@ def build_cmd() -> None:
@click.option("--bind", default="", help="Address to bind on (default: all interfaces)")
def preview_cmd(port: int, bind: str) -> None:
"""Run a local webserver on build output"""
output_dir = Path.cwd() / "ignore" / "build"
output_dir = Path(entrypoint) / "ignore" / "build"
if not output_dir.is_dir():
click.echo("No output to serve. Please run `pxl build` first.", err=True)
sys.exit(1)
Expand Down Expand Up @@ -203,7 +208,7 @@ def deploy_cmd() -> None:
click.echo("Config not initialized. Please run `pxl init` first.", err=False)
sys.exit(1)

output_dir = Path.cwd() / "ignore" / "build"
output_dir = Path(entrypoint) / "ignore" / "build"
if not output_dir.is_dir():
click.echo("No output to deploy. Please run `pxl build` first.", err=False)
sys.exit(1)
Expand Down