-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8bb6ccd
Showing
70 changed files
with
6,311 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
cover/ | ||
.coverage | ||
dist/ | ||
*.egg-info/ | ||
.DS_Store | ||
*.pyc | ||
system_tests/vmdefs/centos*/.vagrant/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM centos:5 | ||
|
||
VOLUME /data | ||
|
||
WORKDIR /data | ||
|
||
RUN sed -i -- 's/mirror.centos.org\/centos/vault.centos.org/g' /etc/yum.repos.d/* && \ | ||
sed -i -- 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/* && \ | ||
sed -i -- 's/#baseurl/baseurl/g' /etc/yum.repos.d/* && \ | ||
sed -i -- 's/\$releasever/5.11/g' /etc/yum.repos.d/* | ||
|
||
RUN yum install -y epel-release &&\ | ||
yum update -y && \ | ||
yum install -y python-nose gnupg &&\ | ||
yum clean all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM centos:6 | ||
|
||
VOLUME /data | ||
|
||
WORKDIR /data | ||
|
||
RUN yum update -y && \ | ||
yum install -y python-nose gnupg &&\ | ||
yum clean all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM centos:7 | ||
|
||
VOLUME /data | ||
|
||
WORKDIR /data | ||
|
||
RUN yum update -y && \ | ||
yum install -y python-nose gnupg &&\ | ||
yum clean all |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
recursive-include convert2rhel/data * | ||
include man/* | ||
include LICENSE | ||
include README |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
IMAGE = convert2rhel | ||
|
||
.PHONY: all | ||
all: clean images tests | ||
|
||
.PHONY: clean | ||
clean: | ||
@rm -rf build/ dist/ *.egg-info .pytest_cache/ | ||
@find . -name '__pycache__' -exec rm -fr {} + | ||
@find . -name '*.pyc' -exec rm -f {} + | ||
@find . -name '*.pyo' -exec rm -f {} + | ||
|
||
.PHONY: images | ||
images: | ||
@docker build -f Dockerfiles/centos5 -t $(IMAGE)/centos5 . | ||
@docker build -f Dockerfiles/centos6 -t $(IMAGE)/centos6 . | ||
@docker build -f Dockerfiles/centos7 -t $(IMAGE)/centos7 . | ||
|
||
.PHONY: tests | ||
tests: | ||
@docker run --rm -v $(shell pwd):/data:Z $(IMAGE)/centos5 ./run_unit_tests.sh | ||
@docker run --rm -v $(shell pwd):/data:Z $(IMAGE)/centos6 ./run_unit_tests.sh | ||
@docker run --rm -v $(shell pwd):/data:Z $(IMAGE)/centos7 ./run_unit_tests.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
For details about the tool, please consult one of the following sources: | ||
1. man page | ||
- run 'man convert2rhel' once the tool is installed on your system | ||
2. Red Hat Knowledgebase article | ||
- https://access.redhat.com/articles/2360841 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
# Make sure you have .copr.conf in the same directory as this script. | ||
# The .copr.conf needs to contain the token from https://<copr URL>/api/. | ||
# Currently it's set up to build the package in the Red Hat internal Copr. | ||
|
||
rm -rf dist/ SRPMS/ | ||
python2 setup.py sdist | ||
|
||
cp convert2rhel.spec convert2rhel.spec.bak | ||
|
||
TIMESTAMP=`date +%Y%m%d%H%MZ -u` | ||
GIT_BRANCH=`git rev-parse --abbrev-ref HEAD` | ||
sed -i "s/1%{?dist}/0.${TIMESTAMP}.${GIT_BRANCH}/g" convert2rhel.spec | ||
|
||
rpmbuild -bs convert2rhel.spec --define "debug_package %{nil}" \ | ||
--define "_sourcedir `pwd`/dist" \ | ||
--define "_srcrpmdir `pwd`/SRPMS" | ||
|
||
copr --config .copr.conf build mbocek/convert2rhel SRPMS/convert2rhel-*.src.rpm & | ||
|
||
mv convert2rhel.spec.bak convert2rhel.spec | ||
rm -rf dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
# Run this script on CentOS/OL/RHEL 5 in the root of the cloned convert2rhel repo | ||
python setup.py sdist --formats=gztar | ||
mkdir -p /usr/src/redhat/SOURCES | ||
rm -rf /usr/src/redhat/{SOURCES,SRPMS}/* | ||
rm -rf /var/tmp/convert2rhel* | ||
cp dist/* /usr/src/redhat/SOURCES | ||
rpmbuild -ba convert2rhel.spec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
# Run this script on CentOS/OL/RHEL 6 or 7 in the root of the cloned convert2rhel repo | ||
python setup.py sdist | ||
cp dist/* ~/rpmbuild/SOURCES | ||
rpmlint convert2rhel.spec | ||
rpmbuild -ba convert2rhel.spec --define "debug_package %{nil}" | ||
rpmlint ~/rpmbuild/RPMS/x86_64/convert2rhel*.rpm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
%{!?__python2: %global __python2 /usr/bin/python2} | ||
%{!?python2_sitelib: %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")} | ||
%{!?python2_sitearch: %global python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")} | ||
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")} | ||
%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")} | ||
|
||
Name: convert2rhel | ||
Version: 0.9 | ||
Release: 1%{?dist} | ||
Summary: Automates the conversion of installed other-than-RHEL Linux distribution to RHEL | ||
Group: System Environment/Libraries | ||
License: GPLv3 | ||
Source0: %{name}-%{version}.tar.gz | ||
|
||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) | ||
BuildRequires: python-devel | ||
BuildRequires: python-setuptools | ||
%if ! 0%{?rhel:1} | ||
BuildRequires: buildsys-macros | ||
%endif # rhel macro not defined | ||
Requires: yum | ||
Requires: yum-utils | ||
Requires: rpm | ||
Requires: sed | ||
Requires: gnupg | ||
Requires: python | ||
Requires: python-dmidecode | ||
Requires: python-setuptools | ||
Requires: python-dateutil | ||
# Warning: The python-ethtool package is available since OL/CentOS 5.7. If the | ||
# convert2rhel is to be installed on an older system, add any repo | ||
# that contains the package or install it manually first from | ||
# a downloaded rpm. | ||
Requires: python-ethtool | ||
Requires: usermode | ||
Requires: m2crypto | ||
# Warning: The virt-what package is available since OL/CentOS 5.7 | ||
Requires: virt-what | ||
%if 0%{?rhel} && 0%{?rhel} <= 5 | ||
# Warning: The python-dateutil package is available since OL/CentOS 5.10 | ||
Requires: python-dateutil | ||
# Warning: The python-simplejson package is available since OL/CentOS 5.7 | ||
Requires: python-simplejson | ||
%endif | ||
%if 0%{?rhel} && 0%{?rhel} == 6 | ||
Requires: python-decorator | ||
%endif | ||
%if 0%{?rhel} && 0%{?rhel} >= 7 | ||
Requires: python-inotify | ||
%endif | ||
|
||
%description | ||
The purpose of the %{name} tool is to provide an automated way of converting | ||
the installed other-than-RHEL OS distribution to Red Hat Enterprise Linux | ||
(RHEL). The conversion is done in situ without the need to restart the system. | ||
The tool replaces all the original OS-signed packages with the RHEL ones. | ||
Available are conversions of CentOS 5/6/7 and Oracle Linux 5/6/7 to the | ||
respective major version of RHEL. The original OS always converts to the latest | ||
RHEL minor version. | ||
|
||
%prep | ||
%setup -q | ||
|
||
%build | ||
%{__python2} setup.py build | ||
%{__python2} setup.py build_manpage | ||
|
||
# Do not include unit test in the package | ||
rm -rf build/lib/%{name}/unit_tests | ||
|
||
%install | ||
%{__python2} setup.py install --skip-build --root %{buildroot} | ||
|
||
# Move system version and architecture specific tool data | ||
# to /usr/share/%{name} | ||
rm -rf %{buildroot}%{python2_sitelib}/%{name}/data | ||
install -d %{buildroot}%{_datadir}/%{name} | ||
cp -a build/lib/%{name}/data/version-independent/. \ | ||
%{buildroot}%{_datadir}/%{name} | ||
cp -a build/lib/%{name}/data/%{rhel}/%{_arch}/. \ | ||
%{buildroot}%{_datadir}/%{name} | ||
|
||
install -d -m 755 %{buildroot}%{_mandir}/man8 | ||
install -p man/%{name}.8 %{buildroot}%{_mandir}/man8/ | ||
|
||
%files | ||
%defattr(-,root,root,-) | ||
|
||
%attr(0755,root,root) %{_bindir}/%{name} | ||
|
||
%{python2_sitelib} | ||
%{_datadir}/%{name} | ||
|
||
%{!?_licensedir:%global license %%doc} | ||
%license LICENSE | ||
%doc README | ||
%attr(0644,root,root) %{_mandir}/man8/%{name}.8.gz | ||
|
||
%changelog | ||
* Fri Dec 13 2019 Michal Bocek <[email protected]> 0.9-1 | ||
- basic rollback capability up to the point before replacing all pkgs | ||
- added basic system tests running on CentOS 5/6/7 Vagrant boxes | ||
- unit tests can be run now in CentOS 5/6/7 Docker images | ||
- improved handling of kernel installation corner cases | ||
- added possibility to upgrade i386 OL5 | ||
- added --debug option | ||
- license changed from GPLv2 to GPLv3 | ||
- autogenerating manpage | ||
- collecting output of 'rpm -Va' before the conversion | ||
- added possibility to use custom repositories instead of RHSM | ||
- removed bundled rpms and repomapping for the public release | ||
|
||
* Fri Nov 10 2017 Michal Bocek <[email protected]> 0.8-1 | ||
- added support for conversion from CentOS/OL 5 to RHEL 5 | ||
- the oldest supported version is CentOS/OL 5.6 | ||
|
||
* Fri Mar 31 2017 Michal Bocek <[email protected]> 0.7-1 | ||
- remove shebang from all the python scripts | ||
- update spec to create arch specific rpms | ||
- move all the tool data into /usr/share/convert2rhel/ | ||
- remove ppc64 RHEL 6 data - CentOS 6 and OL 6 | ||
were not released for this arch | ||
- create new SystemReleaseFile class for handling | ||
/etc/system-release | ||
- do not print traceback on keyboard interrupt | ||
- move initializing Red Hat GPG key fingerprint variable | ||
from main to gpgkey.py | ||
- update configs to add centos-release* to blacklist | ||
|
||
* Wed Jul 20 2016 Michal Bocek <[email protected]> 0.6-1 | ||
- Code refactored and split into new files | ||
- Added support for CentOS/OL 6 to RHEL 6 conversion | ||
- Created 'framework' for unit tests | ||
- Added logging to a file | ||
|
||
* Wed Jun 15 2016 Michal Bocek <[email protected]> 0.5-1 | ||
- The tool renamed to convert2rhel. | ||
- All the original kernels are removed during the conversion now. | ||
- Added man page. | ||
- EULA needs to be accepted before the conversion. | ||
- Packages are filtered per signature, not per vendor. | ||
- Added support for conversions from Oracle Linux 7 to RHEL 7. | ||
- Added support for --auto-attach, --activationkey and --org | ||
subscription-manager arguments. | ||
|
||
* Mon May 09 2016 Michal Bocek <[email protected]> 0.4-1 | ||
- Added both interactive and cmd line option for choosing RHEL variant. | ||
- Added autodetection of platform architecture. | ||
- Implemented handling of unsuccessful subscription attachment. | ||
- Added a config file for each supported distribution. | ||
- Added possibility to blacklist conflicting pkgs. | ||
|
||
* Thu Apr 28 2016 Michal Bocek <[email protected]> 0.3-1 | ||
- Added determining appropriate RHEL repository to use for upgrade. | ||
|
||
* Mon Apr 25 2016 Michal Bocek <[email protected]> 0.2-1 | ||
- Added dark matrix data | ||
|
||
* Tue Apr 19 2016 Michal Bocek <[email protected]> 0.1-1 | ||
- Initial RPM release |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright(C) 2016 Red Hat, Inc. | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
import glob | ||
import shutil | ||
|
||
from convert2rhel.systeminfo import system_info | ||
from convert2rhel import utils | ||
|
||
_redhat_release_cert_dir = "/etc/pki/product-default/" | ||
_subscription_manager_cert_dir = "/etc/pki/product/" | ||
|
||
|
||
def copy_cert_for_rhel_5(): | ||
"""RHEL certificate (.pem) is used by subscription-manager to determine | ||
the running system type/version. On RHEL 5, subscription-manager looks for | ||
the certificates in /etc/pki/product/ even though the redhat-release | ||
package installs it in /etc/pki/product-default/. This discrepancy has been | ||
reported in https://bugzilla.redhat.com/show_bug.cgi?id=1321012 with | ||
WONTFIX status. | ||
""" | ||
if system_info.version == "5": | ||
for cert in glob.glob(_redhat_release_cert_dir + "*.pem"): | ||
utils.mkdir_p(_subscription_manager_cert_dir) | ||
shutil.copy(cert, _subscription_manager_cert_dir) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[system_info] | ||
|
||
# Fingerprints of GPG keys used for signing packages of the OS to be converted. | ||
# The GPG keys are available at: | ||
# https://docs.oracle.com/cd/E37670_01/E39381/html/ol_import_gpg.html | ||
# Delimited by whitespace(s). | ||
gpg_fingerprints = 66ced3de1e5e0159 | ||
|
||
# List of packages that have to be removed before the system conversion starts. | ||
# Delimited by any whitespace(s). | ||
pkg_blacklist = | ||
redhat-release* | ||
oraclelinux-release* | ||
enterprise-release* | ||
oracle-logos | ||
oracle-linux | ||
oracle-validated | ||
oracleasm-support | ||
|
||
default_repository_id = rhel-5-server-rpms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[system_info] | ||
|
||
# Fingerprints of GPG keys used for signing packages of the OS to be converted. | ||
# The GPG keys are available at https://www.centos.org/keys/ | ||
# Delimited by whitespace(s). | ||
gpg_fingerprints = a8a447dce8562897 | ||
|
||
# List of packages that have to be removed before the system conversion starts. | ||
# Delimited by any whitespace(s). | ||
pkg_blacklist = | ||
centos-bookmarks | ||
centos-logos | ||
centos-indexhtml | ||
centos-release* | ||
redhat-release* | ||
|
||
default_repository_id = rhel-5-server-rpms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[system_info] | ||
|
||
# Fingerprints of GPG keys used for signing packages of the OS to be converted. | ||
# The GPG keys are available at: | ||
# https://docs.oracle.com/cd/E37670_01/E39381/html/ol_import_gpg.html | ||
# Delimited by whitespace(s). | ||
gpg_fingerprints = 66ced3de1e5e0159 | ||
|
||
# List of packages that have to be removed before the system conversion starts. | ||
# Delimited by any whitespace(s). | ||
pkg_blacklist = | ||
redhat-release* | ||
oraclelinux-release* | ||
enterprise-release* | ||
oracle-logos | ||
oracle-validated | ||
oracleasm-support | ||
|
||
default_repository_id = rhel-5-server-rpms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[system_info] | ||
|
||
# Fingerprints of GPG keys used for signing packages of the OS to be converted. | ||
# The GPG keys are available at https://www.centos.org/keys/ | ||
# Delimited by whitespace(s). | ||
gpg_fingerprints = 0946fca2c105b9de | ||
|
||
# List of packages that have to be removed before the system conversion starts. | ||
# Delimited by any whitespace(s). | ||
pkg_blacklist = | ||
centos-bookmarks | ||
centos-logos | ||
centos-indexhtml | ||
centos-release* | ||
redhat-release* | ||
libreport-centos | ||
libreport-plugin-mantisbt | ||
|
||
default_repository_id = rhel-6-server-rpms |
Oops, something went wrong.