[gentoo-user] Gentoo install script

June 27th, 2012 - 10:20 pm ET by Michael Mol | Report spam
Very rough, and very much a works-for-me thing, but I thought I'd share.

https://github.com/mikemol/gentoo-install

I wrote it to ease the pain of the "install-configure-build" cycle I
was going through to figure out what was breaking glibc.

:wq
email Follow the discussionReplies 5 repliesReplies Make a reply

Similar topics

Replies

#1 Michael Mol
July 01st, 2012 - 08:40 pm ET | Report spam
On Wed, Jun 27, 2012 at 10:13 PM, Michael Mol wrote:
Very rough, and very much a works-for-me thing, but I thought I'd share.

https://github.com/mikemol/gentoo-install

I wrote it to ease the pain of the "install-configure-build" cycle I
was going through to figure out what was breaking glibc.



Just a bit of a followup. I've got most of the bugs worked out, and
I'm very pleased with it. I've used it to get through most of the
install sequence for inara, and it's currently on package 113/158 of
its second pass of 'emerge -e @world'.

If anyone else gets around to trying it, let me know. :)

:wq
Replies Reply to this message
#2 Kaddeh
July 04th, 2012 - 01:30 am ET | Report spam

Very well done, reminded me of some code that I wrote (poorly, I might add)
but, I dug it up and found some changes that you might be able to implement
instead of lines and lines of static configs. That being said, take some
of these changes into consideration.

Dynamic detection of drives and partitions:

# Get Existing Drives
existing_drives=$(fdisk -l | grep /dev | grep -i disk | cut -c11-13)

# Set default drive
default_drive=$(fdisk -l | grep --max-count=1 /dev | cut -c11-13)

echo -e "What drive do you want to partition? [$existing_drives]: \c"
read drive

and then creating the partition table later:

# Make Drive Selection
if [ "$drive" == "" ]
then
selected_drive=$default_drive
else
# Verify Drive Exists
does_exist=$(fdisk -l | grep --max-count=1 -ci $drive)

if [ "$does_exist" == "1" ]
then
selected_drive=$drive
else
echo -e "The selected drive" $drive "does not exist. Using"
$default_drive "instead."
selected_drive=$default_drive
fi
fi

num_partitions=$(fdisk -l | grep ^/dev | grep -ic $selected_drive)

echo "There are" $num_partitions "partitions on" $selected_drive

partitions=1

# Clear existing partition file
rm -rf partition_table
touch partition_table

while [ "$partitions" -le "$num_partitions" ]
do
# Find partition numbers
edit_partitions=$(fdisk -l | grep ^/dev/$selected_drive | cut -c9)

# Parse out extra partitons
if [ "$partitions" == "1" ]
then
work_partition=$(echo -e $edit_partitions | cut -c$partitions)
# Write to partition_table file
echo -e "d$work_partition" >> partition_table
else
if [ "$partitions_cut" == "" ]
then
# If First Partition after partition 1, cut off $partitions + 1
partitions_cut=$(($partitions+1))
else
partitions_cut=$(($partitions_cut+1))
fi
work_partition=$(echo -e $edit_partitions | cut -c$partitions_cut)
# Write to partition_table file
echo -e "d$work_partition" >> partition_table
((partitions_cut += 1))
fi
((partitions += 1))

done

# build the rest of the table
# Get Total System Memory
total_mem=$(cat /proc/meminfo | grep -i memtotal | cut -c16- | sed s/\
// | sed s/kB//)
swap_space=$(expr $(expr $total_mem + $total_mem) / 1024)

# Write first partition to file
echo -e "np1+100M" >> partition_table

# Write Swap Space (double system memory)
echo -e "np2+"$swap_space"M">> partition_table

# Write / partition to file
echo -e "np3" >> partition_table

# Write partition setting to file and drive write
echo -e "a1t282w" >> partition_table

# Set drive number variables
boot_drive=$(echo $selected_drive"1")
swap_drive=$(echo $selected_drive"2")
root_drive=$(echo $selected_drive"3")

# KEEP THIS COMMENTED OUT BELLOW HERE
fdisk /dev/$selected_drive < partition_table

Mainly due to the fact that you statically set the UUIDs of the drive that
you want to use.

Cheers,
Kad

On Sun, Jul 1, 2012 at 5:28 PM, Michael Mol wrote:

On Wed, Jun 27, 2012 at 10:13 PM, Michael Mol wrote:
> Very rough, and very much a works-for-me thing, but I thought I'd share.
>
> https://github.com/mikemol/gentoo-install
>
> I wrote it to ease the pain of the "install-configure-build" cycle I
> was going through to figure out what was breaking glibc.

Just a bit of a followup. I've got most of the bugs worked out, and
I'm very pleased with it. I've used it to get through most of the
install sequence for inara, and it's currently on package 113/158 of
its second pass of 'emerge -e @world'.

If anyone else gets around to trying it, let me know. :)

