Skip to content

Commit

Permalink
Merge pull request #84 from rackerlabs/development
Browse files Browse the repository at this point in the history
Release 1.4.1
  • Loading branch information
tonyskapunk committed Jun 26, 2019
2 parents 0930ab9 + a2923ec commit 5ba6e09
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 27 deletions.
69 changes: 54 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,66 @@
language: python
---
language: generic
dist: xenial
sudo: enabled
branches:
only:
- master
- development

env:
global:
- VIRTUALENV_SYSTEM_SITE_PACKAGES=false

matrix:
include:
- python: 2.7
env: TOXENV=py27
- python: 3.6
env: TOXENV=py36
- python: 3.7
env: TOXENV=py37
- python: 3.7
env: TOXENV=pycodestyle
- name: "Ubuntu 14.04 (trusty)"
env:
- DISTRO='ubuntu:14.04'
- name: "Ubuntu 16.04 (xenial)"
env:
- DISTRO='ubuntu:16.04'
- name: "Ubuntu 18.04 (bionic)"
env:
- DISTRO='ubuntu:18.04'
- name: "Debian 8 (jessie)"
env:
- DISTRO='debian:8'
- name: "Debian 9 (stretch)"
env:
- DISTRO='debian:9'
- name: "Debian (buster)"
env:
- DISTRO='debian:buster'

before_install:
- pip install tox
- |
docker run \
--detach \
--rm \
--tty \
--privileged \
--network=host \
--name kthresher_on_${DISTRO/:/_} \
--mount type=bind,src="$(pwd)",dst=/kthresher \
${DISTRO}
- |
docker exec \
kthresher_on_${DISTRO/:/_} \
bash -c \
'apt-get update; \
apt-get install -yq --no-install-suggests --no-install-recommends \
python \
python3 \
python-apt \
python3-apt \
python-pip \
python3-pip \
python-setuptools \
python3-setuptools'
- |
docker exec \
kthresher_on_${DISTRO/:/_} \
bash -c 'pip install tox'
script:
- tox
- >
docker exec \
kthresher_on_${DISTRO/:/_} \
bash -c 'cd /kthresher/; tox'
...
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

## [1.4.1] - 2019-02-13
## [1.4.1] - 2019-06-26
### Added
- Only create a syslog handler if /dev/log exists.
- Reference of unattended-updates capability to remove unused kernels.

### Changed
- Use package section from `Version` instead of `Package`.

## [1.4.0] - 2019-02-13
### Added
- Add system logs on purge, show and errors.
- Python3 Support.
Expand Down Expand Up @@ -153,5 +161,6 @@ All notable changes to this project will be documented in this file.
- [delag](https://github.com/delag)
- [disengage00](https://github.com/disengage00)
- [jamrok](https://github.com/jamrok)
- [jkirk](https://github.com/jkirk)
- [Jose R. Gonzalez](https://github.com/Komish)
- [Tony G.](https://github.com/tonyskapunk)
6 changes: 5 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ By default, on apt 1.0 and below, the booted kernel, the latest-installed kernel
Ubuntu has multiple suggestions on how to remove kernels:
https://help.ubuntu.com/community/RemoveOldKernels

A good recommendation is using unattendend-upgrades(`debian <https://wiki.debian.org/UnattendedUpgrades>`__, `ubuntu <https://help.ubuntu.com/community/AutomaticSecurityUpdates>`__) as it has an option to remove unused dependencies, but that applies to all packages not just kernels.
A great recommendation is to make use of unattended-upgrades `u-u` (`debian <https://wiki.debian.org/UnattendedUpgrades>`__, `ubuntu <https://help.ubuntu.com/community/AutomaticSecurityUpdates>`__). Since version **1.0** (`debian <https://packages.debian.org/search?keywords=unattended-upgrades>`__, `ubuntu <https://packages.ubuntu.com/search?keywords=unattended-upgrades>`__) *u-u* removes unused kernel packages by default (*Remove-Unused-Kernel-Packages*).
Some distribution versions may not make reference or may comment out that setting in its configuration, but unless it is explicitly disabled, *u-u* will attempt to remove unused kernels. `More info here <https://github.com/rackerlabs/kthresher/issues/79>`__.

For scenarios where *u-u* is not available or older than **1.0**, `kthresher` is still a good option.


*thresher - A device that first separates the head of a stalk of grain from the straw, and then further separates the kernel from the rest of the head.*

Expand Down
22 changes: 13 additions & 9 deletions kthresher.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
Ubuntu has multiple suggestions on how to remove kernels:
https://help.ubuntu.com/community/RemoveOldKernels
A good recommendation is using unattendend-upgrades as it has an option to
remove unused dependencies, but that applies to all packages not just kernels.
A great recommendation is to make use of unattended-upgrades (u-u). Since
version 1.0 u-u is capable of removing unused kernel packages.
thresher - A device that first separates the head of a stalk of grain from
the straw, and then further separates the kernel from the rest of the head.
Expand All @@ -37,6 +37,7 @@
import logging
import argparse
from glob import iglob
from os import path
from platform import uname
from logging.handlers import SysLogHandler
from distutils.version import LooseVersion
Expand Down Expand Up @@ -74,7 +75,7 @@
sys.exit(1)


__version__ = "1.4.0"
__version__ = "1.4.1"


# Loggers
Expand Down Expand Up @@ -271,8 +272,9 @@ def kthreshing(purge=None, headers=None, keep=1):
)
for pkg_name in apt_cache.keys():
pkg = apt_cache[pkg_name]
section = pkg.candidate.section or ''
if (pkg.is_installed and pkg.is_auto_removable) and (
"kernel" in pkg.section and re.match(kernel_image_regex, pkg_name)
"kernel" in section and re.match(kernel_image_regex, pkg_name)
):
if ver_max_len < len(pkg.installed.version):
ver_max_len = len(pkg.installed.version)
Expand Down Expand Up @@ -430,11 +432,13 @@ def main():
logger.setLevel(logging.INFO)

# Configure syslog handler
sh = SysLogHandler("/dev/log")
sf = logging.Formatter("%(name)s[%(process)d]: %(message)s")
sh.setLevel(logging.ERROR)
sh.setFormatter(sf)
logger.addHandler(sh)
if path.exists("/dev/log"):
sh = SysLogHandler("/dev/log")
sf = logging.Formatter("%(name)s[%(process)d]: %(message)s")
sh.setLevel(logging.ERROR)
sh.setFormatter(sf)
logger.addHandler(sh)

# Create new logging level to be used on syslog
logging.addLevelName(42, "INFO")

Expand Down
4 changes: 3 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
[tox]
skipsdist = True
skip_missing_interpreters = True
sitepackages = True
envlist = py2, py3, pycodestyle

[testenv]
sitepackages = True
commands =
{envpython} -V
{envpython} setup.py install
kthresher --version

[testenv:pycodestyle]
deps =
Expand Down

0 comments on commit 5ba6e09

Please sign in to comment.