From d1b34d3fc70e0330d8149c4f99e4a9742f28b761 Mon Sep 17 00:00:00 2001 From: Kevin Fenzi Date: Mon, 16 May 2016 16:32:38 +0000 Subject: [PATCH] Add new create-filelist call from https://pagure.io/quick-fedora-mirror to replace the rsync call to make fullfiletimelist file. This should allow quick-fedora-mirror script to work. --- roles/bodhi2/backend/files/create-filelist | 36 +++++++++++++++++++ .../bodhi2/backend/files/update-fullfilelist | 2 +- roles/bodhi2/backend/tasks/main.yml | 9 +++++ roles/releng/files/create-filelist | 36 +++++++++++++++++++ roles/releng/files/update-fullfilelist | 2 +- roles/releng/tasks/main.yml | 4 +++ 6 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 roles/bodhi2/backend/files/create-filelist create mode 100644 roles/releng/files/create-filelist diff --git a/roles/bodhi2/backend/files/create-filelist b/roles/bodhi2/backend/files/create-filelist new file mode 100644 index 0000000000..d95000eb67 --- /dev/null +++ b/roles/bodhi2/backend/files/create-filelist @@ -0,0 +1,36 @@ +#!/usr/bin/python + +# A simple script to generate a file list in a format easily consumable by a +# shell script. + +# Originally written by Jason Tibbitts in 2016. +# Donated to the public domain. If you require a statement of license, please +# consider this work to be licensed as "CC0 Universal", any version you choose. + + +from scandir import scandir + + +def get_ftype(entry): + """Return a simple indicator of the file type.""" + if entry.is_symlink(): + return 'l' + if entry.is_dir(): + return 'd' + return 'f' + + +def recursedir(path): + """Just like scandir, but recursively.""" + for entry in scandir(path): + if entry.is_dir(follow_symlinks=False): + for rentry in recursedir(entry.path): + yield rentry + yield entry + + +for entry in recursedir('.'): + info = entry.stat(follow_symlinks=False) + modtime = max(info.st_mtime, info.st_ctime) + ftype = get_ftype(entry) + print('{} {} {}'.format(modtime, ftype, entry.path[2:])) diff --git a/roles/bodhi2/backend/files/update-fullfilelist b/roles/bodhi2/backend/files/update-fullfilelist index bac3f9c909..07e16971d8 100755 --- a/roles/bodhi2/backend/files/update-fullfilelist +++ b/roles/bodhi2/backend/files/update-fullfilelist @@ -25,7 +25,7 @@ popd > /dev/null TMPFILE=$(mktemp -p /tmp/) pushd /pub/$MOD > /dev/null -/usr/bin/rsync --no-h --list-only -r . > $TMPFILE +/usr/local/bin/create-filelist . > $TMPFILE if diff $TMPFILE fullfiletimelist > /dev/null; then rm -f $TMPFILE else diff --git a/roles/bodhi2/backend/tasks/main.yml b/roles/bodhi2/backend/tasks/main.yml index b883ec8a9a..72e0d3333e 100644 --- a/roles/bodhi2/backend/tasks/main.yml +++ b/roles/bodhi2/backend/tasks/main.yml @@ -23,6 +23,7 @@ - python-mock - sigul - python-alembic + - python-scandir tags: - packages - bodhi @@ -228,6 +229,14 @@ - bodhi - cron +- name: add create-filelist script from quick-fedora-mirror + copy: src=create-filelist dest=/usr/local/bin/create-filelist mode=0755 + when: inventory_hostname.startswith('bodhi-backend01') and env == "production" + tags: + - config + - bodhi + - cron + - name: Updates sync cron job. cron: name="updates-sync" minute="15,45" user="ftpsync" job="/usr/local/bin/lock-wrapper fedora-updates-push '/usr/local/bin/fedora-updates-push && /usr/local/bin/update-fullfilelist fedora'" diff --git a/roles/releng/files/create-filelist b/roles/releng/files/create-filelist new file mode 100644 index 0000000000..d95000eb67 --- /dev/null +++ b/roles/releng/files/create-filelist @@ -0,0 +1,36 @@ +#!/usr/bin/python + +# A simple script to generate a file list in a format easily consumable by a +# shell script. + +# Originally written by Jason Tibbitts in 2016. +# Donated to the public domain. If you require a statement of license, please +# consider this work to be licensed as "CC0 Universal", any version you choose. + + +from scandir import scandir + + +def get_ftype(entry): + """Return a simple indicator of the file type.""" + if entry.is_symlink(): + return 'l' + if entry.is_dir(): + return 'd' + return 'f' + + +def recursedir(path): + """Just like scandir, but recursively.""" + for entry in scandir(path): + if entry.is_dir(follow_symlinks=False): + for rentry in recursedir(entry.path): + yield rentry + yield entry + + +for entry in recursedir('.'): + info = entry.stat(follow_symlinks=False) + modtime = max(info.st_mtime, info.st_ctime) + ftype = get_ftype(entry) + print('{} {} {}'.format(modtime, ftype, entry.path[2:])) diff --git a/roles/releng/files/update-fullfilelist b/roles/releng/files/update-fullfilelist index bac3f9c909..07e16971d8 100755 --- a/roles/releng/files/update-fullfilelist +++ b/roles/releng/files/update-fullfilelist @@ -25,7 +25,7 @@ popd > /dev/null TMPFILE=$(mktemp -p /tmp/) pushd /pub/$MOD > /dev/null -/usr/bin/rsync --no-h --list-only -r . > $TMPFILE +/usr/local/bin/create-filelist . > $TMPFILE if diff $TMPFILE fullfiletimelist > /dev/null; then rm -f $TMPFILE else diff --git a/roles/releng/tasks/main.yml b/roles/releng/tasks/main.yml index 90003f85e1..65be0cb24f 100644 --- a/roles/releng/tasks/main.yml +++ b/roles/releng/tasks/main.yml @@ -16,6 +16,9 @@ - name: add ftpsync user user: name=ftpsync uid=263 group=ftpsync createhome=yes system=yes state=present +- name: add create-filelist script from quick-fedora-mirror + copy: src=create-filelist dest=/usr/local/bin/create-filelist mode=0755 owner=ftpsync group=ftpsync + - name: add the ftpsync update-fullfilelist script copy: src=update-fullfilelist dest=/usr/local/bin/update-fullfilelist owner=ftpsync group=ftpsync mode=555 @@ -111,6 +114,7 @@ - hardlink - pungi - compose-utils + - python-scandir when: ansible_distribution_major_version|int > 21 # add sigul to secondary arch compose boxes