summaryrefslogtreecommitdiff
path: root/doc/forum/chroot_for_sbuild/comment_6_9a0b4cce3a9cac8504358d6a280c24bb._comment
blob: b2196f8addb370d19144f16cc4a5888727ce6073 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
[[!comment format=mdwn
 username="picca"
 subject="comment 6"
 date="2015-10-02T14:15:23Z"
 content="""
Just for information, here my solution. It is not perfect but it works :)
thanks a lot for your help

    sbuild :: System -> RevertableProperty
    sbuild system = sbuild' chroot
      where
        chroot = Chroot.debootstrapped system Debootstrap.BuilddD \"/var/lib/sbuild\"
                 & \"/etc/apt/apt.conf.d/01proxy\" `File.hasContent` [\"Acquire::http::Proxy \\"http://w.x.y.z:8080\\";\"]
                 & Apt.installed [\"apt-transport-https\"]


    sbuild' :: Chroot -> RevertableProperty
    sbuild' chroot@(Chroot basedir system _ _) = setup <!> cleanup
      where
        setup = toProp (Chroot.provisioned chroot) `onChange` setup'
    
        setup' = property (\"sbuild-creatchroot \" ++ chrootdir) $ do
          -- unmount helper filesystems such as proc from the chroot
          -- before getting sizes
          liftIO $ Mount.unmountBelow chrootdir
            -- use the chroot for sbuild
          ensureProperty $
              scriptProperty (rmconfig chrootdir ++ 
                              [ \"sbuild-createchroot --setup-only --keep-sbuild-chroot-dir --make-sbuild-tarball=\" ++ tarball ++ \" \" ++ name ++ \" \" ++ chrootdir ++ \" http://httpredir.debian.org/debian\"
                              ])

        cleanup = scriptProperty (rmconfig chrootname ++ [\"rm -f -v \" ++ tarball])
                  `onChange` toProp (revert (Chroot.provisioned chroot))
      
        (name, arch) = case system of
          (System (Debian (Stable suite)) a) -> (suite, a)

        chrootname = name ++ \"-\" ++ arch

        chrootdir = basedir </> chrootname

        tarball = chrootdir ++ \".tar.gz\"

        rmconfig c = [ \"rm -f -v \" ++ \"/etc/schroot/chroot.d\" </> (c ++ \"-sbuild-*\")
                     , \"rm -f -v \" ++ \"/etc/sbuild/chroot\" </> (c ++ \"-sbuild\")
                     ]

"""]]