google/googet

Running goopack on Windows requires backslashes in package files

igorpeshansky opened this issue · 0 comments

Running goopack on Windows does not recognize forward slashes in the files clause of the goospec. Replacing forward slashes with backslashes makes it work. This is due to the glob function returning paths with backslashes (it being Windows).

Repro case:

PS C:\src> mkdir a; mkdir b; $null > a/x; $null > b/y

    Directory: C:\src


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----         2/2/2021  11:45 PM                a
d-----         2/2/2021  11:45 PM                b


PS C:\src> @"
>> {
>>   "name": "goopack-test",
>>   "version": "0.0.0",
>>   "arch": "noarch",
>>   "files": {
>>     "a/x": "<ProgramFiles>/GoopackTest/x",
>>     "b/y": "<ProgramFiles>/GoopackTest/y"
>>   },
>>   "sources": [{
>>     "include": [
>>       "a/x",
>>       "b/y"
>>     ]
>>   }]
>> }
>> "@ | Out-File -encoding ASCII goopack-test.goospec
PS C:\src> goopack goopack-test.goospec
2021/02/02 23:59:18 requested files [a/x b/y] not in package
PS C:\src>

Changing the files to use backslashes makes it work:

PS C:\src> @"
>> {
>>   "name": "goopack-test",
>>   "version": "0.0.0",
>>   "arch": "noarch",
>>   "files": {
>>     "a\\x": "<ProgramFiles>/GoopackTest/x",
>>     "b\\y": "<ProgramFiles>/GoopackTest/y"
>>   },
>>   "sources": [{
>>     "include": [
>>       "a/x",
>>       "b/y"
>>     ]
>>   }]
>> }
>> "@ | Out-File -encoding ASCII goopack-test.goospec
PS C:\src> goopack goopack-test.goospec
PS C:\src> dir *.goo


    Directory: C:\src


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----         2/3/2021  12:03 AM            319 goopack-test.noarch.0.0.0.goo                                          


PS C:\src>

Another minor issue is that there is no indication why the forward slashes produced an error. It would be great to have a debug mode where the globbed file set is printed out.
/cc @adjackura