Overview
Comment: | Partially added latest support but method is not right. Need to re-think |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | v1.60 |
Files: | files | file ages | folders |
SHA1: |
c7e493c05403db0dbe37b4a3e614bfb1 |
User & Date: | matt on 2014-09-12 06:45:13 |
Other Links: | branch diff | manifest | tags |
Context
2014-09-12
| ||
14:17 | Added mutex for db sync check-in: 0ace787cbd user: mrwellan tags: v1.60 | |
06:45 | Partially added latest support but method is not right. Need to re-think check-in: c7e493c054 user: matt tags: v1.60 | |
2014-09-11
| ||
13:58 | Bumping wait-on-journal for portlocker to 5 seconds check-in: 70e98ec239 user: mrwellan tags: v1.60 | |
Changes
Modified datashare-testing/.datashare.config from [ff6a52c3eb] to [3db28d187c].
︙ | ︙ | |||
12 13 14 15 16 17 18 19 20 21 22 23 24 25 | basepath #{getenv BASEPATH} [areas] synthesis asic/synthesis verilog asic/verilog customlibs custom/oalibs [quality] 0 untested 1 lightly tested 2 tested 3 full QA | > | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | basepath #{getenv BASEPATH} [areas] synthesis asic/synthesis verilog asic/verilog customlibs custom/oalibs megatest tools/megatest [quality] 0 untested 1 lightly tested 2 tested 3 full QA |
︙ | ︙ |
Modified datashare.scm from [f6eb31ba0d] to [5579f4ee08].
︙ | ︙ | |||
66 67 68 69 70 71 72 | ;;====================================================================== ;; RECORDS ;;====================================================================== ;; make-vector-record "testing" datastore pkg id area version_name store_type copied source_path iteration submitter datetime storegrp datavol quality disk_id comment ;; testing | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | ;;====================================================================== ;; RECORDS ;;====================================================================== ;; make-vector-record "testing" datastore pkg id area version_name store_type copied source_path iteration submitter datetime storegrp datavol quality disk_id comment ;; testing (define (make-datashare:pkg)(make-vector 15)) (define-inline (datashare:pkg-get-id vec) (vector-ref vec 0)) (define-inline (datashare:pkg-get-area vec) (vector-ref vec 1)) (define-inline (datashare:pkg-get-version_name vec) (vector-ref vec 2)) (define-inline (datashare:pkg-get-store_type vec) (vector-ref vec 3)) (define-inline (datashare:pkg-get-copied vec) (vector-ref vec 4)) (define-inline (datashare:pkg-get-source_path vec) (vector-ref vec 5)) (define-inline (datashare:pkg-get-iteration vec) (vector-ref vec 6)) (define-inline (datashare:pkg-get-submitter vec) (vector-ref vec 7)) (define-inline (datashare:pkg-get-datetime vec) (vector-ref vec 8)) (define-inline (datashare:pkg-get-storegrp vec) (vector-ref vec 9)) (define-inline (datashare:pkg-get-datavol vec) (vector-ref vec 10)) (define-inline (datashare:pkg-get-quality vec) (vector-ref vec 11)) (define-inline (datashare:pkg-get-disk_id vec) (vector-ref vec 12)) (define-inline (datashare:pkg-get-comment vec) (vector-ref vec 13)) (define-inline (datashare:pkg-get-stored_path vec) (vector-ref vec 14)) (define-inline (datashare:pkg-set-id! vec val)(vector-set! vec 0 val)) (define-inline (datashare:pkg-set-area! vec val)(vector-set! vec 1 val)) (define-inline (datashare:pkg-set-version_name! vec val)(vector-set! vec 2 val)) (define-inline (datashare:pkg-set-store_type! vec val)(vector-set! vec 3 val)) (define-inline (datashare:pkg-set-copied! vec val)(vector-set! vec 4 val)) (define-inline (datashare:pkg-set-source_path! vec val)(vector-set! vec 5 val)) (define-inline (datashare:pkg-set-iteration! vec val)(vector-set! vec 6 val)) (define-inline (datashare:pkg-set-submitter! vec val)(vector-set! vec 7 val)) (define-inline (datashare:pkg-set-datetime! vec val)(vector-set! vec 8 val)) (define-inline (datashare:pkg-set-storegrp! vec val)(vector-set! vec 9 val)) (define-inline (datashare:pkg-set-datavol! vec val)(vector-set! vec 10 val)) (define-inline (datashare:pkg-set-quality! vec val)(vector-set! vec 11 val)) (define-inline (datashare:pkg-set-disk_id! vec val)(vector-set! vec 12 val)) (define-inline (datashare:pkg-set-comment! vec val)(vector-set! vec 13 val)) (define-inline (datashare:pkg-set-stored_path! vec val)(vector-set! vec 14 val)) ;;====================================================================== ;; DB ;;====================================================================== (define (datashare:initialize-db db) (for-each |
︙ | ︙ | |||
151 152 153 154 155 156 157 | ;; now store the data (sqlite3:execute db "INSERT INTO pkgs (area,version_name,iteration,store_type,submitter,source_path,quality,comment) VALUES (?,?,?,?,?,?,?,?);" area version-name next-iteration (conc store-type) submitter source-path quality comment))) (sqlite3:finalize! iter-qry) next-iteration)) | | | | | > > > > > > > > > > > > > > > > > > > | 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | ;; now store the data (sqlite3:execute db "INSERT INTO pkgs (area,version_name,iteration,store_type,submitter,source_path,quality,comment) VALUES (?,?,?,?,?,?,?,?);" area version-name next-iteration (conc store-type) submitter source-path quality comment))) (sqlite3:finalize! iter-qry) next-iteration)) (define (datashare:get-id db area version-name iteration) (let ((res #f)) (sqlite3:for-each-row (lambda (id) (set! res id)) db "SELECT id FROM pkgs WHERE area=? AND version_name=? AND iteration=?;" area version-name iteration) res)) (define (datashare:set-stored-path db id path) (sqlite3:execute db "UPDATE pkgs SET stored_path=? WHERE id=?;" path id)) (define (datashare:set-copied db id value) (sqlite3:execute db "UPDATE pkgs SET copied=? WHERE id=?;" value id)) (define (datashare:get-pkg-record db area version-name iteration) (let ((res #f)) (sqlite3:for-each-row (lambda (a . b) (set! res (apply vector a b))) db "SELECT * FROM pkgs WHERE area=? AND version_name=? AND iteration=?;" area version-name iteration) res)) ;; take version-name iteration and register or update "lastest/0" ;; (define (datashare:set-latest db id area version-name iteration) (let* ((rec (datashare:get-pkg-record db area version-name iteration)) (latest-id (datashare:get-id db area "latest" 0)) (stored-path (datashare:pkg-get-stored_path rec))) (if latest-id ;; have a record - bump the link pointer (datashare:set-stored-path db latest-id stored-path) (datashare:register-data db area "latest" 'link "auto" "na" stored-path "latest data")))) ;; Create the sqlite db (define (datashare:open-db configdat) (let ((path (configf:lookup configdat "database" "location"))) (if (and path (directory? path) (file-read-access? path)) (let* ((dbpath (conc path "/datashare.db")) |
︙ | ︙ | |||
247 248 249 250 251 252 253 | ;; DATA IMPORT/EXPORT ;;====================================================================== (define (datashare:import-data configdat source-path dest-path area version iteration) (let* ((space-avail (car dest-path)) (disk-path (cdr dest-path)) (targ-path (conc disk-path "/" area "/" version "/" iteration)) | | | | | | | | | 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | ;; DATA IMPORT/EXPORT ;;====================================================================== (define (datashare:import-data configdat source-path dest-path area version iteration) (let* ((space-avail (car dest-path)) (disk-path (cdr dest-path)) (targ-path (conc disk-path "/" area "/" version "/" iteration)) (id (datashare:get-id db area version iteration)) (db (datashare:open-db configdat))) (if (> space-avail 10000) ;; dumb heuristic (begin (create-directory targ-path #t) (datashare:set-stored-path db id targ-path) (print "Running command: rsync -av " source-path "/ " targ-path "/") (let ((th1 (make-thread (lambda () (let ((pid (process-run "rsync" (list "-av" (conc source-path "/") (conc targ-path "/"))))) (process-wait pid) (datashare:set-copied db id "yes") (sqlite3:finalize! db))) "Data copy"))) (thread-start! th1)) #t) (begin (print "ERROR: Not enough space in storage area " dest-path) (datashare:set-copied db id "no") (sqlite3:finalize! db) #f)))) (define (datashare:get-best-storage configdat) (let* ((storage (configf:lookup configdat "settings" "storage")) (store-areas (if storage (string-split storage) '()))) (print "Looking for available space in " store-areas) (datashare:find-most-space store-areas))) ;; (string->number (list-ref (with-input-from-pipe "df -B1000000 /tmp" (lambda ()(read-line)(string-split (read-line)))) 3)) (define (datashare:find-most-space paths) (fold (lambda (area res) ;; (print "area=" area " res=" res) (let ((maxspace (car res)) (currpath (cdr res))) ;; (print currpath " " maxspace) (if (file-write-access? area) (let ((currspace (string->number |
︙ | ︙ | |||
300 301 302 303 304 305 306 | res)) res))) (cons 0 #f) paths)) ;; remove existing link and if possible ... ;; create path to next of tip of target, create link back to source | | | | | 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | res)) res))) (cons 0 #f) paths)) ;; remove existing link and if possible ... ;; create path to next of tip of target, create link back to source (define (datashare:build-dir-make-link source target) (if (file-exists? target)(datashare:backup-move target)) (create-directory (pathname-directory target) #t) (create-symbolic-link source target)) (define (datashare:backup-move path) (let* ((trashdir (conc (pathname-directory path) "/.trash")) (trashfile (conc trashdir "/" (current-seconds) "-" (pathname-file path)))) (create-directory trashdir #t) (if (directory? path) (system (conc "mv " path " " trashfile)) (file-move path trash-file)))) |
︙ | ︙ | |||
368 369 370 371 372 373 374 | (submitter (current-user-name)) (quality 2) ;; (import-type (if (equal? (iup:attribute copy-link "VALUE") "ON" ) ;; 'copy ;; 'link)) (db (datashare:open-db configdat)) (iteration (datashare:register-data db area-name version publish-type submitter quality spath comment)) | | > | | > > | | | > | 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 | (submitter (current-user-name)) (quality 2) ;; (import-type (if (equal? (iup:attribute copy-link "VALUE") "ON" ) ;; 'copy ;; 'link)) (db (datashare:open-db configdat)) (iteration (datashare:register-data db area-name version publish-type submitter quality spath comment)) (dest-store (datashare:get-best-storage configdat))) (if iteration (if (eq? 'copy publish-type) (begin (datashare:import-data configdat spath dest-store area-name version iteration) (let ((id (datashare:get-id db area-name version iteration))) (datashare:set-latest db id area-name version iteration))) (let ((id (datashare:get-id db area-name version iteration))) (datashare:set-stored-path db id spath) (datashare:set-copied db id "yes") (datashare:set-copied db id "n/a") (datashare:set-latest db id area-name version iteration))) (print "ERROR: Failed to get an iteration number")) (sqlite3:finalize! db)))) (copy (iup:button "Copy and Publish" #:expand "HORIZONTAL" #:action (lambda (obj) (publish 'copy)))) (link (iup:button "Link and Publish" |
︙ | ︙ | |||
410 411 412 413 414 415 416 | (iup:hbox (iup:label "Version:" #:size label-size) version-tb) ;; (iup:hbox (iup:label "Link only" #:size label-size) copy-link) ;; (iup:label "Iteration:") iteration) (iup:hbox (iup:label "Comment:" #:size label-size) comment-tb) (iup:hbox (iup:label "Source base path:" #:size label-size) source-tb browse-btn) (iup:hbox copy link)))) | | | | | 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 | (iup:hbox (iup:label "Version:" #:size label-size) version-tb) ;; (iup:hbox (iup:label "Link only" #:size label-size) copy-link) ;; (iup:label "Iteration:") iteration) (iup:hbox (iup:label "Comment:" #:size label-size) comment-tb) (iup:hbox (iup:label "Source base path:" #:size label-size) source-tb browse-btn) (iup:hbox copy link)))) (define (datashare:lst->path pathlst) (conc "/" (string-intersperse (map conc pathlst) "/"))) (define (datashare:path->lst path) (string-split path "/")) (define (datashare:pathdat-apply-heuristics configdat path) (cond ((file-exists? path) "found") (else (conc path " not installed")))) (define (datashare:get-view configdat) (iup:vbox (iup:hbox |
︙ | ︙ | |||
452 453 454 455 456 457 458 | #:value 0 #:name "Packages" #:expand "YES" #:addexpanded "NO" #:selection-cb (lambda (obj id state) ;; (print "obj: " obj ", id: " id ", state: " state) | | | | | | | | | | | | | | | | | | | | | 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 | #:value 0 #:name "Packages" #:expand "YES" #:addexpanded "NO" #:selection-cb (lambda (obj id state) ;; (print "obj: " obj ", id: " id ", state: " state) (let* ((path (datashare:lst->path (cdr (tree:node->path obj id)))) (record (hash-table-ref/default srcdat path #f))) (if record (begin (set! curr-record record) (iup:attribute-set! submitter "TITLE" (datashare:pkg-get-submitter record)) (iup:attribute-set! date-submitted "TITLE" (time->string (seconds->local-time (datashare:pkg-get-datetime record)))) (iup:attribute-set! comment "TITLE" (datashare:pkg-get-comment record)) (iup:attribute-set! quality "TITLE" (datashare:pkg-get-quality record)) (iup:attribute-set! copy-link "TITLE" (datashare:pkg-get-store_type record)) )) ;; (print "id=" id " path=" path " record=" record);; (tree:node->path obj id) " run-id: " run-id) )))) (tb2 (iup:treebox #:value 0 #:name "Installed" #:expand "YES" #:addexpanded "NO" #:selection-cb (lambda (obj id state) ;; (print "obj: " obj ", id: " id ", state: " state) (let* ((path (datashare:lst->path (cdr (tree:node->path obj id)))) (status (hash-table-ref/default installed-dat path #f))) (iup:attribute-set! installed-status "TITLE" (if status status "")) )))) (refresh (lambda (obj) (let* ((db (datashare:open-db configdat)) (areas (or (configf:get-section configdat "areas") '()))) ;; ;; first update the Sources ;; (for-each (lambda (pkgitem) (let* ((pkg-path (list (datashare:pkg-get-area pkgitem) (datashare:pkg-get-version_name pkgitem) (datashare:pkg-get-iteration pkgitem))) (pkg-id (datashare:pkg-get-id pkgitem)) (path (datashare:lst->path pkg-path))) ;; (print "tree:add-node tb=" tb ", pkg-path=" pkg-path ", pkg-id=" pkg-id) (if (not (hash-table-ref/default srcdat path #f)) (tree:add-node tb "Packages" pkg-path userdata: (conc "pkg-id: " pkg-id))) ;; (print "path=" path " pkgitem=" pkgitem) (hash-table-set! srcdat path pkgitem))) (datashare:get-pkgs db area-filter version-filter iter-filter)) ;; ;; then update the installed ;; (for-each (lambda (area) (let* ((path (conc "/" (cadr area))) (fullpath (conc basepath path))) (if (not (hash-table-ref/default installed-dat path #f)) (tree:add-node tb2 "Installed" (datashare:path->lst path))) (hash-table-set! installed-dat path (datashare:pathdat-apply-heuristics configdat fullpath)))) areas) (sqlite3:finalize! db)))) (apply (iup:button "Apply" #:action (lambda (obj) (if curr-record (let* ((area (datashare:pkg-get-area curr-record)) (stored-path (datashare:pkg-get-stored_path curr-record)) (source-type (datashare:pkg-get-store_type curr-record)) (source-path (case source-type ;; (equal? source-type "link")) ((link)(datashare:pkg-get-source-path curr-record)) ((copy)stored-path) (else #f))) (dest-stub (configf:lookup configdat "areas" area)) (target-path (conc basepath "/" dest-stub))) (datashare:build-dir-make-link stored-path target-path) (print "Creating link from " stored-path " to " target-path))))))) (iup:vbox (iup:hbox tb tb2) (iup:frame #:title "Source Info" (iup:vbox (iup:hbox (iup:button "Refresh" #:action refresh) apply) |
︙ | ︙ | |||
576 577 578 579 580 581 582 | tabs))) (iup:main-loop)) ;;====================================================================== ;; MISC ;;====================================================================== | | | 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 | tabs))) (iup:main-loop)) ;;====================================================================== ;; MISC ;;====================================================================== (define (datashare:find name paths) (if (null? paths) #f (let loop ((hed (car paths)) (tal (cdr paths))) (if (file-exists? (conc hed "/" name)) hed (if (null? tal) |
︙ | ︙ | |||
611 612 613 614 615 616 617 | (define (main) (let* ((args (argv)) (prog (car args)) (rema (cdr args)) (exe-name (pathname-file (car (argv)))) (exe-dir (or (pathname-directory prog) | | | 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 | (define (main) (let* ((args (argv)) (prog (car args)) (rema (cdr args)) (exe-name (pathname-file (car (argv)))) (exe-dir (or (pathname-directory prog) (datashare:find exe-name (string-split (get-environment-variable "PATH") ":")))) (configdat (datashare:load-config exe-dir exe-name))) (cond ((eq? (length rema) 1) (case (string->symbol (car rema)) ((help -h -help --h --help) (print datashare:help)) (else |
︙ | ︙ |