From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 41908 invoked by alias); 10 Apr 2017 09:57:29 -0000 Mailing-List: contact cygwin-apps-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cygwin-apps-cvs-owner@sourceware.org Received: (qmail 41862 invoked by uid 9795); 10 Apr 2017 09:57:28 -0000 Date: Mon, 10 Apr 2017 09:57:00 -0000 Message-ID: <20170410095728.41830.qmail@sourceware.org> From: jturney@sourceware.org To: cygwin-apps-cvs@sourceware.org Subject: [calm - Cygwin server-side packaging maintenance script] branch master, updated. 20160705-59-gae33541 X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 9f8aa81b7ddcdec5e923f8ef7aea8fdb1da43483 X-Git-Newrev: ae33541488c402a3461e75d89241eb7f7ddf8deb X-SW-Source: 2017-q2/txt/msg00003.txt.bz2 https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/calm.git;h=ae33541488c402a3461e75d89241eb7f7ddf8deb commit ae33541488c402a3461e75d89241eb7f7ddf8deb Author: Jon Turney Date: Sat Apr 8 21:11:18 2017 +0100 Remove directories which are empty after updating package listing Diff: --- calm/pkg2html.py | 22 ++++++++++++++++++---- 1 files changed, 18 insertions(+), 4 deletions(-) diff --git a/calm/pkg2html.py b/calm/pkg2html.py index f6b260c..70af62d 100755 --- a/calm/pkg2html.py +++ b/calm/pkg2html.py @@ -31,8 +31,8 @@ # --- if a package listing HTML file doesn't already exist # ---- write a HTML package listing file listing the tar file contents # - write packages.inc, the list of packages -# - remove any listing files for which there was no package -# - remove any empty directories (TBD) +# - remove any .htaccess or listing files for which there was no package +# - remove any directories which are now empty # # note that the directory hierarchy of (noarch|arch)/package/subpackages is # flattened in the package listing to just the package name @@ -84,7 +84,7 @@ def update_package_listings(args, packages, arch): print('Redirect temp /packages/%s/index.html https://cygwin.com/packages/package_list.html' % (arch), file=f) - toremove = glob.glob(os.path.join(base, '*', '*')) + toremove = glob.glob(os.path.join(base, '*', '*')) + glob.glob(os.path.join(base, '*', '.*')) for p in packages: @@ -119,6 +119,10 @@ def update_package_listings(args, packages, arch): # doesn't help for src packages, so is it actually having # any effect? + # this file should exist, so remove from the toremove list + if htaccess in toremove: + toremove.remove(htaccess) + # # for each tarfile, write tarfile listing # @@ -220,7 +224,7 @@ def update_package_listings(args, packages, arch): '''), file=index) # - # remove any remaining listing files for which there was no corresponding package + # remove any remaining files for which there was no corresponding package # for r in toremove: @@ -228,6 +232,16 @@ def update_package_listings(args, packages, arch): if not args.dryrun: os.unlink(r) + # + # remove any directories which are now empty + # + + dirpath = os.path.dirname(r) + if len(os.listdir(dirpath)) == 0: + logging.debug('rmdir %s' % dirpath) + os.rmdir(os.path.join(dirpath)) + + if __name__ == "__main__": htdocs_default = os.path.join(common_constants.HTDOCS, 'packages') relarea_default = common_constants.FTP