mirror of https://github.com/ansible/ansible.git
Remove obsolete release bits (#80347)
Releases are now built using the `packaging/release.py` tool. This makes the `Makefile` and associated files in `packaging/release/` and `packaging/sdist/` obsolete.pull/80354/head
parent
cf44c84396
commit
6a66761e0e
@ -1,132 +0,0 @@
|
||||
# WARN: gmake syntax
|
||||
########################################################
|
||||
# Makefile for Ansible
|
||||
#
|
||||
# useful targets:
|
||||
# make clean ---------------- clean up
|
||||
# make sdist ---------------- produce a tarball
|
||||
|
||||
########################################################
|
||||
# variable section
|
||||
|
||||
NAME = ansible-core
|
||||
OS = $(shell uname -s)
|
||||
PREFIX ?= '/usr/local'
|
||||
SDIST_DIR ?= 'dist'
|
||||
|
||||
# This doesn't evaluate until it's called. The -D argument is the
|
||||
# directory of the target file ($@), kinda like `dirname`.
|
||||
MANPAGES ?= $(patsubst %.rst.in,%,$(wildcard ./docs/man/man1/ansible*.1.rst.in))
|
||||
ifneq ($(shell command -v rst2man 2>/dev/null),)
|
||||
ASCII2MAN = rst2man $< $@
|
||||
else ifneq ($(shell command -v rst2man.py 2>/dev/null),)
|
||||
ASCII2MAN = rst2man.py $< $@
|
||||
else
|
||||
ASCII2MAN = @echo "ERROR: rst2man from docutils command is not installed but is required to build $(MANPAGES)" && exit 1
|
||||
endif
|
||||
|
||||
PYTHON ?= python
|
||||
GENERATE_CLI = hacking/build-ansible.py generate-man
|
||||
|
||||
# fetch version from project release.py as single source-of-truth
|
||||
VERSION := $(shell $(PYTHON) packaging/release/versionhelper/version_helper.py --raw || echo error)
|
||||
ifeq ($(findstring error,$(VERSION)), error)
|
||||
$(error "version_helper failed")
|
||||
endif
|
||||
|
||||
########################################################
|
||||
|
||||
.PHONY: all
|
||||
all: clean python
|
||||
|
||||
# Regenerate %.1.rst if %.1.rst.in has been modified more
|
||||
# recently than %.1.rst.
|
||||
%.1.rst: %.1.rst.in
|
||||
sed "s/%VERSION%/$(VERSION)/" $< > $@
|
||||
rm $<
|
||||
|
||||
# Regenerate %.1 if %.1.rst or release.py has been modified more
|
||||
# recently than %.1. (Implicitly runs the %.1.rst recipe)
|
||||
%.1: %.1.rst lib/ansible/release.py
|
||||
$(ASCII2MAN)
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@echo "Cleaning up distutils stuff"
|
||||
rm -rf build
|
||||
rm -rf dist
|
||||
rm -rf lib/ansible*.egg-info/
|
||||
@echo "Cleaning up byte compiled python stuff"
|
||||
find . -type f -regex ".*\.py[co]$$" -delete
|
||||
find . -type d -name "__pycache__" -delete
|
||||
@echo "Cleaning up editor backup files"
|
||||
find . -type f -not -path ./test/units/inventory_test_data/group_vars/noparse/all.yml~ \( -name "*~" -or -name "#*" \) -delete
|
||||
find . -type f \( -name "*.swp" \) -delete
|
||||
@echo "Cleaning up manpage stuff"
|
||||
find ./docs/man -type f -name "*.xml" -delete
|
||||
find ./docs/man -type f -name "*.rst" -delete
|
||||
find ./docs/man/man3 -type f -name "*.3" -delete
|
||||
rm -f ./docs/man/man1/*
|
||||
@echo "Cleaning up output from test runs"
|
||||
rm -rf test/test_data
|
||||
rm -rf logs/
|
||||
rm -rf .cache/
|
||||
rm -f test/units/.coverage*
|
||||
rm -rf test/results/*/*
|
||||
find test/ -type f -name '*.retry' -delete
|
||||
@echo "Cleaning up symlink cache"
|
||||
rm -f SYMLINK_CACHE.json
|
||||
rm -rf docs/json
|
||||
rm -rf docs/js
|
||||
@echo "Cleaning up docsite"
|
||||
$(MAKE) -C docs/docsite clean
|
||||
|
||||
.PHONY: python
|
||||
python:
|
||||
$(PYTHON) setup.py build
|
||||
|
||||
.PHONY: install
|
||||
install:
|
||||
$(PYTHON) setup.py install
|
||||
|
||||
.PHONY: install_manpages
|
||||
install_manpages:
|
||||
gzip -9 $(wildcard ./docs/man/man1/ansible*.1)
|
||||
cp $(wildcard ./docs/man/man1/ansible*.1.gz) $(PREFIX)/man/man1/
|
||||
|
||||
.PHONY: sdist_check
|
||||
sdist_check:
|
||||
$(PYTHON) -c 'import setuptools, sys; sys.exit(int(not (tuple(map(int, setuptools.__version__.split("."))) > (39, 2, 0))))'
|
||||
$(PYTHON) packaging/sdist/check-link-behavior.py
|
||||
|
||||
.PHONY: sdist
|
||||
sdist: sdist_check clean docs
|
||||
_ANSIBLE_SDIST_FROM_MAKEFILE=1 $(PYTHON) setup.py sdist --dist-dir=$(SDIST_DIR)
|
||||
|
||||
# Official releases generate the changelog as the last commit before the release.
|
||||
# Snapshots shouldn't result in new checkins so the changelog is generated as
|
||||
# part of creating the tarball.
|
||||
.PHONY: snapshot
|
||||
snapshot: sdist_check clean docs changelog
|
||||
_ANSIBLE_SDIST_FROM_MAKEFILE=1 $(PYTHON) setup.py sdist --dist-dir=$(SDIST_DIR)
|
||||
|
||||
.PHONY: sdist_upload
|
||||
sdist_upload: clean docs
|
||||
$(PYTHON) setup.py sdist upload 2>&1 |tee upload.log
|
||||
|
||||
.PHONY: changelog
|
||||
changelog:
|
||||
PYTHONPATH=./lib antsibull-changelog release -vv --use-ansible-doc && PYTHONPATH=./lib antsibull-changelog generate -vv --use-ansible-doc
|
||||
|
||||
.PHONY: generate_rst
|
||||
generate_rst: lib/ansible/cli/*.py
|
||||
mkdir -p ./docs/man/man1/ ; \
|
||||
$(PYTHON) $(GENERATE_CLI) --template-file=docs/templates/man.j2 --output-dir=docs/man/man1/ --output-format man lib/ansible/cli/*.py
|
||||
|
||||
.PHONY: docs
|
||||
docs: generate_rst
|
||||
$(MAKE) $(MANPAGES)
|
||||
|
||||
.PHONY: version
|
||||
version:
|
||||
@echo $(VERSION)
|
@ -1,61 +0,0 @@
|
||||
version ?= $(shell python versionhelper/version_helper.py --raw)
|
||||
|
||||
.PHONY: all
|
||||
all:
|
||||
@echo "USAGE:"
|
||||
@echo
|
||||
@echo "make release version={version} # current version is '${version}'"
|
||||
@echo "make publish"
|
||||
@echo
|
||||
@echo "NOTE: Make sure to source hacking/env-setup before running these targets."
|
||||
|
||||
.PHONY: release
|
||||
release: version summary changelog commit-release
|
||||
git show -p
|
||||
git status
|
||||
@echo
|
||||
@echo 'Run `git push` if you are satisfied with the changes.'
|
||||
|
||||
.PHONY: version
|
||||
version:
|
||||
sed -i.bak "s/^__version__ = .*$$/__version__ = '${version}'/" ../../lib/ansible/release.py
|
||||
rm ../../lib/ansible/release.py.bak
|
||||
|
||||
.PHONY: summary
|
||||
summary:
|
||||
@printf '%s\n%s\n%s\n' \
|
||||
'release_summary: |' \
|
||||
' | Release Date: $(shell date '+%Y-%m-%d')' \
|
||||
' | `Porting Guide <https://docs.ansible.com/ansible/devel/porting_guides.html>`__' > \
|
||||
../../changelogs/fragments/v${version}_summary.yaml
|
||||
|
||||
.PHONY: changelog
|
||||
changelog:
|
||||
antsibull-changelog release -vv --use-ansible-doc && antsibull-changelog generate -vv --use-ansible-doc
|
||||
ansible-test sanity changelogs/
|
||||
|
||||
.PHONY: commit-release
|
||||
commit-release:
|
||||
git add ../../changelogs/ ../../lib/ansible/release.py
|
||||
git commit -m "New release v${version}"
|
||||
|
||||
.PHONY: publish
|
||||
publish: tag postversion commit-postversion
|
||||
git show -p
|
||||
git status
|
||||
@echo
|
||||
@echo 'Run `git push --follow-tags` if you are satisfied with the changes.'
|
||||
|
||||
.PHONY: tag
|
||||
tag:
|
||||
git tag -a v${version} -m "New release v${version}"
|
||||
|
||||
.PHONY: postversion
|
||||
postversion:
|
||||
sed -i.bak "s/^__version__ = .*$$/__version__ = '${version}.post0'/" ../../lib/ansible/release.py
|
||||
rm ../../lib/ansible/release.py.bak
|
||||
|
||||
.PHONY: commit-postversion
|
||||
commit-postversion:
|
||||
git add ../../lib/ansible/release.py
|
||||
git commit -m "Update Ansible release version to v${version}."
|
@ -1,47 +0,0 @@
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
import pytest
|
||||
|
||||
from packaging.version import InvalidVersion
|
||||
from versionhelper.version_helper import AnsibleVersionMunger
|
||||
|
||||
|
||||
@pytest.mark.parametrize('version,revision,codename,output_propname,expected', [
|
||||
('2.5.0.dev1', None, None, 'raw', '2.5.0.dev1'),
|
||||
('2.5.0a0.post0', None, None, 'raw', '2.5.0a0.post0'),
|
||||
('2.5.0', None, None, 'raw', '2.5.0'),
|
||||
('2.5.0.dev1', None, None, 'major_version', '2.5'),
|
||||
('2.5.0', None, None, 'major_version', '2.5'),
|
||||
('2.5.0.dev1', None, None, 'base_version', '2.5.0'),
|
||||
('2.5.0', None, None, 'base_version', '2.5.0'),
|
||||
('2.5.0.dev1', None, None, 'deb_version', '2.5.0~dev1'),
|
||||
('2.5.0b1', None, None, 'deb_version', '2.5.0~b1'),
|
||||
('2.5.0b1.dev1', None, None, 'deb_version', '2.5.0~b1~dev1'),
|
||||
('2.5.0b1.post0', None, None, 'deb_version', '2.5.0~b1~post0'),
|
||||
('2.5.0', None, None, 'deb_version', '2.5.0'),
|
||||
('2.5.0.dev1', None, None, 'deb_release', '1'),
|
||||
('2.5.0b1', 2, None, 'deb_release', '2'),
|
||||
('2.5.0.dev1', None, None, 'rpm_release', '0.1.dev1'),
|
||||
('2.5.0a1', None, None, 'rpm_release', '0.101.a1'),
|
||||
('2.5.0a1.post0', None, None, 'rpm_release', '0.101.a1.post0'),
|
||||
('2.5.0b1', None, None, 'rpm_release', '0.201.b1'),
|
||||
('2.5.0rc1', None, None, 'rpm_release', '0.1001.rc1'),
|
||||
('2.5.0rc1', '0.99', None, 'rpm_release', '0.99.rc1'),
|
||||
('2.5.0.rc.1', None, None, 'rpm_release', '0.1001.rc.1'),
|
||||
('2.5.0.rc1.dev1', None, None, 'rpm_release', '0.1001.rc1.dev1'),
|
||||
('2.5.0', None, None, 'rpm_release', '1'),
|
||||
('2.5.0', 2, None, 'rpm_release', '2'),
|
||||
('2.5.0', None, None, 'codename', 'UNKNOWN'),
|
||||
('2.5.0', None, 'LedZeppelinSongHere', 'codename', 'LedZeppelinSongHere'),
|
||||
('2.5.0x1', None, None, None, InvalidVersion)
|
||||
])
|
||||
def test_output_values(version, revision, codename, output_propname, expected):
|
||||
try:
|
||||
v = AnsibleVersionMunger(version, revision, codename)
|
||||
assert getattr(v, output_propname) == expected
|
||||
except Exception as ex:
|
||||
if isinstance(expected, type):
|
||||
assert isinstance(ex, expected)
|
||||
else:
|
||||
raise
|
@ -1,195 +0,0 @@
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
from packaging.version import Version, VERSION_PATTERN
|
||||
|
||||
|
||||
class AnsibleVersionMunger(object):
|
||||
tag_offsets = dict(
|
||||
dev=0,
|
||||
a=100,
|
||||
b=200,
|
||||
rc=1000
|
||||
)
|
||||
|
||||
# TODO: allow overrides here for packaging bump etc
|
||||
def __init__(self, raw_version, revision=None, codename=None):
|
||||
self._raw_version = raw_version
|
||||
self._revision = revision
|
||||
self._parsed_version = Version(raw_version)
|
||||
self._codename = codename
|
||||
self._parsed_regex_match = re.match(VERSION_PATTERN, raw_version, re.VERBOSE | re.IGNORECASE)
|
||||
|
||||
@property
|
||||
def deb_version(self):
|
||||
v = self._parsed_version
|
||||
|
||||
match = self._parsed_regex_match
|
||||
|
||||
# treat dev/post as prerelease for now; treat dev/post as equivalent and disallow together
|
||||
if v.is_prerelease or match.group('dev') or match.group('post'):
|
||||
if match.group('dev') and match.group('post'):
|
||||
raise Exception("dev and post may not currently be used together")
|
||||
if match.group('pre'):
|
||||
tag_value = match.group('pre')
|
||||
tag_type = match.group('pre_l')
|
||||
if match.group('dev'):
|
||||
tag_value += ('~%s' % match.group('dev').strip('.'))
|
||||
if match.group('post'):
|
||||
tag_value += ('~%s' % match.group('post').strip('.'))
|
||||
elif match.group('dev'):
|
||||
tag_type = "dev"
|
||||
tag_value = match.group('dev').strip('.')
|
||||
elif match.group('post'):
|
||||
tag_type = "dev"
|
||||
tag_value = match.group('post').strip('.')
|
||||
else:
|
||||
raise Exception("unknown prerelease type for version {0}".format(self._raw_version))
|
||||
else:
|
||||
tag_type = None
|
||||
tag_value = ''
|
||||
|
||||
# not a pre/post/dev release, just return base version
|
||||
if not tag_type:
|
||||
return '{base_version}'.format(base_version=self.base_version)
|
||||
|
||||
# it is a pre/dev release, include the tag value with a ~
|
||||
return '{base_version}~{tag_value}'.format(base_version=self.base_version, tag_value=tag_value)
|
||||
|
||||
@property
|
||||
def deb_release(self):
|
||||
return '1' if self._revision is None else str(self._revision)
|
||||
|
||||
@property
|
||||
def rpm_release(self):
|
||||
v = self._parsed_version
|
||||
match = self._parsed_regex_match
|
||||
|
||||
# treat presence of dev/post as prerelease for now; treat dev/post the same and disallow together
|
||||
if v.is_prerelease or match.group('dev') or match.group('post'):
|
||||
if match.group('dev') and match.group('post'):
|
||||
raise Exception("dev and post may not currently be used together")
|
||||
if match.group('pre'):
|
||||
tag_value = match.group('pre')
|
||||
tag_type = match.group('pre_l')
|
||||
tag_ver = match.group('pre_n')
|
||||
if match.group('dev'):
|
||||
tag_value += match.group('dev')
|
||||
if match.group('post'):
|
||||
tag_value += match.group('post')
|
||||
elif match.group('dev'):
|
||||
tag_type = "dev"
|
||||
tag_value = match.group('dev')
|
||||
tag_ver = match.group('dev_n')
|
||||
elif match.group('post'):
|
||||
tag_type = "dev"
|
||||
tag_value = match.group('post')
|
||||
tag_ver = match.group('post_n')
|
||||
else:
|
||||
raise Exception("unknown prerelease type for version {0}".format(self._raw_version))
|
||||
else:
|
||||
tag_type = None
|
||||
tag_value = ''
|
||||
tag_ver = 0
|
||||
|
||||
# not a pre/post/dev release, just append revision (default 1)
|
||||
if not tag_type:
|
||||
if self._revision is None:
|
||||
self._revision = 1
|
||||
return '{revision}'.format(revision=self._revision)
|
||||
|
||||
# cleanse tag value in case it starts with .
|
||||
tag_value = tag_value.strip('.')
|
||||
|
||||
# coerce to int and None == 0
|
||||
tag_ver = int(tag_ver if tag_ver else 0)
|
||||
|
||||
if self._revision is None:
|
||||
tag_offset = self.tag_offsets.get(tag_type)
|
||||
if tag_offset is None:
|
||||
raise Exception('no tag offset defined for tag {0}'.format(tag_type))
|
||||
pkgrel = '0.{0}'.format(tag_offset + tag_ver)
|
||||
else:
|
||||
pkgrel = self._revision
|
||||
|
||||
return '{pkgrel}.{tag_value}'.format(pkgrel=pkgrel, tag_value=tag_value)
|
||||
|
||||
@property
|
||||
def raw(self):
|
||||
return self._raw_version
|
||||
|
||||
# return the x.y.z version without any other modifiers present
|
||||
@property
|
||||
def base_version(self):
|
||||
return self._parsed_version.base_version
|
||||
|
||||
# return the x.y version without any other modifiers present
|
||||
@property
|
||||
def major_version(self):
|
||||
return re.match(r'^(\d+.\d+)', self._raw_version).group(1)
|
||||
|
||||
@property
|
||||
def codename(self):
|
||||
return self._codename if self._codename else "UNKNOWN"
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='Extract/transform Ansible versions to various packaging formats')
|
||||
|
||||
group = parser.add_mutually_exclusive_group(required=True)
|
||||
group.add_argument('--raw', action='store_true')
|
||||
group.add_argument('--majorversion', action='store_true')
|
||||
group.add_argument('--baseversion', action='store_true')
|
||||
group.add_argument('--debversion', action='store_true')
|
||||
group.add_argument('--debrelease', action='store_true')
|
||||
group.add_argument('--rpmrelease', action='store_true')
|
||||
group.add_argument('--codename', action='store_true')
|
||||
group.add_argument('--all', action='store_true')
|
||||
|
||||
parser.add_argument('--revision', action='store', default='auto')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
mydir = os.path.dirname(__file__)
|
||||
release_loc = os.path.normpath(mydir + '/../../../lib')
|
||||
|
||||
sys.path.insert(0, release_loc)
|
||||
|
||||
from ansible import release
|
||||
|
||||
rev = None
|
||||
if args.revision != 'auto':
|
||||
rev = args.revision
|
||||
|
||||
v_raw = release.__version__
|
||||
codename = release.__codename__
|
||||
v = AnsibleVersionMunger(v_raw, revision=rev, codename=codename)
|
||||
|
||||
if args.raw:
|
||||
print(v.raw)
|
||||
elif args.baseversion:
|
||||
print(v.base_version)
|
||||
elif args.majorversion:
|
||||
print(v.major_version)
|
||||
elif args.debversion:
|
||||
print(v.deb_version)
|
||||
elif args.debrelease:
|
||||
print(v.deb_release)
|
||||
elif args.rpmrelease:
|
||||
print(v.rpm_release)
|
||||
elif args.codename:
|
||||
print(v.codename)
|
||||
elif args.all:
|
||||
props = [name for (name, impl) in vars(AnsibleVersionMunger).items() if isinstance(impl, property)]
|
||||
|
||||
for propname in props:
|
||||
print('{0}: {1}'.format(propname, getattr(v, propname)))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,51 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
"""Checks for link behavior required for sdist to retain symlinks."""
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
import os
|
||||
import platform
|
||||
import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
|
||||
def main():
|
||||
"""Main program entry point."""
|
||||
temp_dir = tempfile.mkdtemp()
|
||||
|
||||
target_path = os.path.join(temp_dir, 'file.txt')
|
||||
symlink_path = os.path.join(temp_dir, 'symlink.txt')
|
||||
hardlink_path = os.path.join(temp_dir, 'hardlink.txt')
|
||||
|
||||
try:
|
||||
with open(target_path, 'w'):
|
||||
pass
|
||||
|
||||
os.symlink(target_path, symlink_path)
|
||||
os.link(symlink_path, hardlink_path)
|
||||
|
||||
if not os.path.islink(symlink_path):
|
||||
abort('Symbolic link not created.')
|
||||
|
||||
if not os.path.islink(hardlink_path):
|
||||
# known issue on MacOS (Darwin)
|
||||
abort('Hard link of symbolic link created as a regular file.')
|
||||
finally:
|
||||
shutil.rmtree(temp_dir)
|
||||
|
||||
|
||||
def abort(reason):
|
||||
"""
|
||||
:type reason: str
|
||||
"""
|
||||
sys.exit('ERROR: %s\n'
|
||||
'This will prevent symbolic links from being preserved in the resulting tarball.\n'
|
||||
'Aborting creation of sdist on platform: %s'
|
||||
% (reason, platform.system()))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in New Issue