]> git.donarmstrong.com Git - cran2deb.git/blobdiff - trunk/exec/license
backup license hashes. this is not optimal wrt accountability but should suffice...
[cran2deb.git] / trunk / exec / license
index 74e01a57ea63ece49babfb568f87604b7f2bb6f6..a211525bfb1c801f533bc02bc6bb77cb75885f31 100755 (executable)
@@ -40,13 +40,22 @@ exec_cmd <- function(argc, argv) {
             error('license',license,'is not known; add it first')
             return()
         }
-        if (file.exists(path)) {
-            license_sha1 = digest(readChar(path,file.info(path)$size)
-                                 ,algo='sha1', serialize=FALSE)
-        } else if (length(grep('^[0-9a-f]{40}$',path))) {
-            license_sha1 = path
-        } else {
-            error(path,'does not exist and does not look like an SHA1 hash')
+        if (!file.exists(path)) {
+            error(path,'does not exist')
+            return()
+        }
+        license_sha1 = digest(readChar(path,file.info(path)$size)
+                             ,algo='sha1', serialize=FALSE)
+        db_add_license_hash(license,license_sha1)
+    } else if (cmd == 'hash_sha1') {
+        if (argc != 3) {
+            usage()
+            return()
+        }
+        license = argv[2]
+        license_sha1 = argv[3]
+        if (is.null(db_license_override_name(license))) {
+            error('license',license,'is not known; add it first')
             return()
         }
         db_add_license_hash(license,license_sha1)
@@ -106,7 +115,17 @@ exec_cmd <- function(argc, argv) {
             return()
         }
     } else if (cmd == 'ls') {
-        for (x in db_license_overrides()) print(x)
+        licenses <- db_license_overrides()
+        for (i in rownames(licenses$overrides)) {
+            mode='accept'
+            if (licenses$overrides[i,'accept']==0) {
+                mode='reject'
+            }
+            cat(paste(mode,licenses$overrides[i,'name'],'\n'))
+        }
+        for (i in rownames(licenses$hashes)) {
+            cat(paste('hash_sha1',licenses$hashes[i,'name'],licenses$hashes[i,'sha1'],'\n'))
+        }
     } else if (cmd == 'help') {
         usage()
         return()