Merge ~goneri/cloud-init:freebsd_python3 into cloud-init:master

Proposed by Gonéri Le Bouder
Status: Merged
Approved by: Ryan Harper
Approved revision: bf752d4ccf7ffb67231104f43ab301cf6834998c
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~goneri/cloud-init:freebsd_python3
Merge into: cloud-init:master
Diff against target: 103 lines (+40/-33)
1 file modified
tools/build-on-freebsd (+40/-33)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
Ryan Harper Approve
Review via email: mp+368791@code.launchpad.net

Commit message

tools/build-on-freebsd: update to python3

- use python3 by default
- ability to use any Python version through the PYTHON env-var
- indent with 4 spaces
- use 'set -eux'
- remove trailing whitespace
- drop the cheetah dep, Jinja2 is enough

To post a comment you must log in.
Revision history for this message
Ryan Harper (raharper) wrote :

This patch drops py27 support.

should you allow callers to specify the version ?

For example in tools/bddeb there is --python2
which enables a build for py26/py27

Since you're already extracting the python major, minor
the rest of the code is flexible.

Thoughts?

review: Needs Information
Revision history for this message
Gonéri Le Bouder (goneri) wrote :

A polite "no" :-) Every supported FreeBSD releases come with Python3. I don't see a good reason for making our life (a little bit more) complicated.

Revision history for this message
Ryan Harper (raharper) wrote :

OK, does build-on-freebsd not work at all on py27?

Revision history for this message
Gonéri Le Bouder (goneri) wrote :

Python3 was released 11 years ago and is available in all the major OS and distribution, Python2 is OLD and will be EOL next year, and it's still a major source of problem. If you think Python2 is important, why https://bugs.launchpad.net/cloud-init/+bug/1801364 is still open? I do these FreeBSD patches on my spare time and I don't want to waste it with this kind of futile request.

Revision history for this message
Ryan Harper (raharper) wrote :

I meant no offense and I know this is your free time. We don't test directly on freebsd, so I'm asking for more information from those who do.

While python2 is every OLD and will EOL, it will still be around. I would prefer to default to python3 but not make it impossible for folks using/building python2 to do so, if that makes sense.

Revision history for this message
Gonéri Le Bouder (goneri) wrote :

Hi Ryan,

Sorry for the strong tone of my previous answer. I will adjust the script to allow the user to specify the Python version to use.

Revision history for this message
Gonéri Le Bouder (goneri) wrote :

Done, I pushed my updated version.

Revision history for this message
Ryan Harper (raharper) wrote :

Thanks!

That looks good. One inline comment request for a comment.

Revision history for this message
Gonéri Le Bouder (goneri) :
Revision history for this message
Ryan Harper (raharper) wrote :

Yes

On Mon, Jun 17, 2019 at 10:22 AM Gonéri Le Bouder <email address hidden>
wrote:

>
>
> Diff comments:
>
> > diff --git a/tools/build-on-freebsd b/tools/build-on-freebsd
> > index dc3b974..b73cec8 100755
> > --- a/tools/build-on-freebsd
> > +++ b/tools/build-on-freebsd
> > @@ -3,36 +3,44 @@
> > # installing cloud-init. This script takes care of building and
> installing. It
> > # will optionally make a first run at the end.
> >
> > +set -eux
> > +
> > fail() { echo "FAILED:" "$@" 1>&2; exit 1; }
> >
> > +PYTHON="${PYTHON:-python3}"
> > +if [ ! $(which ${PYTHON}) ]; then
> > + echo "Please install python first."
> > + exit 1
> > +fi
> > +py_prefix=$(${PYTHON} -c 'import sys; print("py%d%d" %
> (sys.version_info.major, sys.version_info.minor))')
> > +
> > # Check dependencies:
> > depschecked=/tmp/c-i.dependencieschecked
> > pkgs="
> > - bash
> > - chpasswd
> > - dmidecode
> > - e2fsprogs
> > - py27-Jinja2
> > - py27-boto
> > - py27-cheetah
> > - py27-configobj
> > - py27-jsonpatch
> > - py27-jsonpointer
> > - py27-jsonschema
> > - py27-oauthlib
> > - py27-requests
> > - py27-serial
> > - py27-six
> > - py27-yaml
> > - python
> > - sudo
> > + bash
> > + chpasswd
> > + dmidecode
> > + e2fsprogs
> > + $py_prefix-Jinja2
> > + $py_prefix-boto
> > + $py_prefix-configobj
> > + $py_prefix-jsonpatch
> > + $py_prefix-jsonpointer
> > + $py_prefix-jsonschema
> > + $py_prefix-oauthlib
> > + $py_prefix-requests
> > + $py_prefix-serial
> > + $py_prefix-six
> > + $py_prefix-yaml
> > + sudo
> > "
> > -[ -f "$depschecked" ] || pkg install ${pkgs} || fail "install packages"
> > +[ -f "$depschecked" ] || pkg install --yes ${pkgs} || fail "install
> packages"
> > touch $depschecked
> >
> > +pkg install $py_prefix-cheetah || true
>
> well, in this case, it's probably better to just disable, isn't it?
>
> > # Build the code and install in /usr/local/:
> > -python2.7 setup.py build
> > -python2.7 setup.py install -O1 --skip-build --prefix /usr/local/
> --init-system sysvinit_freebsd
> > +${PYTHON} setup.py build
> > +${PYTHON} setup.py install -O1 --skip-build --prefix /usr/local/
> --init-system sysvinit_freebsd
> >
> > # Enable cloud-init in /etc/rc.conf:
> > sed -i.bak -e "/cloudinit_enable=.*/d" /etc/rc.conf
>
>
> --
> https://code.launchpad.net/~goneri/cloud-init/+git/cloud-init/+merge/368791
> You are reviewing the proposed merge of ~goneri/cloud-init:freebsd_python3
> into cloud-init:master.
>

