mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Support --exclude-from for rsync publishing using excludes.txt
Add an excludes.txt example file where users can list rsync exclude
specifications. If the site you are publishing has any paths on the
remote site that Pelican should ignore and not remove, list them in
excludes.txt so they are not removed each time you do:
make rsync_upload
The example file has a comment pointing users to the rsync man page
for information on the format used in exclude files. The only entry
in it by default is the .DS_Store entry which was from the rsync
command in tasks.py.
This commit is contained in:
parent
3efb0817e3
commit
9b80a5ddb8
4 changed files with 31 additions and 4 deletions
|
|
@ -391,8 +391,31 @@ needed by Pelican.
|
|||
render_jinja_template("publishconf.py.jinja2", CONF, "publishconf.py")
|
||||
|
||||
if automation:
|
||||
render_jinja_template("tasks.py.jinja2", CONF, "tasks.py")
|
||||
render_jinja_template("Makefile.jinja2", CONF, "Makefile")
|
||||
try:
|
||||
with open(os.path.join(CONF['basedir'], 'tasks.py'),
|
||||
'w', 'utf-8') as fd:
|
||||
_template = _jinja_env.get_template('tasks.py.jinja2')
|
||||
fd.write(_template.render(**CONF))
|
||||
fd.close()
|
||||
except OSError as e:
|
||||
print('Error: {0}'.format(e))
|
||||
try:
|
||||
with open(os.path.join(CONF['basedir'], 'Makefile'),
|
||||
'w', 'utf-8') as fd:
|
||||
py_v = 'python3'
|
||||
_template = _jinja_env.get_template('Makefile.jinja2')
|
||||
fd.write(_template.render(py_v=py_v, **CONF))
|
||||
fd.close()
|
||||
except OSError as e:
|
||||
print('Error: {0}'.format(e))
|
||||
try:
|
||||
with open(os.path.join(CONF['basedir'], 'excludes.txt'),
|
||||
'w', 'utf-8') as fd:
|
||||
_template = _jinja_env.get_template('excludes.txt.jinja2')
|
||||
fd.write(_template.render(**CONF))
|
||||
fd.close()
|
||||
except OSError as e:
|
||||
print('Error: {0}'.format(e))
|
||||
|
||||
print("Done. Your new project is available at {}".format(CONF["basedir"]))
|
||||
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ sftp_upload: publish
|
|||
|
||||
{% set upload = upload + ["rsync_upload"] %}
|
||||
rsync_upload: publish
|
||||
rsync -e "ssh -p $(SSH_PORT)" -P -rvzc --include tags --cvs-exclude --delete "$(OUTPUTDIR)"/ "$(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR)"
|
||||
rsync -e "ssh -p $(SSH_PORT)" -P -rvzc --include tags --cvs-exclude --exclude-from=excludes.txt --delete $(OUTPUTDIR)/ $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR)
|
||||
|
||||
{% endif %}
|
||||
{% if dropbox %}
|
||||
|
|
|
|||
4
pelican/tools/templates/excludes.txt.jinja2
Normal file
4
pelican/tools/templates/excludes.txt.jinja2
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# Files to exclude with rsync(1) during publishing.
|
||||
# See the INCLUDE/EXCLUDE PATTERN RULES section of the rsync man page.
|
||||
|
||||
.DS_Store
|
||||
|
|
@ -169,7 +169,7 @@ def publish(c):
|
|||
"""Publish to production via rsync"""
|
||||
pelican_run("-s {settings_publish}".format(**CONFIG))
|
||||
c.run(
|
||||
'rsync --delete --exclude ".DS_Store" -pthrvz -c '
|
||||
'rsync --delete --exclude-from=excludes.txt -pthrvz -c '
|
||||
'-e "ssh -p {ssh_port}" '
|
||||
"{} {ssh_user}@{ssh_host}:{ssh_path}".format(
|
||||
CONFIG["deploy_path"].rstrip("/") + "/", **CONFIG
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue