This is the mail archive of the
cygwin-apps-cvs
mailing list for the cygwin-apps project.
[calm - Cygwin server-side packaging maintenance script] branch master, updated. 20160705-59-gae33541
- From: jturney at sourceware dot org
- To: cygwin-apps-cvs at sourceware dot org
- Date: 10 Apr 2017 09:57:28 -0000
- Subject: [calm - Cygwin server-side packaging maintenance script] branch master, updated. 20160705-59-gae33541
https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/calm.git;h=ae33541488c402a3461e75d89241eb7f7ddf8deb
commit ae33541488c402a3461e75d89241eb7f7ddf8deb
Author: Jon Turney <jon.turney@dronecode.org.uk>
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):
</div>'''), 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