aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2009-09-29 13:34:39 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2009-09-29 13:36:32 +0000
commit3d4d4b6898b3b32b7c5af3d34d9d8e5d976eb9d6 (patch)
tree93b6f4ec3129b8202656691deb97bf3074246dab
parent629d4653a2c57a74b322d6689865f935c48c49ee (diff)
downloadalpine_aports-3d4d4b6898b3b32b7c5af3d34d9d8e5d976eb9d6.tar.bz2
alpine_aports-3d4d4b6898b3b32b7c5af3d34d9d8e5d976eb9d6.tar.xz
alpine_aports-3d4d4b6898b3b32b7c5af3d34d9d8e5d976eb9d6.zip
main/alpine-conf: fix for setup-disk
-rw-r--r--main/alpine-conf/0001-setup-disk-fix-find_disks.patch76
-rw-r--r--main/alpine-conf/0001-setup-disk-use-uuid-in-fstab-and-extlinux.conf.patch74
-rw-r--r--main/alpine-conf/APKBUILD7
3 files changed, 81 insertions, 76 deletions
diff --git a/main/alpine-conf/0001-setup-disk-fix-find_disks.patch b/main/alpine-conf/0001-setup-disk-fix-find_disks.patch
new file mode 100644
index 0000000000..2b5453d6bf
--- /dev/null
+++ b/main/alpine-conf/0001-setup-disk-fix-find_disks.patch
@@ -0,0 +1,76 @@
1From 5572e8a3db95f179b3433e5ea5f8c6fa2c8c65ab Mon Sep 17 00:00:00 2001
2From: Natanael Copa <ncopa@alpinelinux.org>
3Date: Tue, 29 Sep 2009 09:40:53 +0000
4Subject: [PATCH] setup-disk: fix find_disks
5
6The old way did not detect ida/c0d0. The new should detect it.
7We also filter out md devices.
8---
9 setup-disk.in | 42 ++++++++++++++++++++++++++++++++----------
10 1 files changed, 32 insertions(+), 10 deletions(-)
11
12diff --git a/setup-disk.in b/setup-disk.in
13index d53fba1..33cc868 100644
14--- a/setup-disk.in
15+++ b/setup-disk.in
16@@ -146,25 +146,47 @@ find_swap_size() {
17
18 has_mounted_part() {
19 local p
20- # parse /proc/mounts for moutned devices
21+ # parse /proc/mounts for mounted devices
22 for p in $(awk '$1 ~ /^\/dev\// {gsub("/dev/", "", $1); print $1}' \
23 /proc/mounts); do
24- if [ -e /sys/block/$1/$p ]; then
25- return 0
26- fi
27+ [ -e /sys/block/$1/$p ] && return 0
28 done
29 return 1
30 }
31
32+has_holders() {
33+ local i
34+ # check if device is used by any md devices
35+ for i in $1/holders/* $1/*/holders/*; do
36+ [ -e "$i" ] && return 0
37+ done
38+ return 1
39+}
40+
41+is_available_disk() {
42+ local dev=$1
43+ local b=$(echo $p | sed 's:/:!:g')
44+
45+ # check if its a "root" block device and not a partition
46+ [ -e /sys/block/$b ] || return 1
47+
48+ # check so it does not have mounted partitions
49+ has_mounted_part $dev && return 1
50+
51+ # check so its not part of an md setup
52+ has_holders /sys/block/$b && return 1
53+
54+ # check so its not an md device
55+ [ -e /sys/block/$b/md ] && return 1
56+
57+ return 0
58+}
59+
60 find_disks() {
61- local p= disks=
62+ local p=
63 for p in $(awk '$1 ~ /[0-9]+/ {print $4}' /proc/partitions); do
64- b=$(echo $p | sed 's:/:!:g')
65- if [ -e /sys/block/$b/device ] && ! has_mounted_part $p; then
66- disks="$disks $p"
67- fi
68+ is_available_disk $p && echo -n " $p"
69 done
70- echo $disks
71 }
72
73 useall() {
74--
751.6.4.4
76
diff --git a/main/alpine-conf/0001-setup-disk-use-uuid-in-fstab-and-extlinux.conf.patch b/main/alpine-conf/0001-setup-disk-use-uuid-in-fstab-and-extlinux.conf.patch
deleted file mode 100644
index 6e248ed91a..0000000000
--- a/main/alpine-conf/0001-setup-disk-use-uuid-in-fstab-and-extlinux.conf.patch
+++ /dev/null
@@ -1,74 +0,0 @@
1From 5531beb030b8e0a2f0da5ba5b8833bb01ba21c85 Mon Sep 17 00:00:00 2001
2From: Natanael Copa <ncopa@alpinelinux.org>
3Date: Thu, 17 Sep 2009 11:57:45 +0000
4Subject: [PATCH] setup-disk: use uuid in fstab and extlinux.conf
5
6This helps us avoid the issues when disk changes from sda to hda
7---
8 setup-disk.in | 31 ++++++++++++++++++++++++++++---
9 1 files changed, 28 insertions(+), 3 deletions(-)
10
11diff --git a/setup-disk.in b/setup-disk.in
12index a957b09..881c341 100644
13--- a/setup-disk.in
14+++ b/setup-disk.in
15@@ -15,12 +15,37 @@ in_list() {
16 return 1
17 }
18
19+# wrapper to only show given device
20+_blkid() {
21+ blkid | grep "^$1:"
22+}
23+
24+# if given device have an UUID display it, otherwise return the device
25+uuid_or_device() {
26+ local i=
27+ for i in $(_blkid "$1"); do
28+ case "$i" in
29+ UUID=*) eval $i;;
30+ esac
31+ done
32+ if [ -n "$UUID" ]; then
33+ echo "UUID=$UUID"
34+ else
35+ echo "$1"
36+ fi
37+}
38+
39+# generate an fstab from a given mountpoint. Convert to UUID if possible
40 enumerate_fstab() {
41 local mnt="$1"
42+ local fs_spec= fs_file= fs_vfstype= fs_mntops= fs_freq= fs_passno=
43 [ -z "$mnt" ] && return
44 local escaped_mnt=$(echo $mnt | sed 's:/:\\/:g')
45 awk "\$2 ~ /^$escaped_mnt/ {print \$0}" /proc/mounts | \
46- sed "s:$mnt:/:g; s: :\t:g" | sed 's:/\+:/:g'
47+ sed "s:$mnt:/:g; s: :\t:g" | sed 's:/\+:/:g' | \
48+ while read fs_spec fs_file fs_vfstype fs_mntops fs_freq fs_passno; do
49+ echo -e "$(uuid_or_device $fs_spec)\t${fs_file}\t${fs_vfstype}\t${fs_mntops} ${fs_freq} ${fs_passno}"
50+ done
51 }
52
53 is_vmware() {
54@@ -89,7 +114,7 @@ prompt 1
55 default grsec
56 label grsec
57 kernel /grsec
58- append initrd=/grsec.gz root=$rootdev modules=sd-mod,usb-storage,ext3$raidmod ${pax_nouderef}quiet
59+ append initrd=/grsec.gz root=$(uuid_or_device $rootdev) modules=sd-mod,usb-storage,ext3$raidmod ${pax_nouderef}quiet
60 EOF
61 # fix the fstab
62 enumerate_fstab "$mnt" >> "$mnt"/etc/fstab
63@@ -247,7 +272,7 @@ EOF
64 rc-update --quiet add swap boot
65 # the func to generate fstab does not detect swap. add it manually
66 sed -i -e '/swap/d' /etc/fstab
67- echo -e "$swap_dev\tswap\t\tswap\tdefaults 0 0" >> /etc/fstab
68+ echo -e "$(uuid_or_device $swap_dev)\tswap\t\tswap\tdefaults 0 0" >> /etc/fstab
69 install_mounted_root /mnt
70 }
71
72--
731.6.4.2
74
diff --git a/main/alpine-conf/APKBUILD b/main/alpine-conf/APKBUILD
index ce3c3be667..0ffcb1ff10 100644
--- a/main/alpine-conf/APKBUILD
+++ b/main/alpine-conf/APKBUILD
@@ -1,16 +1,18 @@
1# Maintainer: Natanael Copa <ncopa@alpinelinux.org> 1# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
2pkgname=alpine-conf 2pkgname=alpine-conf
3pkgver=2.0_rc6 3pkgver=2.0_rc6
4pkgrel=0 4pkgrel=1
5pkgdesc="Alpine configuration management scripts" 5pkgdesc="Alpine configuration management scripts"
6url=http://git.alpinelinux.org/cgit/$pkgname 6url=http://git.alpinelinux.org/cgit/$pkgname
7depends="openrc" 7depends="openrc"
8source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2 8source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2
9 0001-setup-disk-fix-find_disks.patch
9 " 10 "
10license="GPL-2" 11license="GPL-2"
11 12
12build() { 13build() {
13 cd "$srcdir/$pkgname-$pkgver" 14 cd "$srcdir/$pkgname-$pkgver"
15 patch -p1 -i ../0001-setup-disk-fix-find_disks.patch || return 1
14 16
15 make || return 1 17 make || return 1
16 make install PREFIX= DESTDIR="$pkgdir" 18 make install PREFIX= DESTDIR="$pkgdir"
@@ -18,4 +20,5 @@ build() {
18 ln -s lbu "$pkgdir"/sbin/lbu_$i 20 ln -s lbu "$pkgdir"/sbin/lbu_$i
19 done 21 done
20} 22}
21md5sums="52d08eaff7ad57581106418deed94d7d alpine-conf-2.0_rc6.tar.bz2" 23md5sums="52d08eaff7ad57581106418deed94d7d alpine-conf-2.0_rc6.tar.bz2
24cb6b8b50e4098174ce20245faeeb84ea 0001-setup-disk-fix-find_disks.patch"