Bladeren bron

Applying patch to fix Debian bug #739738

merge-requests/1/merge
Christoph Haas 10 jaren geleden
bovenliggende
commit
d3ff6e6bfa
9 gewijzigde bestanden met toevoegingen van 193 en 0 verwijderingen
  1. +1
    -0
      ispmail.yml
  2. +6
    -0
      roles/ispmail-postfix/tasks/main.yml
  3. +8
    -0
      roles/thydel.patch/.gitignore
  4. +9
    -0
      roles/thydel.patch/LICENSE.md
  5. +40
    -0
      roles/thydel.patch/README.md
  6. +117
    -0
      roles/thydel.patch/library/patch
  7. +1
    -0
      roles/thydel.patch/meta/.galaxy_install_info
  8. +10
    -0
      roles/thydel.patch/meta/main.yml
  9. +1
    -0
      roles/thydel.patch/tasks/main.yml

+ 1
- 0
ispmail.yml Bestand weergeven

@@ -4,6 +4,7 @@
roles:
- ispmail-packages
- dumpvars
- thydel.patch
- ispmail-certificate
- ispmail-database
- ispmail-postfix


+ 6
- 0
roles/ispmail-postfix/tasks/main.yml Bestand weergeven

@@ -67,6 +67,12 @@
- name: Enabling SMTP authentication during the SMTP protocol
command: postconf smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination

- name: Copying patch for Debuan bug \#739738
copy: src=spamassassin.patch dest=/tmp/spamassassin.patch

- name: Patching Debian bug \#739738
patch: patchfile=/tmp/spamassassin.patch strip=0 basedir=/

- name: Enabling Spamassassin milter
command: postconf smtpd_milters=unix:/spamass/spamass.sock



+ 8
- 0
roles/thydel.patch/.gitignore Bestand weergeven

@@ -0,0 +1,8 @@
.hg/
.hgignore
.hgremote
.gitconfig
.gitremote
.gitfirstcommit
.hgfirstcommit
README.html

+ 9
- 0
roles/thydel.patch/LICENSE.md Bestand weergeven

@@ -0,0 +1,9 @@
The MIT License (MIT)

Copyright (c) 2014 Thierry Delamare

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

+ 40
- 0
roles/thydel.patch/README.md Bestand weergeven

@@ -0,0 +1,40 @@
# Patch

Ansible role to embed patch module

- Original `patch` module from
[luisperlaz/ansible-misc-modules](https://github.com/luisperlaz/ansible-misc-modules)

- Reorganize filetree to fit `galaxy` and new repos to get a better galaxy name.

- Patch module to support
[check-mode](https://github.com/thydel/ansible-misc-modules/commit/ecee1b0d830917bc2f88998f1e47deaca293f799)

## Example Playbook

After declaring `patch` role:

``` yaml
- hosts: all
roles:
- patch
```

You can use patch module:

``` yaml
- name: Patch some paramiko code
patch: patchfile=/tmp/critical.patch strip=1 basedir=/usr/share/pyshared/paramiko"
```

## Prerequisites:

GNU patch installed

## License

MIT

## Author Information

Thierry Delamare

+ 117
- 0
roles/thydel.patch/library/patch Bestand weergeven

@@ -0,0 +1,117 @@
#!/usr/bin/python -tt

# (c) 2012, Luis Alberto Perez Lazaro <luisperlazaro@gmail.com>
#
# This module 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 software 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 software. If not, see <http://www.gnu.org/licenses/>.
#

DOCUMENTATION = '''
---
module: patch
author: Luis Alberto Perez Lazaro
version_added: 0.9
short_description: apply patch files
description:
- Apply patch files using the GNU patch tool. Before using this module make sure the patch tool is installed.
options:
patchfile:
required: true
description:
- A patch file as accepted by the gnu patch tool
strip:
required: true
aliases: [ p ]
description:
- Number that indicates the smallest prefix containing leading slashes that
will be stripped from each file name found in the patch file. For more information
see the strip parameter of the gnu patch tool.
basedir:
required: true
description:
- base directory in which the patch file will be applied
examples:
- code: "patch: patchfile=/tmp/critical.patch strip=1 basedir=/usr/share/pyshared/paramiko"
description: Example git checkout from Ansible Playbooks
'''

def _run(args):
cmd = subprocess.Popen(args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = cmd.communicate()
rc = cmd.returncode
return (rc, out, err)

def _is_already_applied(patch_file, strip):
reverse_cmd = "patch -s -R -N -p%s --dry-run < %s" % (strip, patch_file)
(rc, _, _) = _run(reverse_cmd)
return rc == 0

def _apply_patch(module, patch_file, strip):
patch_cmd = "patch -s -N -t -r - -p%s < %s" % (strip, patch_file)
(rc, out, err) = _run(patch_cmd)
if rc != 0:
msg = out if not err else err
module.fail_json(msg=msg)

def _get_params(module):
patchfile = os.path.expanduser(module.params['patchfile'])
strip = module.params['strip']
basedir = module.params['basedir']

if basedir:
os.chdir(os.path.expanduser(basedir))

if not os.path.exists(patchfile):
module.fail_json(msg="patchfile %s doesn't exist" % (patchfile))
if not os.access(patchfile, os.R_OK):
module.fail_json(msg="patchfile %s not readable" % (patchfile))

if not os.path.exists(basedir):
module.fail_json(msg="basedir %s doesn't exist" % (patchfile))

try:
strip = int(strip)
except Exception:
module.fail_json(msg="p must be a number")

return patchfile, strip, basedir

# ===========================================

def main():
module = AnsibleModule(
argument_spec = dict(
patchfile=dict(required=True),
basedir=dict(),
strip=dict(default=0, aliases=['p'])
),
supports_check_mode = True
)
patchfile, strip, basedir = _get_params(module)

changed = False

if module.check_mode:
if _is_already_applied(patchfile, strip):
module.exit_json(changed=changed)
module.exit_json(changed=True)

if not _is_already_applied(patchfile, strip):
_apply_patch(module, patchfile, strip)
changed = True

module.exit_json(changed=changed)

# include magic from lib/ansible/module_common.py
#<<INCLUDE_ANSIBLE_MODULE_COMMON>>
main()

+ 1
- 0
roles/thydel.patch/meta/.galaxy_install_info Bestand weergeven

@@ -0,0 +1 @@
{install_date: 'Mon Oct 5 13:52:12 2015', version: master}

+ 10
- 0
roles/thydel.patch/meta/main.yml Bestand weergeven

@@ -0,0 +1,10 @@
---
galaxy_info:
author: Thierry Delamare
description: Embed patch module
company: EpiConcept
license: MIT
min_ansible_version: 1.3
categories:
- packaging
dependencies: []

+ 1
- 0
roles/thydel.patch/tasks/main.yml Bestand weergeven

@@ -0,0 +1 @@
---

Laden…
Annuleren
Opslaan