:wq






Very well done, reminded me of some code that I wrote (poorly, I might add) but, I dug it up and found some changes that you might be able to implement instead of lines and lines of static configs.  That being said, take some of these changes into consideration.<div>

<br></div><div>Dynamic detection of drives and partitions:</div><div><pre style="word-wrap:break-word;white-space:pre-wrap"># Get Existing Drives
existing_drives=$(fdisk -l | grep /dev | grep -i disk | cut -c11-13)

# Set default drive
default_drive=$(fdisk -l | grep --max-count=1 /dev | cut -c11-13)

echo -e &quot;What drive do you want to partition? [$existing_drives]: \c&quot;
read drive</pre><div>and then creating the partition table later:</div><div><pre style="word-wrap:break-word;white-space:pre-wrap"># Make Drive Selection
if [ &quot;$drive&quot; == &quot;&quot; ]
then
selected_drive=$default_drive
else
# Verify Drive Exists
does_exist=$(fdisk -l | grep --max-count=1 -ci $drive)

if [ &quot;$does_exist&quot; == &quot;1&quot; ]
then
selected_drive=$drive
else
echo -e &quot;The selected drive&quot; $drive &quot;does not exist. Using&quot; $default_drive &quot;instead.&quot;
selected_drive=$default_drive
fi
fi

num_partitions=$(fdisk -l | grep ^/dev | grep -ic $selected_drive)

echo &quot;There are&quot; $num_partitions &quot;partitions on&quot; $selected_drive

partitions=1

# Clear existing partition file
rm -rf partition_table
touch partition_table

while [ &quot;$partitions&quot; -le &quot;$num_partitions&quot; ]
do
# Find partition numbers
edit_partitions=$(fdisk -l | grep ^/dev/$selected_drive | cut -c9)

# Parse out extra partitons
if [ &quot;$partitions&quot; == &quot;1&quot; ]
then
work_partition=$(echo -e $edit_partitions | cut -c$partitions)
# Write to partition_table file
echo -e &quot;d$work_partition&quot; &gt;&gt; partition_table
else
if [ &quot;$partitions_cut&quot; == &quot;&quot; ]
then
# If First Partition after partition 1, cut off $partitions + 1
partitions_cut=$(($partitions+1))
else
partitions_cut=$(($partitions_cut+1))
fi
work_partition=$(echo -e $edit_partitions | cut -c$partitions_cut)
# Write to partition_table file
echo -e &quot;d$work_partition&quot; &gt;&gt; partition_table
((partitions_cut += 1))
fi
((partitions += 1))

done

