102
104
apparmor-profile: meta/hello.apparmor
105
resultSnap, err := Build(sourceDir, "")
107
resultSnap, err := BuildLegacySnap(sourceDir, "")
106
108
c.Assert(err, IsNil)
107
109
defer os.Remove(resultSnap)
138
140
readFiles, err := exec.Command("dpkg-deb", "-c", "hello_1.0.1_multi.snap").Output()
139
141
c.Assert(err, IsNil)
140
142
for _, needle := range []string{"./meta/package.yaml", "./meta/readme.md", "./bin/hello-world", "./symlink -> bin/hello-world"} {
141
c.Assert(strings.Contains(string(readFiles), needle), Equals, true)
143
expr := fmt.Sprintf(`(?ms).*%s.*`, regexp.QuoteMeta(needle))
144
c.Assert(string(readFiles), Matches, expr)
152
155
- name: bin/hello-world
155
resultSnap, err := Build(sourceDir, "")
158
resultSnap, err := BuildLegacySnap(sourceDir, "")
156
159
c.Assert(err, IsNil)
157
160
defer os.Remove(resultSnap)
194
197
start: bin/hello-world
197
resultSnap, err := Build(sourceDir, "")
200
resultSnap, err := BuildLegacySnap(sourceDir, "")
198
201
c.Assert(err, IsNil)
199
202
defer os.Remove(resultSnap)
236
239
err := ioutil.WriteFile(filepath.Join(hooksDir, "config"), []byte(""), 0755)
237
240
c.Assert(err, IsNil)
239
resultSnap, err := Build(sourceDir, "")
242
resultSnap, err := BuildLegacySnap(sourceDir, "")
240
243
c.Assert(err, IsNil)
241
244
defer os.Remove(resultSnap)
265
268
func (s *SnapTestSuite) TestBuildNoManifestFails(c *C) {
266
269
sourceDir := makeExampleSnapSourceDir(c, "")
267
270
c.Assert(os.Remove(filepath.Join(sourceDir, "meta", "package.yaml")), IsNil)
268
_, err := Build(sourceDir, "")
271
_, err := BuildLegacySnap(sourceDir, "")
269
272
c.Assert(err, NotNil) // XXX maybe make the error more explicit
279
282
apparmor-profile: meta/hello.apparmor
280
283
explicit-license-agreement: Y
282
_, err := Build(sourceDir, "")
285
_, err := BuildLegacySnap(sourceDir, "")
283
286
c.Assert(err, NotNil) // XXX maybe make the error more explicit
296
299
lic := filepath.Join(sourceDir, "meta", "license.txt")
297
300
ioutil.WriteFile(lic, []byte("\n"), 0755)
298
_, err := Build(sourceDir, "")
301
_, err := BuildLegacySnap(sourceDir, "")
299
302
c.Assert(err, Equals, ErrLicenseBlank)
341
344
c.Check(string(out), Matches, `(?m)Only in \S+: foo~`)
347
func (s *SnapTestSuite) TestCopyExcludesTopLevelDEBIAN(c *C) {
348
sourceDir := makeExampleSnapSourceDir(c, "name: hello")
350
// add a toplevel DEBIAN
351
c.Assert(os.MkdirAll(filepath.Join(sourceDir, "DEBIAN", "foo"), 0755), IsNil)
352
// and a non-toplevel DEBIAN
353
c.Assert(os.MkdirAll(filepath.Join(sourceDir, "bar", "DEBIAN", "baz"), 0755), IsNil)
354
c.Assert(copyToBuildDir(sourceDir, target), IsNil)
355
cmd := exec.Command("diff", "-qr", sourceDir, target)
356
cmd.Env = append(cmd.Env, "LANG=C")
357
out, err := cmd.Output()
359
c.Check(string(out), Matches, `(?m)Only in \S+: DEBIAN`)
360
// but *only one* DEBIAN is skipped
361
c.Check(strings.Count(string(out), "Only in"), Equals, 1)
344
364
func (s *SnapTestSuite) TestCopyExcludesWholeDirs(c *C) {
345
365
sourceDir := makeExampleSnapSourceDir(c, "name: hello")
346
366
target := c.MkDir()
391
411
outputDir := filepath.Join(c.MkDir(), "output")
392
412
snapOutput := filepath.Join(outputDir, "hello_1.0.1_multi.snap")
393
resultSnap, err := Build(sourceDir, outputDir)
413
resultSnap, err := BuildLegacySnap(sourceDir, outputDir)
394
414
c.Assert(err, IsNil)
396
416
// check that there is result
425
445
readFiles, err := exec.Command("dpkg-deb", "-c", snapOutput).Output()
426
446
c.Assert(err, IsNil)
427
447
for _, needle := range []string{"./meta/package.yaml", "./meta/readme.md", "./bin/hello-world"} {
428
c.Assert(strings.Contains(string(readFiles), needle), Equals, true)
448
expr := fmt.Sprintf(`(?ms).*%s.*`, regexp.QuoteMeta(needle))
449
c.Assert(string(readFiles), Matches, expr)
441
_, err := Build(sourceDir, "")
462
_, err := BuildLegacySnap(sourceDir, "")
442
463
c.Assert(err, ErrorMatches, ".*binary and service both called foo.*")
469
490
vendor: Foo <foo@example.com>
472
resultSnap, err := Build(sourceDir, "")
493
resultSnap, err := BuildLegacySnap(sourceDir, "")
473
494
c.Assert(err, IsNil)
474
495
defer os.Remove(resultSnap)
490
511
err := syscall.Mkfifo(filepath.Join(sourceDir, "fifo"), 0644)
491
512
c.Assert(err, IsNil)
493
_, err = Build(sourceDir, "")
514
_, err = BuildLegacySnap(sourceDir, "")
494
515
c.Assert(err, ErrorMatches, "can not handle type of file .*")
518
func (s *SnapTestSuite) TestBuildSnapfsSimple(c *C) {
519
sourceDir := makeExampleSnapSourceDir(c, `name: hello
521
vendor: Foo <foo@example.com>
522
architecture: ["i386", "amd64"]
525
apparmor-profile: meta/hello.apparmor
528
resultSnap, err := BuildSnapfsSnap(sourceDir, "")
530
defer os.Remove(resultSnap)
532
// check that there is result
533
_, err = os.Stat(resultSnap)
535
c.Assert(resultSnap, Equals, "hello_1.0.1_multi.snap")
537
// check that the content looks sane
538
output, err := exec.Command("unsquashfs", "-ll", "hello_1.0.1_multi.snap").CombinedOutput()
540
for _, needle := range []string{
544
"symlink -> bin/hello-world",
546
expr := fmt.Sprintf(`(?ms).*%s.*`, regexp.QuoteMeta(needle))
547
c.Assert(string(output), Matches, expr)