On Thu, 2010-07-29 at 13:15 -0400, Tanstaafl wrote: [...] > Wow, Albert, this looks very, very cool. I have heard of using 'make' > and creating your own make files to do things like this, but after a few > minutes of perusing these files I realize this is just way over my head, > at least without some kind of tutorial (I'm just a lowly user whose > (lack of) bash skills would make most of you guys laugh). > Charles,
Well, looks like you are looking for a make tutorial. There are a few make tutorials on the internet (a simple Google search should return something). I am by no means an expert on make or Makefiles, but for my makefile specifically: The first part is simply assigning variables, much like bash. The rest are "recipes" for creating targets (files usually). So we can look at the 2nd recipe which is probably the simplest. I'll past it here and replace the variables with actual values for clarity: base.img: qemu-img create -f raw base.img 60G So our "target" here is the file called "base.img". This recipe has no dependencies (after the colon is where you list dependencies). The TABed in line(s) are the instructions, so to create the base.img file we simply execute that qemu-img command. In the makefile the "default" target is the first one, so the default is "all" in my case. "all" requires "image" and has no instructions. The "image" target requires the RAW_IMAGE we saw above, and a few other dependencies. So the make command will try to satisfy those dependencies before it runs the recipe for "image" > Do you know of any generic tutorials on using creating/using your own > make files to do repetitive tasks (not necessarily like building an > entire system as you are doing here (but if there is something like that > even better)? > Makefiles may not be what you need if you are wanting to do "repetitive tasks", but it depends on what you want to do. For example, the virtual appliance makefile isn't really doing "repetitive" tasks, but a series of tasks that need to be run in a certain order (a recipe). Someone asked me why I chose to use a Makefile instead of just writing a script. The reason is that Makefiles can do "checkpointing" and it makes it much easier to debug the appliance creation process. For example, if your script did the chroot and unpacking but then it failed on "emerge world", well if you fix that and run your script again then it will start from the beginning, which takes a long time. But with Makefiles make will see that the first parts are "up to date" and continue from where it failed. It also lets you test certain parts (targets) without having to run the entire thing. But if you really want a script all you need to do is # make -n > script.sh > If not, no worries. http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=makefile +tutorial > Anyway, thanks for sharing what you've done here... NP. I will be committing a fix soon that will use the default portage directories instead of my funny ones. Oh, and I confirmed that you can create virtual appliances inside a virtual appliance, which is safer. So I will be adding a virtual appliance creating virtual appliance soon. -a