# build the rest of the table
# Get Total System Memory
total_mem=$(cat /proc/meminfo | grep -i memtotal | cut -c16- | sed s/\ // | sed s/kB//)
swap_space=$(expr $(expr $total_mem + $total_mem) / 1024)

# Write first partition to file
echo -e &quot;np1+100M&quot; &gt;&gt; partition_table

# Write Swap Space (double system memory)
echo -e &quot;np2+&quot;$swap_space&quot;M&quot;&gt;&gt; partition_table

# Write / partition to file
echo -e &quot;np3&quot; &gt;&gt; partition_table

# Write partition setting to file and drive write
echo -e &quot;a1t282w&quot; &gt;&gt; partition_table

# Set drive number variables
boot_drive=$(echo $selected_drive&quot;1&quot;)
swap_drive=$(echo $selected_drive&quot;2&quot;)
root_drive=$(echo $selected_drive&quot;3&quot;)

# KEEP THIS COMMENTED OUT BELLOW HERE
fdisk /dev/$selected_drive &lt; partition_table
</pre>Mainly due to the fact that you statically set the UUIDs of the drive that you want to use.</div><div><br></div><div>Cheers,</div><div>Kad</div><div><br><div class="gmail_quote">On Sun, Jul 1, 2012 at 5:28 PM, Michael Mol <span dir="ltr">&lt;<a href="mailto:" target="_blank"></a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Wed, Jun 27, 2012 at 10:13 PM, Michael Mol &lt;<a href="mailto:"></a>&gt; wrote:<br>


&gt; Very rough, and very much a works-for-me thing, but I thought I&#39;d share.<br>
&gt;<br>
&gt; <a href="https://github.com/mikemol/gentoo-install" target="_blank">https://github.com/mikemol/gentoo-i...<br>
&gt;<br>
&gt; I wrote it to ease the pain of the &quot;install-configure-build&quot; cycle I<br>
&gt; was going through to figure out what was breaking glibc.<br>
<br>
</div></div>Just a bit of a followup. I&#39;ve got most of the bugs worked out, and<br>
I&#39;m very pleased with it. I&#39;ve used it to get through most of the<br>
install sequence for inara, and it&#39;s currently on package 113/158 of<br>
its second pass of &#39;emerge -e @world&#39;.<br>
<br>
If anyone else gets around to trying it, let me know. :)<br>
<span class="HOEnZb"><font color="#888888"><br>
:wq<br>
<br>
</font></span></blockquote></div><br></div></div>

Replies Reply to this message
#3 Mark Knecht
July 04th, 2012 - 01:00 pm ET | Report spam
On Sun, Jul 1, 2012 at 5:28 PM, Michael Mol wrote:
On Wed, Jun 27, 2012 at 10:13 PM, Michael Mol wrote:
Very rough, and very much a works-for-me thing, but I thought I'd share.

https://github.com/mikemol/gentoo-install

I wrote it to ease the pain of the "install-configure-build" cycle I
was going through to figure out what was breaking glibc.



Just a bit of a followup. I've got most of the bugs worked out, and
I'm very pleased with it. I've used it to get through most of the
install sequence for inara, and it's currently on package 113/158 of
its second pass of 'emerge -e @world'.

If anyone else gets around to trying it, let me know. :)

:wq




Hi Michael,
Looks interesting. From reading the code it looks like this was a
(proper) reaction to rebuilding the two machines you recently had
trouble with, right?

Not sure when I'll get to it but I'll likely give it a try building
a VM in Virtualbox as a test.

Thanks for doing the heavy lifting and posting the work output.

Cheers,
Mark
Replies Reply to this message
#4 Michael Mol
July 04th, 2012 - 04:10 pm ET | Report spam
On Wed, Jul 4, 2012 at 1:20 AM, Kaddeh wrote:
Very well done, reminded me of some code that I wrote (poorly, I might add)
but, I dug it up and found some changes that you might be able to implement
instead of lines and lines of static configs. That being said, take some of
these changes into consideration.

Dynamic detection of drives and partitions:

# Get Existing Drives
existing_drives=$(fdisk -l | grep /dev | grep -i disk | cut -c11-13)

# Set default drive
default_drive=$(fdisk -l | grep --max-count=1 /dev | cut -c11-13)

echo -e "What drive do you want to partition? [$existing_drives]: \c"
read drive

and then creating the partition table later:

# Make Drive Selection
if [ "$drive" == "" ]
then
selected_drive=$default_drive
else
# Verify Drive Exists
does_exist=$(fdisk -l | grep --max-count=1 -ci $drive)

if [ "$does_exist" == "1" ]
then
selected_drive=$drive
else
echo -e "The selected drive" $drive "does not exist. Using"
$default_drive "instead."
selected_drive=$default_drive
fi
fi

num_partitions=$(fdisk -l | grep ^/dev | grep -ic $selected_drive)

echo "There are" $num_partitions "partitions on" $selected_drive

partitions=1

# Clear existing partition file
rm -rf partition_table
touch partition_table

while [ "$partitions" -le "$num_partitions" ]
do
# Find partition numbers
edit_partitions=$(fdisk -l | grep ^/dev/$selected_drive | cut -c9)

