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)
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()