Check-in [2515a3ade8]
Not logged in
Overview
Comment:More work getting the script block generator working.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | uploaderClient
Files: files | file ages | folders
SHA1: 2515a3ade8655d5802b6154cb7c911d87b0bd720
User & Date: mistachkin on 2016-12-18 00:55:54
Other Links: branch diff | manifest | tags
Context
2016-12-18
03:10
Comments, cleanup, more work in progress on the uploader client. Not yet tested. Also, 'getContainingDirectory' still needs work to forbid mismatched root directories. check-in: e05a3e1067 user: mistachkin tags: uploaderClient
00:55
More work getting the script block generator working. check-in: 2515a3ade8 user: mistachkin tags: uploaderClient
2016-12-17
08:34
Remove superfluous 'return' command. check-in: 07be60251c user: mistachkin tags: uploaderClient
Changes

Modified client/1.0/neutral/pkgr_upload.eagle from [eccf43617e] to [06d64b587a].

33
34
35
36
37
38
39
























40

41
42
43
44
45
46
47
48
49
50
51
52


53
54
55
56
57
58
59
60
61
62
63
64










65
66
67

68
















69
70
71
72
73
74
75
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

64
65
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+











-
+
+











-
+
+
+
+
+
+
+
+
+
+



+

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







  [file tail [info nameofexecutable]]\
  [file tail [info script]] \[apiKey\] \[name\] \[version\] \[language\]\
  \[fileName1\] ... \[fileNameN\]"

    exit 1
  }

  #
  # NOTE: This procedure returns a string value, formatted for use within a
  #       script block being processed by the [string map] command.  The
  #       value argument is the string value to format.  No return value is
  #       reserved to indicate an error.  This procedure may not raise any
  #       script errors.
  #
  proc formatStringMapValue { value } {
    if {[string length $value] == 0} then {
      return \"\"
    }

    set list [list $value]

    if {$value eq $list} then {
      return $value
    } else {
      return $list
    }
  }

  #
  #
  #
  proc getOuterDirectory { fileNames } {
  proc getContainingDirectory { fileNames } {
    set result ""
    set resultParts [list]

    foreach fileName $fileNames {
      set directory [file dirname $fileName]
      set directoryParts [file split $directory]

      if {[llength $resultParts] == 0 || \
          [llength $directoryParts] < [llength $resultParts]} then {
        set result $directory
        set resultParts $directoryParts
      } elseif {[llength $directoryParts] == [llength $resultParts]} then {
      } elseif {[llength $directoryParts] == [llength $resultParts] && \
          $directory ne $result} then {
        set result [file dirname $directory]
        set resultParts [file split $result]
      }
    }

    return $result
  }

  #
  #
  #
  proc getScriptChunkForFileNames { fileNames } {
  proc getScriptChunkForFileNames { fileNames maximumLevels } {
    set directory [getContainingDirectory $fileNames]
    set directoryParts [file split $directory]
    set fileNameIndex [expr {[llength $directoryParts] - 1}]

    if {$fileNameIndex < 0} then {
      error [appendArgs \
          "bad file name index"]
    }

    set relativeFileNames [list]

    foreach fileName $fileNames {
      set fileNameParts [lrange [file split $fileName] $fileNameIndex end]

      if {$maximumLevels > 0 && \
          [llength $fileNameParts] > $maximumLevels} then {
        error [appendArgs \
            "depth for file name \"" $fileName \
            "\" exceeds maximum (" $maximumLevels )]
      }

      set relativeFileName [eval file join $fileNameParts]

      if {[string length $relativeFileName] == 0 || \
          [file pathtype $relativeFileName] ne "relative"} then {
        error [appendArgs \
            "bad file name \"" $relativeFileName "\", not relative"]
      }

      lappend relativeFileNames $relativeFileName
    }

    set result ""

    foreach relativeFileName $relativeFileNames {
      if {[string length $result] > 0} then {
        append result \n
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
111
112
113
135
136
137
138
139
140
141


142
143
144
145
146
147
148
149
150

151
152
153
154
155
156

157
158
159


160
161
162
163
164
165
166
167
168







-
-
+
+
+
+
+
+



-
+





-
+


-
-
+
+







  }

  #
  #
  #
  proc createRepositoryScript { language version platform fileNames options } {
    return [string trim [string map [list \r\n \n \
        %language% $language %version% $version %platform% $platform \
        %fileNames% [getScriptChunkForFileNames $fileNames]] {
        %language% [formatStringMapValue $language] \
        %version% [formatStringMapValue $version] \
        %platform% [formatStringMapValue $platform] \
        %backslash% \\ %ns% ::PackageDownloader %fileNames% \
        [getScriptChunkForFileNames \
        $fileNames 2]] {
apply [list [list] {
  package require Eagle.Package.Downloader

  ::PackageDownloader::resetCookieAndLoginSimple
  %ns%::resetCookieAndLoginSimple

  set fileNames [list]

%fileNames%

  set options [list \
  set options [list %backslash%
      -persistent false -usePgp true -useAutoPath true]

  ::PackageDownloader::downloadFiles %language% %version% %platform% $fileNames $options
  ::PackageDownloader::logoutAndResetCookie
  %ns%::downloadFiles %language% %version% %platform% $fileNames $options
  %ns%::logoutAndResetCookie
}]
    }]]
  }

  #
  # NOTE: Figure out the fully qualified path to the current script file.
  #       If necessary, add it to the auto-path for the interpreter.  The