Add build script for letsencrypt-auto.

Change template language to reference files, saving me some boilerplate over the dict-based .format() thing I originally had in mind.

Put newlines at the ends of bootstrap scripts. It makes the built le-auto script prettier.
This commit is contained in:
Erik Rose
2015-12-02 11:13:23 -05:00
parent ec9a498622
commit cdd855c745
8 changed files with 46 additions and 16 deletions
+30
View File
@@ -0,0 +1,30 @@
#!/usr/bin/env python
"""Stitch together the letsencrypt-auto script.
Implement a simple templating language in which {{ some/file }} turns into the
contents of the file at ./pieces/some/file.
"""
from os.path import dirname, join
import re
from sys import argv
def main():
dir = dirname(argv[0])
def replacer(match):
rel_path = match.group(1)
with open(join(dir, 'pieces', rel_path)) as replacement:
return replacement.read()
with open(join(dir, 'letsencrypt-auto.template')) as template:
result = re.sub(r'{{\s*([A-Za-z0-9_./-]+)\s*}}',
replacer,
template.read())
with open(join(dir, 'letsencrypt-auto'), 'w') as out:
out.write(result)
if __name__ == '__main__':
main()
+10 -10
View File
@@ -49,13 +49,13 @@ DeterminePythonVersion() {
fi
}
{{bootstrap_deb_common}}
{{bootstrap_rpm_common}}
{{bootstrap_suse_common}}
{{bootstrap_arch_common}}
{{bootstrap_gentoo_common}}
{{bootstrap_free_bsd}}
{{bootstrap_mac}}
{{ bootstrappers/deb_common.sh }}
{{ bootstrappers/rpm_common.sh }}
{{ bootstrappers/suse_common.sh }}
{{ bootstrappers/arch_common.sh }}
{{ bootstrappers/gentoo_common.sh }}
{{ bootstrappers/free_bsd.sh }}
{{ bootstrappers/mac.sh }}
# Install required OS packages:
Bootstrap() {
@@ -180,7 +180,7 @@ elif [ "$1" != "--_skip-to-install" ]; then
# There is no $ interpolation due to quotes on heredoc delimiters.
set +e
TEMP_DIR=`$PYTHON - << "UNLIKELY_EOF"
{{download_upgrade}}
{{ download_upgrade.py }}
UNLIKELY_EOF`
DOWNLOAD_STATUS=$?
set -e
@@ -205,11 +205,11 @@ else # --_skip-to-install was passed.
TEMP_DIR="$2"
shift 2
cat << "UNLIKELY_EOF" > $TEMP_DIR/letsencrypt-auto-requirements.txt
{{requirements}}
{{ letsencrypt-auto-requirements.txt }}
UNLIKELY_EOF
cat << "UNLIKELY_EOF" > $TEMP_DIR/peep.py
{{peep}}
{{ peep.py }}
UNLIKELY_EOF
set +e
@@ -24,4 +24,4 @@ BootstrapArchCommon() {
if [ "$missing" ]; then
"$SUDO" pacman -S --needed $missing
fi
}
}
@@ -5,4 +5,4 @@ BootstrapFreeBsd() {
py27-virtualenv \
augeas \
libffi \
}
}
@@ -20,4 +20,4 @@ BootstrapGentooCommon() {
"$SUDO" emerge --noreplace $PACKAGES
;;
esac
}
}
+1 -1
View File
@@ -16,4 +16,4 @@ BootstrapMac() {
echo "virtualenv Not Installed\nInstalling with pip"
pip install virtualenv
fi
}
}
@@ -46,4 +46,4 @@ BootstrapRpmCommon() {
echo "Could not install additional dependencies. Aborting bootstrap!"
exit 1
fi
}
}
@@ -11,4 +11,4 @@ BootstrapSuseCommon() {
libopenssl-devel \
libffi-devel \
ca-certificates \
}
}