# Project: FreeBSD image builder for Raspberry Pi



## qrthur (Feb 14, 2014)

Hello,

I am completely new here, I've been testing FreeBSD for fun the last few days and I really dig it so far. (That ports system, I find it amazing). Anyway, greetings everyone.

So, what I want to do is a program/script that would guide the user through the preparation of his SD card to install FreeBSD for a RPi. I have come accross the crochet-freebsd project that does the same, but I'd like create a brand new script and to add more options to it:

 Sanity checks
 Configure kernel compilation (modules, build options)
 Partition customisation
 Building optional packages

I have the intention to use devel/cdialog to create a configuration menu.

The purpose of this thread is to know what are your thoughts on this. Is it useful? Does it already exists? Do you have ideas of features? Things like that!

It might be worth mentioning that if I do this project, it will be part of my master dissertation for my university.

Cheers,
qrthur


----------



## Carpetsmoker (Feb 14, 2014)

I would recommend using Python, or Perl, or Ruby, or $anything_other than shell scripting, for the sake of your sanity.
Is it _possible_ to use shell scripting and cdialog? Very much so. Will the result be clear, maintainable code? Probably not.
I like shell scripting, but it really has its limits. Every time I've embarked on larger (>100 lines) shell script projects, I've regretted my language choice sooner or later.


----------



## qrthur (Feb 14, 2014)

Indeed, doing everything in shell scripting might be overkill. However if I do this using Python, should my program generate a script shell or should my program execute each shell instruction during the execution_?_


----------



## ondra_knezour (Feb 14, 2014)

Generate the script may be better, because you can prepare "recipes" with your program and distribute them onto build machines with fewer dependencies.


----------



## kpa (Feb 14, 2014)

Python's templates are just made for this type of script creation. Go with the script generation option using Python.


----------



## qrthur (Feb 14, 2014)

OK.

In addition it will allow the program to be run without user privileges, only the script, so it can be reviewed by the user easily (in opposite to review the Python's source)

@kpa: Sounds good, I will look into that.

Thanks for all the advices folks! If you have more by all means go ahead


----------



## SirDice (Feb 16, 2014)

If you're looking for some step-by-step build instructions I have used this one. I actually have never used any of the existing Pi images or scripts 

http://ogris.de/howtos/freebsd-raspberry.html


----------



## qrthur (Feb 16, 2014)

Yeah I want to use this step by step guide to help me do my project. 



			
				SirDice said:
			
		

> I actually have never used any of the existing Pi images or scripts



I hope you will use mine when it is ready then !


----------



## ondra_knezour (Feb 16, 2014)

qrthur said:
			
		

> In addition it will allow the program to be run without user privileges, only the script, so it can be reviewed by the user easily (in opposite to review the Python's source)


Lots of comments in generated script may help here.


----------



## qrthur (Feb 16, 2014)

I did not think of this, that's a good idea!


----------



## Carpetsmoker (Feb 16, 2014)

qrthur said:
			
		

> In addition it will allow the program to be run without user privileges, only the script, so it can be reviewed by the user easily (in opposite to review the Python's source)



So you think a generated shell script is easier to review than Python code?

What's the advantage in generating a shell script? Opposed to just running some Python code? I certainly don't see any obvious one.


----------



## qrthur (Feb 16, 2014)

Carpetsmoker said:
			
		

> qrthur said:
> 
> 
> 
> ...



Well yes I think it is. It will show what is the result of the program. Users that might use my program are not required to have programming knowledge or more specifically python knowledge, but they will most certainly have UNIX knowledge if they use FreeBSD, hence they will be able to decrypt the resulting shell script if they want to make sure it won't destroy their system.

However if it appears that some people prefer not to have a shell script I could add an option to do it in real time during the execution of the program. (Or just execute the generated shell script and erase it afterwards, but it sounds a bit silly, doesn't it?)


----------



## Carpetsmoker (Feb 17, 2014)

Maybe I misunderstood you. If I understand your last post correctly, what you want to do is use a Python program to ask a bunch questions, and based on those questions, generate a shell script with fdisk/tar/etc. commands, and then execute that (non-interactive) as the actual installation process. This generated shell script may actually be very short.

That actually sounds like a pretty good idea.

What I *thought* you meant was use a Python script to generate an interactive shell script, or something (like, GNU autocrap). That seemed a bit silly to me.


----------



## qrthur (Feb 17, 2014)

Yes indeed that would have been completely insane.  Sorry if I did not make myself clear, sometimes I struggle to express my thoughts in English.


----------

