Compare commits
321 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b07f461be3 | ||
|
|
a4c06658fe | ||
|
|
25733242fc | ||
|
|
671ba536fb | ||
|
|
a5c14fc09a | ||
|
|
e977db5bb5 | ||
|
|
095ea10ee8 | ||
|
|
71531021b9 | ||
|
|
30ba0da742 | ||
|
|
5c6fc59f68 | ||
|
|
bf704e0f35 | ||
|
|
48ecde4698 | ||
|
|
7d008ef057 | ||
|
|
e0c6c0c03a | ||
|
|
cb827edde8 | ||
|
|
302d7d3db7 | ||
|
|
05d4b0195f | ||
|
|
39feccb979 | ||
|
|
7ce9f1672e | ||
|
|
d2ef9d19ce | ||
|
|
67e4563a8f | ||
|
|
d6ca9cdf71 | ||
|
|
00f0d772f7 | ||
|
|
f50c4f8172 | ||
|
|
af79ff24df | ||
|
|
d7df97e8f6 | ||
|
|
bd2b3733ee | ||
|
|
534c2e4ea3 | ||
|
|
6f075fff2b | ||
|
|
419fa73865 | ||
|
|
357c49016d | ||
|
|
2384f4fc94 | ||
|
|
8e8bcee209 | ||
|
|
1442601f7b | ||
|
|
7e6b8abc85 | ||
|
|
92f78e09de | ||
|
|
42a4665268 | ||
|
|
4d711a2fe8 | ||
|
|
00eb9594d6 | ||
|
|
8ab0c9fa01 | ||
|
|
2fbde62df9 | ||
|
|
86e5c531f5 | ||
|
|
8d2f1b830d | ||
|
|
17c186ea6b | ||
|
|
8c2fc45601 | ||
|
|
bcfd27bd53 | ||
|
|
f80f341a72 | ||
|
|
c5640b4db3 | ||
|
|
288e36764c | ||
|
|
4aa448a5a3 | ||
|
|
384c917307 | ||
|
|
ac52ecdafc | ||
|
|
5dbeb6800b | ||
|
|
e7e9da5a0c | ||
|
|
8d0a4da313 | ||
|
|
348409a29e | ||
|
|
0ae1da08cc | ||
|
|
3fbb56c3ae | ||
|
|
da315879cc | ||
|
|
c3f51bfb97 | ||
|
|
9d7fd8b3b4 | ||
|
|
a02ff5fc87 | ||
|
|
b26c28e58b | ||
|
|
be24d0368f | ||
|
|
e1c40e8c80 | ||
|
|
4a3a9f1582 | ||
|
|
4127a18e89 | ||
|
|
0d4172901b | ||
|
|
bc63166a40 | ||
|
|
2df63318a2 | ||
|
|
5f008f623a | ||
|
|
10669301a1 | ||
|
|
25628f1d24 | ||
|
|
65a426c645 | ||
|
|
eb7107a8c6 | ||
|
|
454d587d79 | ||
|
|
602e51ca10 | ||
|
|
b4753e66e2 | ||
|
|
6b0382ab77 | ||
|
|
a6adfe4d1d | ||
|
|
70a7a0aa95 | ||
|
|
b1324e9a53 | ||
|
|
89fa6fbf83 | ||
|
|
7e7f4b1aa6 | ||
|
|
ea0a6d83f8 | ||
|
|
869fd09ad9 | ||
|
|
00de98d5e3 | ||
|
|
3ba932209f | ||
|
|
1da5919d91 | ||
|
|
dd0c1cb632 | ||
|
|
9632509060 | ||
|
|
58eabf59fe | ||
|
|
85460a7c55 | ||
|
|
575e24cca7 | ||
|
|
68ce1505f1 | ||
|
|
25ebdbe625 | ||
|
|
e845888580 | ||
|
|
e76d257220 | ||
|
|
29c5c0c03d | ||
|
|
0cf02e9c1d | ||
|
|
e73b577178 | ||
|
|
bb8b28f86a | ||
|
|
a01e44b142 | ||
|
|
0ecb612d59 | ||
|
|
d3204b1ede | ||
|
|
2fc5d1d929 | ||
|
|
e4a0c1ba4a | ||
|
|
9e9cc2bc01 | ||
|
|
0e1c8507bb | ||
|
|
8a1f9d1832 | ||
|
|
f09c436e56 | ||
|
|
4636383ffc | ||
|
|
c1cda48a4c | ||
|
|
d09cf6ef3b | ||
|
|
f58cca0ba6 | ||
|
|
446c5e5901 | ||
|
|
5f33356f33 | ||
|
|
e3d8c3a063 | ||
|
|
4b83ec29de | ||
|
|
ee4ad9d602 | ||
|
|
676eff0a30 | ||
|
|
31b5a77c8a | ||
|
|
13b92b0947 | ||
|
|
d8c20e6311 | ||
|
|
14e9d7fbc2 | ||
|
|
1622e9c943 | ||
|
|
48f78dd391 | ||
|
|
826f414f9d | ||
|
|
6b6f13d2ab | ||
|
|
13ae96092f | ||
|
|
44fe22b6d4 | ||
|
|
2c9abc7e84 | ||
|
|
32b6aa650a | ||
|
|
23945b4cc6 | ||
|
|
d61d642c39 | ||
|
|
8ccbc98706 | ||
|
|
ca43fe715b | ||
|
|
c339f4cec1 | ||
|
|
dddced97aa | ||
|
|
4d9381b84a | ||
|
|
1c75a9eebe | ||
|
|
aa7d626569 | ||
|
|
952ddf4a20 | ||
|
|
527fbca7f5 | ||
|
|
225e9b3631 | ||
|
|
0e5b1cb999 | ||
|
|
f55cfb4b35 | ||
|
|
2e2a7e6a41 | ||
|
|
b5b16535c9 | ||
|
|
973aee30b6 | ||
|
|
b3807b6530 | ||
|
|
2616cf46ff | ||
|
|
bc54e8233f | ||
|
|
29c8245d0a | ||
|
|
a1e25a0cfb | ||
|
|
7dccfc8e11 | ||
|
|
2380dcb222 | ||
|
|
2184f3b1f5 | ||
|
|
a3cf9e6845 | ||
|
|
a6acc8dc69 | ||
|
|
a511e7dc82 | ||
|
|
d406b1f1d0 | ||
|
|
8a64621e8c | ||
|
|
7eb0b9d7e4 | ||
|
|
c58b6573f2 | ||
|
|
956538a32c | ||
|
|
fae8532b05 | ||
|
|
aaade1b168 | ||
|
|
aad0ae0215 | ||
|
|
a084be8849 | ||
|
|
236c4a4485 | ||
|
|
4ffb4c6582 | ||
|
|
f2f0ac2416 | ||
|
|
b2873329d4 | ||
|
|
831993cdc3 | ||
|
|
6a69f8c1d3 | ||
|
|
1b02cdd2e7 | ||
|
|
b7cdcd396b | ||
|
|
094aca80b8 | ||
|
|
cc882a4195 | ||
|
|
6685b7587a | ||
|
|
3ef3f0223e | ||
|
|
a26c04873e | ||
|
|
2e38e66f14 | ||
|
|
61887e9ee1 | ||
|
|
6193fa151e | ||
|
|
018748aa23 | ||
|
|
6dd7bbc38c | ||
|
|
2d03b014f9 | ||
|
|
9230d678af | ||
|
|
f1bf25b51f | ||
|
|
564ab243cc | ||
|
|
de0f851645 | ||
|
|
6cca4a3278 | ||
|
|
3e58a4228b | ||
|
|
7b58f2efc5 | ||
|
|
0530c365ca | ||
|
|
536a34cd59 | ||
|
|
d18b8a1d80 | ||
|
|
3b553b3a1d | ||
|
|
3386e586ac | ||
|
|
bbf1c02e79 | ||
|
|
d175570177 | ||
|
|
e06bbdbe9b | ||
|
|
d23d148660 | ||
|
|
79e8da1f46 | ||
|
|
ca6e6abfdc | ||
|
|
5bb733e559 | ||
|
|
6eb2c967a0 | ||
|
|
1790ef9137 | ||
|
|
1d6d4e4f14 | ||
|
|
046e827be1 | ||
|
|
a0fe2d83f7 | ||
|
|
f2c891533f | ||
|
|
1180ebdc1f | ||
|
|
776e0bd206 | ||
|
|
89da2b3664 | ||
|
|
ee580d1642 | ||
|
|
5d1bcd7fc0 | ||
|
|
3288fb8345 | ||
|
|
0be9f4b3ba | ||
|
|
da9d7280d5 | ||
|
|
f9c5c00f51 | ||
|
|
901efc75c6 | ||
|
|
3fc628beec | ||
|
|
e8d7ca1d6c | ||
|
|
a3443a459b | ||
|
|
0ffb9ece31 | ||
|
|
29408cb2b0 | ||
|
|
99d0479d3a | ||
|
|
f560923a9c | ||
|
|
100e865394 | ||
|
|
d4c7e8d344 | ||
|
|
d52b0f20e5 | ||
|
|
cb67de412c | ||
|
|
f52dea8eac | ||
|
|
69a274189a | ||
|
|
0f2e8bd5ee | ||
|
|
bcae0f16c7 | ||
|
|
729ec14b66 | ||
|
|
d3a83bd0cc | ||
|
|
0a02e01a96 | ||
|
|
7e6b07a491 | ||
|
|
2fd7045c82 | ||
|
|
e74a0cf204 | ||
|
|
89a09b60ab | ||
|
|
ce9a7a3082 | ||
|
|
c0c019aea6 | ||
|
|
57fad5d8c3 | ||
|
|
59ea38c9bd | ||
|
|
be6783e803 | ||
|
|
a4b45196df | ||
|
|
5e04765842 | ||
|
|
56c6443301 | ||
|
|
fe4a4001ba | ||
|
|
ac65590c85 | ||
|
|
d9d06bff63 | ||
|
|
4a967682d4 | ||
|
|
79db262858 | ||
|
|
88faecbdc2 | ||
|
|
a250ee6295 | ||
|
|
685dbb56b2 | ||
|
|
40a1c2bceb | ||
|
|
3f9cdce1cb | ||
|
|
50cc3ce27c | ||
|
|
3bcbb29cf3 | ||
|
|
3e323c953c | ||
|
|
13cb49b218 | ||
|
|
18d857668e | ||
|
|
1e9d0c62f9 | ||
|
|
06c2d5295d | ||
|
|
1d58b4d584 | ||
|
|
f95a24ebb9 | ||
|
|
8c494f7736 | ||
|
|
bf428103d3 | ||
|
|
6dec0a6e17 | ||
|
|
62622813be | ||
|
|
6aab099baa | ||
|
|
bd2b012740 | ||
|
|
fb9c6ac32c | ||
|
|
bdd79a8f2b | ||
|
|
91c46a07c6 | ||
|
|
52a35dd63a | ||
|
|
fc495607dc | ||
|
|
5f4f667e17 | ||
|
|
6c01126ce9 | ||
|
|
a68e395cb6 | ||
|
|
49a7c6df41 | ||
|
|
b5d523741c | ||
|
|
04f1cab5fc | ||
|
|
133f5bb98d | ||
|
|
c5f8416b63 | ||
|
|
3f3b8487d4 | ||
|
|
2133867c8a | ||
|
|
617a42a674 | ||
|
|
f88134f9ca | ||
|
|
a6540b73da | ||
|
|
eac89409b8 | ||
|
|
52dcceb87f | ||
|
|
a34efc058a | ||
|
|
6d1a7750c5 | ||
|
|
f65cd52304 | ||
|
|
9711fabab7 | ||
|
|
5285b6dce8 | ||
|
|
70d0021df1 | ||
|
|
f9a871f9b2 | ||
|
|
3cee5d4f01 | ||
|
|
bc0ef634cf | ||
|
|
538b8a32b9 | ||
|
|
33848ad43c | ||
|
|
95b198a5aa | ||
|
|
f7b4cc602b | ||
|
|
c6b1c2225d | ||
|
|
e290ac758b | ||
|
|
ee35c06119 | ||
|
|
6fbea50682 | ||
|
|
b47ca7bbdc | ||
|
|
e63a7e557d | ||
|
|
659290677b | ||
|
|
9510936fd9 | ||
|
|
6635bc6d46 |
1
.gitignore
vendored
|
|
@ -1,3 +1,4 @@
|
|||
build
|
||||
dist
|
||||
gerbolyze.egg-info
|
||||
__pycache__
|
||||
|
|
|
|||
176
.gitlab-ci.yml
Normal file
|
|
@ -0,0 +1,176 @@
|
|||
variables:
|
||||
GIT_SUBMODULE_STRATEGY: recursive
|
||||
|
||||
stages:
|
||||
- build
|
||||
- test
|
||||
- publish
|
||||
|
||||
include:
|
||||
- local: "/svg-flatten/svg-flatten-wasi-ci.yml"
|
||||
|
||||
build:gerbolyze:
|
||||
stage: build
|
||||
image: "registry.gitlab.com/gerbolyze/build-containers/archlinux:latest"
|
||||
variables:
|
||||
GIT_SUBMODULE_STRATEGY: none
|
||||
script:
|
||||
- git config --global --add safe.directory "$CI_PROJECT_DIR"
|
||||
- uv build
|
||||
artifacts:
|
||||
name: "gerbolyze-$CI_COMMIT_REF_NAME-gerbolyze"
|
||||
paths:
|
||||
- dist/*
|
||||
|
||||
publish:gerbolyze:
|
||||
stage: publish
|
||||
id_tokens:
|
||||
PYPI_ID_TOKEN:
|
||||
aud: pypi
|
||||
variables:
|
||||
GIT_SUBMODULE_STRATEGY: none
|
||||
image: "registry.gitlab.com/gerbolyze/build-containers/archlinux:latest"
|
||||
cache: {}
|
||||
script:
|
||||
- export TWINE_USERNAME TWINE_PASSWORD
|
||||
- twine upload dist/*
|
||||
dependencies:
|
||||
- build:gerbolyze
|
||||
only:
|
||||
- /^v.*$/
|
||||
|
||||
# Builds for debian are disabled until they get a C++20-capable compiler.
|
||||
#build:svg-flatten-debian_11:
|
||||
# stage: build
|
||||
# image: "registry.gitlab.com/gerbolyze/build-containers/debian:11"
|
||||
# script:
|
||||
# - "export CXX=clang++"
|
||||
# - "make -C svg-flatten"
|
||||
# artifacts:
|
||||
# name: "gerbolyze-$CI_COMMIT_REF_NAME-svg-flatten-deb11"
|
||||
# paths:
|
||||
# - svg-flatten/build/svg-flatten
|
||||
# - svg-flatten/build/nopencv-test
|
||||
|
||||
# Tests for debian are disabled until they get python 3.10.
|
||||
# test:svg-flatten-debian_11:
|
||||
# stage: test
|
||||
# variables:
|
||||
# GIT_SUBMODULE_STRATEGY: none
|
||||
# image: "registry.gitlab.com/gerbolyze/build-containers/debian:11"
|
||||
# script:
|
||||
# - git config --global --add safe.directory "$CI_PROJECT_DIR"
|
||||
# - "export PATH=$HOME/.local/bin:$HOME/.cargo/bin:$PATH"
|
||||
# - "touch svg-flatten/build/svg-flatten svg-flatten/build/nopencv-test"
|
||||
# - "python3 setup.py install --user"
|
||||
# - "gerbolyze --help"
|
||||
# - "make -C svg-flatten tests"
|
||||
# dependencies:
|
||||
# - build:svg-flatten-debian_11
|
||||
# artifacts:
|
||||
# name: "gerbolyze-$CI_COMMIT_REF_NAME-test-deb11"
|
||||
# when: on_failure
|
||||
# paths:
|
||||
# - svg-flatten/testcase-fails/*.png
|
||||
# - svg-flatten/testcase-fails/*.svg
|
||||
|
||||
#build:svg-flatten-ubuntu_rolling:
|
||||
# stage: build
|
||||
# image: "registry.gitlab.com/gerbolyze/build-containers/ubuntu:rolling"
|
||||
# script:
|
||||
# - "export CXX=clang++"
|
||||
# - "make -C svg-flatten"
|
||||
# artifacts:
|
||||
# name: "gerbolyze-$CI_COMMIT_REF_NAME-svg-flatten-uburl"
|
||||
# paths:
|
||||
# - svg-flatten/build/svg-flatten
|
||||
# - svg-flatten/build/nopencv-test
|
||||
|
||||
# test:svg-flatten-ubuntu_rolling:
|
||||
# stage: test
|
||||
# variables:
|
||||
# GIT_SUBMODULE_STRATEGY: none
|
||||
# image: "registry.gitlab.com/gerbolyze/build-containers/ubuntu:rolling"
|
||||
# script:
|
||||
# - git config --global --add safe.directory "$CI_PROJECT_DIR"
|
||||
# - "export PATH=$HOME/.local/bin:$HOME/.cargo/bin:$PATH"
|
||||
# - "touch svg-flatten/build/svg-flatten svg-flatten/build/nopencv-test"
|
||||
# - pip3 install --user --break-system-packages 'pillow>=9.1.1'
|
||||
# - "python3 setup.py install --user"
|
||||
# - "gerbolyze --help"
|
||||
# - "make -C svg-flatten tests"
|
||||
# dependencies:
|
||||
# - build:svg-flatten-ubuntu_rolling
|
||||
# artifacts:
|
||||
# name: "gerbolyze-$CI_COMMIT_REF_NAME-test-uburl"
|
||||
# when: on_failure
|
||||
# paths:
|
||||
# - svg-flatten/testcase-fails/*.png
|
||||
# - svg-flatten/testcase-fails/*.svg
|
||||
|
||||
build:svg-flatten-fedora_latest:
|
||||
stage: build
|
||||
image: "registry.gitlab.com/gerbolyze/build-containers/fedora:latest"
|
||||
script:
|
||||
- "export CXX=clang++"
|
||||
- "make -C svg-flatten"
|
||||
artifacts:
|
||||
name: "gerbolyze-$CI_COMMIT_REF_NAME-svg-flatten-fedlt"
|
||||
paths:
|
||||
- svg-flatten/build/svg-flatten
|
||||
- svg-flatten/build/nopencv-test
|
||||
|
||||
#test:svg-flatten-fedora_latest:
|
||||
# stage: test
|
||||
# variables:
|
||||
# GIT_SUBMODULE_STRATEGY: none
|
||||
# image: "registry.gitlab.com/gerbolyze/build-containers/fedora:latest"
|
||||
# script:
|
||||
# - git config --global --add safe.directory "$CI_PROJECT_DIR"
|
||||
# - "export PATH=$HOME/.local/bin:$HOME/.cargo/bin:$PATH"
|
||||
# - "touch svg-flatten/build/svg-flatten svg-flatten/build/nopencv-test"
|
||||
# - pip3 install --user 'pillow>=9.1.1'
|
||||
# - "python3 setup.py install --user"
|
||||
# - "gerbolyze --help"
|
||||
# - "make -C svg-flatten tests"
|
||||
# dependencies:
|
||||
# - build:svg-flatten-fedora_latest
|
||||
# artifacts:
|
||||
# name: "gerbolyze-$CI_COMMIT_REF_NAME-test-fedlt"
|
||||
# when: on_failure
|
||||
# paths:
|
||||
# - svg-flatten/testcase-fails/*.png
|
||||
# - svg-flatten/testcase-fails/*.svg
|
||||
|
||||
build:svg-flatten-archlinux:
|
||||
stage: build
|
||||
image: "registry.gitlab.com/gerbolyze/build-containers/archlinux:latest"
|
||||
script:
|
||||
- "make -C svg-flatten"
|
||||
artifacts:
|
||||
name: "gerbolyze-$CI_COMMIT_REF_NAME-svg-flatten-arch"
|
||||
paths:
|
||||
- svg-flatten/build/svg-flatten
|
||||
- svg-flatten/build/nopencv-test
|
||||
|
||||
#test:svg-flatten-archlinux:
|
||||
# stage: test
|
||||
# variables:
|
||||
# GIT_SUBMODULE_STRATEGY: none
|
||||
# image: "registry.gitlab.com/gerbolyze/build-containers/archlinux:latest"
|
||||
# script:
|
||||
# - git config --global --add safe.directory "$CI_PROJECT_DIR"
|
||||
# - "export PATH=$HOME/.local/bin:$HOME/.cargo/bin:$PATH"
|
||||
# - "touch svg-flatten/build/svg-flatten svg-flatten/build/nopencv-test"
|
||||
# - "python setup.py install --user"
|
||||
# - "gerbolyze --help"
|
||||
# - "make -C svg-flatten tests"
|
||||
# dependencies:
|
||||
# - build:svg-flatten-archlinux
|
||||
# artifacts:
|
||||
# name: "gerbolyze-$CI_COMMIT_REF_NAME-test-arch"
|
||||
# when: on_failure
|
||||
# paths:
|
||||
# - svg-flatten/testcase-fails/*.png
|
||||
# - svg-flatten/testcase-fails/*.svg
|
||||
#
|
||||
36
.gitmodules
vendored
|
|
@ -1,6 +1,30 @@
|
|||
[submodule "gerboweb/deploy/checkouts/pogojig"]
|
||||
path = gerboweb/deploy/checkouts/pogojig
|
||||
url = https://github.com/jaseg/pogojig.git
|
||||
[submodule "gerboweb/deploy/library/ansible-collection"]
|
||||
path = gerboweb/deploy/library/inwx-collection
|
||||
url = https://github.com/inwx/ansible-collection
|
||||
[submodule "upstream/cpp-base64"]
|
||||
path = upstream/cpp-base64
|
||||
url = https://gitlab.com/gerbolyze/gerbolyze-cpp-base64.git
|
||||
[submodule "upstream/voronoi"]
|
||||
path = upstream/voronoi
|
||||
url = https://github.com/JCash/voronoi
|
||||
[submodule "upstream/poisson-disk-sampling"]
|
||||
path = upstream/poisson-disk-sampling
|
||||
url = https://github.com/thinks/poisson-disk-sampling
|
||||
[submodule "upstream/argagg"]
|
||||
path = upstream/argagg
|
||||
url = https://gitlab.com/gerbolyze/gerbolyze-argagg.git
|
||||
[submodule "upstream/CavalierContours"]
|
||||
path = upstream/CavalierContours
|
||||
url = https://github.com/jbuckmccready/CavalierContours
|
||||
[submodule "upstream/subprocess.h"]
|
||||
path = upstream/subprocess.h
|
||||
url = https://github.com/sheredom/subprocess.h
|
||||
[submodule "svg-flatten/upstream/minunit"]
|
||||
path = upstream/minunit
|
||||
url = https://github.com/siu/minunit
|
||||
[submodule "upstream/stb"]
|
||||
path = upstream/stb
|
||||
url = https://github.com/nothings/stb
|
||||
[submodule "upstream/filesystem"]
|
||||
path = upstream/filesystem
|
||||
url = https://github.com/gulrak/filesystem
|
||||
[submodule "upstream/pugixml"]
|
||||
path = upstream/pugixml
|
||||
url = https://github.com/zeux/pugixml
|
||||
|
|
|
|||
11
MANIFEST.in
|
|
@ -1 +1,12 @@
|
|||
# setuptools'es default strategy of packing everything into the archive that is in git is really the opposite of smart
|
||||
# here, especially because AFAICT after hours of googling there is no way to turn it off. Meh. Why is python packaging
|
||||
# like this? what is so hard about putting a few files in a zip?!
|
||||
global-exclude *
|
||||
|
||||
include README.rst
|
||||
include LICENSE
|
||||
include MANIFEST.in
|
||||
include setup.py
|
||||
recursive-include gerbolyze *.py
|
||||
recursive-include bin *
|
||||
recursive-include gerbolyze.egg-info *
|
||||
|
|
|
|||
686
README.rst
|
|
@ -1,87 +1,541 @@
|
|||
Gerbolyze high-resolution image-to-PCB converter
|
||||
================================================
|
||||
Gerbolyze high-fidelity SVG/PNG/JPG to PCB converter
|
||||
====================================================
|
||||
|
||||
.. note::
|
||||
|
||||
The command-line usage and SVG template format of gerbolyze changed between v2.0 and v3.0. You can find details on
|
||||
the new format below under command_line_usage_
|
||||
|
||||
Gerbolyze renders SVG vector and PNG/JPG raster images into existing gerber PCB manufacturing files.
|
||||
Vector data from SVG files is rendered losslessly *without* an intermediate rasterization/revectorization step.
|
||||
Still, gerbolyze supports (almost) the full SVG 1.1 spec including complex, self-intersecting paths with holes,
|
||||
patterns, dashes and transformations.
|
||||
|
||||
Raster images can either be vectorized through contour tracing (like gerbolyze v1.0 did) or they can be embedded using
|
||||
high-resolution grayscale emulation while (mostly) guaranteeing trace/space design rules.
|
||||
|
||||
Try gerbolyze online at https://dyna.kokoroyukuma.de/gerboweb
|
||||
|
||||
.. figure:: pics/pcbway_sample_02_small.jpg
|
||||
:width: 800px
|
||||
|
||||
Drawing by `トーコ Toko <https://twitter.com/fluffy2038/status/1317231121269104640>`__ converted using Gerbolyze and printed at PCBWay.
|
||||
|
||||
.. image:: https://raw.githubusercontent.com/jaseg/gerbolyze/master/sample1.jpg
|
||||
|
||||
Tooling for PCB art is quite limited in both open source and closed source ecosystems. Something as simple as putting a
|
||||
pretty picture on a PCB can be an extremely tedious task. Depending on the PCB tool used, various arcane incantations
|
||||
may be necessary and even modestly complex images will slow down most PCB tools to a crawl.
|
||||
|
||||
Gerbolyze solves this problem in a toolchain-agnostic way by directly vectorizing bitmap files onto existing gerber
|
||||
layers. Gerbolyze has been tested against both the leading open-source KiCAD toolchain and the industry-standard Altium
|
||||
Designer. Gerbolyze is written with performance in mind and will happily vectorize tens of thousands of primitives,
|
||||
generating tens of megabytes of gerber code without crapping itself. With gerbolyze you can finally be confident that
|
||||
your PCB fab's toolchain will fall over before yours does if you overdo it with the high-poly anime silkscreen.
|
||||
Gerbolyze solves this problem in a toolchain-agnostic way by directly vectorizing SVG vector and PNG or JPG bitmap files
|
||||
onto existing gerber layers. Gerbolyze processes any spec-compliant SVG and "gerbolyzes" SVG vector data into a Gerber
|
||||
spec-compliant form. Gerbolyze has been tested against both the leading open-source KiCAD toolchain and the
|
||||
industry-standard Altium Designer. Gerbolyze is written with performance in mind and will happily vectorize tens of
|
||||
thousands of primitives, generating tens of megabytes of gerber code without crapping itself. With gerbolyze you can
|
||||
finally be confident that your PCB fab's toolchain will fall over before yours does if you overdo it with the high-poly
|
||||
anime silkscreen.
|
||||
|
||||
Gerbolyze is based on gerbonara_.
|
||||
|
||||
.. image:: pics/process-overview.png
|
||||
:width: 800px
|
||||
|
||||
.. contents::
|
||||
|
||||
Produce high-quality artistic PCBs in three easy steps!
|
||||
-------------------------------------------------------
|
||||
Tl;dr: Produce high-quality artistic PCBs in three easy steps!
|
||||
--------------------------------------------------------------
|
||||
|
||||
Gerbolyze works in three steps.
|
||||
|
||||
1. Generate a scale-accurate preview of the finished PCB from your CAD tool's gerber output:
|
||||
1. Generate a scale-accurate template of the finished PCB from your CAD tool's gerber output:
|
||||
|
||||
.. code::
|
||||
|
||||
$ gerbolyze render top my_gerber_dir preview.png
|
||||
$ gerbolyze template --top template_top.svg [--bottom template_bottom.svg] my_gerber_dir
|
||||
|
||||
2. Load the resulting preview image into the GIMP or another image editing program. Use it as a guide to position scale
|
||||
your artwork. Create a black-and-white image from your scaled artwork using GIMP's newsprint filter. Make sure most
|
||||
details are larger than about 10px to ensure manufacturing goes smooth.
|
||||
2. Load the resulting template image Inkscape_ or another SVG editing program. Put your artwork on the appropriate SVG
|
||||
layer. Dark colors become filled gerber primitives, bright colors become unfilled primitives. You can directly put
|
||||
raster images (PNG/JPG) into this SVG as well, just position and scale them like everything else. SVG clips work for
|
||||
images, too. Masks are not supported.
|
||||
|
||||
3. Vectorize the resulting grayscale image drectly into the PCB's gerber files:
|
||||
3. Vectorize the edited SVG template image drectly into the PCB's gerber files:
|
||||
|
||||
.. code::
|
||||
|
||||
$ gerbolyze vectorize top input_gerber_dir output_gerber_dir black_and_white_artwork.png
|
||||
$ gerbolyze paste template_top_edited.svg my_gerber_dir output_gerber_dir
|
||||
|
||||
Image preprocessing guide
|
||||
-------------------------
|
||||
Quick Start Installation (Any Platform)
|
||||
---------------------------------------
|
||||
|
||||
Nice black-and-white images can be generated from any grayscale image using the GIMP's newsprint filter. The
|
||||
straight-forward pre-processing steps necessary for use by ``gerbolyze vectorize`` are as follows.
|
||||
.. code-block:: shell
|
||||
|
||||
1 Import a render of the board generated using ``gerbolyze render``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
python -m pip install --user gerbolyze resvg-wasi
|
||||
|
||||
``gerbolyze render`` will automatically scale the render such that ten pixels in the render correspond to 6mil on the
|
||||
board, which is about the smallest detail most manufacturers can resolve on the silkscreen layer. You can control this
|
||||
setting using the ``--fab-resolution`` and ``--oversampling`` options. Refer to ``gerbolyze --help`` for details.
|
||||
If you already have resvg installed, you can omit the resvg-wasi package.
|
||||
|
||||
.. image:: https://raw.githubusercontent.com/jaseg/gerbolyze/master/screenshots/01import01.png
|
||||
To uninstall, run
|
||||
|
||||
2 Import your desired artwork
|
||||
.. code-block:: shell
|
||||
|
||||
python -m pip uninstall gerbolyze gerbonara resvg-wasi svg-flatten-wasi
|
||||
|
||||
To update, run
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
python -m pip install --user --upgrade --upgrade-strategy eager gerbolyze
|
||||
|
||||
Speeding up gerbolyze using natively-built binaries
|
||||
---------------------------------------------------
|
||||
|
||||
This will install gerbolyze's binary dependency resvg and gerbolyze's svg-flatten utility as pre-built cross-platform
|
||||
WASM binaries. When you first run gerbolyze, it will take some time (~30s) to link these binaries for your system. The
|
||||
output is cached, so any future run is going to be fast.
|
||||
|
||||
WASM is slower than natively-built binaries. To speed up gerbolyze, you can natively build its two binary dependencies:
|
||||
|
||||
1. Install resvg natively using rust's cargo package manager: ``cargo install resvg``
|
||||
2. Install gerbolyze's svg-flatten utility natively. You can get pre-built binaries from gerbolyze's gitlab CI jobs `at
|
||||
this link <https://gitlab.com/gerbolyze/gerbolyze/-/pipelines?scope=tags&page=1>`__ by clicking the three dots on the
|
||||
right next to the version you want. These pre-built binaries should work on any x86_64 linux since they are
|
||||
statically linked. You can also build svg-flatten yourself by running ``make`` inside the ``svg-flatten`` folder from
|
||||
a gerbolyze checkout.
|
||||
|
||||
Gerbolyze will pick up these binaries when installed in your ``$PATH``. resvg is also picked up when it is installed by
|
||||
cargo in your home's ``~/.cargo``, even if it's not in your ``$PATH``. You can override the resvg, usvg or svg-flatten
|
||||
binary that gerbolyze uses by giving it the absoulute path to a binary in the ``$RESVG``, ``$USVG`` and ``$SVG_FLATTEN``
|
||||
environment variables.
|
||||
|
||||
|
||||
Build from source (any distro)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
git clone --recurse-submodules https://git.jaseg.de/gerbolyze.git
|
||||
cd gerbolyze
|
||||
|
||||
python3 -m venv
|
||||
source venv/bin/activate
|
||||
python3 setup.py install
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
Input on the left, output on the right.
|
||||
|
||||
.. image:: pics/test_svg_readme_composited.png
|
||||
:width: 800px
|
||||
|
||||
* Almost full SVG 1.1 static spec coverage (!)
|
||||
|
||||
* Paths with beziers, self-intersections and holes
|
||||
* Strokes, even with dashes and markers
|
||||
* Pattern fills and strokes
|
||||
* Transformations and nested groups
|
||||
* Proper text rendering with support for complex text layout (e.g. Arabic)
|
||||
* <image> elements via either built-in vectorizer or built-in halftone processor
|
||||
* (some) CSS
|
||||
|
||||
* Writes Gerber, SVG or KiCAD S-Expression (``.kicad_mod``) formats
|
||||
* Can export from top/bottom SVGs to a whole gerber layer stack at once with filename autodetection
|
||||
* Can export SVGs to ``.kicad_mod`` files like svg2mod (but with full SVG support)
|
||||
* Beziers flattening with configurable tolerance using actual math!
|
||||
* Polygon intersection removal
|
||||
* Polygon hole removal (!)
|
||||
* Optionally vector-compositing of output: convert black/white/transparent image to black/transparent image
|
||||
* Renders SVG templates from input gerbers for accurate and easy scaling and positioning of artwork
|
||||
* layer masking with offset (e.g. all silk within 1mm of soldermask)
|
||||
* Can read gerbers from zip files
|
||||
* Limited SVG support for board outline layers (no fill/region support)
|
||||
* Dashed lines supported on board outline layers
|
||||
|
||||
Gerbolyze is the end-to-end "paste this svg into these gerbers" command that handles all layers on both board sides at
|
||||
once. The heavy-duty computer geometry logic of gerbolyze is handled by the svg-flatten utility (``svg-flatten``
|
||||
directory). svg-flatten reads an SVG file and renders it into a variety of output formats. svg-flatten can be used like
|
||||
a variant of the popular svg2mod that supports all of SVG and handles arbitrary input ``<path>`` elements.
|
||||
|
||||
Algorithm Overview
|
||||
------------------
|
||||
|
||||
This is the algorithm gerbolyze uses to process a stack of gerbers.
|
||||
|
||||
* Map input files to semantic layers by their filenames
|
||||
* For each layer:
|
||||
|
||||
* load input gerber
|
||||
* Pass mask layers through ``gerbv`` for conversion to SVG
|
||||
* Pass mask layers SVG through ``svg-flatten --dilate``
|
||||
* Pass input SVG through ``svg-flatten --only-groups [layer]``
|
||||
* Overlay input gerber, mask and input svg
|
||||
* Write result to output gerber
|
||||
|
||||
This is the algorithm svg-flatten uses to process an SVG.
|
||||
|
||||
* pass input SVG through usvg_
|
||||
* iterate depth-first through resulting SVG.
|
||||
|
||||
* for groups: apply transforms and clip and recurse
|
||||
* for images: Vectorize using selected vectorizer
|
||||
* for paths:
|
||||
|
||||
* flatten path using Cairo
|
||||
* remove self-intersections using Clipper
|
||||
* if stroke is set: process dash, then offset using Clipper
|
||||
* apply pattern fills
|
||||
* clip to clip-path
|
||||
* remove holes using Clipper
|
||||
|
||||
* for KiCAD S-Expression export: vector-composite results using CavalierContours: subtract each clear output primitive
|
||||
from all previous dark output primitives
|
||||
|
||||
Web interface
|
||||
-------------
|
||||
|
||||
You can try gerbolyze online at https://dyna.kokoroyukuma.de/gerboweb
|
||||
|
||||
The web interface does not expose all of gerbolyze's bells and whistles, but it allows you to simply paste a single SVG
|
||||
file on a board to try out gerbolyze. Upload your design on the web interface, then download the template for either the
|
||||
top or bottom side, and put your artwork on the appropriate layer of that template using Inkscape_. Finally, upload the
|
||||
modified template and let gerbolyze process your design.
|
||||
|
||||
Command-line usage
|
||||
------------------
|
||||
.. _command_line_usage:
|
||||
|
||||
Generate SVG template from Gerber files:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
gerbolyze template [options] [--top|--bottom] input_dir_or.zip output.svg
|
||||
|
||||
Render design from an SVG made with the template above into a set of gerber files:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
gerbolyze paste [options] artwork.svg input_dir_or.zip output_dir_or.zip
|
||||
|
||||
Use svg-flatten to convert an SVG file into Gerber or flattened SVG:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
svg-flatten [options] --format [gerber|svg] [input_file.svg] [output_file]
|
||||
|
||||
Use svg-flatten to convert an SVG file into the given layer of a KiCAD S-Expression (``.kicad_mod``) file:
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
svg-flatten [options] --format kicad --sexp-layer F.SilkS --sexp-mod-name My_Module [input_file.svg] [output_file]
|
||||
|
||||
Use svg-flatten to convert an SVG file into a ``.kicad_mod`` with SVG layers fed into separate KiCAD layers based on
|
||||
their IDs like the popular ``svg2mod`` is doing:
|
||||
|
||||
Note:
|
||||
Right now, the input SVG's layers must have *ids* that match up KiCAD's s-exp layer names. Note that when you name
|
||||
a layer in Inkscape that only sets a ``name`` attribute, but does not change the ID. In order to change the ID in
|
||||
Inkscape, you have to use Inkscape's "object properties" context menu function.
|
||||
|
||||
Also note that svg-flatten expects the layer names KiCAD uses in their S-Expression format. These are *different* to
|
||||
the layer names KiCAD exposes in the UI (even though most of them match up!).
|
||||
|
||||
For your convenience, there is an SVG template with all the right layer names and IDs located next to this README.
|
||||
|
||||
.. code-block:: shell
|
||||
|
||||
svg-flatten [options] --format kicad --sexp-mod-name My_Module [input_file.svg] [output_file]
|
||||
|
||||
``gerbolyze template``
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Usage: ``gerbolyze template [OPTIONS] INPUT``
|
||||
|
||||
Generate SVG template for gerbolyze paste from gerber files.
|
||||
|
||||
INPUT may be a gerber file, directory of gerber files or zip file with gerber files. The output file contains a preview
|
||||
image of the input gerbers to allow you to position your artwork, as well as prepared Inkscape layers corresponding to
|
||||
each gerber layer. Simply place your artwork in this SVG template using Inkscape. Starting in v3.0, gerbolyze
|
||||
automatically keeps track of which board side (top or bottom) is contained in an SVG template.
|
||||
|
||||
Options:
|
||||
********
|
||||
``--top | --bottom``
|
||||
Output top or bottom side template. This affects both the preview image and the prepared Inkscape layers.
|
||||
|
||||
``--vector | --raster``
|
||||
Embed preview renders into output file as SVG vector graphics instead of rendering them to PNG bitmaps. The
|
||||
resulting preview may slow down your SVG editor.
|
||||
|
||||
``--raster-dpi FLOAT``
|
||||
DPI for rastering preview
|
||||
|
||||
``--bbox TEXT``
|
||||
Output file bounding box. Format: "w,h" to force [w] mm by [h] mm output canvas OR "x,y,w,h" to force [w] mm by [h]
|
||||
mm output canvas with its bottom left corner at the given input gerber coördinates.
|
||||
|
||||
|
||||
``gerbolyze paste``
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
(see `below <vectorization_>`__)
|
||||
|
||||
Usage: ``gerbolyze paste [OPTIONS] INPUT_GERBERS OVERLAY_SVG OUTPUT_GERBERS``
|
||||
|
||||
Render vector data and raster images from SVG file into gerbers. The SVG input file can be generated using ``gerbolyze
|
||||
template`` and contains the name and board side of each layer. Note that for board outline layers, handling slightly
|
||||
differs from other layers as PCB fabs do not support filled Gerber regions on these layers.
|
||||
|
||||
Options:
|
||||
********
|
||||
|
||||
``--bbox TEXT``
|
||||
Output file bounding box. Format: "w,h" to force [w] mm by [h] mm output canvas OR "x,y,w,h" to force [w] mm by [h]
|
||||
mm output canvas with its bottom left corner at the given input gerber coördinates. This **must match the ``--bbox`` value given to
|
||||
template**!
|
||||
|
||||
``--subtract TEXT``
|
||||
Use user subtraction script from argument (see `below <subtraction_script_>`_)
|
||||
|
||||
``--no-subtract``
|
||||
Disable subtraction (see `below <subtraction_script_>`_)
|
||||
|
||||
``--dilate FLOAT``
|
||||
Default dilation for subtraction operations in mm (see `below <subtraction_script_>`_)
|
||||
|
||||
``--trace-space FLOAT``
|
||||
Passed through to svg-flatten, see `below <svg_flatten_>`__.
|
||||
|
||||
``--vectorizer TEXT``
|
||||
Passed through to svg-flatten, see `its description below <svg_flatten_>`__. Also have a look at `the examples below <vectorization_>`_.
|
||||
|
||||
``--vectorizer-map TEXT``
|
||||
Passed through to svg-flatten, see `below <svg_flatten_>`__.
|
||||
|
||||
``--exclude-groups TEXT``
|
||||
Passed through to svg-flatten, see `below <svg_flatten_>`__.
|
||||
|
||||
|
||||
.. _outline_layers:
|
||||
|
||||
Outline layers
|
||||
**************
|
||||
|
||||
Outline layers require special handling since PCB fabs do not support filled G36/G37 polygons on these layers. The main
|
||||
difference between normal layers and outline layers is how strokes are handled. On outline layers, strokes are
|
||||
translated to normal Gerber draw commands (D01, D02 etc.) with an aperture set to the stroke's width instead of tracing
|
||||
them to G36/G37 filled regions. This means that on outline layers, SVG end caps and line join types do not work: All
|
||||
lines are redered with round joins and end caps.
|
||||
|
||||
One exception from this are patterns, which work as expected for both fills and strokes with full support for joins and
|
||||
end caps.
|
||||
|
||||
Dashed strokes are supported on outline layers and can be used to make easy mouse bites.
|
||||
|
||||
.. _subtraction_script:
|
||||
|
||||
Subtraction scripts
|
||||
*******************
|
||||
|
||||
.. image:: pics/subtract_example.png
|
||||
:width: 800px
|
||||
|
||||
Subtraction scripts tell ``gerbolyze paste`` to remove an area around certain input layers to from an overlay layer.
|
||||
When a input layer is given in the subtraction script, gerbolyze will dilate (extend outwards) everything on this input
|
||||
layer and remove it from the target overlay layer. By default, Gerbolyze subtracts the mask layer from the silk layer to
|
||||
make sure there are no silk primitives that overlap bare copper, and subtracts each input layer from its corresponding
|
||||
overlay to make sure the two do not overlap. In the picture above you can see both at work: The overlay contains
|
||||
halftone primitives all over the place. The subtraction script has cut out an area around all pads (mask layer) and all
|
||||
existing silkscreen. You can turn off this behavior by passing ``--no-subtract`` or pass your own "script".
|
||||
|
||||
The syntax of these scripts is:
|
||||
|
||||
.. code-block::
|
||||
|
||||
{target layer} -= {source layer} {dilation} [; ...]
|
||||
|
||||
The target layer must be ``out.{layer name}`` and the source layer ``in.{layer name}``. The layer names are gerbolyze's
|
||||
internal layer names, i.e.: ``paste, silk, mask, copper, outline, drill``
|
||||
|
||||
The dilation value is optional, but can be a float with a leading ``+`` or ``-``. If given, before subtraction the
|
||||
source layer's features will be extended by that many mm. If not given, the dilation defaults to the value given by
|
||||
``--dilate`` if given or 0.1 mm otherwise. To disable dilation, simply pass ``+0`` here.
|
||||
|
||||
Multiple commands can be separated by semicolons ``;`` or line breaks.
|
||||
|
||||
The default subtraction script is:
|
||||
|
||||
.. code-block::
|
||||
|
||||
out.silk -= in.mask
|
||||
out.silk -= in.silk+0.5
|
||||
out.mask -= in.mask+0.5
|
||||
out.copper -= in.copper+0.5
|
||||
|
||||
.. _svg_flatten:
|
||||
|
||||
``svg-flatten``
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Usage: ``svg-flatten [OPTIONS]... [INPUT_FILE] [OUTPUT_FILE]``
|
||||
|
||||
Specify ``-`` for stdin/stdout.
|
||||
|
||||
Options:
|
||||
********
|
||||
|
||||
``-h, --help``
|
||||
Print help and exit
|
||||
|
||||
``-v, --version``
|
||||
Print version and exit
|
||||
|
||||
``-o, --format``
|
||||
Output format. Supported: gerber, gerber-outline (for board outline layers), svg, s-exp (KiCAD S-Expression)
|
||||
|
||||
``-p, --precision``
|
||||
Number of decimal places use for exported coordinates (gerber: 1-9, SVG: >=0). Note that not all gerber viewers are
|
||||
happy with too many digits. 5 or 6 is a reasonable choice.
|
||||
|
||||
``--clear-color``
|
||||
SVG color to use in SVG output for "clear" areas (default: white)
|
||||
|
||||
``--dark-color``
|
||||
SVG color to use in SVG output for "dark" areas (default: black)
|
||||
|
||||
``-f, --flip-gerber-polarity``
|
||||
Flip polarity of all output gerber primitives for --format gerber.
|
||||
|
||||
``-d, --trace-space``
|
||||
Minimum feature size of elements in vectorized graphics (trace/space) in mm. Default: 0.1mm.
|
||||
|
||||
``--no-header``
|
||||
Do not export output format header/footer, only export the primitives themselves
|
||||
|
||||
``--flatten``
|
||||
Flatten output so it only consists of non-overlapping white polygons. This perform composition at the vector level.
|
||||
Potentially slow. This defaults to on when using KiCAD S-Exp export because KiCAD does not know polarity or colors.
|
||||
|
||||
``--no-flatten``
|
||||
Disable automatic flattening for KiCAD S-Exp export
|
||||
|
||||
``--dilate``
|
||||
Dilate output gerber primitives by this amount in mm. Used for masking out other layers.
|
||||
|
||||
``-g, --only-groups``
|
||||
Comma-separated list of group IDs to export.
|
||||
|
||||
``-b, --vectorizer``
|
||||
Vectorizer to use for bitmap images. One of poisson-disc (default), hex-grid, square-grid, binary-contours,
|
||||
dev-null. Have a look at `the examples below <vectorization_>`_.
|
||||
|
||||
``--vectorizer-map``
|
||||
Map from image element id to vectorizer. Overrides --vectorizer. Format: id1=vectorizer,id2=vectorizer,...
|
||||
|
||||
You can use this to set a certain vectorizer for specific images, e.g. if you want to use both halftone
|
||||
vectorization and contour tracing in the same SVG. Note that you can set an ``<image>`` element's SVG ID from within
|
||||
Inkscape though the context menu's Object Properties tool.
|
||||
|
||||
``--force-svg``
|
||||
Force SVG input irrespective of file name
|
||||
|
||||
``--force-png``
|
||||
Force bitmap graphics input irrespective of file name
|
||||
|
||||
``-s, --size``
|
||||
Bitmap mode only: Physical size of output image in mm. Format: 12.34x56.78
|
||||
|
||||
``--sexp-mod-name``
|
||||
Module name for KiCAD S-Exp output. This is a mandatory argument if using S-Exp output.
|
||||
|
||||
``--sexp-layer``
|
||||
Layer for KiCAD S-Exp output. Defaults to auto-detect layers from SVG layer/top-level group IDs. If given, SVG
|
||||
groups and layers are completely ignored and everything is simply vectorized into this layer, though you cna still
|
||||
use ``-g`` for group selection.
|
||||
|
||||
``-a, --preserve-aspect-ratio``
|
||||
Bitmap mode only: Preserve aspect ratio of image. Allowed values are meet, slice. Can also parse full SVG
|
||||
preserveAspectRatio syntax.
|
||||
|
||||
``--no-usvg``
|
||||
Do not preprocess input using usvg (do not use unless you know *exactly* what you're doing)
|
||||
|
||||
``--usvg-dpi``
|
||||
Passed through to usvg's --dpi, in case the input file has different ideas of DPI than usvg has.
|
||||
|
||||
``--scale``
|
||||
Scale input svg lengths by this factor (-o gerber only).
|
||||
|
||||
``-e, --exclude-groups``
|
||||
Comma-separated list of group IDs to exclude from export. Takes precedence over --only-groups.
|
||||
|
||||
.. _vectorization:
|
||||
|
||||
Gerbolyze image vectorization
|
||||
-----------------------------
|
||||
|
||||
Gerbolyze has two built-in strategies to translate pixel images into vector images. One is its built-in halftone
|
||||
processor that tries to approximate grayscale. The other is its built-in binary vectorizer that traces contours in
|
||||
black-and-white images. Below are examples for the four options.
|
||||
|
||||
The vectorizers can be used in isolation through ``svg-flatten`` with either an SVG input that contains an image or a
|
||||
PNG/JPG input.
|
||||
|
||||
The vectorizer can be controlled globally using the ``--vectorizer`` flag in both ``gerbolyze`` and ``svg-flatten``. It
|
||||
can also be set on a per-image basis in both using ``--vectorizer-map [image svg id]=[option]["," ...]``.
|
||||
|
||||
.. for f in vec_*.png; convert -background white -gravity center $f -resize 500x500 -extent 500x500 (basename -s .png $f)-square.png; end
|
||||
.. for vec in hexgrid square poisson contours; convert vec_"$vec"_whole-square.png vec_"$vec"_detail-square.png -background transparent -splice 25x0+0+0 +append -chop 25x0+0+0 vec_"$vec"_composited.png; end
|
||||
|
||||
``--vectorizer poisson-disc`` (the default)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. image:: pics/vec_poisson_composited.png
|
||||
:width: 800px
|
||||
|
||||
``--vectorizer hex-grid``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. image:: pics/vec_hexgrid_composited.png
|
||||
:width: 800px
|
||||
|
||||
``--vectorizer square-grid``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. image:: pics/vec_square_composited.png
|
||||
:width: 800px
|
||||
|
||||
``--vectorizer binary-contours``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. image:: pics/vec_contours_composited.png
|
||||
:width: 800px
|
||||
|
||||
The binary contours vectorizer requires a black-and-white binary input image. As you can see, like every bitmap tracer
|
||||
it will produce some artifacts. For artistic input this is usually not too bad as long as the input data is
|
||||
high-resolution. Antialiased edges in the input image are not only OK, they may even help with an accurate
|
||||
vectorization.
|
||||
|
||||
GIMP halftone preprocessing guide
|
||||
---------------------------------
|
||||
|
||||
Gerbolyze has its own built-in halftone processor, but you can also use the high-quality "newsprint" filter built into
|
||||
GIMP_ instead if you like. This section will guide you through this. The PNG you get out of this can then be fed into
|
||||
gerbolyze using ``--vectorizer binary-contours``.
|
||||
|
||||
1 Import your desired artwork
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Though anime or manga pictures are highly recommended, you can use any image including photographs. Be careful to select
|
||||
a picture with comparatively low detail that remains recognizable at very low resolution. While working on a screen this
|
||||
is hard to vizualize, but the grain resulting from the low resolution of a PCB's silkscreen is quite coarse.
|
||||
|
||||
.. image:: https://raw.githubusercontent.com/jaseg/gerbolyze/master/screenshots/02import02.png
|
||||
.. image:: screenshots/02import02.png
|
||||
:width: 800px
|
||||
|
||||
3 Paste the artwork onto the render as a new layer
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. image:: https://raw.githubusercontent.com/jaseg/gerbolyze/master/screenshots/03paste.png
|
||||
|
||||
4 Scale, rotate and position the artwork to the desired size
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. image:: https://raw.githubusercontent.com/jaseg/gerbolyze/master/screenshots/04scale_cut.png
|
||||
|
||||
For alignment it may help to set the artwork layer's mode in the layers dialog to ``overlay``, which makes the PCB
|
||||
render layer below shine through more. If you can't set the layer's mode, make sure you have actually made a new layer
|
||||
from the floating selection you get when pasting one image into another in the GIMP.
|
||||
|
||||
.. image:: https://raw.githubusercontent.com/jaseg/gerbolyze/master/screenshots/05position.png
|
||||
|
||||
5 Convert the image to grayscale
|
||||
2 Convert the image to grayscale
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. image:: https://raw.githubusercontent.com/jaseg/gerbolyze/master/screenshots/06grayscale.png
|
||||
.. image:: screenshots/06grayscale.png
|
||||
:width: 800px
|
||||
|
||||
6 Fine-tune the image's contrast
|
||||
3 Fine-tune the image's contrast
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
To look well on the PCB, contrast is critical. If your source image is in color, you may have lost some contrast during
|
||||
|
|
@ -92,9 +546,10 @@ dots that might be beyond your PCB manufacturer's maximum resolution. To control
|
|||
of the grayscale value curve as shown (exaggerated) in the picture below. These steps saturate very bright grays to
|
||||
white and very dark grays to black while preserving the values in the middle.
|
||||
|
||||
.. image:: https://raw.githubusercontent.com/jaseg/gerbolyze/master/screenshots/08curve_cut.png
|
||||
.. image:: screenshots/08curve_cut.png
|
||||
:width: 800px
|
||||
|
||||
7 Retouch details
|
||||
4 Retouch details
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
Therer might be small details that don't look right yet, such as the image's background color or small highlights that
|
||||
|
|
@ -105,14 +560,16 @@ If you don't want the image's background to show up on the final PCB at all, jus
|
|||
Particularly on low-resolution source images it may make sense to apply a blur with a radius similar to the following
|
||||
newsprint filter's cell size (10px) to smooth out the dot pattern generated by the newsprint filter.
|
||||
|
||||
.. image:: https://raw.githubusercontent.com/jaseg/gerbolyze/master/screenshots/09retouch.png
|
||||
.. image:: screenshots/09retouch.png
|
||||
:width: 800px
|
||||
|
||||
In the following example, I retouched the highlights in the hair of the character in the picture to make them completely
|
||||
white instead of light-gray, so they still stand out nicely in the finished picture.
|
||||
|
||||
.. image:: https://raw.githubusercontent.com/jaseg/gerbolyze/master/screenshots/10retouched.png
|
||||
.. image:: screenshots/10retouched.png
|
||||
:width: 800px
|
||||
|
||||
8 Run the newsprint filter
|
||||
5 Run the newsprint filter
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Now, run the GIMP's newsprint filter, under filters, distorts, newsprint.
|
||||
|
|
@ -123,32 +580,131 @@ with ``gerbolyze render`` default settings for good-quality silkscreen). In gene
|
|||
The second important setting is oversampling, which should be set to four or slightly higher. This improves the result
|
||||
of the edge reconstruction of ``gerbolyze vectorize``.
|
||||
|
||||
.. image:: https://raw.githubusercontent.com/jaseg/gerbolyze/master/screenshots/11newsprint.png
|
||||
.. image:: screenshots/11newsprint.png
|
||||
:width: 800px
|
||||
|
||||
The following are examples on the detail resulting from the newsprint filter.
|
||||
|
||||
.. image:: https://raw.githubusercontent.com/jaseg/gerbolyze/master/screenshots/12newsprint.png
|
||||
.. image:: screenshots/12newsprint.png
|
||||
:width: 800px
|
||||
|
||||
.. image:: https://raw.githubusercontent.com/jaseg/gerbolyze/master/screenshots/13newsprint.png
|
||||
|
||||
.. image:: https://raw.githubusercontent.com/jaseg/gerbolyze/master/screenshots/14newsprint.png
|
||||
|
||||
9 Export the image for use with ``gerbolyze vectorize``
|
||||
6 Export the image for use with ``gerbolyze vectorize``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Simply export the image as a PNG file. Below are some pictures of the output ``gerbolyze vectorize`` produced for this
|
||||
example.
|
||||
|
||||
.. image:: https://raw.githubusercontent.com/jaseg/gerbolyze/master/screenshots/14result_cut.png
|
||||
.. image:: screenshots/14result_cut.png
|
||||
:width: 800px
|
||||
|
||||
.. image:: https://raw.githubusercontent.com/jaseg/gerbolyze/master/screenshots/15result_cut.png
|
||||
.. image:: screenshots/15result_cut.png
|
||||
:width: 800px
|
||||
|
||||
.. image:: https://raw.githubusercontent.com/jaseg/gerbolyze/master/screenshots/16result_cut.png
|
||||
Manufacturing Considerations
|
||||
----------------------------
|
||||
|
||||
The main consideration when designing artwork for PCB processes is the processes' trace/space design rule. The two
|
||||
things you can do here is one, to be creative with graphical parts of the design and avoid extremely narrow lines,
|
||||
wedges or other thin features that will not come out well. Number two is to keep detail in raster images several times
|
||||
larger than the manufacturing processes native capability. For example, to target a trace/space design rule of 100 µm,
|
||||
the smallest detail in embedded raster graphics should not be much below 1mm.
|
||||
|
||||
Gerbolyze's halftone vectorizers have built-in support for trace/space design rules. While they can still produce small
|
||||
artifacts that violate these rules, their output should be close enough to satifsy board houses and close enough for the
|
||||
result to look good. The way gerbolyze does this is to clip the halftone cell's values to zero whenevery they get too
|
||||
small, and to forcefully split or merge two neighboring cells when they get too close. While this process introduces
|
||||
slight steps at the top and bottom of grayscale response, for most inputs these are not noticeable.
|
||||
|
||||
On the other hand, for SVG vector elements as well as for traced raster images, Gerbolyze cannot help with these design
|
||||
rules. There is no heuristic that would allow Gerbolyze to non-destructively "fix" a design here, so all that's on the
|
||||
roadmap here is to eventually include a gerber-level design rule checker.
|
||||
|
||||
As far as board houses go, I have made good experiences with the popular Chinese board houses. In my experience, JLC
|
||||
will just produce whatever you send them with little fucks being given about design rule adherence or validity of the
|
||||
input gerbers. This is great if you just want artistic circuit boards without much of a hassle, and you don't care if
|
||||
they come out exactly as you imagined. The worst I've had happen was when an older version of gerbolyze generated
|
||||
polygons with holes assuming standard fill-rule processing. The in the board house's online gerber viewer things looked
|
||||
fine, and neither did they complain during file review. However, the resulting boards looked completely wrong because
|
||||
all the dark halftones were missing.
|
||||
|
||||
PCBWay on the other hand has a much more rigurous file review process. They <em>will</em> complain when you throw
|
||||
illegal garbage gerbers at them, and they will helpfully guide you through your design rule violations. In this way you
|
||||
get much more of a professional service from them and for designs that have to be functional their higher level of
|
||||
scrutiny definitely is a good thing. For the design you saw in the first picture in this article, I ended up begging
|
||||
them to just plot my files if it doesn't physically break their machines and to their credit, while they seemed unhappy
|
||||
about it they did it and the result looks absolutely stunning.
|
||||
|
||||
PCBWay is a bit more expensive on their lowest-end offering than JLC, but I found that for anything else (large boards,
|
||||
multi-layer, gold plating etc.) their prices match. PCBWay offers a much broader range of manufacturing options such as
|
||||
flexible circuit boards, multi-layer boards, thick or thin substrates and high-temperature substrates.
|
||||
|
||||
When in doubt about how your design is going to come out on the board, do not hesitate to contact your board house. Most
|
||||
of the end customer-facing online PCB services have a number of different factories that do a number of different
|
||||
fabrication processes for them depending on order parameters. Places like PCBWay have exceptional quality control and
|
||||
good customer service, but that is mostly focused on the technical aspects of the PCB. If you rely on visual aspects
|
||||
like silkscreen uniformity or solder mask color that is a strong no concern to everyone else in the electronics
|
||||
industry, you may find significant variations between manufacturers or even between orders with the same manufacturer
|
||||
and you may encounter challenges communicating your requirements.
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
|
||||
SVG raster features
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Currently, SVG masks and filters are not supported. Though SVG is marketed as a "vector graphics format", these two
|
||||
features are really raster primitives that all SVG viewers perform at the pixel level after rasterization. Since
|
||||
supporting these would likely not end up looking like what you want, it is not a planned feature. If you need masks or
|
||||
filters, simply export the relevant parts of the SVG as a PNG then include that in your template.
|
||||
|
||||
Gerber pass-through
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Since gerbolyze has to composite your input gerbers with its own output, it has to fully parse and re-serialize them.
|
||||
gerbolyze gerbonara_ for all its gerber parsing needs. Thus, gerbonara will interpret your gerbers and output will be in
|
||||
gerbonara's gerber "dialect". If you find a corner case where this does not work and the output looks wrong, please file
|
||||
a bug report with an example file on the gerbonara_ bug tracker. *Always* check the output files for errors before
|
||||
submitting them to production.
|
||||
|
||||
Gerbolyze is provided without any warranty, but still please open an issue or `send me an email
|
||||
<mailto:gerbolyze@jaseg.de>`__ if you find any errors or inconsistencies.
|
||||
|
||||
Trace/Space design rule adherence
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
While the grayscale halftone vectorizers do a reasonable job adhering to a given trace/space design rule, they can still
|
||||
produce small parts of output that violate it. For the contour vectorizer as well as for all SVG primitives, you are
|
||||
responsible for adhering to design rules yourself as there is no algorithm that gerboyze could use to "fix" its input.
|
||||
|
||||
A design rule checker is planned as a future addition to gerbolyze, but is not yet part of it. If in doubt, talk to your
|
||||
fab and consider doing a test run of your design before ordering assembled boards ;)
|
||||
|
||||
Gallery
|
||||
-------
|
||||
|
||||
.. image:: https://raw.githubusercontent.com/jaseg/gerbolyze/master/sample2.jpg
|
||||
.. image:: pics/sample3.jpg
|
||||
:width: 400px
|
||||
|
||||
.. image:: https://raw.githubusercontent.com/jaseg/gerbolyze/master/sample3.jpg
|
||||
For a demonstration of ``gerbolyze convert``, check out the `Gerbolyze Protoboard Index`_, where you can download gerber
|
||||
files for over 7.000 SMD and THT protoboard layouts.
|
||||
|
||||
Licensing
|
||||
---------
|
||||
|
||||
This tool is licensed under the rather radical AGPLv3 license. Briefly, this means that you have to provide users of a
|
||||
webapp using this tool in the backend with this tool's source.
|
||||
|
||||
I get that some people have issues with the AGPL. In case this license prevents you from using this software, please
|
||||
send me `an email <mailto:agpl.sucks@jaseg.de>`__ and I can grant you an exception. I want this software to be useful to as
|
||||
many people as possible and I wouldn't want the license to be a hurdle to anyone. OTOH I see a danger of some cheap
|
||||
board house just integrating a fork into their webpage without providing their changes back upstream, and I want to
|
||||
avoid that so the default license is still AGPL.
|
||||
|
||||
.. _usvg: https://github.com/RazrFalcon/resvg
|
||||
.. _Inkscape: https://inkscape.org/
|
||||
.. _pcb-tools: https://github.com/curtacircuitos/pcb-tools
|
||||
.. _pcb-tools-extension: https://github.com/opiopan/pcb-tools-extension
|
||||
.. _GIMP: https://gimp.org/
|
||||
.. _gerbonara: https://gitlab.com/gerbolyze/gerbonara
|
||||
.. _`Gerbolyze Protoboard Index`: https://dyna.kokoroyukuma.de/protos/
|
||||
|
||||
|
|
|
|||
8
TODO
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
[ ] Do not just return "error 255" if usvg is not installed
|
||||
[ ] Straighten up svg-flatten input unit handling
|
||||
[x] split up python code into modules
|
||||
[x] Add backwards-compatible vectorize drop-in
|
||||
[x] Figure out handling of drill layers
|
||||
[x] Re-publish my own pcb-tools, pcb-tools-extension forks with actual maintenance
|
||||
[ ] For pattern rendering: validate pattern origin aligns with what the svg spec expects
|
||||
[ ] Invert SVG color interpretation (use saturation maybe? or sat * val?)
|
||||
5
bin/gerbolyze
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
if __name__ == '__main__':
|
||||
import gerbolyze
|
||||
gerbolyze.cli()
|
||||
26
export_previews.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import multiprocessing as mp
|
||||
import subprocess
|
||||
import pathlib
|
||||
|
||||
import click
|
||||
from tqdm import tqdm
|
||||
|
||||
def process_file(indir, outdir, inpath):
|
||||
outpath = outdir / inpath.relative_to(indir).with_suffix('.png')
|
||||
outpath.parent.mkdir(parents=True, exist_ok=True)
|
||||
subprocess.run(['resvg', '--export-id', 'g-top-copper', '--width', '1000', inpath, outpath],
|
||||
check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
|
||||
@click.command()
|
||||
@click.argument('indir', type=click.Path(exists=True, file_okay=False, dir_okay=True, path_type=pathlib.Path))
|
||||
def export(indir):
|
||||
jobs = list(indir.glob('svg/**/*.svg'))
|
||||
with tqdm(total = len(jobs)) as tq:
|
||||
with mp.Pool() as pool:
|
||||
results = [ pool.apply_async(process_file, (indir / 'svg', indir / 'png', path), callback=lambda _res: tq.update(1)) for path in jobs ]
|
||||
results = [ res.get() for res in results ]
|
||||
|
||||
if __name__ == '__main__':
|
||||
export()
|
||||
26
export_protoboards.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import multiprocessing as mp
|
||||
import subprocess
|
||||
import pathlib
|
||||
|
||||
import click
|
||||
from tqdm import tqdm
|
||||
|
||||
def process_file(indir, outdir, inpath):
|
||||
outpath = outdir / inpath.relative_to(indir).with_suffix('.zip')
|
||||
outpath.parent.mkdir(parents=True, exist_ok=True)
|
||||
subprocess.run('python3 -m gerbolyze convert --zip --pattern-complete-tiles-only --use-apertures-for-patterns'.split() + [inpath, outpath],
|
||||
check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
|
||||
@click.command()
|
||||
@click.argument('indir', type=click.Path(exists=True, file_okay=False, dir_okay=True, path_type=pathlib.Path))
|
||||
def export(indir):
|
||||
jobs = list(indir.glob('svg/**/*.svg'))
|
||||
with tqdm(total = len(jobs)) as tq:
|
||||
with mp.Pool() as pool:
|
||||
results = [ pool.apply_async(process_file, (indir / 'svg', indir / 'gerber', path), callback=lambda _res: tq.update(1)) for path in jobs ]
|
||||
results = [ res.get() for res in results ]
|
||||
|
||||
if __name__ == '__main__':
|
||||
export()
|
||||
550
generate_protoboards.py
Normal file
|
|
@ -0,0 +1,550 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import itertools
|
||||
import pathlib
|
||||
import textwrap
|
||||
|
||||
import click
|
||||
|
||||
from gerbolyze.protoboard import ProtoBoard, EmptyProtoArea, THTProtoArea, SMDProtoAreaRectangles, ManhattanProtoArea
|
||||
|
||||
common_defs = '''
|
||||
empty = Empty(copper=False);
|
||||
ground = Empty(copper=True);
|
||||
|
||||
tht = THTPads();
|
||||
thtsq = THTPads(pad_shape="square");
|
||||
thtl = THTPads(drill=1.2);
|
||||
thtxl = THTPads(drill=1.6, pad_size=2.1, pad_shape="square");
|
||||
tht50 = THTPads(pad_size=1.0, drill=0.6, pitch=1.27);
|
||||
tht50sq = THTPads(pad_size=1.0, drill=0.6, pitch=1.27, pad_shape="square");
|
||||
manhattan = Manhattan();
|
||||
|
||||
conn125 = THTPads(drill=0.6, pad_size=1.0, pitch=1.25);
|
||||
conn250 = THTPads(drill=1.0, pad_size=1.6, pitch=2.00);
|
||||
conn200 = THTPads(drill=1.2, pad_size=2.0, pitch=2.50);
|
||||
conn350 = THTPads(drill=1.6, pad_size=2.8, pitch=3.50);
|
||||
conn396 = THTPads(drill=1.6, pad_size=2.8, pitch=3.96);
|
||||
|
||||
smd100 = SMDPads(1.27, 2.54);
|
||||
smd100r = SMDPads(2.54, 1.27);
|
||||
smd950 = SMDPads(0.95, 2.5);
|
||||
smd950r = SMDPads(2.5, 0.95);
|
||||
smd800 = SMDPads(0.80, 2.0);
|
||||
smd800r = SMDPads(2.0, 0.80);
|
||||
smd650 = SMDPads(0.65, 2.0);
|
||||
smd650r = SMDPads(2.0, 0.65);
|
||||
smd500 = SMDPads(0.5, 2.0);
|
||||
smd500r = SMDPads(2.0, 0.5);
|
||||
'''
|
||||
|
||||
|
||||
smd_basic = {
|
||||
'smd100': 'smd_soic_100mil',
|
||||
'smd950': 'smd_sot_950um',
|
||||
'smd800': 'smd_sop_800um',
|
||||
'smd650': 'smd_sot_650um',
|
||||
'smd500': 'smd_sop_500um',
|
||||
'manhattan': 'manhattan_400mil'}
|
||||
|
||||
connector_pitches = {
|
||||
'tht50': '50mil',
|
||||
'conn125': '1.25mm',
|
||||
'conn200': '2.00mm',
|
||||
'conn250': '2.50mm',
|
||||
'conn350': '3.50mm',
|
||||
'conn396': '3.96mm',
|
||||
}
|
||||
|
||||
#lengths_large = [15, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 90, 100, 120, 150, 160, 180, 200, 250, 300]
|
||||
lengths_large = [30, 40, 50, 60, 80, 100, 120, 150, 160]
|
||||
sizes_large = list(itertools.combinations(lengths_large, 2))
|
||||
|
||||
lengths_small = [15, 20, 25, 30, 40, 50, 60, 80, 100]
|
||||
sizes_small = list(itertools.combinations(lengths_small, 2))
|
||||
|
||||
lengths_medium = lengths_large
|
||||
sizes_medium = list(itertools.combinations(lengths_medium, 2))
|
||||
|
||||
def min_dim(sizes, dim):
|
||||
return [(w, h) for w, h in sizes if w > dim and h > dim]
|
||||
|
||||
def write_index(index, outdir):
|
||||
tht_pitches = lambda patterns: [ p.pitch for p in patterns if isinstance(p, THTProtoArea) ]
|
||||
smd_pitches = lambda patterns: [ min(p.pitch_x, p.pitch_y) for p in patterns if isinstance(p, SMDProtoAreaRectangles) ]
|
||||
has_ground_plane = lambda patterns: any(isinstance(p, EmptyProtoArea) and p.copper for p in patterns)
|
||||
has_manhattan_area = lambda patterns: any(isinstance(p, ManhattanProtoArea) for p in patterns)
|
||||
has_square_pads = lambda patterns: any(isinstance(p, THTProtoArea) and p.pad_shape == 'square' for p in patterns)
|
||||
has_large_holes = lambda patterns: any(isinstance(p, THTProtoArea) and abs(p.pitch_x - 2.54) < 0.01 and p.drill > 1.1 for p in patterns)
|
||||
format_pitches = lambda pitches: ', '.join(f'{p:.2f}' for p in sorted(pitches))
|
||||
format_length = lambda length_or_none, default='': default if length_or_none is None else f'{length_or_none:.2f} mm'
|
||||
area_count = lambda patterns: len(set(p for p in patterns if not isinstance(p, EmptyProtoArea)))
|
||||
|
||||
table_rows = [
|
||||
('<tr>'
|
||||
f'<td><a href="gerber/{path.relative_to(outdir / "svg").with_suffix(".zip")}" download>Gerber</a></td>'
|
||||
f'<td><a href="png/{path.relative_to(outdir / "svg").with_suffix(".png")}">Preview</a></td>'
|
||||
f'<td><a href="{path.relative_to(outdir)}" download>SVG</a></td>'
|
||||
f'<td>{w:.2f}</td>'
|
||||
f'<td>{h:.2f}</td>'
|
||||
f'<td>{"Yes" if hole_dia is not None else "No"}</td>'
|
||||
f'<td>{f"{hole_dia:.2f}" if hole_dia is not None else ""}</td>'
|
||||
f'<td>{area_count(patterns)}</td>'
|
||||
f'<td>{"Yes" if symmetric else "No"}</td>'
|
||||
f'<td>{"Yes" if has_ground_plane(patterns) else "No"}</td>'
|
||||
f'<td>{"Yes" if has_manhattan_area(patterns) else "No"}</td>'
|
||||
f'<td>{"Yes" if has_square_pads(patterns) else "No"}</td>'
|
||||
f'<td>{"Yes" if has_large_holes(patterns) else "No"}</td>'
|
||||
f'<td>{format_pitches(tht_pitches(patterns))}</td>'
|
||||
f'<td>{format_pitches(smd_pitches(patterns))}</td>'
|
||||
'</tr>')
|
||||
for path, (w, h, hole_dia, symmetric, patterns) in index.items()
|
||||
]
|
||||
table_content = '\n'.join(table_rows)
|
||||
length_sort = lambda length: float(length.partition(' ')[0])
|
||||
filter_cols = {
|
||||
'Width': sorted(set(w for w, h, *rest in index.values())),
|
||||
'Height': sorted(set(h for w, h, *rest in index.values())),
|
||||
'Mounting Hole Diameter': sorted(set(dia for w, h, dia, *rest in index.values() if dia)) + ['None'],
|
||||
'Number of Areas': sorted(set(area_count(patterns) for *_rest, patterns in index.values())),
|
||||
'Symmetric Top and Bottom?': ['Yes', 'No'],
|
||||
'Ground Plane?': ['Yes', 'No'],
|
||||
'Manhattan Area?': ['Yes', 'No'],
|
||||
'Square Pads?': ['Yes', 'No'],
|
||||
'Large Holes?': ['Yes', 'No'],
|
||||
'THT Pitches': sorted(set(p for *_rest, patterns in index.values() for p in tht_pitches(patterns))) + ['None'],
|
||||
'SMD Pitches': sorted(set(p for *_rest, patterns in index.values() for p in smd_pitches(patterns))) + ['None'],
|
||||
}
|
||||
filter_headers = '\n'.join(f'<th>{key}</th>' for key in filter_cols)
|
||||
key_id = lambda key: key.lower().replace("?", "").replace(" ", "_")
|
||||
val_id = lambda value: str(value).replace(".", "_")
|
||||
|
||||
def format_value(value):
|
||||
if isinstance(value, str):
|
||||
return value
|
||||
elif isinstance(value, int):
|
||||
return str(value)
|
||||
elif isinstance(value, bool):
|
||||
return value and 'Yes' or 'No'
|
||||
else:
|
||||
return format_length(value)
|
||||
|
||||
filter_cols = {
|
||||
key: '\n'.join(f'<div class="filter-check"><input type="checkbox" id="check-{key_id(key)}-{val_id(value)}"><label for="check-{key_id(key)}-{val_id(value)}">{format_value(value)}</label></div>' for value in values)
|
||||
for key, values in filter_cols.items() }
|
||||
filter_cols = [f'<td id="filter-{key_id(key)}">{values}</td>' for key, values in filter_cols.items()]
|
||||
filter_content = '\n'.join(filter_cols)
|
||||
|
||||
filter_js = textwrap.dedent('''
|
||||
function get_filters(){
|
||||
let filters = {};
|
||||
table = document.querySelector('#filter');
|
||||
for (let filter of table.querySelectorAll('td')) {
|
||||
selected = [];
|
||||
for (let checkbox of filter.querySelectorAll('input')) {
|
||||
if (checkbox.checked) {
|
||||
selected.push(checkbox.nextElementSibling.textContent.replace(/ mm$/, ''));
|
||||
}
|
||||
}
|
||||
filters[filter.id.replace(/^filter-/, '')] = selected;
|
||||
}
|
||||
return filters;
|
||||
}
|
||||
|
||||
filter_indices = {
|
||||
};
|
||||
for (const [i, header] of document.querySelectorAll("#listing th").entries()) {
|
||||
if (header.hasAttribute('data-filter-key')) {
|
||||
filter_indices[header.attributes['data-filter-key'].value] = i;
|
||||
}
|
||||
}
|
||||
|
||||
function filter_row(filters, row) {
|
||||
cols = row.querySelectorAll('td');
|
||||
|
||||
for (const [filter_id, values] of Object.entries(filters)) {
|
||||
if (values.length == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const row_value = cols[filter_indices[filter_id]].textContent;
|
||||
|
||||
if (values.includes("None") && !row_value) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (values.includes(row_value)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
let timeout = undefined;
|
||||
function apply_filters() {
|
||||
if (timeout) {
|
||||
clearTimeout(timeout);
|
||||
timeout = undefined;
|
||||
}
|
||||
const filters = get_filters();
|
||||
for (let row of document.querySelectorAll("#listing tbody tr")) {
|
||||
if (filter_row(filters, row)) {
|
||||
row.style.display = '';
|
||||
} else {
|
||||
row.style.display = 'none';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function refresh_filters() {
|
||||
if (timeout) {
|
||||
clearTimeout(timeout);
|
||||
}
|
||||
timeout = setTimeout(apply_filters, 2000);
|
||||
}
|
||||
|
||||
function reset_filters() {
|
||||
for (let checkbox of document.querySelectorAll("#filter input")) {
|
||||
checkbox.checked = false;
|
||||
}
|
||||
refresh_filters();
|
||||
}
|
||||
|
||||
document.querySelector("#apply").onclick = apply_filters;
|
||||
document.querySelector("#reset-filters").onclick = reset_filters;
|
||||
for (let checkbox of document.querySelectorAll("#filter input")) {
|
||||
checkbox.onchange = refresh_filters;
|
||||
}
|
||||
|
||||
apply_filters();
|
||||
'''.strip())
|
||||
|
||||
style = textwrap.dedent('''
|
||||
:root {
|
||||
--gray1: #d0d0d0;
|
||||
--gray2: #eeeeee;
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
box-shadow: 0 0 3px gray;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
td {
|
||||
border: 1px solid var(--gray1);
|
||||
padding: .1em .5em;
|
||||
}
|
||||
|
||||
th {
|
||||
border: 1px solid var(--gray1);
|
||||
padding: .5em;
|
||||
background: linear-gradient(0deg, #e0e0e0, #eeeeee);
|
||||
}
|
||||
|
||||
#listing tr:hover {
|
||||
background-color: #ffff80;
|
||||
}
|
||||
|
||||
#listing tr td {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#listing tr td:nth-child(4), #listing tr td:nth-child(5) {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
#filter {
|
||||
margin-top: 2em;
|
||||
}
|
||||
|
||||
button {
|
||||
margin: 2em 0.2em;
|
||||
padding: .5em 1em;
|
||||
}
|
||||
|
||||
body {
|
||||
max-width: 80em;
|
||||
margin: 3em auto;
|
||||
}
|
||||
|
||||
body > div {
|
||||
width: 100%;
|
||||
}
|
||||
'''.strip())
|
||||
html = textwrap.dedent(f'''
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head><title>Gerbolyze Protoboard Index</title></head>
|
||||
<script src="tablesort.min.js"></script>
|
||||
<script src="tablesort.number.min.js"></script>
|
||||
<style>
|
||||
{style}
|
||||
</style>
|
||||
<body>
|
||||
<h1>Gerbolyze Protoboard Index</h1>
|
||||
<p>
|
||||
This page contains gerbers for many different types of prototype circuit boards. Everything from different pitches
|
||||
of THT hole patterns to SMD pad patterns is included in many different sizes and with several mounting hole options.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
All downloads on this page are licensed under the <a href="https://unlicense.org">Unlicense</a>. This means you can
|
||||
download what you like and do with it whatever you want. Just note that everything here is provided without any
|
||||
warranty, so if you send files you find here to a pcb board house and what you get back from them is all wrong,
|
||||
that's your problem.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
All files on this page have been generated automatically from a number of templates using
|
||||
<a href="https://gitlab.com/gerbolyze/gerbolyze/">gerbolyze</a>
|
||||
(<a href="https://github.com/jaseg/gerbolyze">github mirror</a>). If you have any suggestions for additional layouts
|
||||
or layout options, please feel free to file an issue on
|
||||
<a href="https://github.com/jaseg/gerbolyze/issues">Gerbolyze's issue tracker</a> on github.
|
||||
</p>
|
||||
<div id="filters-container">
|
||||
<table id="filter">
|
||||
<tr>
|
||||
{filter_headers}
|
||||
</tr>
|
||||
<tr>
|
||||
{filter_content}
|
||||
</tr>
|
||||
</table>
|
||||
<button type="button" id="apply">Apply</button>
|
||||
<button type="button" id="reset-filters">Reset filters</button>
|
||||
</div>
|
||||
<div id="listing-container">
|
||||
<table id="listing">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-sort-method="none" width="6em">Download</th>
|
||||
<th data-sort-method="none" width="6em">Preview</th>
|
||||
<th data-sort-method="none" width="3em">Source SVG</th>
|
||||
<th data-filter-key="width" width="3.5em">Width [mm]</th>
|
||||
<th data-filter-key="height" width="3.5em">Height [mm]</th>
|
||||
<th width="3em">Has Mounting Holes?</th>
|
||||
<th data-filter-key="mounting_hole_diameter" width="3em">Mounting Hole Diameter [mm]</th>
|
||||
<th data-filter-key="number_of_areas" width="3em">Number of Areas</th>
|
||||
<th data-filter-key="symmetric_top_and_bottom" width="3em">Symmetric Top and Bottom?</th>
|
||||
<th data-filter-key="ground_plane" width="3em">Ground Plane?</th>
|
||||
<th data-filter-key="manhattan_area" width="3em">Manhattan Area?</th>
|
||||
<th data-filter-key="square_pads" width="3em">Square Pads?</th>
|
||||
<th data-filter-key="large_holes" width="3em">Large Holes?</th>
|
||||
<th data-filter-key="tht_pitches">THT Pitches [mm]</th>
|
||||
<th data-filter-key="smd_pitches">SMD Pitches [mm]</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{table_content}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<script>
|
||||
new Tablesort(document.getElementById('listing'));
|
||||
|
||||
{filter_js}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
'''.strip())
|
||||
(outdir / 'index.html').write_text(html)
|
||||
|
||||
|
||||
def generate(outdir, fun, sizes=sizes_large, name=None, generate_svg=True):
|
||||
name = name or fun.__name__
|
||||
outdir = outdir / f'{name}'
|
||||
plain_dir = outdir / 'no_mounting_holes'
|
||||
plain_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
for w, h in sizes:
|
||||
outfile = plain_dir / f'{name}_{w}x{h}.svg'
|
||||
board = fun((w, h))
|
||||
yield outfile, (float(w), float(h), None, board.symmetric_sides, board.used_patterns)
|
||||
if generate_svg:
|
||||
outfile.write_text(board.generate(w, h))
|
||||
|
||||
for dia in (2, 2.5, 3, 4):
|
||||
hole_dir = outdir / f'mounting_holes_M{dia:.1f}'
|
||||
hole_dir.mkdir(exist_ok=True)
|
||||
|
||||
for w, h in sizes:
|
||||
if w < 25 or h < 25:
|
||||
continue
|
||||
outfile = hole_dir / f'{name}_{w}x{h}_holes_M{dia:.1f}.svg'
|
||||
try:
|
||||
# Add 0.2 mm tolerance to mounting holes for easier insertion of screw
|
||||
board = fun((w, h), (dia+0.2, dia+2))
|
||||
yield outfile, (float(w), float(h), float(dia), board.symmetric_sides, board.used_patterns)
|
||||
if generate_svg:
|
||||
outfile.write_text(board.generate(w, h))
|
||||
except ValueError: # mounting hole keepout too large for small board, ignore.
|
||||
pass
|
||||
|
||||
@click.command()
|
||||
@click.argument('outdir', type=click.Path(file_okay=False, dir_okay=True, path_type=pathlib.Path))
|
||||
@click.option('--generate-svg/--no-generate-svg')
|
||||
def generate_all(outdir, generate_svg):
|
||||
index_d = {}
|
||||
def index(sizes=sizes_large, name=None):
|
||||
def deco(fun):
|
||||
nonlocal index_d
|
||||
index_d.update(generate(outdir / 'svg', fun, sizes=sizes, name=name, generate_svg=generate_svg))
|
||||
return fun
|
||||
return deco
|
||||
|
||||
@index()
|
||||
def tht_normal_pitch100mil(size, mounting_holes=None):
|
||||
return ProtoBoard(common_defs, 'tht', mounting_holes, border=2)
|
||||
|
||||
@index()
|
||||
def tht_normal_pitch100mil_large_holes(size, mounting_holes=None):
|
||||
return ProtoBoard(common_defs, 'thtl', mounting_holes, border=2)
|
||||
|
||||
@index()
|
||||
def tht_normal_pitch100mil_xl_holes(size, mounting_holes=None):
|
||||
return ProtoBoard(common_defs, 'thtl', mounting_holes, border=2)
|
||||
|
||||
@index()
|
||||
def tht_normal_pitch100mil_square_pads(size, mounting_holes=None):
|
||||
return ProtoBoard(common_defs, 'thtl', mounting_holes, border=2)
|
||||
|
||||
@index()
|
||||
def tht_pitch_50mil(size, mounting_holes=None):
|
||||
return ProtoBoard(common_defs, 'tht50', mounting_holes, border=2)
|
||||
|
||||
@index()
|
||||
def tht_pitch_50mil_square_pads(size, mounting_holes=None):
|
||||
return ProtoBoard(common_defs, 'tht50', mounting_holes, border=2)
|
||||
|
||||
@index()
|
||||
def tht_mixed_pitch(size, mounting_holes=None):
|
||||
w, h = size
|
||||
f = max(1.27*5, min(30, h*0.3))
|
||||
return ProtoBoard(common_defs, f'tht50@{f}mm / tht', mounting_holes, border=2, tight_layout=True)
|
||||
|
||||
@index()
|
||||
def tht_mixed_pitch_square_pads(size, mounting_holes=None):
|
||||
w, h = size
|
||||
f = max(1.27*5, min(30, h*0.3))
|
||||
return ProtoBoard(common_defs, f'tht50@{f}mm / tht', mounting_holes, border=2, tight_layout=True)
|
||||
|
||||
for pattern, name in connector_pitches.items():
|
||||
@index(name=f'tht_and_connector_area_{name}')
|
||||
def tht_and_connector_area(size, mounting_holes=None):
|
||||
w, h = size
|
||||
f = max(3.96*2.1, min(15, h*0.1))
|
||||
return ProtoBoard(common_defs, f'{pattern}@{f}mm / tht', border=2, tight_layout=True)
|
||||
|
||||
@index()
|
||||
def tht_and_connector_areas(size, mounting_holes=None):
|
||||
w, h = size
|
||||
fh = max(3.96*2.1, min(15, h*0.1))
|
||||
fw = max(3.96*2.1, min(15, w*0.1))
|
||||
return ProtoBoard(common_defs, f'conn396@{fw}mm | ((tht50 | conn200)@{fh}mm / tht / (conn125|conn250)@{fh}mm) | conn350@{fw}mm', border=2, tight_layout=True)
|
||||
|
||||
for pattern, name in smd_basic.items():
|
||||
pattern_sizes = sizes_small if pattern not in ['manhattan'] else sizes_medium
|
||||
# Default to ground plane on back for manhattan proto boards
|
||||
pattern_back = pattern if pattern not in ['manhattan'] else 'ground'
|
||||
|
||||
@index(sizes=pattern_sizes, name=f'{name}_ground_plane')
|
||||
def gen(size, mounting_holes=None):
|
||||
return ProtoBoard(common_defs, f'{pattern} + ground', mounting_holes, border=1)
|
||||
|
||||
@index(sizes=pattern_sizes, name=f'{name}_single_side')
|
||||
def gen(size, mounting_holes=None):
|
||||
return ProtoBoard(common_defs, f'{pattern} + empty', mounting_holes, border=1)
|
||||
|
||||
@index(sizes=pattern_sizes, name=f'{name}_double_side')
|
||||
def gen(size, mounting_holes=None):
|
||||
return ProtoBoard(common_defs, f'{pattern} + {pattern}', mounting_holes, border=1)
|
||||
|
||||
@index(sizes=pattern_sizes, name=f'tht_and_{name}_large_holes')
|
||||
def gen(size, mounting_holes=None):
|
||||
w, h = size
|
||||
f = max(1.27*5, min(30, h*0.3))
|
||||
return ProtoBoard(common_defs, f'({pattern} + {pattern_back})@{f}mm / thtl', mounting_holes, border=1, tight_layout=True)
|
||||
|
||||
@index(sizes=pattern_sizes, name=f'{name}_and_tht_large_holes')
|
||||
def gen(size, mounting_holes=None):
|
||||
w, h = size
|
||||
f = max(1.27*5, min(30, h*0.3))
|
||||
return ProtoBoard(common_defs, f'({pattern} + {pattern_back}) / thtl@{f}mm', mounting_holes, border=1, tight_layout=True)
|
||||
|
||||
@index(sizes=pattern_sizes, name=f'tht_and_{name}')
|
||||
def gen(size, mounting_holes=None):
|
||||
w, h = size
|
||||
f = max(1.27*5, min(30, h*0.3))
|
||||
return ProtoBoard(common_defs, f'({pattern} + {pattern_back})@{f}mm / tht', mounting_holes, border=1, tight_layout=True)
|
||||
|
||||
@index(sizes=pattern_sizes, name=f'{name}_and_tht')
|
||||
def gen(size, mounting_holes=None):
|
||||
w, h = size
|
||||
f = max(1.27*5, min(30, h*0.3))
|
||||
return ProtoBoard(common_defs, f'({pattern} + {pattern_back}) / tht@{f}mm', mounting_holes, border=1, tight_layout=True)
|
||||
|
||||
@index(sizes=min_dim(pattern_sizes, 20), name=f'{name}_and_connector_areas')
|
||||
def gen(size, mounting_holes=None):
|
||||
w, h = size
|
||||
fh = max(3.96*2.1, min(15, h*0.1))
|
||||
fw = max(3.96*2.1, min(15, w*0.1))
|
||||
return ProtoBoard(common_defs, f'conn396@{fw}mm | ((tht50 | conn200)@{fh}mm / ({pattern} + {pattern_back}) / (conn125|conn250)@{fh}mm) | conn350@{fw}mm', border=2, tight_layout=True)
|
||||
|
||||
*_, suffix = name.split('_')
|
||||
if suffix not in ('100mil', '950um'):
|
||||
@index(sizes=sizes_medium, name=f'tht_and_three_smd_100mil_950um_{suffix}')
|
||||
def gen(size, mounting_holes=None):
|
||||
w, h = size
|
||||
f = max(1.27*5, min(50, h*0.3))
|
||||
f2 = max(1.27*5, min(30, w*0.2))
|
||||
pattern_rot = f'{pattern}r' if pattern not in ['manhattan'] else pattern
|
||||
pattern_back_rot = f'{pattern_back}r' if pattern not in ['manhattan'] else 'ground'
|
||||
return ProtoBoard(common_defs, f'((smd100 + smd100) | (smd950 + smd950) | ({pattern_rot} + {pattern_back_rot})@{f2}mm)@{f}mm / tht', mounting_holes, border=1, tight_layout=True)
|
||||
|
||||
for (pattern1, name1), (pattern2, name2) in itertools.combinations(smd_basic.items(), 2):
|
||||
*_, name1 = name1.split('_')
|
||||
*_, name2 = name2.split('_')
|
||||
|
||||
@index(sizes=sizes_small, name=f'tht_and_two_smd_{name1}_{name2}')
|
||||
def gen(size, mounting_holes=None):
|
||||
w, h = size
|
||||
f = max(1.27*5, min(30, h*0.3))
|
||||
return ProtoBoard(common_defs, f'(({pattern1} + {pattern1}) | ({pattern2} + {pattern2}))@{f}mm / tht', mounting_holes, border=1, tight_layout=True)
|
||||
|
||||
@index(sizes=sizes_small, name=f'tht_and_two_sided_smd_{name1}_{name2}')
|
||||
def gen(size, mounting_holes=None):
|
||||
w, h = size
|
||||
f = max(1.27*5, min(30, h*0.3))
|
||||
return ProtoBoard(common_defs, f'({pattern1} + {pattern2})@{f}mm / tht', mounting_holes, border=1, tight_layout=True)
|
||||
|
||||
@index(sizes=sizes_small, name=f'two_sided_smd_{name1}_{name2}')
|
||||
def gen(size, mounting_holes=None):
|
||||
w, h = size
|
||||
f = max(1.27*5, min(30, h*0.3))
|
||||
return ProtoBoard(common_defs, f'{pattern1} + {pattern2}', mounting_holes, border=1)
|
||||
|
||||
@index(sizes_medium, name=f'tht_and_50mil_and_two_smd_100mil_950um')
|
||||
def gen(size, mounting_holes=None):
|
||||
w, h = size
|
||||
f = max(1.27*5, min(50, h*0.3))
|
||||
f2 = max(1.27*5, min(30, w*0.2))
|
||||
return ProtoBoard(common_defs, f'((smd100 + smd100) | (smd950 + smd950) | tht50@{f2}mm)@{f}mm / tht', mounting_holes, border=1, tight_layout=True)
|
||||
|
||||
@index(sizes=min_dim(sizes_medium, 60), name=f'all_tht_and_smd')
|
||||
def gen(size, mounting_holes=None):
|
||||
w, h = size
|
||||
f = max(1.27*5, min(30, h*0.3))
|
||||
f2 = max(1.27*5, min(25, w*0.1))
|
||||
return ProtoBoard(common_defs, f'tht50@10mm | tht | ((smd100r + smd100r) / (smd950r + smd950r) / (smd800 + smd800)@{f2}mm / (smd650 + smd650)@{f2}mm / (smd500 + smd500)@{f2}mm)@{f}mm', mounting_holes, border=1, tight_layout=True)
|
||||
|
||||
write_index(index_d, outdir)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
generate_all()
|
||||
|
||||
115
generate_scaled_footprints.py
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
#/usr/bin/env python3
|
||||
|
||||
import re
|
||||
import tempfile
|
||||
import os
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
import click
|
||||
|
||||
default_widths = '3mm,5mm,8mm,10mm,12mm,15mm,18mm,20mm,25mm,30mm,35mm,40mm,45mm,50mm,60mm,70mm,80mm,90mm,100mm,120mm,150mm'
|
||||
|
||||
|
||||
# Mostly from https://www.w3.org/TR/css-values/#absolute-lengths
|
||||
UNIT_FACTORS = {
|
||||
'm': 1000,
|
||||
'cm': 10,
|
||||
'mm': 1,
|
||||
'Q': 1/4,
|
||||
'in': 25.4,
|
||||
'mil': 25.4/1000,
|
||||
'pc': 25.4/6,
|
||||
'pt': 25.4/72,
|
||||
'px': 25.4/96,
|
||||
}
|
||||
|
||||
def parse_length(foo, default_unit=None):
|
||||
''' Parse given physical length, and return result converted to mm. '''
|
||||
|
||||
match = re.fullmatch(r'(.*?)(m|cm|mm|Q|in|mil|pc|pt|px|)', foo.strip().lower())
|
||||
if not match:
|
||||
raise ValueError(f'Invalid length "{foo}"')
|
||||
num, unit = match.groups()
|
||||
|
||||
if not unit:
|
||||
if default_unit:
|
||||
unit = default_unit
|
||||
else:
|
||||
raise ValueError(f'Unit missing from length "{foo}"')
|
||||
|
||||
return float(num) * UNIT_FACTORS[unit]
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.option('--width')
|
||||
@click.option('--height')
|
||||
@click.option('--sexp-layer', default='F.SilkS')
|
||||
@click.option('--basename', help='Base name for generated symbols and library')
|
||||
@click.argument('input_svg')
|
||||
def export(width, height, basename, sexp_layer, input_svg):
|
||||
svg_flatten = str(Path(os.environ.get('SVG_FLATTEN', 'svg-flatten')).expanduser())
|
||||
usvg = str(Path(os.environ.get('USVG', 'usvg')).expanduser())
|
||||
|
||||
if not basename:
|
||||
match = re.fullmatch(r'(.*?)(([-_.][0-9.,]+)(m|cm|mm|Q|in|mil|pc|pt|px|))?', Path(input_svg).stem)
|
||||
basename, *rest = match.groups()
|
||||
print(f'No --basename given. Using "{basename}"')
|
||||
|
||||
export_width, export_height = width, height
|
||||
if not export_width or export_height:
|
||||
export_width = default_widths
|
||||
|
||||
elif export_width and export_height:
|
||||
raise click.ClickException('Only one of --width or --height must be given.')
|
||||
|
||||
if export_width:
|
||||
targets = export_width
|
||||
axis = 'width'
|
||||
else:
|
||||
targets = export_height
|
||||
axis = 'height'
|
||||
|
||||
# Determine input document size
|
||||
with tempfile.NamedTemporaryFile() as f:
|
||||
try:
|
||||
subprocess.run([usvg, input_svg, f.name], check=True)
|
||||
except FileNotFoundError:
|
||||
raise click.ClickException('Cannot find usvg binary in PATH. You can give a custom path to the usvg binary by setting the USVG environment variable.')
|
||||
|
||||
soup = BeautifulSoup(f.read(), features='xml')
|
||||
svg = soup.find('svg')
|
||||
doc_w_mm, doc_h_mm = parse_length(svg['width'], default_unit='px'), parse_length(svg['height'], default_unit='px')
|
||||
|
||||
print(f'Input file has dimensions width {doc_w_mm:.1f} mm by height {doc_h_mm:.1f} mm')
|
||||
|
||||
outdir = Path(f'{basename}.pretty')
|
||||
outdir.mkdir(exist_ok=True)
|
||||
|
||||
for target_length in targets.split(','):
|
||||
target_length = parse_length(target_length, default_unit='mm')
|
||||
|
||||
if axis == 'width':
|
||||
scaling_factor = target_length / doc_w_mm
|
||||
else:
|
||||
scaling_factor = target_length / doc_h_mm
|
||||
|
||||
instance_name = f'{basename}_{target_length:.1f}mm'
|
||||
outfile = outdir / f'{instance_name}.kicad_mod'
|
||||
print(f'{outfile}: Scaling to target {axis} {target_length:.1f} mm using scaling factor {scaling_factor:.3f}')
|
||||
|
||||
try:
|
||||
proc = subprocess.run([svg_flatten,
|
||||
'-o', 'sexp',
|
||||
'--sexp-layer', sexp_layer,
|
||||
'--sexp-mod-name', instance_name,
|
||||
'--scale', str(scaling_factor),
|
||||
input_svg], check=True, capture_output=True)
|
||||
outfile.write_bytes(proc.stdout)
|
||||
except FileNotFoundError:
|
||||
raise click.ClickException('Cannot find svg-flatten binary in PATH. You can give a custom path to the svg-flatten binary by setting the SVG_FLATTEN environment variable.')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
export()
|
||||
35
gerbolyze
|
|
@ -1,35 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import gerbolyze
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Parse command line arguments
|
||||
import argparse
|
||||
parser = argparse.ArgumentParser()
|
||||
|
||||
subcommand = parser.add_subparsers(help='Sub-commands')
|
||||
subcommand.required, subcommand.dest = True, 'command'
|
||||
vectorize_parser = subcommand.add_parser('vectorize', help='Vectorize bitmap image onto gerber layer')
|
||||
render_parser = subcommand.add_parser('render', help='Render bitmap preview of board suitable as a template for positioning and scaling the input image')
|
||||
|
||||
parser.add_argument('-d', '--debugdir', type=str, default=None, help='Directory to place intermediate images into for debuggin')
|
||||
|
||||
vectorize_parser.add_argument('side', choices=['top', 'bottom'], help='Target board side')
|
||||
vectorize_parser.add_argument('--layer', '-l', choices=['silk', 'mask', 'copper'], default='silk', help='Target layer on given side')
|
||||
|
||||
vectorize_parser.add_argument('source', help='Source gerber directory')
|
||||
vectorize_parser.add_argument('target', help='Target gerber directory')
|
||||
vectorize_parser.add_argument('image', help='Image to render')
|
||||
|
||||
render_parser.add_argument('--fab-resolution', '-r', type=float, nargs='?', default=6.0, help='Smallest feature size supported by PCB manufacturer, in mil. On silkscreen layers, this is the minimum font stroke width.')
|
||||
render_parser.add_argument('--oversampling', '-o', type=float, nargs='?', default=10, help='Oversampling factor for the image. If set to say, 10 pixels, one minimum feature size (see --fab-resolution) will be 10 pixels long. The input image for vectorization should not contain any detail of smaller pixel size than this number in order to be manufacturable.')
|
||||
render_parser.add_argument('side', choices=['top', 'bottom'], help='Target board side')
|
||||
render_parser.add_argument('source', help='Source gerber directory')
|
||||
render_parser.add_argument('image', help='Output image filename')
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.command == 'vectorize':
|
||||
gerbolyze.process_gerbers(args.source, args.target, args.image, args.side, args.layer, args.debugdir)
|
||||
else: # command == render
|
||||
gerbolyze.render_preview(args.source, args.image, args.side, args.fab_resolution, args.oversampling)
|
||||
|
||||
372
gerbolyze.py
|
|
@ -1,372 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import tempfile
|
||||
import os.path as path
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import shutil
|
||||
import math
|
||||
|
||||
import gerber
|
||||
from gerber.render.cairo_backend import GerberCairoContext
|
||||
import numpy as np
|
||||
import cv2
|
||||
import enum
|
||||
import tqdm
|
||||
|
||||
def generate_mask(
|
||||
outline,
|
||||
target,
|
||||
scale,
|
||||
bounds,
|
||||
debugimg,
|
||||
status_print,
|
||||
extend_overlay_r_mil,
|
||||
subtract_gerber
|
||||
):
|
||||
# Render all gerber layers whose features are to be excluded from the target image, such as board outline, the
|
||||
# original silk layer and the solder paste layer to binary images.
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
img_file = path.join(tmpdir, 'target.png')
|
||||
|
||||
status_print('Combining keepout composite')
|
||||
fg, bg = gerber.render.RenderSettings((1, 1, 1)), gerber.render.RenderSettings((0, 0, 0))
|
||||
ctx = GerberCairoContext(scale=scale)
|
||||
status_print(' * outline')
|
||||
ctx.render_layer(outline, settings=fg, bgsettings=bg, bounds=bounds)
|
||||
status_print(' * target layer')
|
||||
ctx.render_layer(target, settings=fg, bgsettings=bg, bounds=bounds)
|
||||
for fn, sub in subtract_gerber:
|
||||
status_print(' * extra layer', os.path.basename(fn))
|
||||
layer = gerber.loads(sub)
|
||||
ctx.render_layer(layer, settings=fg, bgsettings=bg, bounds=bounds)
|
||||
status_print('Rendering keepout composite')
|
||||
ctx.dump(img_file)
|
||||
|
||||
# Vertically flip exported image
|
||||
original_img = cv2.imread(img_file, cv2.IMREAD_GRAYSCALE)[::-1, :]
|
||||
|
||||
f = 1 if outline.units == 'inch' else 25.4
|
||||
r = 1+2*max(1, int(extend_overlay_r_mil/1000 * f * scale))
|
||||
status_print('Expanding keepout composite by', r)
|
||||
|
||||
# Extend image by a few pixels and flood-fill from (0, 0) to mask out the area outside the outermost outline
|
||||
# This ensures no polygons are generated outside the board even for non-rectangular boards.
|
||||
border = 10
|
||||
outh, outw = original_img.shape
|
||||
extended_img = np.zeros((outh + 2*border, outw + 2*border), dtype=np.uint8)
|
||||
extended_img[border:outh+border, border:outw+border] = original_img
|
||||
debugimg(extended_img, 'outline')
|
||||
cv2.floodFill(extended_img, None, (0, 0), (255,))
|
||||
original_img = extended_img[border:outh+border, border:outw+border]
|
||||
debugimg(extended_img, 'flooded')
|
||||
|
||||
# Dilate the white areas of the image using gaussian blur and threshold. Use these instead of primitive dilation
|
||||
# here for their non-directionality.
|
||||
target_img = cv2.blur(original_img, (r, r))
|
||||
_, target_img = cv2.threshold(target_img, 255//(1+r), 255, cv2.THRESH_BINARY)
|
||||
return target_img
|
||||
|
||||
def render_gerbers_to_image(*gerbers, scale, bounds=None):
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
img_file = path.join(tmpdir, 'target.png')
|
||||
fg, bg = gerber.render.RenderSettings((1, 1, 1)), gerber.render.RenderSettings((0, 0, 0))
|
||||
ctx = GerberCairoContext(scale=scale)
|
||||
|
||||
for grb in gerbers:
|
||||
ctx.render_layer(grb, settings=fg, bgsettings=bg, bounds=bounds)
|
||||
|
||||
ctx.dump(img_file)
|
||||
# Vertically flip exported image to align coordinate systems
|
||||
return cv2.imread(img_file, cv2.IMREAD_GRAYSCALE)[::-1, :]
|
||||
|
||||
def pcb_area_mask(outline, scale, bounds):
|
||||
# Merge layers to target mask
|
||||
img = render_gerbers_to_image(outline, scale=scale, bounds=bounds)
|
||||
# Extend
|
||||
imgh, imgw = img.shape
|
||||
img_ext = np.zeros(shape=(imgh+2, imgw+2), dtype=np.uint8)
|
||||
img_ext[1:-1, 1:-1] = img
|
||||
# Binarize
|
||||
img_ext[img_ext < 128] = 0
|
||||
img_ext[img_ext >= 128] = 255
|
||||
# Flood-fill
|
||||
cv2.floodFill(img_ext, None, (0, 0), (255,)) # Flood-fill with white from top left corner (0,0)
|
||||
img_ext_snap = img_ext.copy()
|
||||
cv2.floodFill(img_ext, None, (0, 0), (0,)) # Flood-fill with black
|
||||
cv2.floodFill(img_ext, None, (0, 0), (255,)) # Flood-fill with white
|
||||
return np.logical_xor(img_ext_snap, img_ext)[1:-1, 1:-1].astype(float)
|
||||
|
||||
def generate_template(
|
||||
silk, mask, copper, outline, drill,
|
||||
image,
|
||||
process_resolution:float=6, # mil
|
||||
resolution_oversampling:float=10, # times
|
||||
status_print=lambda *args:None
|
||||
):
|
||||
|
||||
silk, mask, copper, outline, *drill = map(gerber.load_layer_data, [silk, mask, copper, outline, *drill])
|
||||
silk.layer_class = 'topsilk'
|
||||
mask.layer_class = 'topmask'
|
||||
copper.layer_class = 'top'
|
||||
outline.layer_class = 'outline'
|
||||
|
||||
|
||||
f = 1.0 if outline.cam_source.units == 'metric' else 25.4
|
||||
scale = (1000/process_resolution) / 25.4 * resolution_oversampling * f # dpmm
|
||||
bounds = outline.cam_source.bounding_box
|
||||
|
||||
# Create a new drawing context
|
||||
ctx = GerberCairoContext(scale=scale)
|
||||
|
||||
ctx.render_layer(outline, bounds=bounds)
|
||||
ctx.render_layer(copper, bounds=bounds)
|
||||
ctx.render_layer(mask, bounds=bounds)
|
||||
ctx.render_layer(silk, bounds=bounds)
|
||||
for dr in drill:
|
||||
ctx.render_layer(dr, bounds=bounds)
|
||||
ctx.dump(image)
|
||||
|
||||
def paste_image(
|
||||
target_gerber:str,
|
||||
outline_gerber:str,
|
||||
source_img:np.ndarray,
|
||||
subtract_gerber:list=[],
|
||||
extend_overlay_r_mil:float=6,
|
||||
extend_picture_r_mil:float=2,
|
||||
status_print=lambda *args:None,
|
||||
debugdir:str=None):
|
||||
|
||||
debugctr = 0
|
||||
def debugimg(img, name):
|
||||
nonlocal debugctr
|
||||
if debugdir:
|
||||
cv2.imwrite(path.join(debugdir, '{:02d}{}.png'.format(debugctr, name)), img)
|
||||
debugctr += 1
|
||||
|
||||
# Parse outline layer to get bounds of gerber file
|
||||
status_print('Parsing outline gerber')
|
||||
outline = gerber.loads(outline_gerber)
|
||||
bounds = (minx, maxx), (miny, maxy) = outline.bounding_box
|
||||
grbw, grbh = maxx - minx, maxy - miny
|
||||
status_print(' * outline has offset {}, size {}'.format((minx, miny), (grbw, grbh)))
|
||||
|
||||
# Parse target layer
|
||||
status_print('Parsing target gerber')
|
||||
target = gerber.loads(target_gerber)
|
||||
(tminx, tmaxx), (tminy, tmaxy) = target.bounding_box
|
||||
status_print(' * target layer has offset {}, size {}'.format((tminx, tminy), (tmaxx-tminx, tmaxy-tminy)))
|
||||
|
||||
# Read source image
|
||||
imgh, imgw = source_img.shape
|
||||
scale = math.ceil(max(imgw/grbw, imgh/grbh)) # scale is in dpmm
|
||||
status_print(' * source image has size {}, going for scale {}dpmm'.format((imgw, imgh), scale))
|
||||
|
||||
# Merge layers to target mask
|
||||
target_img = generate_mask(outline, target, scale, bounds, debugimg, status_print, extend_overlay_r_mil, subtract_gerber)
|
||||
|
||||
# Threshold source image. Ideally, the source image is already binary but in case it's not, or in case it's not
|
||||
# exactly binary (having a few very dark or very light grays e.g. due to JPEG compression) we're thresholding here.
|
||||
status_print('Thresholding source image')
|
||||
qr = 1+2*max(1, int(extend_picture_r_mil/1000 * scale))
|
||||
source_img = source_img[::-1]
|
||||
_, source_img = cv2.threshold(source_img, 127, 255, cv2.THRESH_BINARY)
|
||||
debugimg(source_img, 'thresh')
|
||||
|
||||
# Pad image to size of target layer images generated above. After this, `scale` applies to the padded image as well
|
||||
# as the gerber renders. For padding, zoom or shrink the image to completely fit the gerber's rectangular bounding
|
||||
# box. Center the image vertically or horizontally if it has a different aspect ratio.
|
||||
status_print('Padding source image')
|
||||
tgth, tgtw = target_img.shape
|
||||
padded_img = np.zeros(shape=target_img.shape, dtype=source_img.dtype)
|
||||
offx = int((minx-tminx if tminx < minx else 0)*scale)
|
||||
offy = int((miny-tminy if tminy < miny else 0)*scale)
|
||||
offx += int(grbw*scale - imgw) // 2
|
||||
offy += int(grbh*scale - imgh) // 2
|
||||
endx, endy = min(offx+imgw, tgtw), min(offy+imgh, tgth)
|
||||
print('off', (offx, offy), 'end', (endx, endy), 'img', (imgw, imgh), 'tgt', (tgtw, tgth))
|
||||
padded_img[offy:endy, offx:endx] = source_img[:endy-offy, :endx-offx]
|
||||
debugimg(padded_img, 'padded')
|
||||
debugimg(target_img, 'target')
|
||||
|
||||
# Mask out excluded gerber features (source silk, holes, solder mask etc.) from the target image
|
||||
status_print('Masking source image')
|
||||
out_img = (np.multiply((padded_img/255.0), (target_img/255.0) * -1 + 1) * 255).astype(np.uint8)
|
||||
|
||||
debugimg(out_img, 'multiplied')
|
||||
|
||||
# Calculate contours from masked target image and plot them to the target gerber context
|
||||
status_print('Calculating contour lines')
|
||||
plot_contours(out_img,
|
||||
target,
|
||||
offx=(minx, miny),
|
||||
scale=scale,
|
||||
status_print=lambda *args: status_print(' ', *args))
|
||||
|
||||
# Write target gerber context to disk
|
||||
status_print('Generating output gerber')
|
||||
from gerber.render import rs274x_backend
|
||||
ctx = rs274x_backend.Rs274xContext(target.settings)
|
||||
target.render(ctx)
|
||||
out = ctx.dump().getvalue()
|
||||
status_print('Done.')
|
||||
return out
|
||||
|
||||
|
||||
def plot_contours(
|
||||
img:np.ndarray,
|
||||
layer:gerber.rs274x.GerberFile,
|
||||
offx:tuple,
|
||||
scale:float,
|
||||
debug=lambda *args:None,
|
||||
status_print=lambda *args:None):
|
||||
from gerber.primitives import Line, Region, Circle
|
||||
imgh, imgw = img.shape
|
||||
|
||||
# Extract contour hierarchy using OpenCV
|
||||
status_print('Extracting contours')
|
||||
# See https://stackoverflow.com/questions/48291581/how-to-use-cv2-findcontours-in-different-opencv-versions/48292371
|
||||
contours, hierarchy = cv2.findContours(img, cv2.RETR_TREE, cv2.CHAIN_APPROX_TC89_KCOS)[-2:]
|
||||
|
||||
aperture = list(layer.apertures)[0] if layer.apertures else Circle(None, 0.10)
|
||||
|
||||
status_print('offx', offx, 'scale', scale)
|
||||
|
||||
xbias, ybias = offx
|
||||
def map(coord):
|
||||
x, y = coord
|
||||
return (x/scale + xbias, y/scale + ybias)
|
||||
def contour_lines(c):
|
||||
return [ Line(map(start), map(end), aperture, units=layer.settings.units)
|
||||
for start, end in zip(c, np.vstack((c[1:], c[:1]))) ]
|
||||
|
||||
done = []
|
||||
process_stack = [-1]
|
||||
next_process_stack = []
|
||||
parents = [ (i, first_child != -1, parent) for i, (_1, _2, first_child, parent) in enumerate(hierarchy[0]) ]
|
||||
is_dark = True
|
||||
status_print('Converting contours to gerber primitives')
|
||||
with tqdm.tqdm(total=len(contours)) as progress:
|
||||
while len(done) != len(contours):
|
||||
for i, has_children, parent in parents[:]:
|
||||
if parent in process_stack:
|
||||
contour = contours[i]
|
||||
polarity = 'dark' if is_dark else 'clear'
|
||||
debug('rendering {} with parent {} as {} with {} vertices'.format(i, parent, polarity, len(contour)))
|
||||
debug('process_stack is', process_stack)
|
||||
debug()
|
||||
layer.primitives.append(Region(contour_lines(contour[:,0]), level_polarity=polarity, units=layer.settings.units))
|
||||
if has_children:
|
||||
next_process_stack.append(i)
|
||||
done.append(i)
|
||||
parents.remove((i, has_children, parent))
|
||||
progress.update(1)
|
||||
debug('skipping to next level')
|
||||
process_stack, next_process_stack = next_process_stack, []
|
||||
is_dark = not is_dark
|
||||
debug('done', done)
|
||||
|
||||
# Utility foo
|
||||
# ===========
|
||||
|
||||
def find_gerber_in_dir(dir_path, extensions, exclude=''):
|
||||
contents = os.listdir(dir_path)
|
||||
exts = extensions.split('|')
|
||||
excs = exclude.split('|')
|
||||
for entry in contents:
|
||||
if any(entry.lower().endswith(ext.lower()) for ext in exts) and not any(entry.lower().endswith(ex) for ex in excs if exclude):
|
||||
lname = path.join(dir_path, entry)
|
||||
if not path.isfile(lname):
|
||||
continue
|
||||
with open(lname, 'r') as f:
|
||||
return lname, f.read()
|
||||
|
||||
raise ValueError(f'Cannot find file with suffix {extensions} in dir {dir_path}')
|
||||
|
||||
# Gerber file name extensions for Altium/Protel | KiCAD | Eagle
|
||||
LAYER_SPEC = {
|
||||
'top': {
|
||||
'paste': '.gtp|-F_Paste.gbr|-F.Paste.gbr|.pmc',
|
||||
'silk': '.gto|-F_SilkS.gbr|-F.SilkS.gbr|.plc',
|
||||
'mask': '.gts|-F_Mask.gbr|-F.Mask.gbr|.stc',
|
||||
'copper': '.gtl|-F_Cu.gbr|-F.Cu.gbr|.cmp',
|
||||
'outline': '.gko|.gm1|-Edge_Cuts.gbr|-Edge.Cuts.gbr|.gmb',
|
||||
},
|
||||
'bottom': {
|
||||
'paste': '.gbp|-B_Paste.gbr|-B.Paste.gbr|.pms',
|
||||
'silk': '.gbo|-B_SilkS.gbr|-B.SilkS.gbr|.pls',
|
||||
'mask': '.gbs|-B_Mask.gbr|-B.Mask.gbr|.sts',
|
||||
'copper': '.gbl|-B_Cu.gbr|-B.Cu.gbr|.sol',
|
||||
'outline': '.gko|.gm1|-Edge_Cuts.gbr|-Edge.Cuts.gbr|.gmb'
|
||||
},
|
||||
}
|
||||
|
||||
# Command line interface
|
||||
# ======================
|
||||
|
||||
def process_gerbers(source, target, image, side, layer, debugdir):
|
||||
if not os.path.isdir(source):
|
||||
raise ValueError(f'Given source "{source}" is not a directory.')
|
||||
|
||||
# Load input files
|
||||
source_img = cv2.imread(image, cv2.IMREAD_GRAYSCALE)
|
||||
if source_img is None:
|
||||
print(f'"{image}" is not a valid image file', file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
tlayer, slayer = {
|
||||
'silk': ('silk', 'mask'),
|
||||
'mask': ('mask', 'silk'),
|
||||
'copper': ('copper', None)
|
||||
}[layer]
|
||||
|
||||
layers = LAYER_SPEC[side]
|
||||
tname, tgrb = find_gerber_in_dir(source, layers[tlayer])
|
||||
print('Target layer file {}'.format(os.path.basename(tname)))
|
||||
oname, ogrb = find_gerber_in_dir(source, layers['outline'])
|
||||
print('Outline layer file {}'.format(os.path.basename(oname)))
|
||||
subtract = find_gerber_in_dir(source, layers[slayer]) if slayer else None
|
||||
|
||||
# Prepare output. Do this now to error out as early as possible if there's a problem.
|
||||
if os.path.exists(target):
|
||||
if os.path.isdir(target) and sorted(os.listdir(target)) == sorted(os.listdir(source)):
|
||||
shutil.rmtree(target)
|
||||
else:
|
||||
print('Error: Target already exists and does not look like source. Please manually remove the target dir before proceeding.', file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
# Generate output
|
||||
out = paste_image(tgrb, ogrb, source_img, [subtract], debugdir=debugdir, status_print=lambda *args: print(*args, flush=True))
|
||||
|
||||
shutil.copytree(source, target)
|
||||
with open(os.path.join(target, os.path.basename(tname)), 'w') as f:
|
||||
f.write(out)
|
||||
|
||||
def render_preview(source, image, side, process_resolution, resolution_oversampling):
|
||||
def load_layer(layer):
|
||||
name, grb = find_gerber_in_dir(source, LAYER_SPEC[side][layer])
|
||||
print(f'{layer} layer file {os.path.basename(name)}')
|
||||
return grb
|
||||
|
||||
outline = load_layer('outline')
|
||||
silk = load_layer('silk')
|
||||
mask = load_layer('mask')
|
||||
copper = load_layer('copper')
|
||||
|
||||
try:
|
||||
nm, npth = find_gerber_in_dir(source, '-npth.drl')
|
||||
print(f'npth drill file {nm}')
|
||||
except ValueError:
|
||||
npth = None
|
||||
nm, drill = find_gerber_in_dir(source, '.drl|.txt', exclude='-npth.drl')
|
||||
print(f'drill file {nm}')
|
||||
drill = ([npth] if npth else []) + [drill]
|
||||
|
||||
generate_template(
|
||||
silk, mask, copper, outline, drill,
|
||||
image,
|
||||
process_resolution=process_resolution,
|
||||
resolution_oversampling=resolution_oversampling,
|
||||
)
|
||||
|
||||
17
gerboweb.service
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
[Unit]
|
||||
Description=Gerboweb server service
|
||||
Documentation=https://gitlab.com/gerbolyze/gerbolyze
|
||||
Wants=network-online.target
|
||||
Wants=nginx.service
|
||||
After=nginx.service
|
||||
RequiresMountsFor=/var/run/container/storage
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/podman run --secret=gerboweb --conmon-pidfile=%t/container-gerboweb.pid --volume=${RUNTIME_DIRECTORY}:/run/uwsgi --detach gerboweb
|
||||
ExecStop=/usr/bin/podman stop --time 2 gerboweb
|
||||
Type=forking
|
||||
PIDFile=%t/container-gerboweb.pid
|
||||
RuntimeDirectory=gerboweb-uwsgi
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
19
gerboweb/Containerfile
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
FROM docker.io/archlinux:latest
|
||||
MAINTAINER gerbolyze@jaseg.de
|
||||
RUN pacman --noconfirm -Syu
|
||||
RUN pacman --noconfirm -Sy pugixml opencv pango cairo git python make clang cargo python-pip base-devel gerbv rsync tmux uwsgi uwsgi-plugin-python
|
||||
RUN cargo install usvg resvg
|
||||
RUN python3 -m pip install pip==21.3.1
|
||||
RUN python3 -m pip install flask numpy lxml wasmtime svg_flatten_wasi resvg_wasi flask_wtf
|
||||
RUN --mount=type=bind,rw,destination=/git \
|
||||
cd /git/gerbonara && \
|
||||
python3 -m pip --disable-pip-version-check install . && \
|
||||
cd /git && \
|
||||
python3 -m pip --disable-pip-version-check install .
|
||||
RUN mkdir /gerboweb
|
||||
ADD ["gerboweb/uwsgi-gerboweb.ini","gerboweb/gerboweb.py","gerboweb/job_processor.py","gerboweb/job_queue.py","/gerboweb/"]
|
||||
ADD ["gerboweb/static","/gerboweb/static"]
|
||||
ADD ["gerboweb/templates","/gerboweb/templates"]
|
||||
ADD gerboweb/gerboweb_prod.cfg /gerboweb/gerboweb.cfg
|
||||
RUN mkdir /var/cache/gerboweb
|
||||
ENTRYPOINT uwsgi --ini /gerboweb/uwsgi-gerboweb.ini --chmod-socket=660 --socket=/run/uwsgi/socket
|
||||
12
gerboweb/Containerfile.develop
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
FROM docker.io/archlinux:latest
|
||||
MAINTAINER gerbolyze@jaseg.de
|
||||
RUN pacman --noconfirm -Syu
|
||||
RUN pacman --noconfirm -Sy pugixml opencv pango cairo git python make clang rustup cargo python-pip base-devel gerbv rsync tmux
|
||||
RUN rustup install stable
|
||||
RUN rustup default stable
|
||||
RUN cargo install usvg resvg
|
||||
RUN mkdir /app /gerbolyze
|
||||
RUN python3 -m pip install pip==21.3.1
|
||||
RUN python3 -m pip install flask numpy lxml wasmtime svg_flatten_wasi resvg_wasi flask_wtf
|
||||
COPY develop-startup.sh /app/
|
||||
ENTRYPOINT /app/develop-startup.sh
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
MAX_CONTENT_LENGTH=10000000
|
||||
MAX_CONTENT_LENGTH=50000000
|
||||
SECRET_KEY="{{lookup('password', 'gerboweb_flask_secret.txt length=32')}}"
|
||||
UPLOAD_PATH="{{gerboweb_cache}}/upload"
|
||||
JOB_QUEUE_DB="{{gerboweb_cache}}/job_queue.sqlite3"
|
||||
86
gerboweb/ansible/gerboweb.yml
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
---
|
||||
- name: Setup gerboweb
|
||||
hosts: all
|
||||
tasks:
|
||||
- name: Set local facts
|
||||
set_fact:
|
||||
gerboweb_cache: /var/cache/gerboweb
|
||||
|
||||
- name: Install packages into gerbolyze container
|
||||
pacman:
|
||||
name: python3,python-numpy,python-pip,imagemagick,pugixml,git,python,make,clang,rustup,cargo
|
||||
state: present
|
||||
|
||||
- name: Setup usvg
|
||||
shell: cargo install usvg resvg
|
||||
args:
|
||||
creates: /usr/bin/usvg
|
||||
|
||||
- name: Copy webapp sources
|
||||
git:
|
||||
repo: ../..
|
||||
dest: /var/lib/gerboweb
|
||||
|
||||
- name: Create uwsgi worker user and group
|
||||
user:
|
||||
name: uwsgi-gerboweb
|
||||
create_home: no
|
||||
group: uwsgi
|
||||
password: '!'
|
||||
shell: /sbin/nologin
|
||||
system: yes
|
||||
|
||||
- name: Template webapp config
|
||||
template:
|
||||
src: gerboweb.cfg.j2
|
||||
dest: /var/lib/gerboweb/gerboweb_prod.cfg
|
||||
owner: uwsgi-gerboweb
|
||||
group: root
|
||||
mode: 0660
|
||||
|
||||
- name: Copy uwsgi config
|
||||
copy:
|
||||
src: uwsgi-gerboweb.ini
|
||||
dest: /etc/uwsgi.d/gerboweb.ini
|
||||
owner: uwsgi-gerboweb
|
||||
group: uwsgi
|
||||
mode: 0440
|
||||
|
||||
- name: Copy job processor systemd service config
|
||||
template:
|
||||
src: gerboweb-job-processor.service.j2
|
||||
dest: /etc/systemd/system/gerboweb-job-processor.service
|
||||
|
||||
- name: Enable uwsgi systemd socket
|
||||
systemd:
|
||||
daemon-reload: yes
|
||||
name: uwsgi-app@gerboweb.socket
|
||||
enabled: yes
|
||||
|
||||
- name: Copy gerboweb cache dir tmpfiles.d config
|
||||
template:
|
||||
src: tmpfiles-gerboweb.conf.j2
|
||||
dest: /etc/tmpfiles.d/gerboweb.conf
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
register: tmpfiles_config
|
||||
|
||||
- name: Kick systemd tmpfiles service to create cache dir
|
||||
command: systemd-tmpfiles --create
|
||||
when: tmpfiles_config is changed
|
||||
|
||||
- name: Create job queue db
|
||||
file:
|
||||
path: "{{gerboweb_cache}}/job_queue.sqlite3"
|
||||
owner: root
|
||||
group: uwsgi
|
||||
mode: 0660
|
||||
state: touch
|
||||
|
||||
- name: Enable and launch job processor
|
||||
systemd:
|
||||
name: gerboweb-job-processor.service
|
||||
enabled: yes
|
||||
state: restarted
|
||||
|
||||
17
gerboweb/ansible/render.sh.j2
Executable file
|
|
@ -0,0 +1,17 @@
|
|||
#!/bin/sh
|
||||
|
||||
[ $# != 1 ] && exit 1
|
||||
ID=$1
|
||||
egrep -x -q '^[-0-9A-Za-z]{36}$'<<<"$ID" || exit 2
|
||||
|
||||
systemd-nspawn \
|
||||
-D {{gerboweb_root}} \
|
||||
-x --bind={{gerboweb_cache}}/upload/$ID:/mnt \
|
||||
/bin/sh -c "set -euo pipefail
|
||||
unzip -j -d /tmp/gerber /mnt/gerber.zip
|
||||
rm -f /mnt/template_top.svg /mnt/template_bottom.svg /mnt/template_top.preview.png /mnt/template_bottom.preview.png
|
||||
date; echo 'Rendering'
|
||||
gerbolyze template --top /mnt/template_top.svg --bottom /mnt/template_bottom.svg /tmp/gerber
|
||||
date; echo 'Scaling down'
|
||||
convert /mnt/template_top.svg -resize 500x500 -negate -brightness-contrast 30x30 -colorspace gray /mnt/template_top.preview.png
|
||||
convert /mnt/template_bottom.svg -resize 500x500 -negate -brightness-contrast 30x30 -colorspace gray /mnt/template_bottom.preview.png
|
||||
|
|
@ -7,4 +7,5 @@ plugins = python3
|
|||
chdir = /var/lib/gerboweb
|
||||
mount = /=gerboweb:app
|
||||
env = GERBOWEB_SETTINGS=gerboweb_prod.cfg
|
||||
mule = job_processor.py
|
||||
|
||||
|
|
@ -12,7 +12,7 @@ systemd-nspawn \
|
|||
/bin/sh -c "set -euo pipefail
|
||||
cd /tmp
|
||||
unzip -j -d gerber_in /mnt/gerber.zip
|
||||
gerbolyze vectorize $LAYER gerber_in gerber /mnt/overlay.png
|
||||
gerbolyze paste "--"$LAYER /mnt/overlay.svg gerber_in gerber
|
||||
rm -f /mnt/gerber_out.zip
|
||||
zip -r /mnt/gerber_out.zip gerber"
|
||||
|
||||
4
gerboweb/deploy/.gitignore
vendored
|
|
@ -1,4 +0,0 @@
|
|||
*_secret.txt
|
||||
*_apikey.txt
|
||||
playbook.retry
|
||||
credentials.ini
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
---
|
||||
- name: Set local path facts
|
||||
set_fact:
|
||||
image: "/var/lib/machines/{{ container }}.img"
|
||||
root: "/var/lib/machines/{{ container }}"
|
||||
"{{container}}_root": "/var/lib/machines/{{ container }}"
|
||||
|
||||
- name: Create container image file
|
||||
command: truncate -s 4G "{{image}}"
|
||||
args:
|
||||
creates: "{{image}}"
|
||||
register: create_container
|
||||
|
||||
- name: Download arch bootstrap image
|
||||
get_url:
|
||||
url: http://mirror.rackspace.com/archlinux/iso/2020.03.01/archlinux-bootstrap-2020.03.01-x86_64.tar.gz
|
||||
dest: /tmp/arch-bootstrap.tar.xz
|
||||
checksum: sha256:49c7aa8718e48f5a4ec570624520fa50616ed3e044af101ec3aa16c155136f82
|
||||
when: create_container is changed
|
||||
|
||||
- name: Create container image filesystem
|
||||
filesystem:
|
||||
dev: "{{image}}"
|
||||
fstype: btrfs
|
||||
|
||||
- name: Create container image fstab entry
|
||||
mount:
|
||||
src: "{{image}}"
|
||||
path: "{{root}}"
|
||||
state: mounted
|
||||
fstype: btrfs
|
||||
opts: loop
|
||||
|
||||
- name: Unpack bootstrap image
|
||||
unarchive:
|
||||
remote_src: yes
|
||||
src: /tmp/arch-bootstrap.tar.xz
|
||||
dest: "{{root}}"
|
||||
extra_opts: --strip-components=1
|
||||
creates: "{{root}}/etc"
|
||||
|
||||
- name: Copy mirrorlist into container
|
||||
copy:
|
||||
src: mirrorlist
|
||||
dest: "{{root}}/etc/pacman.d/mirrorlist"
|
||||
|
||||
- name: Initialize container pacman keyring
|
||||
shell: arch-chroot "{{root}}" pacman-key --init && arch-chroot "{{root}}" pacman-key --populate archlinux
|
||||
args:
|
||||
creates: "{{root}}/etc/pacman.d/gnupg"
|
||||
|
||||
- name: Fixup pacman.conf for pacman to work in chroot without its own root fs
|
||||
lineinfile:
|
||||
path: "{{root}}/etc/pacman.conf"
|
||||
regexp: '^CheckSpace'
|
||||
line: '#CheckSpace'
|
||||
|
||||
- name: Update container and install software
|
||||
shell: arch-chroot "{{root}}" pacman -Syu --noconfirm
|
||||
|
||||
|
Before Width: | Height: | Size: 102 KiB |
|
|
@ -1,20 +0,0 @@
|
|||
css=/cgit.css
|
||||
logo= /cgit.png
|
||||
|
||||
enable-http-clone=1
|
||||
robots=noindex, nofollow
|
||||
virtual-root=/
|
||||
|
||||
readme=:README.rst
|
||||
about-filter=/usr/libexec/cgit/filters/about-formatting.sh
|
||||
|
||||
enable-index-links=1
|
||||
enable-commit-grpah=1
|
||||
enable-log-filecount=1
|
||||
enable-log-linecount=1
|
||||
enable-git-config=1
|
||||
|
||||
source-filter=/usr/libexec/cgit/filters/syntax-highlighting.py
|
||||
|
||||
project-list=/var/lib/gitolite3/projects.list
|
||||
scan-path=/var/lib/gitolite3/repositories
|
||||
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 13a57211f0d0feb34b452b3e19be83a095707ed6
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
# SPDX-License-Identifier: LGPL-2.1+
|
||||
#
|
||||
# This file is part of systemd.
|
||||
#
|
||||
# systemd is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
[Unit]
|
||||
Description=Clippy container
|
||||
PartOf=machines.target
|
||||
Before=machines.target
|
||||
After=network.target systemd-resolved.service
|
||||
RequiresMountsFor=/var/lib/machines
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/systemd-nspawn --quiet --keep-unit --ephemeral --boot -U --settings=override --machine=clippy
|
||||
KillMode=mixed
|
||||
Type=notify
|
||||
RestartForceExitStatus=133
|
||||
SuccessExitStatus=133
|
||||
WatchdogSec=3min
|
||||
Slice=machine.slice
|
||||
Delegate=yes
|
||||
TasksMax=512
|
||||
|
||||
# Enforce a strict device policy, similar to the one nspawn configures when it
|
||||
# allocates its own scope unit. Make sure to keep these policies in sync if you
|
||||
# change them!
|
||||
DevicePolicy=closed
|
||||
DeviceAllow=/dev/net/tun rwm
|
||||
DeviceAllow=char-pts rw
|
||||
|
||||
[Install]
|
||||
WantedBy=machines.target
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
[Network]
|
||||
VirtualEthernet=no
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
[Unit]
|
||||
Description=Clippy listener daemon
|
||||
|
||||
[Service]
|
||||
WorkingDirectory=/var/lib/clippy.git
|
||||
ExecStart=/usr/bin/python3 clippy.py -s -x 60x30 -e
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
[inwx]
|
||||
user=...
|
||||
pass=...
|
||||
|
|
@ -1,202 +0,0 @@
|
|||
# configuration variables for gitolite
|
||||
|
||||
# This file is in perl syntax. But you do NOT need to know perl to edit it --
|
||||
# just mind the commas, use single quotes unless you know what you're doing,
|
||||
# and make sure the brackets and braces stay matched up!
|
||||
|
||||
# (Tip: perl allows a comma after the last item in a list also!)
|
||||
|
||||
# HELP for commands can be had by running the command with "-h".
|
||||
|
||||
# HELP for all the other FEATURES can be found in the documentation (look for
|
||||
# "list of non-core programs shipped with gitolite" in the master index) or
|
||||
# directly in the corresponding source file.
|
||||
|
||||
%RC = (
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
# default umask gives you perms of '0700'; see the rc file docs for
|
||||
# how/why you might change this
|
||||
UMASK => 0027,
|
||||
|
||||
# look for "git-config" in the documentation
|
||||
GIT_CONFIG_KEYS => 'core\.sharedRepository',
|
||||
|
||||
# comment out if you don't need all the extra detail in the logfile
|
||||
LOG_EXTRA => 1,
|
||||
# logging options
|
||||
# 1. leave this section as is for 'normal' gitolite logging (default)
|
||||
# 2. uncomment this line to log ONLY to syslog:
|
||||
# LOG_DEST => 'syslog',
|
||||
# 3. uncomment this line to log to syslog and the normal gitolite log:
|
||||
# LOG_DEST => 'syslog,normal',
|
||||
# 4. prefixing "repo-log," to any of the above will **also** log just the
|
||||
# update records to "gl-log" in the bare repo directory:
|
||||
# LOG_DEST => 'repo-log,normal',
|
||||
# LOG_DEST => 'repo-log,syslog',
|
||||
# LOG_DEST => 'repo-log,syslog,normal',
|
||||
# syslog 'facility': defaults to 'local0', uncomment if needed. For example:
|
||||
# LOG_FACILITY => 'local4',
|
||||
|
||||
# roles. add more roles (like MANAGER, TESTER, ...) here.
|
||||
# WARNING: if you make changes to this hash, you MUST run 'gitolite
|
||||
# compile' afterward, and possibly also 'gitolite trigger POST_COMPILE'
|
||||
ROLES => {
|
||||
READERS => 1,
|
||||
WRITERS => 1,
|
||||
},
|
||||
|
||||
# enable caching (currently only Redis). PLEASE RTFM BEFORE USING!!!
|
||||
# CACHE => 'Redis',
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
# rc variables used by various features
|
||||
|
||||
# the 'info' command prints this as additional info, if it is set
|
||||
# SITE_INFO => 'Please see http://blahblah/gitolite for more help',
|
||||
|
||||
# the CpuTime feature uses these
|
||||
# display user, system, and elapsed times to user after each git operation
|
||||
# DISPLAY_CPU_TIME => 1,
|
||||
# display a warning if total CPU times (u, s, cu, cs) crosses this limit
|
||||
# CPU_TIME_WARN_LIMIT => 0.1,
|
||||
|
||||
# the Mirroring feature needs this
|
||||
# HOSTNAME => "foo",
|
||||
|
||||
# TTL for redis cache; PLEASE SEE DOCUMENTATION BEFORE UNCOMMENTING!
|
||||
# CACHE_TTL => 600,
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
# suggested locations for site-local gitolite code (see cust.html)
|
||||
|
||||
# this one is managed directly on the server
|
||||
# LOCAL_CODE => "$ENV{HOME}/local",
|
||||
|
||||
# or you can use this, which lets you put everything in a subdirectory
|
||||
# called "local" in your gitolite-admin repo. For a SECURITY WARNING
|
||||
# on this, see http://gitolite.com/gitolite/non-core.html#pushcode
|
||||
# LOCAL_CODE => "$rc{GL_ADMIN_BASE}/local",
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
# List of commands and features to enable
|
||||
|
||||
ENABLE => [
|
||||
|
||||
# COMMANDS
|
||||
|
||||
# These are the commands enabled by default
|
||||
'help',
|
||||
'desc',
|
||||
'info',
|
||||
'perms',
|
||||
'writable',
|
||||
|
||||
# Uncomment or add new commands here.
|
||||
# 'create',
|
||||
# 'fork',
|
||||
# 'mirror',
|
||||
# 'readme',
|
||||
# 'sskm',
|
||||
'D',
|
||||
|
||||
# These FEATURES are enabled by default.
|
||||
|
||||
# essential (unless you're using smart-http mode)
|
||||
'ssh-authkeys',
|
||||
|
||||
# creates git-config entries from gitolite.conf file entries like 'config foo.bar = baz'
|
||||
'git-config',
|
||||
|
||||
# creates git-daemon-export-ok files; if you don't use git-daemon, comment this out
|
||||
'daemon',
|
||||
|
||||
# creates projects.list file; if you don't use gitweb, comment this out
|
||||
'gitweb',
|
||||
|
||||
# These FEATURES are disabled by default; uncomment to enable. If you
|
||||
# need to add new ones, ask on the mailing list :-)
|
||||
|
||||
# user-visible behaviour
|
||||
|
||||
# prevent wild repos auto-create on fetch/clone
|
||||
# 'no-create-on-read',
|
||||
# no auto-create at all (don't forget to enable the 'create' command!)
|
||||
# 'no-auto-create',
|
||||
|
||||
# access a repo by another (possibly legacy) name
|
||||
# 'Alias',
|
||||
|
||||
# give some users direct shell access. See documentation in
|
||||
# sts.html for details on the following two choices.
|
||||
# "Shell $ENV{HOME}/.gitolite.shell-users",
|
||||
# 'Shell alice bob',
|
||||
|
||||
# set default roles from lines like 'option default.roles-1 = ...', etc.
|
||||
# 'set-default-roles',
|
||||
|
||||
# show more detailed messages on deny
|
||||
# 'expand-deny-messages',
|
||||
|
||||
# show a message of the day
|
||||
# 'Motd',
|
||||
|
||||
# system admin stuff
|
||||
|
||||
# enable mirroring (don't forget to set the HOSTNAME too!)
|
||||
# 'Mirroring',
|
||||
|
||||
# allow people to submit pub files with more than one key in them
|
||||
# 'ssh-authkeys-split',
|
||||
|
||||
# selective read control hack
|
||||
# 'partial-copy',
|
||||
|
||||
# manage local, gitolite-controlled, copies of read-only upstream repos
|
||||
# 'upstream',
|
||||
|
||||
# updates 'description' file instead of 'gitweb.description' config item
|
||||
# 'cgit',
|
||||
|
||||
# allow repo-specific hooks to be added
|
||||
# 'repo-specific-hooks',
|
||||
|
||||
# performance, logging, monitoring...
|
||||
|
||||
# be nice
|
||||
# 'renice 10',
|
||||
|
||||
# log CPU times (user, system, cumulative user, cumulative system)
|
||||
# 'CpuTime',
|
||||
|
||||
# syntactic_sugar for gitolite.conf and included files
|
||||
|
||||
# allow backslash-escaped continuation lines in gitolite.conf
|
||||
# 'continuation-lines',
|
||||
|
||||
# create implicit user groups from directory names in keydir/
|
||||
# 'keysubdirs-as-groups',
|
||||
|
||||
# allow simple line-oriented macros
|
||||
# 'macros',
|
||||
|
||||
# Kindergarten mode
|
||||
|
||||
# disallow various things that sensible people shouldn't be doing anyway
|
||||
# 'Kindergarten',
|
||||
],
|
||||
|
||||
);
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# per perl rules, this should be the last line in such a file:
|
||||
1;
|
||||
|
||||
# Local variables:
|
||||
# mode: perl
|
||||
# End:
|
||||
# vim: set syn=perl:
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
---
|
||||
all:
|
||||
hosts:
|
||||
wendelstein:
|
||||
ansible_host: wendelstein.jaseg.net
|
||||
ansible_ssh_identity_file: ~/.ssh/id_ed25519
|
||||
ansible_user: root
|
||||
ansible_python_interpreter: /usr/bin/python3
|
||||
localhost:
|
||||
ansible_connection: local
|
||||
ansible_python_interpreter: "{{ansible_playbook_python}}"
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
# Generated by iptables-save v1.8.0 on Thu Apr 4 11:06:33 2019
|
||||
*nat
|
||||
:PREROUTING ACCEPT [13:648]
|
||||
:INPUT ACCEPT [8:440]
|
||||
:OUTPUT ACCEPT [18:1260]
|
||||
:POSTROUTING ACCEPT [18:1260]
|
||||
-A PREROUTING -i eth0 -p tcp -m tcp --dport 23 -j REDIRECT --to-ports 2342
|
||||
COMMIT
|
||||
# Completed on Thu Apr 4 11:06:33 2019
|
||||
# Generated by iptables-save v1.8.0 on Thu Apr 4 11:06:33 2019
|
||||
*filter
|
||||
:INPUT ACCEPT [0:0]
|
||||
:FORWARD ACCEPT [0:0]
|
||||
:OUTPUT ACCEPT [360:761646]
|
||||
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
|
||||
-A INPUT -p icmp -j ACCEPT
|
||||
-A INPUT -i lo -j ACCEPT
|
||||
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
|
||||
-A INPUT -p tcp -m state --state NEW -m tcp --dport 2342 -j ACCEPT
|
||||
-A INPUT -p tcp -m state --state NEW -m tcp --dport 23 -j ACCEPT
|
||||
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
|
||||
-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
|
||||
-A INPUT -p udp --dport 53 -j ACCEPT
|
||||
-A INPUT -j REJECT --reject-with icmp-host-prohibited
|
||||
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
|
||||
COMMIT
|
||||
# Completed on Thu Apr 4 11:06:33 2019
|
||||
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 0ac040da14cc9d834098addc03cd8d4d26647df0
|
||||
|
|
@ -1,474 +0,0 @@
|
|||
##
|
||||
## Arch Linux repository mirrorlist
|
||||
## Generated on 2017-06-06
|
||||
##
|
||||
|
||||
## Worldwide
|
||||
#Server = https://archlinux.surlyjake.com/archlinux/$repo/os/$arch
|
||||
#Server = http://mirrors.evowise.com/archlinux/$repo/os/$arch
|
||||
Server = http://mirror.rackspace.com/archlinux/$repo/os/$arch
|
||||
|
||||
## Australia
|
||||
#Server = https://mirror.aarnet.edu.au/pub/archlinux/$repo/os/$arch
|
||||
#Server = http://archlinux.mirror.digitalpacific.com.au/$repo/os/$arch
|
||||
#Server = http://ftp.iinet.net.au/pub/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.internode.on.net/pub/archlinux/$repo/os/$arch
|
||||
#Server = http://ftp.swin.edu.au/archlinux/$repo/os/$arch
|
||||
#Server = http://archlinux.uberglobalmirror.com/$repo/os/$arch
|
||||
|
||||
## Austria
|
||||
#Server = http://mirror.digitalnova.at/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.easyname.at/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror1.htu.tugraz.at/archlinux/$repo/os/$arch
|
||||
|
||||
## Belarus
|
||||
#Server = http://ftp.byfly.by/pub/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.datacenter.by/pub/archlinux/$repo/os/$arch
|
||||
|
||||
## Belgium
|
||||
#Server = http://archlinux.cu.be/$repo/os/$arch
|
||||
#Server = http://archlinux.mirror.kangaroot.net/$repo/os/$arch
|
||||
|
||||
## Bosnia and Herzegovina
|
||||
#Server = http://burek.archlinux.ba/$repo/os/$arch
|
||||
#Server = http://archlinux.mirror.ba/$repo/os/$arch
|
||||
|
||||
## Brazil
|
||||
#Server = http://br.mirror.archlinux-br.org/$repo/os/$arch
|
||||
#Server = http://archlinux.c3sl.ufpr.br/$repo/os/$arch
|
||||
#Server = http://linorg.usp.br/archlinux/$repo/os/$arch
|
||||
#Server = http://pet.inf.ufsc.br/mirrors/archlinux/$repo/os/$arch
|
||||
#Server = http://archlinux.pop-es.rnp.br/$repo/os/$arch
|
||||
|
||||
## Bulgaria
|
||||
#Server = http://mirror.host.ag/archlinux/$repo/os/$arch
|
||||
#Server = http://mirrors.netix.net/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.telepoint.bg/archlinux/$repo/os/$arch
|
||||
#Server = http://mirrors.uni-plovdiv.net/archlinux/$repo/os/$arch
|
||||
#Server = https://mirrors.uni-plovdiv.net/archlinux/$repo/os/$arch
|
||||
|
||||
## Canada
|
||||
#Server = http://mirror.cedille.club/archlinux/$repo/os/$arch
|
||||
#Server = http://archlinux.mirror.colo-serv.net/$repo/os/$arch
|
||||
#Server = http://mirror.csclub.uwaterloo.ca/archlinux/$repo/os/$arch
|
||||
#Server = https://mirror.csclub.uwaterloo.ca/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.frgl.pw/archlinux/$repo/os/$arch
|
||||
#Server = https://mirror.frgl.pw/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.its.dal.ca/archlinux/$repo/os/$arch
|
||||
#Server = http://muug.ca/mirror/archlinux/$repo/os/$arch
|
||||
#Server = https://muug.ca/mirror/archlinux/$repo/os/$arch
|
||||
#Server = http://archlinux.mirror.rafal.ca/$repo/os/$arch
|
||||
|
||||
## Chile
|
||||
#Server = http://mirror.archlinux.cl/$repo/os/$arch
|
||||
|
||||
## China
|
||||
#Server = http://mirrors.163.com/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.lzu.edu.cn/archlinux/$repo/os/$arch
|
||||
#Server = http://mirrors.neusoft.edu.cn/archlinux/$repo/os/$arch
|
||||
#Server = https://mirrors.skyshe.cn/archlinux/$repo/os/$arch
|
||||
#Server = http://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$arch
|
||||
#Server = https://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$arch
|
||||
#Server = http://mirrors.ustc.edu.cn/archlinux/$repo/os/$arch
|
||||
#Server = https://mirrors.ustc.edu.cn/archlinux/$repo/os/$arch
|
||||
#Server = http://mirrors.xjtu.edu.cn/archlinux/$repo/os/$arch
|
||||
#Server = https://mirrors.xjtu.edu.cn/archlinux/$repo/os/$arch
|
||||
#Server = http://mirrors.zju.edu.cn/archlinux/$repo/os/$arch
|
||||
|
||||
## Colombia
|
||||
#Server = http://mirror.edatel.net.co/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.upb.edu.co/archlinux/$repo/os/$arch
|
||||
|
||||
## Croatia
|
||||
#Server = http://archlinux.iskon.hr/$repo/os/$arch
|
||||
|
||||
## Czech Republic
|
||||
#Server = http://mirror.dkm.cz/archlinux/$repo/os/$arch
|
||||
#Server = https://mirror.dkm.cz/archlinux/$repo/os/$arch
|
||||
#Server = http://ftp.fi.muni.cz/pub/linux/arch/$repo/os/$arch
|
||||
#Server = http://ftp.linux.cz/pub/linux/arch/$repo/os/$arch
|
||||
#Server = http://gluttony.sin.cvut.cz/arch/$repo/os/$arch
|
||||
#Server = https://gluttony.sin.cvut.cz/arch/$repo/os/$arch
|
||||
#Server = http://mirrors.nic.cz/archlinux/$repo/os/$arch
|
||||
#Server = http://ftp.sh.cvut.cz/arch/$repo/os/$arch
|
||||
#Server = https://ftp.sh.cvut.cz/arch/$repo/os/$arch
|
||||
#Server = http://mirror.vpsfree.cz/archlinux/$repo/os/$arch
|
||||
|
||||
## Denmark
|
||||
#Server = http://mirrors.dotsrc.org/archlinux/$repo/os/$arch
|
||||
#Server = https://mirrors.dotsrc.org/archlinux/$repo/os/$arch
|
||||
#Server = http://ftp.klid.dk/ftp/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.one.com/archlinux/$repo/os/$arch
|
||||
#Server = https://mirror.one.com/archlinux/$repo/os/$arch
|
||||
|
||||
## Ecuador
|
||||
#Server = http://mirror.cedia.org.ec/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.espoch.edu.ec/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.uta.edu.ec/archlinux/$repo/os/$arch
|
||||
|
||||
## Finland
|
||||
#Server = http://arch.mirror.far.fi/$repo/os/$arch
|
||||
|
||||
## France
|
||||
#Server = http://archlinux.de-labrusse.fr/$repo/os/$arch
|
||||
#Server = http://mirror.archlinux.ikoula.com/archlinux/$repo/os/$arch
|
||||
#Server = http://archlinux.vi-di.fr/$repo/os/$arch
|
||||
#Server = https://archlinux.vi-di.fr/$repo/os/$arch
|
||||
#Server = http://mirror.armbrust.me/archlinux/$repo/os/$arch
|
||||
#Server = https://mirror.armbrust.me/archlinux/$repo/os/$arch
|
||||
#Server = https://archlinux.ec-tech.fr/$repo/os/$arch
|
||||
#Server = http://fooo.biz/archlinux/$repo/os/$arch
|
||||
#Server = https://fooo.biz/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.gerhard.re/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.ibcp.fr/pub/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.lastmikoi.net/archlinux/$repo/os/$arch
|
||||
#Server = http://archlinux.mailtunnel.eu/$repo/os/$arch
|
||||
#Server = https://www.mailtunnel.eu/archlinux/$repo/os/$arch
|
||||
#Server = http://mir.archlinux.fr/$repo/os/$arch
|
||||
#Server = http://archlinux.mirrors.ovh.net/archlinux/$repo/os/$arch
|
||||
#Server = http://archlinux.mirror.pkern.at/$repo/os/$arch
|
||||
#Server = https://archlinux.mirror.pkern.at/$repo/os/$arch
|
||||
#Server = http://archlinux.polymorf.fr/$repo/os/$arch
|
||||
#Server = http://mirrors.standaloneinstaller.com/archlinux/$repo/os/$arch
|
||||
#Server = http://arch.tamcore.eu/$repo/os/$arch
|
||||
#Server = http://mirror.tyborek.pl/arch/$repo/os/$arch
|
||||
#Server = https://mirror.tyborek.pl/arch/$repo/os/$arch
|
||||
#Server = http://ftp.u-strasbg.fr/linux/distributions/archlinux/$repo/os/$arch
|
||||
#Server = https://mirror.wormhole.eu/archlinux/$repo/os/$arch
|
||||
#Server = http://arch.yourlabs.org/$repo/os/$arch
|
||||
|
||||
## Germany
|
||||
#Server = http://mirror.23media.de/archlinux/$repo/os/$arch
|
||||
#Server = https://arch.32g.eu/$repo/os/$arch
|
||||
#Server = http://artfiles.org/archlinux.org/$repo/os/$arch
|
||||
#Server = https://fabric-mirror.vps.hosteurope.de/archlinux/$repo/os/$arch
|
||||
#Server = https://mirror.bethselamin.de/$repo/os/$arch
|
||||
#Server = http://mirror.euserv.net/linux/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.f4st.host/archlinux/$repo/os/$arch
|
||||
#Server = https://mirror.f4st.host/archlinux/$repo/os/$arch
|
||||
#Server = http://ftp.fau.de/archlinux/$repo/os/$arch
|
||||
#Server = https://ftp.fau.de/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.fluxent.de/archlinux/$repo/os/$arch
|
||||
#Server = https://mirror.fluxent.de/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.gnomus.de/$repo/os/$arch
|
||||
#Server = http://www.gutscheindrache.com/mirror/archlinux/$repo/os/$arch
|
||||
#Server = http://ftp.gwdg.de/pub/linux/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.hactar.xyz/$repo/os/$arch
|
||||
#Server = https://mirror.hactar.xyz/$repo/os/$arch
|
||||
#Server = http://archlinux.honkgong.info/$repo/os/$arch
|
||||
#Server = http://ftp.hosteurope.de/mirror/ftp.archlinux.org/$repo/os/$arch
|
||||
#Server = http://ftp-stud.hs-esslingen.de/pub/Mirrors/archlinux/$repo/os/$arch
|
||||
#Server = http://archlinux.mirror.iphh.net/$repo/os/$arch
|
||||
#Server = http://repo.itmettke.de/archlinux/$repo/os/$arch
|
||||
#Server = https://repo.itmettke.de/archlinux/$repo/os/$arch
|
||||
#Server = https://mirror.jankoppe.de/archlinux/$repo/os/$arch
|
||||
#Server = http://arch.jensgutermuth.de/$repo/os/$arch
|
||||
#Server = https://arch.jensgutermuth.de/$repo/os/$arch
|
||||
#Server = http://mirror.js-webcoding.de/pub/archlinux/$repo/os/$arch
|
||||
#Server = https://mirror.js-webcoding.de/pub/archlinux/$repo/os/$arch
|
||||
#Server = http://k42.ch/mirror/archlinux/$repo/os/$arch
|
||||
#Server = https://k42.ch/mirror/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.de.leaseweb.net/archlinux/$repo/os/$arch
|
||||
Server = https://mirror.de.leaseweb.net/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.loli.forsale/arch/$repo/os/$arch
|
||||
#Server = https://mirror.loli.forsale/arch/$repo/os/$arch
|
||||
#Server = http://mirror.metalgamer.eu/archlinux/$repo/os/$arch
|
||||
#Server = https://mirror.metalgamer.eu/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.michael-eckert.net/archlinux/$repo/os/$arch
|
||||
#Server = https://mirror.michael-eckert.net/archlinux/$repo/os/$arch
|
||||
#Server = http://mirrors.n-ix.net/archlinux/$repo/os/$arch
|
||||
#Server = https://mirrors.n-ix.net/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.netcologne.de/archlinux/$repo/os/$arch
|
||||
Server = https://mirror.netcologne.de/archlinux/$repo/os/$arch
|
||||
#Server = http://mirrors.niyawe.de/archlinux/$repo/os/$arch
|
||||
#Server = https://mirrors.niyawe.de/archlinux/$repo/os/$arch
|
||||
#Server = http://archlinux.nullpointer.io/$repo/os/$arch
|
||||
#Server = https://archlinux.nullpointer.io/$repo/os/$arch
|
||||
#Server = http://mirror.pseudoform.org/$repo/os/$arch
|
||||
#Server = https://mirror.pseudoform.org/$repo/os/$arch
|
||||
#Server = https://www.ratenzahlung.de/mirror/archlinux/$repo/os/$arch
|
||||
#Server = http://ftp.halifax.rwth-aachen.de/archlinux/$repo/os/$arch
|
||||
#Server = http://linux.rz.rub.de/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.selfnet.de/archlinux/$repo/os/$arch
|
||||
#Server = http://ftp.spline.inf.fu-berlin.de/mirrors/archlinux/$repo/os/$arch
|
||||
#Server = https://ftp.spline.inf.fu-berlin.de/mirrors/archlinux/$repo/os/$arch
|
||||
#Server = http://archlinux.thaller.ws/$repo/os/$arch
|
||||
#Server = https://archlinux.thaller.ws/$repo/os/$arch
|
||||
#Server = http://archlinux.thelinuxnetworx.rocks/$repo/os/$arch
|
||||
#Server = https://archlinux.thelinuxnetworx.rocks/$repo/os/$arch
|
||||
#Server = http://archmirror.tomforb.es/$repo/os/$arch
|
||||
#Server = https://archmirror.tomforb.es/$repo/os/$arch
|
||||
#Server = http://ftp.tu-chemnitz.de/pub/linux/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.ubrco.de/archlinux/$repo/os/$arch
|
||||
#Server = https://mirror.ubrco.de/archlinux/$repo/os/$arch
|
||||
#Server = http://ftp.uni-bayreuth.de/linux/archlinux/$repo/os/$arch
|
||||
#Server = http://ftp.uni-hannover.de/archlinux/$repo/os/$arch
|
||||
#Server = http://ftp.uni-kl.de/pub/linux/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.united-gameserver.de/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.vfn-nrw.de/archlinux/$repo/os/$arch
|
||||
#Server = https://mirror.vfn-nrw.de/archlinux/$repo/os/$arch
|
||||
|
||||
## Greece
|
||||
#Server = http://ftp.cc.uoc.gr/mirrors/linux/archlinux/$repo/os/$arch
|
||||
#Server = http://foss.aueb.gr/mirrors/linux/archlinux/$repo/os/$arch
|
||||
#Server = https://foss.aueb.gr/mirrors/linux/archlinux/$repo/os/$arch
|
||||
#Server = http://mirrors.myaegean.gr/linux/archlinux/$repo/os/$arch
|
||||
#Server = http://ftp.ntua.gr/pub/linux/archlinux/$repo/os/$arch
|
||||
#Server = http://ftp.otenet.gr/linux/archlinux/$repo/os/$arch
|
||||
|
||||
## Hong Kong
|
||||
#Server = http://arch-mirror.wtako.net/$repo/os/$arch
|
||||
#Server = https://arch-mirror.wtako.net/$repo/os/$arch
|
||||
|
||||
## Hungary
|
||||
#Server = http://ftp.energia.mta.hu/pub/mirrors/ftp.archlinux.org/$repo/os/$arch
|
||||
#Server = http://archmirror.hbit.sztaki.hu/archlinux/$repo/os/$arch
|
||||
|
||||
## Iceland
|
||||
#Server = http://mirror.system.is/arch/$repo/os/$arch
|
||||
#Server = https://mirror.system.is/arch/$repo/os/$arch
|
||||
|
||||
## India
|
||||
#Server = http://mirror.cse.iitk.ac.in/archlinux/$repo/os/$arch
|
||||
#Server = http://ftp.iitm.ac.in/archlinux/$repo/os/$arch
|
||||
|
||||
## Indonesia
|
||||
#Server = http://mirror.devilzc0de.org/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.poliwangi.ac.id/archlinux/$repo/os/$arch
|
||||
#Server = http://suro.ubaya.ac.id/archlinux/$repo/os/$arch
|
||||
|
||||
## Iran
|
||||
#Server = http://repo.sadjad.ac.ir/arch/$repo/os/$arch
|
||||
#Server = https://repo.sadjad.ac.ir/arch/$repo/os/$arch
|
||||
|
||||
## Ireland
|
||||
#Server = http://ftp.heanet.ie/mirrors/ftp.archlinux.org/$repo/os/$arch
|
||||
#Server = https://ftp.heanet.ie/mirrors/ftp.archlinux.org/$repo/os/$arch
|
||||
|
||||
## Israel
|
||||
#Server = http://mirror.isoc.org.il/pub/archlinux/$repo/os/$arch
|
||||
|
||||
## Italy
|
||||
#Server = http://archlinux.prometeolibero.eu/archlinux/$repo/os/$arch
|
||||
#Server = https://archlinux.prometeolibero.eu/archlinux/$repo/os/$arch
|
||||
#Server = https://archlinux.beccacervello.it/archlinux/$repo/os/$arch
|
||||
#Server = http://mi.mirror.garr.it/mirrors/archlinux/$repo/os/$arch
|
||||
#Server = http://mirrors.prometeus.net/archlinux/$repo/os/$arch
|
||||
#Server = http://archlinux.students.cs.unibo.it/$repo/os/$arch
|
||||
|
||||
## Japan
|
||||
#Server = http://ftp.tsukuba.wide.ad.jp/Linux/archlinux/$repo/os/$arch
|
||||
Server = http://ftp.jaist.ac.jp/pub/Linux/ArchLinux/$repo/os/$arch
|
||||
|
||||
## Kazakhstan
|
||||
#Server = http://mirror.neolabs.kz/archlinux/$repo/os/$arch
|
||||
|
||||
## Latvia
|
||||
#Server = http://archlinux.koyanet.lv/archlinux/$repo/os/$arch
|
||||
|
||||
## Lithuania
|
||||
#Server = http://mirrors.atviras.lt/archlinux/$repo/os/$arch
|
||||
#Server = https://mirrors.atviras.lt/archlinux/$repo/os/$arch
|
||||
|
||||
## Luxembourg
|
||||
#Server = http://archlinux.mirror.root.lu/$repo/os/$arch
|
||||
|
||||
## Macedonia
|
||||
#Server = http://arch.softver.org.mk/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.t-home.mk/archlinux/$repo/os/$arch
|
||||
#Server = https://mirror.t-home.mk/archlinux/$repo/os/$arch
|
||||
|
||||
## Netherlands
|
||||
#Server = http://arch.apt-get.eu/$repo/os/$arch
|
||||
#Server = http://mirror.i3d.net/pub/archlinux/$repo/os/$arch
|
||||
#Server = https://mirror.i3d.net/pub/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.nl.leaseweb.net/archlinux/$repo/os/$arch
|
||||
#Server = https://mirror.nl.leaseweb.net/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.netrouting.net/archlinux/$repo/os/$arch
|
||||
#Server = http://ftp.nluug.nl/os/Linux/distr/archlinux/$repo/os/$arch
|
||||
#Server = http://ftp.snt.utwente.nl/pub/os/linux/archlinux/$repo/os/$arch
|
||||
#Server = http://archlinux.mirror.wearetriple.com/$repo/os/$arch
|
||||
#Server = https://archlinux.mirror.wearetriple.com/$repo/os/$arch
|
||||
|
||||
## New Caledonia
|
||||
#Server = http://mirror.lagoon.nc/pub/archlinux/$repo/os/$arch
|
||||
#Server = http://archlinux.nautile.nc/archlinux/$repo/os/$arch
|
||||
|
||||
## New Zealand
|
||||
#Server = https://mirror.smith.geek.nz/archlinux/$repo/os/$arch
|
||||
|
||||
## Norway
|
||||
#Server = http://mirror.archlinux.no/$repo/os/$arch
|
||||
#Server = http://archlinux.uib.no/$repo/os/$arch
|
||||
#Server = http://mirror.neuf.no/archlinux/$repo/os/$arch
|
||||
#Server = https://mirror.neuf.no/archlinux/$repo/os/$arch
|
||||
|
||||
## Philippines
|
||||
#Server = http://mirror.rise.ph/archlinux/$repo/os/$arch
|
||||
|
||||
## Poland
|
||||
#Server = http://mirror.chmuri.net/archmirror/$repo/os/$arch
|
||||
#Server = http://arch.midov.pl/arch/$repo/os/$arch
|
||||
#Server = http://mirror.onet.pl/pub/mirrors/archlinux/$repo/os/$arch
|
||||
#Server = http://piotrkosoft.net/pub/mirrors/ftp.archlinux.org/$repo/os/$arch
|
||||
#Server = http://ftp.vectranet.pl/archlinux/$repo/os/$arch
|
||||
|
||||
## Portugal
|
||||
#Server = http://glua.ua.pt/pub/archlinux/$repo/os/$arch
|
||||
#Server = https://glua.ua.pt/pub/archlinux/$repo/os/$arch
|
||||
#Server = http://ftp.rnl.tecnico.ulisboa.pt/pub/archlinux/$repo/os/$arch
|
||||
|
||||
## Qatar
|
||||
#Server = http://mirror.qnren.qa/archlinux/$repo/os/$arch
|
||||
|
||||
## Romania
|
||||
#Server = http://mirror.archlinux.ro/archlinux/$repo/os/$arch
|
||||
#Server = http://archlinux.mirrors.linux.ro/$repo/os/$arch
|
||||
#Server = http://mirrors.m247.ro/archlinux/$repo/os/$arch
|
||||
#Server = http://mirrors.pidginhost.com/arch/$repo/os/$arch
|
||||
|
||||
## Russia
|
||||
#Server = http://mirror.aur.rocks/$repo/os/$arch
|
||||
#Server = https://mirror.aur.rocks/$repo/os/$arch
|
||||
#Server = http://mirror.rol.ru/archlinux/$repo/os/$arch
|
||||
#Server = https://mirror.rol.ru/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.yandex.ru/archlinux/$repo/os/$arch
|
||||
#Server = https://mirror.yandex.ru/archlinux/$repo/os/$arch
|
||||
|
||||
## Serbia
|
||||
#Server = http://mirror.pmf.kg.ac.rs/archlinux/$repo/os/$arch
|
||||
|
||||
## Singapore
|
||||
#Server = http://mirror.0x.sg/archlinux/$repo/os/$arch
|
||||
#Server = http://download.nus.edu.sg/mirror/arch/$repo/os/$arch
|
||||
|
||||
## Slovakia
|
||||
#Server = http://mirror.lnx.sk/pub/linux/archlinux/$repo/os/$arch
|
||||
#Server = https://mirror.lnx.sk/pub/linux/archlinux/$repo/os/$arch
|
||||
#Server = http://tux.rainside.sk/archlinux/$repo/os/$arch
|
||||
|
||||
## Slovenia
|
||||
#Server = http://archimonde.ts.si/archlinux/$repo/os/$arch
|
||||
#Server = https://archimonde.ts.si/archlinux/$repo/os/$arch
|
||||
|
||||
## South Africa
|
||||
#Server = http://za.mirror.archlinux-br.org/$repo/os/$arch
|
||||
#Server = http://ftp.wa.co.za/pub/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.is.co.za/mirror/archlinux.org/$repo/os/$arch
|
||||
#Server = http://mirror.wbs.co.za/archlinux/$repo/os/$arch
|
||||
|
||||
## South Korea
|
||||
#Server = http://ftp.kaist.ac.kr/ArchLinux/$repo/os/$arch
|
||||
#Server = http://mirror.premi.st/archlinux/$repo/os/$arch
|
||||
|
||||
## Spain
|
||||
#Server = http://osl.ugr.es/archlinux/$repo/os/$arch
|
||||
#Server = http://sunsite.rediris.es/mirror/archlinux/$repo/os/$arch
|
||||
|
||||
## Sweden
|
||||
#Server = http://ftp.acc.umu.se/mirror/archlinux/$repo/os/$arch
|
||||
#Server = https://ftp.acc.umu.se/mirror/archlinux/$repo/os/$arch
|
||||
#Server = http://archlinux.dynamict.se/$repo/os/$arch
|
||||
#Server = https://archlinux.dynamict.se/$repo/os/$arch
|
||||
#Server = http://ftp.lysator.liu.se/pub/archlinux/$repo/os/$arch
|
||||
#Server = https://ftp.lysator.liu.se/pub/archlinux/$repo/os/$arch
|
||||
#Server = http://ftp.myrveln.se/pub/linux/archlinux/$repo/os/$arch
|
||||
#Server = https://ftp.myrveln.se/pub/linux/archlinux/$repo/os/$arch
|
||||
#Server = https://mirror.osbeck.com/archlinux/$repo/os/$arch
|
||||
#Server = http://ftp.portlane.com/pub/os/linux/archlinux/$repo/os/$arch
|
||||
|
||||
## Switzerland
|
||||
#Server = http://pkg.adfinis-sygroup.ch/archlinux/$repo/os/$arch
|
||||
#Server = https://pkg.adfinis-sygroup.ch/archlinux/$repo/os/$arch
|
||||
#Server = http://archlinux.puzzle.ch/$repo/os/$arch
|
||||
|
||||
## Taiwan
|
||||
#Server = http://archlinux.cs.nctu.edu.tw/$repo/os/$arch
|
||||
#Server = http://shadow.ind.ntou.edu.tw/archlinux/$repo/os/$arch
|
||||
#Server = http://ftp.tku.edu.tw/Linux/ArchLinux/$repo/os/$arch
|
||||
#Server = http://ftp.yzu.edu.tw/Linux/archlinux/$repo/os/$arch
|
||||
|
||||
## Thailand
|
||||
#Server = http://mirror.adminbannok.com/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.kku.ac.th/archlinux/$repo/os/$arch
|
||||
#Server = https://mirror.kku.ac.th/archlinux/$repo/os/$arch
|
||||
|
||||
## Turkey
|
||||
#Server = http://ftp.linux.org.tr/archlinux/$repo/os/$arch
|
||||
|
||||
## Ukraine
|
||||
#Server = http://archlinux.ip-connect.vn.ua/$repo/os/$arch
|
||||
#Server = https://archlinux.ip-connect.vn.ua/$repo/os/$arch
|
||||
#Server = http://mirrors.nix.org.ua/linux/archlinux/$repo/os/$arch
|
||||
#Server = https://mirrors.nix.org.ua/linux/archlinux/$repo/os/$arch
|
||||
|
||||
## United Kingdom
|
||||
#Server = http://mirror.bytemark.co.uk/archlinux/$repo/os/$arch
|
||||
#Server = http://mirrors.manchester.m247.com/arch-linux/$repo/os/$arch
|
||||
#Server = http://www.mirrorservice.org/sites/ftp.archlinux.org/$repo/os/$arch
|
||||
#Server = http://arch.serverspace.co.uk/arch/$repo/os/$arch
|
||||
#Server = http://archlinux.mirrors.uk2.net/$repo/os/$arch
|
||||
|
||||
## United States
|
||||
#Server = http://mirrors.acm.wpi.edu/archlinux/$repo/os/$arch
|
||||
#Server = http://mirrors.advancedhosters.com/archlinux/$repo/os/$arch
|
||||
#Server = http://mirrors.aggregate.org/archlinux/$repo/os/$arch
|
||||
#Server = http://ca.us.mirror.archlinux-br.org/$repo/os/$arch
|
||||
#Server = http://il.us.mirror.archlinux-br.org/$repo/os/$arch
|
||||
#Server = http://archlinux.surlyjake.com/archlinux/$repo/os/$arch
|
||||
#Server = http://arlm.tyzoid.com/$repo/os/$arch
|
||||
#Server = http://mirror.as65535.net/archlinux/$repo/os/$arch
|
||||
#Server = http://mirrors.cat.pdx.edu/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.cc.columbia.edu/pub/linux/archlinux/$repo/os/$arch
|
||||
#Server = http://arch.mirror.constant.com/$repo/os/$arch
|
||||
#Server = https://arch.mirror.constant.com/$repo/os/$arch
|
||||
#Server = http://cosmos.cites.illinois.edu/pub/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.cs.pitt.edu/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.cs.vt.edu/pub/ArchLinux/$repo/os/$arch
|
||||
#Server = http://mirror.epiphyte.network/archlinux/$repo/os/$arch
|
||||
#Server = https://mirror.epiphyte.network/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.es.its.nyu.edu/archlinux/$repo/os/$arch
|
||||
#Server = http://mirrors.gigenet.com/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.grig.io/archlinux/$repo/os/$arch
|
||||
#Server = https://mirror.grig.io/archlinux/$repo/os/$arch
|
||||
#Server = http://www.gtlib.gatech.edu/pub/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror1.hackingand.coffee/arch/$repo/os/$arch
|
||||
#Server = http://mirror2.hackingand.coffee/arch/$repo/os/$arch
|
||||
#Server = http://mirror3.hackingand.coffee/arch/$repo/os/$arch
|
||||
#Server = http://mirror.htnshost.com/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.jmu.edu/pub/archlinux/$repo/os/$arch
|
||||
#Server = http://mirrors.kernel.org/archlinux/$repo/os/$arch
|
||||
#Server = https://mirrors.kernel.org/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.us.leaseweb.net/archlinux/$repo/os/$arch
|
||||
#Server = https://mirror.us.leaseweb.net/archlinux/$repo/os/$arch
|
||||
#Server = http://il.mirrors.linaxe.net/archlinux/$repo/os/$arch
|
||||
#Server = http://mirrors.liquidweb.com/archlinux/$repo/os/$arch
|
||||
#Server = http://arch.localmsp.org/arch/$repo/os/$arch
|
||||
#Server = https://arch.localmsp.org/arch/$repo/os/$arch
|
||||
#Server = http://mirror.lty.me/archlinux/$repo/os/$arch
|
||||
#Server = https://mirror.lty.me/archlinux/$repo/os/$arch
|
||||
#Server = http://mirrors.lug.mtu.edu/archlinux/$repo/os/$arch
|
||||
#Server = https://mirrors.lug.mtu.edu/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.math.princeton.edu/pub/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.metrocast.net/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.kaminski.io/archlinux/$repo/os/$arch
|
||||
#Server = https://mirror.kaminski.io/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.nexcess.net/archlinux/$repo/os/$arch
|
||||
#Server = http://mirrors.ocf.berkeley.edu/archlinux/$repo/os/$arch
|
||||
#Server = https://mirrors.ocf.berkeley.edu/archlinux/$repo/os/$arch
|
||||
#Server = http://ftp.osuosl.org/pub/archlinux/$repo/os/$arch
|
||||
#Server = http://arch.mirrors.pair.com/$repo/os/$arch
|
||||
#Server = http://mirrors.rit.edu/archlinux/$repo/os/$arch
|
||||
#Server = https://mirrors.rit.edu/archlinux/$repo/os/$arch
|
||||
#Server = http://mirrors.rutgers.edu/archlinux/$repo/os/$arch
|
||||
#Server = https://mirrors.rutgers.edu/archlinux/$repo/os/$arch
|
||||
#Server = https://mirrors.tuxns.net/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.umd.edu/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.vtti.vt.edu/archlinux/$repo/os/$arch
|
||||
#Server = http://mirrors.xmission.com/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror.yellowfiber.net/archlinux/$repo/os/$arch
|
||||
|
||||
## Vietnam
|
||||
#Server = http://f.archlinuxvn.org/archlinux/$repo/os/$arch
|
||||
#Server = http://mirror-fpt-telecom.fpt.net/archlinux/$repo/os/$arch
|
||||
|
||||
|
|
@ -1,412 +0,0 @@
|
|||
# For more information on configuration, see:
|
||||
# * Official English Documentation: http://nginx.org/en/docs/
|
||||
# * Official Russian Documentation: http://nginx.org/ru/docs/
|
||||
|
||||
user nginx;
|
||||
worker_processes auto;
|
||||
error_log /var/log/nginx/error.log;
|
||||
pid /run/nginx.pid;
|
||||
|
||||
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
|
||||
include /usr/share/nginx/modules/*.conf;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
|
||||
access_log /var/log/nginx/access.log main;
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
types_hash_max_size 4096;
|
||||
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
# Load modular configuration files from the /etc/nginx/conf.d directory.
|
||||
# See http://nginx.org/en/docs/ngx_core_module.html#include
|
||||
# for more information.
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
server_name .jaseg.net;
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2 default_server;
|
||||
listen [::]:443 ssl http2 default_server;
|
||||
server_name gerbolyze.jaseg.net;
|
||||
root /usr/share/nginx/html;
|
||||
|
||||
ssl_certificate "/etc/letsencrypt/live/gerbolyze.jaseg.net/fullchain.pem";
|
||||
ssl_certificate_key "/etc/letsencrypt/live/gerbolyze.jaseg.net/privkey.pem";
|
||||
ssl_dhparam "/etc/letsencrypt/ssl-dhparams.pem";
|
||||
include /etc/letsencrypt/options-ssl-nginx.conf;
|
||||
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
|
||||
resolver 67.207.67.2 67.207.67.3 valid=300s;
|
||||
resolver_timeout 10s;
|
||||
|
||||
add_header Strict-Transport-Security "max-age=86400";
|
||||
|
||||
# Load configuration files for the default server block.
|
||||
include /etc/nginx/default.d/*.conf;
|
||||
|
||||
location ^~ /static/ {
|
||||
root /var/lib/gerboweb;
|
||||
}
|
||||
|
||||
location / {
|
||||
include uwsgi_params;
|
||||
uwsgi_pass unix:/run/uwsgi/gerboweb.socket;
|
||||
}
|
||||
|
||||
error_page 404 /404.html;
|
||||
location = /40x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name blog.jaseg.net;
|
||||
root /usr/share/nginx/html;
|
||||
|
||||
ssl_certificate "/etc/letsencrypt/live/blog.jaseg.net/fullchain.pem";
|
||||
ssl_certificate_key "/etc/letsencrypt/live/blog.jaseg.net/privkey.pem";
|
||||
ssl_dhparam "/etc/letsencrypt/ssl-dhparams.pem";
|
||||
include /etc/letsencrypt/options-ssl-nginx.conf;
|
||||
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
|
||||
resolver 67.207.67.2 67.207.67.3 valid=300s;
|
||||
resolver_timeout 10s;
|
||||
|
||||
add_header Strict-Transport-Security "max-age=86400";
|
||||
|
||||
# Load configuration files for the default server block.
|
||||
include /etc/nginx/default.d/*.conf;
|
||||
|
||||
location / {
|
||||
root /var/www/blog.jaseg.net;
|
||||
}
|
||||
|
||||
location /d/ {
|
||||
access_log off;
|
||||
log_not_found off;
|
||||
rewrite ^/d/(.*)$ /$1 break;
|
||||
include uwsgi_params;
|
||||
uwsgi_pass unix:/run/uwsgi/secure-download.socket;
|
||||
}
|
||||
|
||||
error_page 404 /404.html;
|
||||
location = /40x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name automation.jaseg.de;
|
||||
root /usr/share/nginx/html;
|
||||
|
||||
ssl_certificate "/etc/letsencrypt/live/automation.jaseg.de/fullchain.pem";
|
||||
ssl_certificate_key "/etc/letsencrypt/live/automation.jaseg.de/privkey.pem";
|
||||
ssl_dhparam "/etc/letsencrypt/ssl-dhparams.pem";
|
||||
include /etc/letsencrypt/options-ssl-nginx.conf;
|
||||
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
|
||||
resolver 67.207.67.2 67.207.67.3 valid=300s;
|
||||
resolver_timeout 10s;
|
||||
|
||||
add_header Strict-Transport-Security "max-age=86400";
|
||||
|
||||
# Load configuration files for the default server block.
|
||||
include /etc/nginx/default.d/*.conf;
|
||||
|
||||
location / {
|
||||
include uwsgi_params;
|
||||
uwsgi_pass unix:/run/uwsgi/notification-proxy.socket;
|
||||
}
|
||||
|
||||
error_page 404 /404.html;
|
||||
location = /40x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name kochbuch.jaseg.net;
|
||||
root /usr/share/nginx/html;
|
||||
|
||||
ssl_certificate "/etc/letsencrypt/live/kochbuch.jaseg.net/fullchain.pem";
|
||||
ssl_certificate_key "/etc/letsencrypt/live/kochbuch.jaseg.net/privkey.pem";
|
||||
ssl_dhparam "/etc/letsencrypt/ssl-dhparams.pem";
|
||||
include /etc/letsencrypt/options-ssl-nginx.conf;
|
||||
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
|
||||
resolver 67.207.67.2 67.207.67.3 valid=300s;
|
||||
resolver_timeout 10s;
|
||||
|
||||
add_header Strict-Transport-Security "max-age=86400";
|
||||
|
||||
# Load configuration files for the default server block.
|
||||
include /etc/nginx/default.d/*.conf;
|
||||
|
||||
location / {
|
||||
auth_basic "blubb";
|
||||
auth_basic_user_file /etc/nginx/kochbuch.htpasswd;
|
||||
root /var/www/kochbuch.jaseg.net;
|
||||
}
|
||||
|
||||
error_page 404 /404.html;
|
||||
location = /40x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name pogojig.jaseg.net;
|
||||
root /usr/share/nginx/html;
|
||||
|
||||
ssl_certificate "/etc/letsencrypt/live/pogojig.jaseg.net/fullchain.pem";
|
||||
ssl_certificate_key "/etc/letsencrypt/live/pogojig.jaseg.net/privkey.pem";
|
||||
ssl_dhparam "/etc/letsencrypt/ssl-dhparams.pem";
|
||||
include /etc/letsencrypt/options-ssl-nginx.conf;
|
||||
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
|
||||
resolver 67.207.67.2 67.207.67.3 valid=300s;
|
||||
resolver_timeout 10s;
|
||||
client_max_body_size 10M;
|
||||
|
||||
add_header Strict-Transport-Security "max-age=86400";
|
||||
|
||||
# Load configuration files for the default server block.
|
||||
include /etc/nginx/default.d/*.conf;
|
||||
|
||||
location ^~ /pogospace/ {
|
||||
root /var/lib/pogojig/pogospace;
|
||||
}
|
||||
|
||||
location / {
|
||||
include uwsgi_params;
|
||||
uwsgi_pass unix:/run/uwsgi/pogojig.socket;
|
||||
}
|
||||
|
||||
error_page 404 /404.html;
|
||||
location = /40x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name tracespace.jaseg.net;
|
||||
root /usr/share/nginx/html;
|
||||
|
||||
ssl_certificate "/etc/letsencrypt/live/tracespace.jaseg.net/fullchain.pem";
|
||||
ssl_certificate_key "/etc/letsencrypt/live/tracespace.jaseg.net/privkey.pem";
|
||||
ssl_dhparam "/etc/letsencrypt/ssl-dhparams.pem";
|
||||
include /etc/letsencrypt/options-ssl-nginx.conf;
|
||||
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
|
||||
resolver 67.207.67.2 67.207.67.3 valid=300s;
|
||||
resolver_timeout 10s;
|
||||
|
||||
add_header Strict-Transport-Security "max-age=86400";
|
||||
|
||||
# Load configuration files for the default server block.
|
||||
include /etc/nginx/default.d/*.conf;
|
||||
|
||||
location / {
|
||||
root /var/www/tracespace.jaseg.net;
|
||||
}
|
||||
|
||||
error_page 404 /404.html;
|
||||
location = /40x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name openjscad.jaseg.net;
|
||||
root /usr/share/nginx/html;
|
||||
|
||||
ssl_certificate "/etc/letsencrypt/live/openjscad.jaseg.net/fullchain.pem";
|
||||
ssl_certificate_key "/etc/letsencrypt/live/openjscad.jaseg.net/privkey.pem";
|
||||
ssl_dhparam "/etc/letsencrypt/ssl-dhparams.pem";
|
||||
include /etc/letsencrypt/options-ssl-nginx.conf;
|
||||
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
|
||||
resolver 67.207.67.2 67.207.67.3 valid=300s;
|
||||
resolver_timeout 10s;
|
||||
|
||||
add_header Strict-Transport-Security "max-age=86400";
|
||||
|
||||
# Load configuration files for the default server block.
|
||||
include /etc/nginx/default.d/*.conf;
|
||||
|
||||
location / {
|
||||
root /var/www/openjscad.jaseg.net;
|
||||
}
|
||||
|
||||
error_page 404 /404.html;
|
||||
location = /40x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name git.jaseg.net;
|
||||
root /usr/share/nginx/html;
|
||||
|
||||
ssl_certificate "/etc/letsencrypt/live/git.jaseg.net/fullchain.pem";
|
||||
ssl_certificate_key "/etc/letsencrypt/live/git.jaseg.net/privkey.pem";
|
||||
ssl_dhparam "/etc/letsencrypt/ssl-dhparams.pem";
|
||||
include /etc/letsencrypt/options-ssl-nginx.conf;
|
||||
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
|
||||
resolver 67.207.67.2 67.207.67.3 valid=300s;
|
||||
resolver_timeout 10s;
|
||||
|
||||
add_header Strict-Transport-Security "max-age=86400";
|
||||
|
||||
# Load configuration files for the default server block.
|
||||
include /etc/nginx/default.d/*.conf;
|
||||
|
||||
location ~ ^/(cgit.css|robots.txt) {
|
||||
root /usr/share/cgit;
|
||||
expires 30d;
|
||||
}
|
||||
|
||||
location ~ ^/(cgit.png|favicon.png) {
|
||||
alias /var/www/git.jaseg.net/cgit.png;
|
||||
}
|
||||
|
||||
location / {
|
||||
include uwsgi_params;
|
||||
uwsgi_modifier1 9;
|
||||
uwsgi_pass unix:/run/uwsgi/cgit.socket;
|
||||
}
|
||||
|
||||
error_page 404 /404.html;
|
||||
location = /40x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name dyndns.jaseg.de;
|
||||
root /usr/share/nginx/html;
|
||||
|
||||
ssl_certificate "/etc/letsencrypt/live/dyndns.jaseg.de/fullchain.pem";
|
||||
ssl_certificate_key "/etc/letsencrypt/live/dyndns.jaseg.de/privkey.pem";
|
||||
ssl_dhparam "/etc/letsencrypt/ssl-dhparams.pem";
|
||||
include /etc/letsencrypt/options-ssl-nginx.conf;
|
||||
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
|
||||
resolver 67.207.67.2 67.207.67.3 valid=300s;
|
||||
resolver_timeout 10s;
|
||||
|
||||
add_header Strict-Transport-Security "max-age=86400";
|
||||
|
||||
# Load configuration files for the default server block.
|
||||
include /etc/nginx/default.d/*.conf;
|
||||
|
||||
location / {
|
||||
include uwsgi_params;
|
||||
uwsgi_pass unix:/run/uwsgi/dyndns.socket;
|
||||
}
|
||||
|
||||
error_page 404 /404.html;
|
||||
location = /40x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
# For more information on configuration, see:
|
||||
# * Official English Documentation: http://nginx.org/en/docs/
|
||||
# * Official Russian Documentation: http://nginx.org/ru/docs/
|
||||
|
||||
user nginx;
|
||||
worker_processes auto;
|
||||
error_log /var/log/nginx/error.log;
|
||||
pid /run/nginx.pid;
|
||||
|
||||
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
|
||||
include /usr/share/nginx/modules/*.conf;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
|
||||
access_log /var/log/nginx/access.log main;
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
types_hash_max_size 4096;
|
||||
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
# Load modular configuration files from the /etc/nginx/conf.d directory.
|
||||
# See http://nginx.org/en/docs/ngx_core_module.html#include
|
||||
# for more information.
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
|
||||
server {
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
server_name gerbolyze.jaseg.net;
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
server_name blog.jaseg.net;
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,179 +0,0 @@
|
|||
import smtplib
|
||||
import ssl
|
||||
import email.utils
|
||||
import hmac
|
||||
from email.mime.text import MIMEText
|
||||
from datetime import datetime
|
||||
import time
|
||||
import functools
|
||||
import json
|
||||
import binascii
|
||||
import uwsgidecorators
|
||||
|
||||
import sqlite3
|
||||
|
||||
from flask import Flask, request, abort
|
||||
|
||||
app = Flask(__name__)
|
||||
app.config.from_pyfile('config.py')
|
||||
|
||||
db = sqlite3.connect(app.config['SQLITE_DB'], check_same_thread=False)
|
||||
with db as conn:
|
||||
conn.execute('''CREATE TABLE IF NOT EXISTS seqs_seen
|
||||
(route_name TEXT PRIMARY KEY,
|
||||
seq INTEGER)''')
|
||||
conn.execute('''CREATE TABLE IF NOT EXISTS time_seen
|
||||
(route_name TEXT PRIMARY KEY)''')
|
||||
|
||||
conn.execute('''CREATE TABLE IF NOT EXISTS heartbeats_seen
|
||||
(route_name TEXT PRIMARY KEY,
|
||||
timestamp INTEGER,
|
||||
notified INTEGER)''')
|
||||
# Clear table on startup to avoid spurious notifications
|
||||
conn.execute('''DELETE FROM heartbeats_seen''')
|
||||
|
||||
mail_routes = {}
|
||||
|
||||
def mail_route(name, receiver, secret):
|
||||
def wrap(func):
|
||||
global routes
|
||||
mail_routes[name] = (receiver, func, secret)
|
||||
return func
|
||||
return wrap
|
||||
|
||||
|
||||
def authenticate(route_name, secret, clock_delta_tolerance:'s'=120):
|
||||
with db as conn:
|
||||
if not request.is_json:
|
||||
print('Rejecting notification: Incorrect content type')
|
||||
abort(400)
|
||||
|
||||
if not 'auth' in request.json and 'payload' in request.json:
|
||||
print('Rejecting notification: signature or payload not found')
|
||||
abort(400)
|
||||
|
||||
if not isinstance(request.json['auth'], str):
|
||||
print('Rejecting notification: signature is of incorrect type')
|
||||
abort(400)
|
||||
their_digest = binascii.unhexlify(request.json['auth'])
|
||||
|
||||
our_digest = hmac.digest(secret.encode('utf-8'), request.json['payload'].encode('utf-8'), 'sha256')
|
||||
if not hmac.compare_digest(their_digest, our_digest):
|
||||
print('Rejecting notification: Incorrect signature')
|
||||
abort(403)
|
||||
|
||||
try:
|
||||
payload = json.loads(request.json['payload'])
|
||||
except:
|
||||
print('Rejecting notification: Payload is not JSON')
|
||||
abort(400)
|
||||
|
||||
last_seqnum = conn.execute('SELECT seq FROM seqs_seen WHERE route_name = ?', (route_name,)).fetchone() or 0
|
||||
# We can check for seq here: Only an attacker with knowledge of the secret would be able to remove
|
||||
# seq from a message. This means for a single key, only messages with or without seq may ever be used.
|
||||
if 'seq' in payload:
|
||||
seq = payload['seq']
|
||||
if not isinstance(seq, int):
|
||||
print('Rejecting notification: seq of wrong type')
|
||||
abort(400)
|
||||
|
||||
if seq <= last_seqnum:
|
||||
print('Rejecting notification: seq out of order')
|
||||
abort(400)
|
||||
|
||||
conn.execute('INSERT OR REPLACE INTO seqs_seen VALUES (?, ?)', (route_name, seq))
|
||||
|
||||
elif last_seqnum:
|
||||
print('Rejecting notification: seq not included but past messages included seq')
|
||||
abort(400)
|
||||
|
||||
msg_time = None
|
||||
if 'time' in payload:
|
||||
msg_time = payload['time']
|
||||
if not isinstance(msg_time, int):
|
||||
print('Rejecting notification: time of wrong type')
|
||||
abort(400)
|
||||
|
||||
if abs(msg_time - int(time.time())) > clock_delta_tolerance:
|
||||
print('Rejecting notification: timestamp too far in the future or past')
|
||||
abort(400)
|
||||
|
||||
conn.execute('INSERT OR REPLACE INTO time_seen VALUES (?)', (route_name,))
|
||||
|
||||
elif conn.execute('SELECT * FROM time_seen WHERE route_name = ?', (route_name,)).fetchone():
|
||||
print('Rejecting notification: time not included but past messages included time')
|
||||
abort(400)
|
||||
|
||||
if msg_time is None:
|
||||
msg_time = int(time.time())
|
||||
|
||||
return msg_time, payload['scope'], payload['d']
|
||||
|
||||
@mail_route('klingel', 'computerstuff@jaseg.de', app.config['SECRET_KLINGEL'])
|
||||
def klingel(classification='somewhere', rms=None, capture=None, **kwargs):
|
||||
return (f'It rang {classification}!',
|
||||
f'rms={rms}\ncapture={capture}\nextra_args={kwargs}')
|
||||
|
||||
|
||||
def send_mail(route_name, receiver, subject, body):
|
||||
try:
|
||||
context = ssl.create_default_context()
|
||||
smtp = smtplib.SMTP_SSL(app.config['SMTP_HOST'], app.config['SMTP_PORT'])
|
||||
smtp.login('apikey', app.config['SENDGRID_APIKEY'])
|
||||
|
||||
sender = f'{route_name}@{app.config["DOMAIN"]}'
|
||||
|
||||
msg = MIMEText(body)
|
||||
msg['Subject'] = subject
|
||||
msg['From'] = sender
|
||||
msg['To'] = receiver
|
||||
msg['Date'] = email.utils.formatdate()
|
||||
|
||||
smtp.sendmail(sender, receiver, msg.as_string())
|
||||
finally:
|
||||
smtp.quit()
|
||||
|
||||
@app.route('/v1/notify/<route_name>', methods=['POST'])
|
||||
def notify(route_name):
|
||||
receiver, func, secret = mail_routes[route_name]
|
||||
msg_time, scope, kwargs = authenticate(route_name, secret)
|
||||
|
||||
if scope == 'default':
|
||||
# Exceptions will yield a 500 error
|
||||
subject, body = func(**kwargs)
|
||||
send_mail(route_name, receiver, subject, body or 'empty message')
|
||||
|
||||
elif scope == 'info':
|
||||
send_mail(route_name, receiver, f'System info: {kwargs["info_msg"]}', f'Logged data: {kwargs}')
|
||||
|
||||
elif scope == 'boot':
|
||||
formatted = datetime.utcfromtimestamp(msg_time).isoformat()
|
||||
send_mail(route_name, receiver, 'System startup', f'System powered up at {formatted}')
|
||||
|
||||
elif scope == 'heartbeat':
|
||||
with db as conn:
|
||||
conn.execute('INSERT OR REPLACE INTO heartbeats_seen VALUES (?, ?, 0)', (route_name, int(time.time())))
|
||||
|
||||
elif scope == 'error':
|
||||
print(f'Device error: {kwargs}')
|
||||
|
||||
return 'success'
|
||||
|
||||
@uwsgidecorators.timer(60)
|
||||
def heartbeat_timer(_uwsgi_signum):
|
||||
threshold = int(time.time()) - app.config['HEARTBEAT_TIMEOUT']
|
||||
with db as conn:
|
||||
for route, ts in db.execute(
|
||||
'SELECT route_name, timestamp FROM heartbeats_seen WHERE timestamp <= ? AND notified == 0',
|
||||
(threshold,)).fetchall():
|
||||
print(f'Heartbeat expired for {route}: {ts} < {threshold}')
|
||||
|
||||
receiver, *_ = mail_routes[route]
|
||||
last = datetime.utcfromtimestamp(ts).isoformat()
|
||||
|
||||
send_mail(route, receiver, 'Heartbeat timeout', f'Last heartbeat at {last}')
|
||||
db.execute('UPDATE heartbeats_seen SET notified = ? WHERE route_name = ?', (int(time.time()), route))
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run()
|
||||
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
|
||||
SENDGRID_APIKEY = '{{lookup('file', 'notification_proxy_sendgrid_apikey.txt')}}'
|
||||
DOMAIN = 'automation.jaseg.de'
|
||||
SMTP_HOST = "smtp.sendgrid.net"
|
||||
SMTP_PORT = 465
|
||||
HEARTBEAT_TIMEOUT = 300
|
||||
SQLITE_DB = '{{notification_proxy_sqlite_dbfile}}'
|
||||
|
||||
SECRET_KLINGEL = '{{lookup('password', 'notification_proxy_klingel_secret.txt length=32')}}'
|
||||
|
|
@ -1,111 +0,0 @@
|
|||
- name: DNS setup
|
||||
hosts: localhost
|
||||
module_defaults:
|
||||
inwx:
|
||||
username: "{{lookup('ini', 'user section=inwx file=credentials.ini')}}"
|
||||
password: "{{lookup('ini', 'pass section=inwx file=credentials.ini')}}"
|
||||
vars:
|
||||
subdomains:
|
||||
- git.jaseg.net
|
||||
- blog.jaseg.net
|
||||
- kochbuch.jaseg.net
|
||||
- gerbolyze.jaseg.net
|
||||
- tracespace.jaseg.net
|
||||
- openjscad.jaseg.net
|
||||
- pogojig.jaseg.net
|
||||
- automation.jaseg.de
|
||||
- dyndns.jaseg.de
|
||||
fastmail_domains:
|
||||
- jaseg.net
|
||||
- jaseg.de
|
||||
tasks:
|
||||
- name: Gather wendelstein facts
|
||||
setup:
|
||||
delegate_to: wendelstein
|
||||
delegate_facts: True
|
||||
|
||||
- name: Setup DNS
|
||||
include_tasks: dns.yml
|
||||
|
||||
|
||||
- name: Wendelstein setup
|
||||
hosts: wendelstein
|
||||
tasks:
|
||||
- name: Set hostname
|
||||
hostname:
|
||||
name: wendelstein.jaseg.net
|
||||
|
||||
- name: Install common admin tools
|
||||
dnf:
|
||||
name: htop,tmux,fish,mosh,neovim,sqlite
|
||||
state: latest
|
||||
|
||||
- name: Install host requisites
|
||||
dnf:
|
||||
name: nginx,uwsgi,python3-flask,python3-flask-wtf,uwsgi-plugin-python3,certbot,python3-certbot-nginx,libselinux-python,git,iptables-services,python3-pycryptodomex,zip,python3-uwsgidecorators,nsd
|
||||
state: latest
|
||||
|
||||
- name: Disable password-based root login
|
||||
lineinfile:
|
||||
path: /etc/ssh/sshd_config
|
||||
regexp: '^PermitRootLogin'
|
||||
line: 'PermitRootLogin without-password'
|
||||
register: disable_root_pw_ssh
|
||||
|
||||
- name: Restart sshd
|
||||
systemd:
|
||||
name: sshd
|
||||
state: restarted
|
||||
when: disable_root_pw_ssh is changed
|
||||
|
||||
- name: Configure iptables firewall service
|
||||
copy:
|
||||
src: iptables.rules
|
||||
dest: /etc/sysconfig/iptables
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0664
|
||||
|
||||
- name: Enable iptables firewall service
|
||||
systemd:
|
||||
name: iptables
|
||||
enabled: yes
|
||||
state: started
|
||||
|
||||
- name: Create containers
|
||||
include_tasks: setup_containers.yml
|
||||
vars:
|
||||
containers:
|
||||
- gerboweb
|
||||
- clippy
|
||||
- pogojig
|
||||
|
||||
- name: Setup web server
|
||||
include_tasks: setup_webserver.yml
|
||||
|
||||
- name: Setup gerboweb
|
||||
include_tasks: setup_gerboweb.yml
|
||||
|
||||
- name: Setup clippy
|
||||
include_tasks: setup_clippy.yml
|
||||
|
||||
- name: Setup secure download
|
||||
include_tasks: setup_secure_download.yml
|
||||
|
||||
- name: Setup tracespace
|
||||
include_tasks: setup_tracespace.yml
|
||||
|
||||
- name: Setup openjscad
|
||||
include_tasks: setup_openjscad.yml
|
||||
|
||||
- name: Setup pogojig
|
||||
include_tasks: setup_pogojig.yml
|
||||
|
||||
- name: Setup notification proxy
|
||||
include_tasks: setup_notification_proxy.yml
|
||||
|
||||
- name: Setup semi-public git server
|
||||
include_tasks: setup_git.yml
|
||||
|
||||
- name: Setup private DynDNS service
|
||||
include_tasks: setup_dyndns.yml
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
[Unit]
|
||||
Description=Pogojig render job processor
|
||||
|
||||
[Service]
|
||||
WorkingDirectory=/var/lib/pogojig
|
||||
ExecStart=/usr/bin/python3 job_processor.py {{pogojig_cache}}/job_queue.sqlite3
|
||||
|
||||
[Install]
|
||||
WantedBy=uwsgi-app@pogojig.service
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
MAX_CONTENT_LENGTH=10000000
|
||||
SECRET_KEY="{{lookup('password', 'pogojig_flask_secret.txt length=32')}}"
|
||||
UPLOAD_PATH="{{pogojig_cache}}/upload"
|
||||
JOB_QUEUE_DB="{{pogojig_cache}}/job_queue.sqlite3"
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
[ $# != 1 ] && exit 1
|
||||
ID=$1
|
||||
egrep -x -q '^[-0-9A-Za-z]{36}$'<<<"$ID" || exit 2
|
||||
|
||||
systemd-nspawn \
|
||||
-D {{pogojig_root}} \
|
||||
-x --bind={{pogojig_cache}}/upload/$ID:/mnt \
|
||||
/bin/sh -c "set -euo pipefail
|
||||
cd /mnt
|
||||
|
||||
date; echo 'Cleaning up previous output'
|
||||
rm -rf pcb_shape.dxf jig.stl kicad kicad.zip sources.zip
|
||||
|
||||
date; echo 'Rendering'
|
||||
cp -r /var/lib/pogojig_renderer sources
|
||||
cp input.svg sources/
|
||||
make -C sources
|
||||
|
||||
date; echo 'Packing source bundle'
|
||||
cp -r sources/out/pcb_shape.dxf sources/out/jig.stl sources/out/kicad ./
|
||||
zip -r sources.zip sources
|
||||
zip -r kicad.zip kicad
|
||||
rm -rf sources"
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
[ $# != 1 ] && exit 1
|
||||
ID=$1
|
||||
egrep -x -q '^[-0-9A-Za-z]{36}$'<<<"$ID" || exit 2
|
||||
|
||||
systemd-nspawn \
|
||||
-D {{gerboweb_root}} \
|
||||
-x --bind={{gerboweb_cache}}/upload/$ID:/mnt \
|
||||
/bin/sh -c "set -euo pipefail
|
||||
unzip -j -d /tmp/gerber /mnt/gerber.zip
|
||||
rm -f /mnt/render_top.png /mnt/render_bottom.png /mnt/render_top.small.png /mnt/render_bottom.small.png
|
||||
date; echo 'Rendering bottom layer'
|
||||
gerbolyze render top /tmp/gerber /mnt/render_top.png
|
||||
date; echo 'Scaling down'
|
||||
convert /mnt/render_top.png -resize 500x500 -negate -brightness-contrast 30x30 -colorspace gray /mnt/render_top.small.png
|
||||
date; echo 'Rendering top layer'
|
||||
gerbolyze render bottom /tmp/gerber /mnt/render_bottom.png
|
||||
date; echo 'Scaling down'
|
||||
convert /mnt/render_bottom.png -resize 500x500 -negate -brightness-contrast 30x30 -colorspace gray /mnt/render_bottom.small.png"
|
||||
|
|
@ -1 +0,0 @@
|
|||
SERVE_PATH="{{secure_download_dir}}"
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
---
|
||||
- name: Clone pixelterm git
|
||||
git:
|
||||
repo: https://github.com/jaseg/pixelterm
|
||||
dest: "{{clippy_root}}/var/lib/pixelterm.git"
|
||||
|
||||
- name: Clone clippy git
|
||||
git:
|
||||
repo: https://github.com/jaseg/clippy
|
||||
dest: "{{clippy_root}}/var/lib/clippy.git"
|
||||
|
||||
- name: Setup required packages for clippy
|
||||
command: arch-chroot "{{clippy_root}}" pacman -Syu --noconfirm python3 python-pip python-numpy python-pillow
|
||||
|
||||
- name: Setup pixelterm
|
||||
command: arch-chroot "{{clippy_root}}" sh -c "cd /var/lib/pixelterm.git && python3 setup.py install"
|
||||
|
||||
- name: Setup container clippy systemd service file
|
||||
template:
|
||||
src: clippy.service.j2
|
||||
dest: "{{clippy_root}}/etc/systemd/system/clippy.service"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0664
|
||||
|
||||
- name: Enable systemd machines target
|
||||
systemd:
|
||||
name: machines.target
|
||||
enabled: yes
|
||||
|
||||
- name: Copy over clippy container auto boot service file
|
||||
copy:
|
||||
src: clippy-nspawn.service
|
||||
dest: /etc/systemd/system/clippy-nspawn.service
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0664
|
||||
|
||||
- name: Create systemd-nspawn config dir
|
||||
file:
|
||||
path: /etc/systemd/nspawn
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0775
|
||||
|
||||
- name: Copy over clippy container config
|
||||
copy:
|
||||
src: clippy.nspawn
|
||||
dest: /etc/systemd/nspawn/clippy.nspawn
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0664
|
||||
|
||||
- name: Enable clippy container auto boot
|
||||
systemd:
|
||||
daemon-reload: yes
|
||||
name: clippy-nspawn.service
|
||||
enabled: yes
|
||||
|
||||
- name: Restart clippy container
|
||||
shell: |
|
||||
systemctl stop clippy-nspawn
|
||||
sleep 1
|
||||
systemctl start clippy-nspawn
|
||||
for x in $(seq 0 30); do
|
||||
systemctl -M clippy is-system-running && exit
|
||||
sleep 1
|
||||
done
|
||||
|
||||
- name: Enable clippy systemd service in container
|
||||
command: systemctl enable -M clippy clippy.service
|
||||
|
||||
- name: Restart clippy systemd service in container
|
||||
command: systemctl restart -M clippy clippy.service
|
||||
|
||||
#- name: Enable host networkd
|
||||
# systemd:
|
||||
# name: systemd-networkd
|
||||
# enabled: yes
|
||||
# state: started
|
||||
|
||||
#- name: Enable clippy container networkd
|
||||
# command: systemctl enable -M clippy systemd-networkd
|
||||
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
---
|
||||
- name: Install host requisites
|
||||
dnf:
|
||||
name: btrfs-progs,arch-install-scripts,systemd-container,libselinux-python
|
||||
state: latest
|
||||
|
||||
- name: Create individual containers
|
||||
include_tasks: bootstrap_arch_container.yml
|
||||
with_items: "{{ containers }}"
|
||||
loop_control:
|
||||
loop_var: container
|
||||
|
||||
- name: Cleanup bootstrap image
|
||||
file:
|
||||
path: /tmp/arch-bootstrap.tar.xz
|
||||
state: absent
|
||||
|
||||
|
|
@ -1,100 +0,0 @@
|
|||
---
|
||||
- name: Set local facts
|
||||
set_fact:
|
||||
gerboweb_cache: /var/cache/gerboweb
|
||||
|
||||
- name: Copy render script
|
||||
template:
|
||||
src: render.sh.j2
|
||||
dest: /usr/local/sbin/gerbolyze_render.sh
|
||||
mode: ug+x
|
||||
|
||||
- name: Copy vector script
|
||||
template:
|
||||
src: vector.sh.j2
|
||||
dest: /usr/local/sbin/gerbolyze_vector.sh
|
||||
mode: ug+x
|
||||
|
||||
- name: Install packages into gerbolyze container
|
||||
shell: arch-chroot "{{gerboweb_root}}" pacman -Syu --noconfirm python3 opencv hdf5 gtk3 python-numpy python-pip imagemagick unzip zip
|
||||
|
||||
- name: Workaround for cairoffi problem
|
||||
shell: arch-chroot "{{gerboweb_root}}" pip install -U --upgrade-strategy=eager wheel
|
||||
|
||||
# TODO maybe install directly from local git checkout?
|
||||
- name: Install gerbolyze
|
||||
shell: arch-chroot "{{gerboweb_root}}" pip install -U --upgrade-strategy=eager gerbolyze
|
||||
|
||||
- name: Copy webapp sources
|
||||
synchronize:
|
||||
# FIXME: make this path configurable
|
||||
src: ~/gerbolyze/gerboweb/
|
||||
dest: /var/lib/gerboweb/
|
||||
rsync_opts:
|
||||
- "--exclude=/deploy"
|
||||
group: no
|
||||
owner: no
|
||||
|
||||
- name: Create uwsgi worker user and group
|
||||
user:
|
||||
name: uwsgi-gerboweb
|
||||
create_home: no
|
||||
group: uwsgi
|
||||
password: '!'
|
||||
shell: /sbin/nologin
|
||||
system: yes
|
||||
|
||||
- name: Template webapp config
|
||||
template:
|
||||
src: gerboweb.cfg.j2
|
||||
dest: /var/lib/gerboweb/gerboweb_prod.cfg
|
||||
owner: uwsgi-gerboweb
|
||||
group: root
|
||||
mode: 0660
|
||||
|
||||
- name: Copy uwsgi config
|
||||
copy:
|
||||
src: uwsgi-gerboweb.ini
|
||||
dest: /etc/uwsgi.d/gerboweb.ini
|
||||
owner: uwsgi-gerboweb
|
||||
group: uwsgi
|
||||
mode: 0440
|
||||
|
||||
- name: Copy job processor systemd service config
|
||||
template:
|
||||
src: gerboweb-job-processor.service.j2
|
||||
dest: /etc/systemd/system/gerboweb-job-processor.service
|
||||
|
||||
- name: Enable uwsgi systemd socket
|
||||
systemd:
|
||||
daemon-reload: yes
|
||||
name: uwsgi-app@gerboweb.socket
|
||||
enabled: yes
|
||||
|
||||
- name: Copy gerboweb cache dir tmpfiles.d config
|
||||
template:
|
||||
src: tmpfiles-gerboweb.conf.j2
|
||||
dest: /etc/tmpfiles.d/gerboweb.conf
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
register: tmpfiles_config
|
||||
|
||||
- name: Kick systemd tmpfiles service to create cache dir
|
||||
command: systemd-tmpfiles --create
|
||||
when: tmpfiles_config is changed
|
||||
|
||||
- name: Create job queue db
|
||||
file:
|
||||
path: "{{gerboweb_cache}}/job_queue.sqlite3"
|
||||
owner: root
|
||||
group: uwsgi
|
||||
mode: 0660
|
||||
state: touch
|
||||
|
||||
- name: Enable and launch job processor
|
||||
systemd:
|
||||
name: gerboweb-job-processor.service
|
||||
enabled: yes
|
||||
state: restarted
|
||||
|
||||
|
|
@ -1,115 +0,0 @@
|
|||
- name: Install host requisites
|
||||
dnf:
|
||||
name: cgit,gitolite3,python3-pygments,python3-docutils,nodejs-markdown
|
||||
state: latest
|
||||
|
||||
- name: Copy cgit favicon
|
||||
copy:
|
||||
src: cgit-logo.png
|
||||
dest: /var/www/git.jaseg.net/cgit.png
|
||||
|
||||
- name: Create cgit instance config dir
|
||||
file:
|
||||
path: /var/lib/cgit
|
||||
state: directory
|
||||
mode: 0755
|
||||
|
||||
- name: Copy cgit rc
|
||||
copy:
|
||||
src: cgitrc
|
||||
dest: /var/lib/cgit/cgitrc-gitolite-public
|
||||
mode: 0644
|
||||
|
||||
- name: Create uwsgi worker user and group
|
||||
user:
|
||||
name: uwsgi-cgit
|
||||
create_home: no
|
||||
group: uwsgi
|
||||
password: '!'
|
||||
shell: /sbin/nologin
|
||||
system: yes
|
||||
|
||||
- name: Copy uwsgi config
|
||||
copy:
|
||||
src: uwsgi-cgit.ini
|
||||
dest: /etc/uwsgi.d/cgit.ini
|
||||
owner: uwsgi-cgit
|
||||
group: uwsgi
|
||||
mode: 0440
|
||||
|
||||
- name: Enable uwsgi systemd socket
|
||||
systemd:
|
||||
daemon-reload: yes
|
||||
name: uwsgi-app@cgit.socket
|
||||
enabled: yes
|
||||
|
||||
- name: Copy gitolite admin pubkey
|
||||
copy:
|
||||
src: ~/.ssh/id_ed25519.gitolite.pub
|
||||
dest: /tmp/jaseg-gitolite.pub
|
||||
owner: gitolite3
|
||||
group: gitolite3
|
||||
|
||||
- name: Run gitolite initialization
|
||||
command: gitolite setup -pk /tmp/jaseg-gitolite.pub
|
||||
become: true
|
||||
become_method: su
|
||||
become_user: gitolite3
|
||||
become_flags: '-s /bin/sh'
|
||||
args:
|
||||
creates: /var/lib/gitolite3/projects.list
|
||||
|
||||
- name: Remove leftover admin pubkey
|
||||
file:
|
||||
state: absent
|
||||
path: /tmp/jaseg-gitolite.pub
|
||||
|
||||
- name: Allow uwsgi group to access gitolite repo dir
|
||||
file:
|
||||
path: /var/lib/gitolite3
|
||||
state: directory
|
||||
owner: gitolite3
|
||||
group: uwsgi
|
||||
|
||||
- name: Add cgit uwsgi user to gitolite group
|
||||
user:
|
||||
name: uwsgi-cgit
|
||||
groups: gitolite3
|
||||
append: yes
|
||||
|
||||
- name: Allow cgit uwsgi user to access gitolite repos
|
||||
file:
|
||||
path: /var/lib/gitolite3/repositories
|
||||
mode: 0750
|
||||
|
||||
- name: Allow cgit uwsgi user to gitolite repo list
|
||||
file:
|
||||
path: /var/lib/gitolite3/projects.list
|
||||
mode: 0640
|
||||
|
||||
- name: Copy gitolite rc
|
||||
copy:
|
||||
src: gitolite.rc
|
||||
dest: /var/lib/gitolite3/.gitolite.rc
|
||||
owner: gitolite3
|
||||
group: gitolite3
|
||||
mode: 0600
|
||||
|
||||
- name: Query system user account info
|
||||
getent:
|
||||
database: passwd
|
||||
key: gitolite3
|
||||
|
||||
- name: Create git alias user
|
||||
user:
|
||||
name: git
|
||||
create_home: no
|
||||
group: gitolite3
|
||||
password: '!'
|
||||
comment: Alias for gitolite3 user
|
||||
shell: "{{ getent_passwd['gitolite3'][5] }}"
|
||||
system: yes
|
||||
non_unique: yes
|
||||
home: "{{ getent_passwd['gitolite3'][4] }}"
|
||||
uid: "{{ getent_passwd['gitolite3'][1] }}"
|
||||
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
---
|
||||
- name: Set local facts
|
||||
set_fact:
|
||||
notification_proxy_sqlite_dbfile: /var/lib/notification-proxy/db.sqlite3
|
||||
|
||||
- name: Create notification proxy worker user and group
|
||||
user:
|
||||
name: uwsgi-notification-proxy
|
||||
create_home: no
|
||||
group: uwsgi
|
||||
password: '!'
|
||||
shell: /sbin/nologin
|
||||
system: yes
|
||||
|
||||
- name: Create webapp dir
|
||||
file:
|
||||
path: /var/lib/notification-proxy
|
||||
state: directory
|
||||
owner: uwsgi-notification-proxy
|
||||
group: uwsgi
|
||||
mode: 0750
|
||||
|
||||
- name: Copy webapp sources
|
||||
copy:
|
||||
src: notification_proxy.py
|
||||
dest: /var/lib/notification-proxy/
|
||||
owner: uwsgi-notification-proxy
|
||||
group: uwsgi
|
||||
mode: 0440
|
||||
|
||||
- name: Template webapp config
|
||||
template:
|
||||
src: notification_proxy_config.py.j2
|
||||
dest: /var/lib/notification-proxy/config.py
|
||||
owner: uwsgi-notification-proxy
|
||||
group: root
|
||||
mode: 0660
|
||||
|
||||
- name: Copy uwsgi config
|
||||
copy:
|
||||
src: uwsgi-notification-proxy.ini
|
||||
dest: /etc/uwsgi.d/notification-proxy.ini
|
||||
owner: uwsgi-notification-proxy
|
||||
group: uwsgi
|
||||
mode: 0440
|
||||
|
||||
- name: Enable uwsgi systemd socket
|
||||
systemd:
|
||||
daemon-reload: yes
|
||||
name: uwsgi-app@notification-proxy.socket
|
||||
enabled: yes
|
||||
|
||||
- name: Create sqlite db file
|
||||
file:
|
||||
path: "{{notification_proxy_sqlite_dbfile}}"
|
||||
owner: uwsgi-notification-proxy
|
||||
group: uwsgi
|
||||
mode: 0660
|
||||
state: touch
|
||||
|
||||
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
---
|
||||
- name: Copy openjscad webapp sources
|
||||
synchronize:
|
||||
# FIXME: make this path configurable
|
||||
src: ~/openjscad_dist/
|
||||
dest: /var/www/openjscad.jaseg.net/
|
||||
group: no
|
||||
owner: no
|
||||
|
||||
|
|
@ -1,125 +0,0 @@
|
|||
---
|
||||
- name: Set local facts
|
||||
set_fact:
|
||||
pogojig_cache: /var/cache/pogojig
|
||||
|
||||
- name: Copy render script
|
||||
template:
|
||||
src: pogojig_generate.sh.j2
|
||||
dest: /usr/local/sbin/pogojig_generate.sh
|
||||
mode: ug+x
|
||||
|
||||
- name: Install packages into pogojig container
|
||||
shell: arch-chroot "{{pogojig_root}}" pacman -Syu --noconfirm python3 python-pip imagemagick unzip zip openscad inkscape make python-lxml xorg-server-xvfb
|
||||
|
||||
- name: Install python dependencies into pogojig container
|
||||
shell: arch-chroot "{{pogojig_root}}" pip install -U --upgrade-strategy=eager ezdxf xvfbwrapper
|
||||
|
||||
- name: Install pogojig
|
||||
synchronize:
|
||||
# FIXME: make this path configurable
|
||||
src: checkouts/pogojig/renderer/
|
||||
dest: "{{pogojig_root}}/var/lib/pogojig_renderer"
|
||||
group: no
|
||||
|
||||
- name: Copy webapp sources
|
||||
synchronize:
|
||||
# FIXME: make this path configurable
|
||||
src: checkouts/pogojig/webapp/
|
||||
dest: /var/lib/pogojig
|
||||
delete: true
|
||||
group: no
|
||||
owner: no
|
||||
|
||||
- name: Pack makefile template zip
|
||||
archive:
|
||||
path: "{{pogojig_root}}/var/lib/pogojig_renderer"
|
||||
dest: /var/lib/pogojig/static/pogojig_makefile_template.zip
|
||||
format: zip
|
||||
|
||||
- name: Create web home for modified tracespace
|
||||
file:
|
||||
path: /var/lib/pogojig/pogospace
|
||||
state: directory
|
||||
owner: nginx
|
||||
group: nginx
|
||||
mode: 0550
|
||||
|
||||
- name: Unpack modified tracespace sources
|
||||
unarchive:
|
||||
src: resource/pogojig-tracespace.tar.gz
|
||||
dest: /var/lib/pogojig/pogospace
|
||||
extra_opts: [--strip-components=1]
|
||||
owner: nginx
|
||||
group: nginx
|
||||
|
||||
- name: Create uwsgi worker user and group
|
||||
user:
|
||||
name: uwsgi-pogojig
|
||||
create_home: no
|
||||
group: uwsgi
|
||||
password: '!'
|
||||
shell: /sbin/nologin
|
||||
system: yes
|
||||
|
||||
- name: Template webapp config
|
||||
template:
|
||||
src: pogojig.cfg.j2
|
||||
dest: /var/lib/pogojig/pogojig_prod.cfg
|
||||
owner: uwsgi-pogojig
|
||||
group: root
|
||||
mode: 0660
|
||||
|
||||
- name: Copy uwsgi config
|
||||
copy:
|
||||
src: uwsgi-pogojig.ini
|
||||
dest: /etc/uwsgi.d/pogojig.ini
|
||||
owner: uwsgi-pogojig
|
||||
group: uwsgi
|
||||
mode: 440
|
||||
|
||||
- name: Copy job processor systemd service config
|
||||
template:
|
||||
src: pogojig-job-processor.service.j2
|
||||
dest: /etc/systemd/system/pogojig-job-processor.service
|
||||
|
||||
- name: Enable uwsgi systemd socket
|
||||
systemd:
|
||||
daemon-reload: yes
|
||||
name: uwsgi-app@pogojig.socket
|
||||
enabled: yes
|
||||
|
||||
# FIXME the socket doesn't seem to work properly
|
||||
- name: Enable uwsgi systemd service
|
||||
systemd:
|
||||
daemon-reload: yes
|
||||
name: uwsgi-app@pogojig.service
|
||||
enabled: yes
|
||||
|
||||
- name: Copy pogojig cache dir tmpfiles.d config
|
||||
template:
|
||||
src: tmpfiles-pogojig.conf.j2
|
||||
dest: /etc/tmpfiles.d/pogojig.conf
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
register: pogojig_tmpfiles_config
|
||||
|
||||
- name: Kick systemd tmpfiles service to create cache dir
|
||||
command: systemd-tmpfiles --create
|
||||
when: pogojig_tmpfiles_config is changed
|
||||
|
||||
- name: Create job queue db
|
||||
file:
|
||||
path: "{{pogojig_cache}}/job_queue.sqlite3"
|
||||
owner: root
|
||||
group: uwsgi
|
||||
mode: 0660
|
||||
state: touch
|
||||
|
||||
- name: Enable and launch job processor
|
||||
systemd:
|
||||
name: pogojig-job-processor.service
|
||||
enabled: yes
|
||||
state: restarted
|
||||
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
---
|
||||
- name: Set local facts
|
||||
set_fact:
|
||||
secure_download_dir: /var/cache/secure_download
|
||||
|
||||
- name: Copy webapp sources
|
||||
synchronize:
|
||||
# FIXME: make this path configurable
|
||||
src: ~/secure_download/
|
||||
dest: /var/lib/secure_download/
|
||||
group: no
|
||||
owner: no
|
||||
|
||||
- name: Create secure download worker user and group
|
||||
user:
|
||||
name: uwsgi-secure-download
|
||||
create_home: no
|
||||
group: uwsgi
|
||||
password: '!'
|
||||
shell: /sbin/nologin
|
||||
system: yes
|
||||
|
||||
- name: Template webapp config
|
||||
template:
|
||||
src: secure_download.cfg.j2
|
||||
dest: /var/lib/secure_download/secure_download_prod.cfg
|
||||
owner: uwsgi-secure-download
|
||||
group: root
|
||||
mode: 0660
|
||||
|
||||
- name: Copy uwsgi config
|
||||
copy:
|
||||
src: uwsgi-secure-download.ini
|
||||
dest: /etc/uwsgi.d/secure-download.ini
|
||||
owner: uwsgi-secure-download
|
||||
group: uwsgi
|
||||
mode: 440
|
||||
|
||||
- name: Enable uwsgi systemd socket
|
||||
systemd:
|
||||
daemon-reload: yes
|
||||
name: uwsgi-app@secure-download.socket
|
||||
enabled: yes
|
||||
|
||||
- name: Copy server dir tmpfiles.d config
|
||||
template:
|
||||
src: tmpfiles-secure-download.conf.j2
|
||||
dest: /etc/tmpfiles.d/secure-download.conf
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
register: sec_dl_tmpfiles_config
|
||||
|
||||
- name: Kick systemd tmpfiles service to create serve dir
|
||||
command: systemd-tmpfiles --create
|
||||
when: sec_dl_tmpfiles_config is changed
|
||||
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
---
|
||||
- name: Copy tracespace webapp sources
|
||||
synchronize:
|
||||
# FIXME: make this path configurable
|
||||
src: ~/tracespace_dist/
|
||||
dest: /var/www/tracespace.jaseg.net/
|
||||
group: no
|
||||
owner: no
|
||||
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
- name: Copy first stage nginx config
|
||||
copy:
|
||||
src: nginx_nossl.conf
|
||||
dest: /etc/nginx/nginx.conf
|
||||
|
||||
- name: Add nginx user to uwsgi group for access to uwsgi socket
|
||||
user:
|
||||
name: nginx
|
||||
groups: uwsgi
|
||||
append: yes
|
||||
|
||||
- name: Create subdomain content dirs
|
||||
file:
|
||||
path: /var/www/{{item}}
|
||||
state: directory
|
||||
owner: nginx
|
||||
group: nginx
|
||||
mode: 0550
|
||||
loop:
|
||||
- git.jaseg.net
|
||||
- blog.jaseg.net
|
||||
- kochbuch.jaseg.net
|
||||
- tracespace.jaseg.net
|
||||
- openjscad.jaseg.net
|
||||
- automation.jaseg.de
|
||||
|
||||
- name: Copy uwsgi systemd socket config
|
||||
copy:
|
||||
src: uwsgi-app@.socket
|
||||
dest: /etc/systemd/system/
|
||||
|
||||
- name: Copy uwsgi systemd service config
|
||||
copy:
|
||||
src: uwsgi-app@.service
|
||||
dest: /etc/systemd/system/
|
||||
|
||||
- name: Set SELinux to permissive mode # FIXME this is to let nginx talk to uwsgi
|
||||
selinux:
|
||||
state: permissive
|
||||
policy: targeted
|
||||
|
||||
- name: Enable and launch nginx systemd service
|
||||
systemd:
|
||||
name: nginx.service
|
||||
enabled: yes
|
||||
state: restarted
|
||||
|
||||
- name: Create subdomain letsencrypt certificates
|
||||
command: certbot --nginx certonly -d {{item}} -n --agree-tos --email {{item}}-letsencrypt@jaseg.net
|
||||
args:
|
||||
creates: /etc/letsencrypt/live/{{item}}/fullchain.pem
|
||||
loop:
|
||||
- git.jaseg.net
|
||||
- blog.jaseg.net
|
||||
- kochbuch.jaseg.net
|
||||
- gerbolyze.jaseg.net
|
||||
- tracespace.jaseg.net
|
||||
- openjscad.jaseg.net
|
||||
- pogojig.jaseg.net
|
||||
- automation.jaseg.de
|
||||
- dyndns.jaseg.de
|
||||
|
||||
- name: Copy final nginx config
|
||||
copy:
|
||||
src: nginx.conf
|
||||
dest: /etc/nginx/nginx.conf
|
||||
|
||||
- name: Restart nginx to load new cert
|
||||
systemd:
|
||||
name: nginx.service
|
||||
state: restarted
|
||||
|
||||
- name: Enable certbot renewal timer
|
||||
systemd:
|
||||
name: certbot-renew.timer
|
||||
enabled: yes
|
||||
|
||||
|
|
@ -1 +0,0 @@
|
|||
d {{pogojig_cache}} 770 uwsgi-pogojig uwsgi 2d
|
||||
|
|
@ -1 +0,0 @@
|
|||
d {{secure_download_dir}} 770 uwsgi-download uwsgi 45d
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
[Unit]
|
||||
Description=%i uWSGI app
|
||||
After=syslog.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/sbin/uwsgi \
|
||||
--ini /etc/uwsgi.d/%i.ini \
|
||||
--chmod-socket=660 \
|
||||
--socket=/run/uwsgi/%i.socket
|
||||
User=uwsgi-%i
|
||||
Group=uwsgi
|
||||
Restart=on-failure
|
||||
KillSignal=SIGQUIT
|
||||
Type=notify
|
||||
StandardError=syslog
|
||||
NotifyAccess=all
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
[Unit]
|
||||
Description=Socket for uWSGI app %i
|
||||
|
||||
[Socket]
|
||||
ListenStream=/run/uwsgi/%i.socket
|
||||
SocketUser=uwsgi-%i
|
||||
SocketGroup=nginx
|
||||
SocketMode=0660
|
||||
|
||||
[Install]
|
||||
WantedBy=sockets.target
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
[uwsgi]
|
||||
master = True
|
||||
plugins = cgi
|
||||
chdir = /var/lib/gitolite3
|
||||
processes = 1
|
||||
threads = 2
|
||||
cgi = /var/www/cgi-bin/cgit
|
||||
env = CGIT_CONFIG=/var/lib/cgit/cgitrc-gitolite-public
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
[uwsgi]
|
||||
master = True
|
||||
cheap = True
|
||||
die-on-idle = False
|
||||
manage-script-name = True
|
||||
log-format = [pid: %(pid)|app: -|req: -/-] %(addr) (%(user)) {%(vars) vars in %(pktsize) bytes} [%(ctime)] %(method) [URI hidden] => generated %(rsize) bytes in %(msecs) msecs (%(proto) %(status)) %(headers) headers in %(hsize) bytes (%(switches) switches on core %(core))
|
||||
plugins = python3
|
||||
chdir = /var/lib/notification-proxy
|
||||
mount = /=notification_proxy:app
|
||||
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
[uwsgi]
|
||||
master = True
|
||||
cheap = True
|
||||
die-on-idle = False
|
||||
manage-script-name = True
|
||||
plugins = python3
|
||||
chdir = /var/lib/pogojig
|
||||
mount = /=pogojig:app
|
||||
env = POGOJIG_SETTINGS=pogojig_prod.cfg
|
||||
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
[uwsgi]
|
||||
master = True
|
||||
cheap = True
|
||||
die-on-idle = False
|
||||
manage-script-name = True
|
||||
log-format = [pid: %(pid)|app: -|req: -/-] %(addr) (%(user)) {%(vars) vars in %(pktsize) bytes} [%(ctime)] %(method) [URI hidden] => generated %(rsize) bytes in %(msecs) msecs (%(proto) %(status)) %(headers) headers in %(hsize) bytes (%(switches) switches on core %(core))
|
||||
plugins = python3
|
||||
chdir = /var/lib/secure_download
|
||||
mount = /=server:app
|
||||
env = SECURE_DOWNLOAD_SETTINGS=secure_download_prod.cfg
|
||||
|
||||
22
gerboweb/develop-startup.sh
Executable file
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd /gerbolyze/gerbonara
|
||||
echo "### Setting up gerbonara ###"
|
||||
# newer pip is buggy and just crashes so we pinned an old version.
|
||||
# python packaging infrastructure is such an incoherent, buggy mess
|
||||
# also ignore the running pip as root warning, it's dumb and here we actually want to do just that.
|
||||
python3 -m pip --disable-pip-version-check install .
|
||||
cd /gerbolyze
|
||||
echo "### Setting up gerbolyze ###"
|
||||
python3 -m pip --disable-pip-version-check install .
|
||||
|
||||
export PATH=$PATH:$HOME/.cargo/bin
|
||||
cd /gerbolyze/gerboweb
|
||||
echo "### Launching app ###"
|
||||
tmux new-session -d -s dev env GERBOWEB_SETTINGS=gerboweb-develop.cfg FLASK_APP=gerboweb.py flask run -h 0.0.0.0
|
||||
tmux bind -n C-q kill-session
|
||||
tmux rename-window gerboweb
|
||||
tmux split-window -t 0 -v python3 job_processor.py /var/cache/job_queue.sqlite3
|
||||
tmux attach
|
||||
4
gerboweb/gerboweb-develop.cfg
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
MAX_CONTENT_LENGTH=50000000
|
||||
SECRET_KEY="development mode"
|
||||
UPLOAD_PATH="/var/cache/upload"
|
||||
JOB_QUEUE_DB="/var/cache/job_queue.sqlite3"
|
||||
|
|
@ -6,6 +6,7 @@ import tempfile
|
|||
import uuid
|
||||
from functools import wraps
|
||||
from os import path
|
||||
from pathlib import Path
|
||||
import os
|
||||
import sqlite3
|
||||
|
||||
|
|
@ -15,25 +16,34 @@ from flask_wtf.file import FileField, FileRequired
|
|||
from wtforms.fields import RadioField
|
||||
from wtforms.validators import DataRequired
|
||||
from werkzeug.utils import secure_filename
|
||||
import uwsgidecorators
|
||||
|
||||
from job_queue import JobQueue
|
||||
import job_processor
|
||||
|
||||
app = Flask(__name__, static_url_path='/static')
|
||||
app = Flask(__name__, static_url_path='/gerboweb/static')
|
||||
app.config.from_envvar('GERBOWEB_SETTINGS')
|
||||
if app.config['SECRET_KEY'] is None:
|
||||
if (p := Path('/run/secrets/gerboweb')).is_file():
|
||||
app.config['SECRET_KEY'] = p.read_bytes()
|
||||
else:
|
||||
app.config['SECRET_KEY'] = os.urandom(32)
|
||||
|
||||
class UploadForm(FlaskForm):
|
||||
upload_file = FileField(validators=[DataRequired()])
|
||||
|
||||
class OverlayForm(UploadForm):
|
||||
upload_file = FileField(validators=[FileRequired()])
|
||||
side = RadioField('Side', choices=[('top', 'Top'), ('bottom', 'Bottom')],
|
||||
default=lambda: session.get('side_selected', session.get('last_download')))
|
||||
|
||||
class ResetForm(FlaskForm):
|
||||
pass
|
||||
|
||||
job_queue = JobQueue(app.config['JOB_QUEUE_DB'])
|
||||
|
||||
@uwsgidecorators.timer(1)
|
||||
def job_processor_timer(_num):
|
||||
job_processor.process_job(job_queue)
|
||||
|
||||
def tempfile_path(namespace):
|
||||
""" Return a path for a per-session temporary file identified by the given namespace. Create the session tempfile
|
||||
dir if necessary. The application tempfile dir is controlled via the upload_path config value and not managed by
|
||||
|
|
@ -64,15 +74,18 @@ def index():
|
|||
|
||||
for job_type in ('vector_job', 'render_job'):
|
||||
if job_type in session:
|
||||
job = job_queue[session[job_type]]
|
||||
if job.finished:
|
||||
if job.result != 0:
|
||||
flash(f'Error processing gerber files', 'success') # FIXME make this an error, add CSS
|
||||
del session[job_type]
|
||||
try:
|
||||
job = job_queue[session[job_type]]
|
||||
if job.finished:
|
||||
if not job.result:
|
||||
flash(f'Error processing gerber files', 'success') # FIXME make this an error, add CSS
|
||||
del session[job_type]
|
||||
except:
|
||||
session.clear()
|
||||
|
||||
r = make_response(render_template('index.html',
|
||||
has_renders = path.isfile(tempfile_path('gerber.zip')),
|
||||
has_output = path.isfile(tempfile_path('overlay.png')),
|
||||
has_output = path.isfile(tempfile_path('overlay.svg')),
|
||||
**forms))
|
||||
if 'vector_job' in session or 'render_job' in session:
|
||||
r.headers.set('refresh', '10')
|
||||
|
|
@ -85,17 +98,30 @@ def index():
|
|||
|
||||
def vectorize():
|
||||
if 'vector_job' in session:
|
||||
job_queue[session['vector_job']].abort()
|
||||
try:
|
||||
job_queue[session['vector_job']].abort()
|
||||
except:
|
||||
pass
|
||||
session['vector_job'] = job_queue.enqueue('vector',
|
||||
client=request.remote_addr,
|
||||
session_id=session['session_id'],
|
||||
side=session['side_selected'])
|
||||
gerber_in=tempfile_path('gerber.zip'),
|
||||
overlay=tempfile_path('overlay.svg'),
|
||||
gerber_out=tempfile_path('gerber_out.zip'))
|
||||
|
||||
def render():
|
||||
if 'render_job' in session:
|
||||
job_queue[session['render_job']].abort()
|
||||
try:
|
||||
job_queue[session['render_job']].abort()
|
||||
except:
|
||||
pass
|
||||
session['render_job'] = job_queue.enqueue('render',
|
||||
session_id=session['session_id'],
|
||||
infile=tempfile_path('gerber.zip'),
|
||||
preview_top_out=tempfile_path('preview_top.png'),
|
||||
preview_bottom_out=tempfile_path('preview_bottom.png'),
|
||||
template_top_out=tempfile_path('template_top.svg'),
|
||||
template_bottom_out=tempfile_path('template_bottom.svg'),
|
||||
client=request.remote_addr)
|
||||
|
||||
@app.route('/upload/gerber', methods=['POST'])
|
||||
|
|
@ -108,7 +134,7 @@ def upload_gerber():
|
|||
session['filename'] = secure_filename(f.filename) # Cache filename for later download
|
||||
|
||||
render()
|
||||
if path.isfile(tempfile_path('overlay.png')): # Re-vectorize when gerbers change
|
||||
if path.isfile(tempfile_path('overlay.svg')): # Re-vectorize when gerbers change
|
||||
vectorize()
|
||||
|
||||
flash(f'Gerber file successfully uploaded.', 'success')
|
||||
|
|
@ -119,11 +145,8 @@ def upload_gerber():
|
|||
def upload_overlay():
|
||||
upload_form = OverlayForm()
|
||||
if upload_form.validate_on_submit():
|
||||
# FIXME raise error when no side selected
|
||||
f = upload_form.upload_file.data
|
||||
f.save(tempfile_path('overlay.png'))
|
||||
session['side_selected'] = upload_form.side.data
|
||||
|
||||
f.save(tempfile_path('overlay.svg'))
|
||||
vectorize()
|
||||
|
||||
flash(f'Overlay file successfully uploaded.', 'success')
|
||||
|
|
@ -133,7 +156,7 @@ def upload_overlay():
|
|||
def render_preview(side):
|
||||
if not side in ('top', 'bottom'):
|
||||
return abort(400, 'side must be either "top" or "bottom"')
|
||||
return send_file(tempfile_path(f'render_{side}.small.png'))
|
||||
return send_file(tempfile_path(f'preview_{side}.png'))
|
||||
|
||||
@app.route('/render/download/<side>')
|
||||
def render_download(side):
|
||||
|
|
@ -141,10 +164,10 @@ def render_download(side):
|
|||
return abort(400, 'side must be either "top" or "bottom"')
|
||||
|
||||
session['last_download'] = side
|
||||
return send_file(tempfile_path(f'render_{side}.png'),
|
||||
mimetype='image/png',
|
||||
return send_file(tempfile_path(f'template_{side}.svg'),
|
||||
mimetype='image/svg',
|
||||
as_attachment=True,
|
||||
attachment_filename=f'{path.splitext(session["filename"])[0]}_render_{side}.png')
|
||||
attachment_filename=f'{path.splitext(session["filename"])[0]}_template_{side}.svg')
|
||||
|
||||
@app.route('/output/download')
|
||||
def output_download():
|
||||
|
|
@ -157,9 +180,15 @@ def output_download():
|
|||
@require_session_id
|
||||
def session_reset():
|
||||
if 'render_job' in session:
|
||||
job_queue[session['render_job']].abort()
|
||||
try:
|
||||
job_queue[session['render_job']].abort()
|
||||
except:
|
||||
pass
|
||||
if 'vector_job' in session:
|
||||
job_queue[session['vector_job']].abort()
|
||||
try:
|
||||
job_queue[session['vector_job']].abort()
|
||||
except:
|
||||
pass
|
||||
session.clear()
|
||||
flash('Session reset', 'success');
|
||||
return redirect(url_for('index'))
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
MAX_CONTENT_LENGTH=10000000
|
||||
SECRET_KEY="FIXME: CHANGE THIS KEY"
|
||||
UPLOAD_PATH="/var/cache/gerboweb/upload"
|
||||
JOB_QUEUE_DB="/var/cache/gerboweb/job_queue.sqlite3"
|
||||
APPLICATION_ROOT="/gerboweb/"
|
||||
|
|
@ -1,11 +1,79 @@
|
|||
|
||||
import os
|
||||
import sys
|
||||
import signal
|
||||
import subprocess
|
||||
import logging
|
||||
import itertools
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
from job_queue import JobQueue
|
||||
|
||||
def run_resvg(*args):
|
||||
if 'RESVG' in os.environ:
|
||||
subprocess.run([os.environ['RESVG'], *args], check=True)
|
||||
|
||||
else:
|
||||
# By default, try four options:
|
||||
for candidate in [
|
||||
# somewhere in $PATH
|
||||
'resvg',
|
||||
|
||||
# in user-local cargo installation
|
||||
Path.home() / '.cargo' / 'bin' / 'resvg',
|
||||
|
||||
# somewhere in $PATH
|
||||
'wasi-resvg',
|
||||
|
||||
# in user-local pip installation
|
||||
Path.home() / '.local' / 'bin' / 'wasi-resvg',
|
||||
|
||||
# next to our current python interpreter (e.g. in virtualenv)
|
||||
str(Path(sys.executable).parent / 'resvg'),
|
||||
str(Path(sys.executable).parent / 'wasi-resvg') ]:
|
||||
|
||||
try:
|
||||
subprocess.run([candidate, *args], check=True)
|
||||
print('used svg-flatten at', candidate)
|
||||
break
|
||||
|
||||
except (FileNotFoundError, ModuleNotFoundError):
|
||||
continue
|
||||
|
||||
else:
|
||||
raise SystemError('svg-flatten executable not found')
|
||||
|
||||
def process_job(job_queue):
|
||||
logging.debug('Checking for jobs')
|
||||
for job in job_queue.job_iter('render'):
|
||||
logging.info(f'Processing {job.type} job {job.id} session {job["session_id"]} from {job.client} submitted {job.created}')
|
||||
with job:
|
||||
try:
|
||||
with tempfile.NamedTemporaryFile(suffix='.svg') as svg:
|
||||
subprocess.run(['python3', '-m', 'gerbonara', '--top', job['infile'], svg.name], check=True)
|
||||
run_resvg('--dpi', '300', svg.name, job['preview_top_out'])
|
||||
with tempfile.NamedTemporaryFile(suffix='.svg') as svg:
|
||||
subprocess.run(['python3', '-m', 'gerbonara', '--bottom', job['infile'], svg.name], check=True)
|
||||
run_resvg('--dpi', '300', svg.name, job['preview_bottom_out'])
|
||||
subprocess.run(['python3', '-m', 'gerbolyze', 'template', '--top', job['infile'], job['template_top_out']], check=True)
|
||||
subprocess.run(['python3', '-m', 'gerbolyze', 'template', '--bottom', job['infile'], job['template_bottom_out']], check=True)
|
||||
logging.info(f'Finishied processing {job.type} job {job.id}')
|
||||
job.result = True
|
||||
except:
|
||||
logging.exception('Error during job processing')
|
||||
job.result = False
|
||||
|
||||
for job in job_queue.job_iter('vector'):
|
||||
logging.info(f'Processing {job.type} job {job.id} session {job["session_id"]} from {job.client} submitted {job.created}')
|
||||
with job:
|
||||
try:
|
||||
subprocess.run(['python3', '-m', 'gerbolyze', 'paste', job['gerber_in'], job['overlay'], job['gerber_out']], check=True)
|
||||
logging.info(f'Finishied processing {job.type} job {job.id}')
|
||||
job.result = True
|
||||
except:
|
||||
logging.exception('Error during job processing')
|
||||
job.result = False
|
||||
|
||||
if __name__ == '__main__':
|
||||
import argparse
|
||||
|
|
@ -20,21 +88,11 @@ if __name__ == '__main__':
|
|||
logging.basicConfig(level=numeric_level)
|
||||
|
||||
job_queue = JobQueue(args.queue)
|
||||
print('Job processor online')
|
||||
|
||||
signal.signal(signal.SIGALRM, lambda *args: None) # Ignore incoming alarm signals while processing jobs
|
||||
signal.setitimer(signal.ITIMER_REAL, 0.001, 1)
|
||||
while signal.sigwait([signal.SIGALRM, signal.SIGINT]) == signal.SIGALRM:
|
||||
logging.debug('Checking for jobs')
|
||||
for job in job_queue.job_iter('render'):
|
||||
logging.info(f'Processing {job.type} job {job.id} session {job["session_id"]} from {job.client} submitted {job.created}')
|
||||
with job:
|
||||
job.result = subprocess.call(['sudo', '/usr/local/sbin/gerbolyze_render.sh', job['session_id']])
|
||||
logging.info(f'Finishied processing {job.type} job {job.id}')
|
||||
|
||||
for job in job_queue.job_iter('vector'):
|
||||
logging.info(f'Processing {job.type} job {job.id} session {job["session_id"]} from {job.client} submitted {job.created}')
|
||||
with job:
|
||||
job.result = subprocess.call(['sudo', '/usr/local/sbin/gerbolyze_vector.sh', job['session_id'], job['side']])
|
||||
logging.info(f'Finishied processing {job.type} job {job.id}')
|
||||
process_job(job_queue)
|
||||
logging.info('Caught SIGINT. Exiting.')
|
||||
|
||||
|
|
|
|||
7
gerboweb/run-develop.sh
Executable file
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd "$(dirname $0)"
|
||||
podman build -f Containerfile.develop --tag gerbolyze-develop
|
||||
podman run -p 127.0.0.1:5000:5000 -v ..:/gerbolyze -ti gerbolyze-develop
|
||||
|
Before Width: | Height: | Size: 246 KiB After Width: | Height: | Size: 509 KiB |
|
|
@ -73,7 +73,6 @@ body {
|
|||
}
|
||||
|
||||
div.header {
|
||||
background-image: url("/static/bg10.jpg");
|
||||
background-position: center;
|
||||
background-size: cover;
|
||||
background-repeat: no-repeat;
|
||||
|
|
@ -283,7 +282,6 @@ a.preview:link, a.preview:hover, a.preview:visited, a.preview:active {
|
|||
line-height: 70px;
|
||||
/* background-image: linear-gradient(to top right, var(--cg5), var(--cg6)); */
|
||||
|
||||
background-image: url("/static/bg10.jpg");
|
||||
background-position: center;
|
||||
background-size: cover;
|
||||
background-repeat: no-repeat;
|
||||
|
|
|
|||
|
|
@ -1,166 +1,172 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Gerbolyze Raster image to PCB renderer</title>
|
||||
<title>Gerbolyze Image to PCB Toolchain</title>
|
||||
<link rel="stylesheet" type="text/css" href="{{url_for('static', filename='style.css')}}">
|
||||
<link rel="icon" type="image/png" href="{{url_for('static', filename='favicon-512.png')}}">
|
||||
<link rel="apple-touch-icon" href="{{url_for('static', filename='favicon-512.png')}}">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<style>
|
||||
|
||||
div.header {
|
||||
background-image: url("{{url_for('static', filename='bg10.jpg')}}");
|
||||
}
|
||||
|
||||
.sample-images > h1 {
|
||||
background-image: url("{{url_for('static', filename='bg10.jpg')}}");
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div class="layout-container">
|
||||
<div class="header">
|
||||
<div class="desc">
|
||||
<h1>Raster image to PCB converter</h1>
|
||||
<p>
|
||||
Gerbolyze is a tool for rendering black and white raster (PNG) images directly onto gerber layers. You can
|
||||
use this to put art on a PCB's silkscreen, solder mask or copper layers. The input is a black-and-white PNG
|
||||
image that is vectorized and rendered into an existing gerber file. Gerbolyze works with gerber files
|
||||
produced with any EDA toolchain and has been tested to work with both Altium and KiCAD.
|
||||
</p>
|
||||
</div>
|
||||
<div class="desc">
|
||||
<h1>SVG/JPG/PNG to PCB converter</h1>
|
||||
<p>
|
||||
This is the toy web frontend to <a href="https://github.com/jaseg/gerbolyze">Gerbolyze</a>.
|
||||
|
||||
Gerbolyze is a tool for rendering arbitrary vector (SVG) and raster (PNG/JPG) images directly onto gerber layers.
|
||||
You can use this to put art on a PCB's silkscreen, solder mask or copper layers. The input is an SVG file
|
||||
generated from a template. This SVG file has one layer for each PCB layer and the layers are rendered one by one
|
||||
into the existing gerber file. SVG primitives are converted as-is with (almost) full SVG support, and bitmap
|
||||
images are vectorized using a vector halftone processor. Gerbolyze works with gerber files produced with any EDA
|
||||
toolchain and has been tested to work with both Altium and KiCAD.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% with messages = get_flashed_messages(with_categories=True) %}
|
||||
{% if messages %}
|
||||
<div class="flashes">
|
||||
{% for category, message in messages %}
|
||||
<div class="flash flash-{{category}}">{{ message }}</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if messages %}
|
||||
<div class="flashes">
|
||||
{% for category, message in messages %}
|
||||
<div class="flash flash-{{category}}">{{ message }}</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
|
||||
<form id="reset-form" method="POST" action="{{url_for('session_reset')}}" class="reset-form">{{reset_form.csrf_token}}</form>
|
||||
|
||||
<div class="steps">
|
||||
<div class="step" id="step1">
|
||||
<div class="description">
|
||||
<h2>Upload zipped gerber files</h2>
|
||||
<p>
|
||||
First, upload a zip file containing all your gerber files. The default file names used by KiCAD, Eagle
|
||||
and Altium are supported.
|
||||
</p>
|
||||
</div>
|
||||
<div class="step" id="step1">
|
||||
<div class="description">
|
||||
<h2>Upload zipped gerber files</h2>
|
||||
<p>
|
||||
First, upload a zip file containing all your gerber files. The default file names used by KiCAD, Eagle
|
||||
and Altium are supported.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="controls">
|
||||
<form id="gerber-upload-form" method="POST" action="{{url_for('upload_gerber')}}" enctype="multipart/form-data">
|
||||
{{gerber_form.csrf_token}}
|
||||
</form>
|
||||
<div class="form-controls">
|
||||
<div class="upload-label">Upload Gerber file:</div>
|
||||
<input class='upload-button' form="gerber-upload-form" name="upload_file" size="20" type="file">
|
||||
</div>
|
||||
<div class="submit-buttons">
|
||||
<input class='reset-button' form="reset-form" type="submit" value="Start over">
|
||||
<input class='submit-button' form="gerber-upload-form" type="submit" value="Submit">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<form id="gerber-upload-form" method="POST" action="{{url_for('upload_gerber')}}" enctype="multipart/form-data">
|
||||
{{gerber_form.csrf_token}}
|
||||
</form>
|
||||
<div class="form-controls">
|
||||
<div class="upload-label">Upload Gerber file:</div>
|
||||
<input class='upload-button' form="gerber-upload-form" name="upload_file" size="20" type="file">
|
||||
</div>
|
||||
<div class="submit-buttons">
|
||||
<input class='reset-button' form="reset-form" type="submit" value="Start over">
|
||||
<input class='submit-button' form="gerber-upload-form" type="submit" value="Submit">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if 'render_job' in session or has_renders %}
|
||||
<div class="step" id="step2">
|
||||
<div class="description">
|
||||
<h2>Download the target side's preview image</h2>
|
||||
<p>
|
||||
Second, download either the top or bottom preview image and use it to align and scale your own artwork
|
||||
in an image editing program such as Gimp. Then upload your overlay image below.
|
||||
{% if 'render_job' in session or has_renders %}
|
||||
<div class="step" id="step2">
|
||||
<div class="description">
|
||||
<h2>Download the target side's preview image</h2>
|
||||
<p>
|
||||
Second, download either the top or bottom SVG template and place your own artwork in it on the appropriate
|
||||
layers. The template is made to work well with the excellent open-source <a href="https://inkscape.org">Inkscape</a>
|
||||
vector graphics editor. When you are done, upload your overlay below.
|
||||
|
||||
Note that you will have to convert grayscale images into binary images yourself. Gerbolyze can't do this
|
||||
for you since there are lots of variables involved. Our <a href="https://github.com/jaseg/gerbolyze/blob/master/README.rst#image-preprocessing-guide">Guideline on image processing</a> gives an overview on
|
||||
<i>one</i> way to produce agreeable binary images from grayscale source material.
|
||||
</p>
|
||||
</div>
|
||||
<div class="controls">
|
||||
{% if 'render_job' in session %}
|
||||
<div class="loading-message">
|
||||
<div class="lds-ring"><div></div><div></div><div></div><div></div></div>
|
||||
<div><strong>Processing...</strong></div>
|
||||
<div>(this may take several minutes!)</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="preview-images">
|
||||
<a href="{{url_for('render_download', side='top')}}" onclick="document.querySelector('#side-0').checked=true" class="preview preview-top" style="background-image:url('{{url_for('render_preview', side='top')}}');">
|
||||
<div class="overlay">top</div>
|
||||
</a>
|
||||
<a href="{{url_for('render_download', side='bottom')}}" onclick="document.querySelector('#side-1').checked=true" class="preview preview-bottom" style="background-image:url('{{url_for('render_preview', side='bottom')}}');">
|
||||
<div class="overlay">bot<br/>tom</div>
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="submit-buttons">
|
||||
<input class='reset-button' form="reset-form" type="submit" value="Start over">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
If you wish to put a bitmap image (PNG/JPG) on your board, simply place it into the SVG on the appropriate
|
||||
layer. Make sure you select Inkscape's "embed image" option when importing it.
|
||||
</p>
|
||||
</div>
|
||||
<div class="controls">
|
||||
{% if 'render_job' in session %}
|
||||
<div class="loading-message">
|
||||
<div class="lds-ring"><div></div><div></div><div></div><div></div></div>
|
||||
<div><strong>Processing...</strong></div>
|
||||
<div>(this may take several minutes!)</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="preview-images">
|
||||
<a href="{{url_for('render_download', side='top')}}" onclick="document.querySelector('#side-0').checked=true" class="preview preview-top" style="background-image:url('{{url_for('render_preview', side='top')}}');">
|
||||
<div class="overlay">top</div>
|
||||
</a>
|
||||
<a href="{{url_for('render_download', side='bottom')}}" onclick="document.querySelector('#side-1').checked=true" class="preview preview-bottom" style="background-image:url('{{url_for('render_preview', side='bottom')}}');">
|
||||
<div class="overlay">bot<br/>tom</div>
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="submit-buttons">
|
||||
<input class='reset-button' form="reset-form" type="submit" value="Start over">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="step" id="step3">
|
||||
<div class="description">
|
||||
<h2>Upload overlay image</h2>
|
||||
<p>
|
||||
Now, upload your binary overlay image as a PNG and let gerbolyze render it onto the target layer. The PNG
|
||||
file should be a black and white binary file with details generally above about 10px size. <b>Antialiased
|
||||
edges are supported.</b>
|
||||
</p>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<form id="overlay-upload-form" method="POST" action="{{url_for('upload_overlay')}}" enctype="multipart/form-data">
|
||||
{{overlay_form.csrf_token}}
|
||||
</form>
|
||||
<div class="form-controls">
|
||||
<div class="form-label upload-label">Upload Overlay PNG file:</div>
|
||||
<input class='upload-button' form="overlay-upload-form" name="upload_file" size="20" type="file">
|
||||
</div>
|
||||
<div class="form-controls">
|
||||
<div class="form-label target-label">Target layer:</div>
|
||||
<input form="overlay-upload-form" name="side" id="side-0" type="radio" value="top">
|
||||
<label for="side-0">Top</label>
|
||||
<input form="overlay-upload-form" name="side" id="side-1" type="radio" value="top">
|
||||
<label for="side-1">Bottom</label>
|
||||
</div>
|
||||
<div class="submit-buttons">
|
||||
<input class='reset-button' form="reset-form" type="submit" value="Start over">
|
||||
<input class='submit-button' form="overlay-upload-form" type="submit" value="Submit">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="step" id="step3">
|
||||
<div class="description">
|
||||
<h2>Upload overlay SVG</h2>
|
||||
<p>
|
||||
Now, upload your binary overlay as an SVG and let gerbolyze paste it onto the target layers.
|
||||
</p>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<form id="overlay-upload-form" method="POST" action="{{url_for('upload_overlay')}}" enctype="multipart/form-data">
|
||||
{{overlay_form.csrf_token}}
|
||||
</form>
|
||||
<div class="form-controls">
|
||||
<div class="form-label upload-label">Upload Overlay SVG file:</div>
|
||||
<input class='upload-button' form="overlay-upload-form" name="upload_file" size="20" type="file">
|
||||
</div>
|
||||
<div class="submit-buttons">
|
||||
<input class='reset-button' form="reset-form" type="submit" value="Start over">
|
||||
<input class='submit-button' form="overlay-upload-form" type="submit" value="Submit">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if 'vector_job' in session or has_output %}
|
||||
<div class="step" id="step4">
|
||||
<div class="description">
|
||||
<h2>Download the processed gerber files</h2>
|
||||
</div>
|
||||
<div class="controls">
|
||||
{% if 'vector_job' in session %}
|
||||
<div class="loading-message">
|
||||
<div class="lds-ring"><div></div><div></div><div></div><div></div></div>
|
||||
<div><strong>Processing...</strong></div>
|
||||
<div>(this may take several minutes!)</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class='download-controls'>
|
||||
<a class='output-download' href="{{url_for('output_download')}}">Click to download</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="submit-buttons">
|
||||
<input class='reset-button' form="reset-form" type="submit" value="Start over">
|
||||
</div>
|
||||
<!--4>Debug foo</h4>
|
||||
<div class="loading-message">
|
||||
<div class="lds-ring"><div></div><div></div><div></div><div></div></div>
|
||||
<div><strong>Processing...</strong></div>
|
||||
<div>(this may take several minutes!)</div>
|
||||
</div-->
|
||||
</div>
|
||||
</div>
|
||||
{% endif %} {# vector job #}
|
||||
{% endif %} {# render job #}
|
||||
{% if 'vector_job' in session or has_output %}
|
||||
<div class="step" id="step4">
|
||||
<div class="description">
|
||||
<h2>Download the processed gerber files</h2>
|
||||
</div>
|
||||
<div class="controls">
|
||||
{% if 'vector_job' in session %}
|
||||
<div class="loading-message">
|
||||
<div class="lds-ring"><div></div><div></div><div></div><div></div></div>
|
||||
<div><strong>Processing...</strong></div>
|
||||
<div>(this may take several minutes!)</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class='download-controls'>
|
||||
<a class='output-download' href="{{url_for('output_download')}}">Click to download</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="submit-buttons">
|
||||
<input class='reset-button' form="reset-form" type="submit" value="Start over">
|
||||
</div>
|
||||
<!--4>Debug foo</h4>
|
||||
<div class="loading-message">
|
||||
<div class="lds-ring"><div></div><div></div><div></div><div></div></div>
|
||||
<div><strong>Processing...</strong></div>
|
||||
<div>(this may take several minutes!)</div>
|
||||
</div-->
|
||||
</div>
|
||||
</div>
|
||||
{% endif %} {# vector job #}
|
||||
{% endif %} {# render job #}
|
||||
</div>
|
||||
<div class="sample-images">
|
||||
<h1>Sample images</h1>
|
||||
<img src="{{url_for('static', filename='sample1.jpg')}}">
|
||||
<img src="{{url_for('static', filename='sample2.jpg')}}">
|
||||
<img src="{{url_for('static', filename='sample3.jpg')}}">
|
||||
<h1>Sample images</h1>
|
||||
<img src="{{url_for('static', filename='sample1.jpg')}}">
|
||||
<img src="{{url_for('static', filename='sample2.jpg')}}">
|
||||
<img src="{{url_for('static', filename='sample3.jpg')}}">
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
|
|
|||
12
gerboweb/uwsgi-gerboweb.ini
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
[uwsgi]
|
||||
master = True
|
||||
cheap = True
|
||||
die-on-idle = False
|
||||
manage-script-name = True
|
||||
plugins = python
|
||||
chdir = /gerboweb
|
||||
chmod-socket=666
|
||||
mount = /gerboweb=gerboweb:app
|
||||
env = GERBOWEB_SETTINGS=gerboweb.cfg
|
||||
mule = job_processor.py /var/cache/gerboweb/job_queue.sqlite3
|
||||
static-map = /static=/gerboweb/static
|
||||
95
kicad_mod_template.svg
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="160mm"
|
||||
height="100mm"
|
||||
viewBox="0 0 160 100"
|
||||
version="1.1"
|
||||
id="svg8"
|
||||
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07, custom)"
|
||||
sodipodi:docname="kicad_mod_template.svg">
|
||||
<metadata
|
||||
id="metadata20">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs18" />
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1019"
|
||||
id="namedview16"
|
||||
showgrid="false"
|
||||
inkscape:zoom="1.1197381"
|
||||
inkscape:cx="293.88402"
|
||||
inkscape:cy="186.11375"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="F.SilkS" />
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
id="Eco2.User"
|
||||
inkscape:label="Eco2.User" />
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
id="Eco1.User"
|
||||
inkscape:label="Eco1.User" />
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
id="Margin"
|
||||
inkscape:label="Margin" />
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
id="F.CrtYd"
|
||||
inkscape:label="F.CrtYd" />
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
id="F.Fab"
|
||||
inkscape:label="F.Fab" />
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
id="Dwgs.User"
|
||||
inkscape:label="Dwgs.User" />
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
id="Cmts.User"
|
||||
inkscape:label="Cmts.User" />
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
id="Edge.Cuts"
|
||||
inkscape:label="Edge.Cuts" />
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
id="g5"
|
||||
inkscape:label="F.Cu" />
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
id="F.Mask"
|
||||
inkscape:label="F.Mask" />
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
id="F.SilkS"
|
||||
inkscape:label="F.SilkS" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.4 KiB |
BIN
pics/ex-flattening.png
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
pics/ex-intersections.png
Normal file
|
After Width: | Height: | Size: 47 KiB |
BIN
pics/ex-strokes.png
Normal file
|
After Width: | Height: | Size: 66 KiB |
BIN
pics/ex-svg-joins.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
pics/ex-svg-strokes.png
Normal file
|
After Width: | Height: | Size: 66 KiB |
BIN
pics/ex-svg-winding.png
Normal file
|
After Width: | Height: | Size: 34 KiB |
BIN
pics/fr4_comparison2.jpg
Normal file
|
After Width: | Height: | Size: 266 KiB |
BIN
pics/pcbway_sample_01_small.jpg
Normal file
|
After Width: | Height: | Size: 442 KiB |
BIN
pics/pcbway_sample_02_small.jpg
Normal file
|
After Width: | Height: | Size: 509 KiB |
BIN
pics/pcbway_sample_03_small.jpg
Normal file
|
After Width: | Height: | Size: 729 KiB |
BIN
pics/process-overview.png
Normal file
|
After Width: | Height: | Size: 504 KiB |
7230
pics/process-overview.svg
Normal file
|
After Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 293 KiB After Width: | Height: | Size: 293 KiB |
|
Before Width: | Height: | Size: 246 KiB After Width: | Height: | Size: 246 KiB |
|
Before Width: | Height: | Size: 167 KiB After Width: | Height: | Size: 167 KiB |
BIN
pics/subtract_example.png
Normal file
|
After Width: | Height: | Size: 232 KiB |
515
pics/test_svg_readme.svg
Normal file
|
After Width: | Height: | Size: 143 KiB |
BIN
pics/test_svg_readme_composited.png
Normal file
|
After Width: | Height: | Size: 1.2 MiB |
BIN
pics/vec_contours_composited.png
Normal file
|
After Width: | Height: | Size: 40 KiB |
BIN
pics/vec_hexgrid_composited.png
Normal file
|
After Width: | Height: | Size: 243 KiB |
BIN
pics/vec_poisson_composited.png
Normal file
|
After Width: | Height: | Size: 272 KiB |
BIN
pics/vec_square_composited.png
Normal file
|
After Width: | Height: | Size: 197 KiB |
10
podman/arch-testenv
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
FROM docker.io/archlinux:latest
|
||||
MAINTAINER gerbolyze@jaseg.de
|
||||
RUN pacman --noconfirm -Syu
|
||||
RUN pacman --noconfirm -Sy pugixml opencv pango cairo git python make clang rustup cargo python-pip base-devel gerbv rsync
|
||||
RUN python3 -m pip install pytest-parallel setuptools wasmtime
|
||||
RUN rustup install stable
|
||||
RUN rustup default stable
|
||||
RUN cargo install resvg
|
||||
RUN python3 -m pip install --upgrade gerbonara
|
||||