# Parse out extra partitons
if [ "$partitions" == "1" ]
then
work_partition=$(echo -e $edit_partitions | cut -c$partitions)
# Write to partition_table file
echo -e "d$work_partition" >> partition_table
else
if [ "$partitions_cut" == "" ]
then
# If First Partition after partition 1, cut off $partitions + 1
partitions_cut=$(($partitions+1))
else
partitions_cut=$(($partitions_cut+1))
fi
work_partition=$(echo -e $edit_partitions | cut -c$partitions_cut)
# Write to partition_table file
echo -e "d$work_partition" >> partition_table
((partitions_cut += 1))
fi
((partitions += 1))

done

# build the rest of the table
# Get Total System Memory
total_mem=$(cat /proc/meminfo | grep -i memtotal | cut -c16- | sed s/\ // |
sed s/kB//)
swap_space=$(expr $(expr $total_mem + $total_mem) / 1024)

# Write first partition to file
echo -e "np1+100M" >> partition_table

# Write Swap Space (double system memory)
echo -e "np2+"$swap_space"M">> partition_table

# Write / partition to file
echo -e "np3" >> partition_table

# Write partition setting to file and drive write
echo -e "a1t282w" >> partition_table

# Set drive number variables
boot_drive=$(echo $selected_drive"1")
swap_drive=$(echo $selected_drive"2")
root_drive=$(echo $selected_drive"3")

# KEEP THIS COMMENTED OUT BELLOW HERE
fdisk /dev/$selected_drive < partition_table

Mainly due to the fact that you statically set the UUIDs of the drive that
you want to use.

Cheers,
Kad



Thank you very much.

I'd gladly entertain a pull request if you'd like to integrate it. I'm
not doing much in the way of active development on the script until I
have either (or both) of my machines operational again; they're almost
there, but I'm a sticking point with the 3.3.8 kernel, got past that,
and have now discovered that stable genkernel and stable
gentoo-sources don't play well together. (Because stable genkernel is
using a slightly older version of busybox which doesn't know about
some moved kernel header files). That stuff is slowly moving on b.g.o,
and I'm slowly working around at home. It's only a matter of time, of
which nobody seems to have enough...

:wq
Replies Reply to this message
#5 Michael Mol
July 04th, 2012 - 04:20 pm ET | Report spam
On Wed, Jul 4, 2012 at 12:53 PM, Mark Knecht wrote:
On Sun, Jul 1, 2012 at 5:28 PM, Michael Mol wrote:
On Wed, Jun 27, 2012 at 10:13 PM, Michael Mol wrote:
Very rough, and very much a works-for-me thing, but I thought I'd share.

https://github.com/mikemol/gentoo-install

I wrote it to ease the pain of the "install-configure-build" cycle I
was going through to figure out what was breaking glibc.



Just a bit of a followup. I've got most of the bugs worked out, and
I'm very pleased with it. I've used it to get through most of the
install sequence for inara, and it's currently on package 113/158 of
its second pass of 'emerge -e @world'.

If anyone else gets around to trying it, let me know. :)

:wq




Hi Michael,
Looks interesting. From reading the code it looks like this was a
(proper) reaction to rebuilding the two machines you recently had
trouble with, right?



Indeed. Inara and kaylee are still incomplete, but the script at least
helped me get to a working, up-to-date chroot environment, and that's
a major improvement over where I was.


Not sure when I'll get to it but I'll likely give it a try building
a VM in Virtualbox as a test.



I can tell you right now that you'll hit a circular dependency problem
toward the end, where it starts installing what I'd call "comfort
tools." The general(ish) solution is probably going to be a two-pass
emerge. One with USE="-gtk", followed by a one-two sequence without
that. It's a typical gtk->cups->avahi cyclic dependency, and since gtk
is the most-core element in the cycle, I figure it probably it'll be
part of most cyclic dependency problems that might crop up in the
future, so suppressing it likely covers the most ground. (By the same
reasoning, it's probably appropriate to include -qt, -gnome and -kde
in that first pass, too.)


Thanks for doing the heavy lifting and posting the work output.



Np. It beat the *pants* off of manually trying different CFLAGS to
figure out why glibc was puking. I only had to go through the manual
steps twice before I got sick of it and wrote the bulk of the script
in a couple hours. The rest has mostly been letting the thing run,
discover where I missed something, modify the script, and let it run
again.

:wq
email Follow the discussion Replies Reply to this message
Help Create a new topicReplies Make a reply
Search Make your own search