Revision history for this message
Gonéri Le Bouder (goneri) wrote :

done

Revision history for this message
Ryan Harper (raharper) wrote :

Thanks!

review: Approve
Revision history for this message
Ryan Harper (raharper) wrote :

Once more, now with more commit message.

Revision history for this message
Server Team CI bot (server-team-bot) :
review: Approve (continuous-integration)

Update scan failed

At least one of the branches involved have failed to scan. You can manually schedule a rescan if required.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/tools/build-on-freebsd b/tools/build-on-freebsd
2index dc3b974..8ae6456 100755
3--- a/tools/build-on-freebsd
4+++ b/tools/build-on-freebsd
5@@ -3,36 +3,43 @@
6 # installing cloud-init. This script takes care of building and installing. It
7 # will optionally make a first run at the end.
8
9+set -eux
10+
11 fail() { echo "FAILED:" "$@" 1>&2; exit 1; }
12
13+PYTHON="${PYTHON:-python3}"
14+if [ ! $(which ${PYTHON}) ]; then
15+ echo "Please install python first."
16+ exit 1
17+fi
18+py_prefix=$(${PYTHON} -c 'import sys; print("py%d%d" % (sys.version_info.major, sys.version_info.minor))')
19+
20 # Check dependencies:
21 depschecked=/tmp/c-i.dependencieschecked
22 pkgs="
23- bash
24- chpasswd
25- dmidecode
26- e2fsprogs
27- py27-Jinja2
28- py27-boto
29- py27-cheetah
30- py27-configobj
31- py27-jsonpatch
32- py27-jsonpointer
33- py27-jsonschema
34- py27-oauthlib
35- py27-requests
36- py27-serial
37- py27-six
38- py27-yaml
39- python
40- sudo
41+ bash
42+ chpasswd
43+ dmidecode
44+ e2fsprogs
45+ $py_prefix-Jinja2
46+ $py_prefix-boto
47+ $py_prefix-configobj
48+ $py_prefix-jsonpatch
49+ $py_prefix-jsonpointer
50+ $py_prefix-jsonschema
51+ $py_prefix-oauthlib
52+ $py_prefix-requests
53+ $py_prefix-serial
54+ $py_prefix-six
55+ $py_prefix-yaml
56+ sudo
57 "
58-[ -f "$depschecked" ] || pkg install ${pkgs} || fail "install packages"
59+[ -f "$depschecked" ] || pkg install --yes ${pkgs} || fail "install packages"
60 touch $depschecked
61
62 # Build the code and install in /usr/local/:
63-python2.7 setup.py build
64-python2.7 setup.py install -O1 --skip-build --prefix /usr/local/ --init-system sysvinit_freebsd
65+${PYTHON} setup.py build
66+${PYTHON} setup.py install -O1 --skip-build --prefix /usr/local/ --init-system sysvinit_freebsd
67
68 # Enable cloud-init in /etc/rc.conf:
69 sed -i.bak -e "/cloudinit_enable=.*/d" /etc/rc.conf
70@@ -40,21 +47,21 @@ echo 'cloudinit_enable="YES"' >> /etc/rc.conf
71
72 echo "Installation completed."
73
74-if [ "$1" = "run" ]; then
75- echo "Ok, now let's see if it works."
76+if [ "$#" -gt 1 ] && [ "$1" = "run" ]; then
77+ echo "Ok, now let's see if it works."
78
79- # Backup SSH keys
80- mv /etc/ssh/ssh_host_* /tmp/
81+ # Backup SSH keys
82+ mv /etc/ssh/ssh_host_* /tmp/
83
84- # Remove old metadata
85- rm -rf /var/lib/cloud
86+ # Remove old metadata
87+ rm -rf /var/lib/cloud
88
89- # Just log everything, quick&dirty
90- rm /usr/local/etc/cloud/cloud.cfg.d/05_logging.cfg
91+ # Just log everything, quick&dirty
92+ rm /usr/local/etc/cloud/cloud.cfg.d/05_logging.cfg
93
94- # Start:
95- /usr/local/etc/rc.d/cloudinit start
96+ # Start:
97+ /usr/local/etc/rc.d/cloudinit start
98
99- # Restore SSH keys
100- mv /tmp/ssh_host_* /etc/ssh/
101+ # Restore SSH keys
102+ mv /tmp/ssh_host_* /etc/ssh/
103 fi

Subscribers

People subscribed via source and target branches