Skip to content

Commit 35fe0c1

Browse files
committed
Turn the py file into an m4 script
1 parent ba5b0c4 commit 35fe0c1

File tree

5 files changed

+109
-22
lines changed

5 files changed

+109
-22
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
install.py
12
.mypy_cache/
23

34
# Created by https://www.gitignore.io/api/vim,emacs,python

Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.PHONY: clean
2+
3+
HEAD_PATH=.git/$(shell cat .git/HEAD | cut -d' ' -f2)
4+
5+
install.py: \
6+
install.py.m4 \
7+
LICENSE \
8+
Makefile \
9+
$(HEAD_PATH)
10+
m4 -P -D "HEAD_PATH=$(HEAD_PATH)" $< > $@
11+
./git-ready-to-deploy.sh
12+
13+
clean:
14+
rm -f install.py

README.rst

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,29 @@ The utility is implemented as a standalone Python file, |install_py|_.
7171
User Guide
7272
==========
7373

74-
Copy |install_py|_ into the directory containing the files that you would like
74+
Where is the Python script?
75+
---------------------------
76+
77+
To ensure proper accreditation, manage releases, and reduce code
78+
duplication, ``install.py`` is generated from `an m4 template
79+
<install.py.m4>`_. To get the shell script, either:
80+
81+
1. Fetch the
82+
`latest <https://github.com/oleks/install.py/releases/latest>`_
83+
`release <https://github.com/oleks/install.py/releases>`_
84+
of the shell script, or;
85+
2. Type ``make`` to build it, if you happen to have the
86+
`m4 macro processor <https://www.gnu.org/software/m4/m4.html>`_
87+
installed.
88+
89+
Please note, the last step of building ``install.py`` is to
90+
execute ``git-ready-to-deploy.sh``. This ensures a clean release
91+
of ``install.py``, so long as you mind the exit code of ``make``.
92+
93+
What do I do with the Python script?
94+
------------------------------------
95+
96+
Copy ``install_py`` into the directory containing the files that you would like
7597
to install. Create an INI file, (e.g., called ``config.ini``) having a
7698
``install.py`` section with the properties ``src_dir``, ``dst_dir``, and
7799
``files``. The values of the properties may be arbitrary Python expressions,

git-ready-to-deploy.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env bash
2+
3+
# This file was generated from an m4 template.
4+
# Generation date-time (ISO 8601): 2018-06-22T10:10+00:00
5+
# Git repository URL: https://github.com/oleks/git-ready-to-deploy
6+
# Commit ID: 394c2b040558a890d33d996c402d6594d1e5dfc6
7+
8+
# Copyright (c) 2016-2018 Oleks <[email protected]>
9+
#
10+
# Permission is hereby granted, free of charge, to any person obtaining
11+
# a copy of this software and associated documentation files (the
12+
# "Software"), to deal in the Software without restriction, including
13+
# without limitation the rights to use, copy, modify, merge, publish,
14+
# distribute, sublicense, and/or sell copies of the Software, and to
15+
# permit persons to whom the Software is furnished to do so, subject to
16+
# the following conditions:
17+
#
18+
# The above copyright notice and this permission notice shall be
19+
# included in all copies or substantial portions of the Software.
20+
#
21+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
25+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
26+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27+
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28+
29+
set -euo pipefail
30+
31+
failcode=1
32+
33+
nlines=$(git status . --porcelain | wc -l)
34+
if [ ${nlines} -ne 0 ] ; then
35+
cat <<EOF
36+
#####################################################
37+
# Nice! You have changes. Now commit or stash them. #
38+
#####################################################
39+
EOF
40+
git status .
41+
exit ${failcode}
42+
fi
43+
44+
echo "Let me check your remote.."
45+
git remote update
46+
47+
nlines=$(git cherry | (grep "^+" || true) | wc -l)
48+
if [ ${nlines} -ne 0 ] ; then
49+
cat <<EOF
50+
#####################################
51+
# Nice! You have commits. Now push. #
52+
#####################################
53+
EOF
54+
git status .
55+
exit ${failcode}
56+
fi
57+
58+
echo "Looks like you are up-to-date."

install.py renamed to install.py.m4

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,19 @@
11
#!/usr/bin/env python3
22

33
# install.py — A simple, file-system-based install utility
4-
# See also https://github.com/oleks/install.py
5-
6-
# Copyright (c) 2017 Oleks <[email protected]>
7-
#
8-
# Permission is hereby granted, free of charge, to any person obtaining a copy
9-
# of this software and associated documentation files (the "Software"), to deal
10-
# in the Software without restriction, including without limitation the rights
11-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12-
# copies of the Software, and to permit persons to whom the Software is
13-
# furnished to do so, subject to the following conditions:
14-
#
15-
# The above copyright notice and this permission notice shall be included in
16-
# all copies or substantial portions of the Software.
17-
#
18-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24-
# SOFTWARE.
4+
5+
# This file was generated from an m4 template.
6+
m4_syscmd(`date -u --iso-8601=minutes |
7+
sed "s/^/# Generation date-time (ISO 8601): /"')m4_dnl
8+
m4_syscmd(`git remote get-url origin |
9+
tr ":" "/" |
10+
sed "s/^git@/https:\\/\\//" |
11+
sed "s/\\.git$//" |
12+
sed "s/^/# Git repository URL: /"')m4_dnl
13+
m4_format(`# Commit ID: %s', m4_include(HEAD_PATH))m4_dnl
14+
15+
m4_syscmd(`perl -pe "chomp if eof" LICENSE |
16+
sed "s/^/# /"')
2517

2618
import configparser
2719
import os.path

0 commit comments

Comments
 (0)