aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2010-12-03 09:31:07 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2010-12-03 09:32:55 +0000
commitd98fee839dff01a68747a69df124660ff774a2f6 (patch)
tree380bda00b842f61cd42166522281d92d450b9024
parent7016b23025fc387306f35a04391fe2bcd8eebcc2 (diff)
downloadalpine_aports-d98fee839dff01a68747a69df124660ff774a2f6.tar.bz2
alpine_aports-d98fee839dff01a68747a69df124660ff774a2f6.tar.xz
alpine_aports-d98fee839dff01a68747a69df124660ff774a2f6.zip
main/alpine-conf: add support for read-only lbu media
ref #477
-rw-r--r--main/alpine-conf/0001-lbu-remount-LBU_MEDIA-as-read-write-if-it-was-read-o.patch87
-rw-r--r--main/alpine-conf/APKBUILD9
2 files changed, 93 insertions, 3 deletions
diff --git a/main/alpine-conf/0001-lbu-remount-LBU_MEDIA-as-read-write-if-it-was-read-o.patch b/main/alpine-conf/0001-lbu-remount-LBU_MEDIA-as-read-write-if-it-was-read-o.patch
new file mode 100644
index 0000000000..ad8dd2e5c1
--- /dev/null
+++ b/main/alpine-conf/0001-lbu-remount-LBU_MEDIA-as-read-write-if-it-was-read-o.patch
@@ -0,0 +1,87 @@
1From 4e7ab7455206ec157a72d07c40c07f1a299529f1 Mon Sep 17 00:00:00 2001
2From: Natanael Copa <ncopa@alpinelinux.org>
3Date: Fri, 3 Dec 2010 08:49:43 +0000
4Subject: [PATCH] lbu: remount LBU_MEDIA as read-write if it was read-only
5
6ref #477
7---
8 lbu.in | 34 +++++++++++++++++++++++++++++-----
9 1 files changed, 29 insertions(+), 5 deletions(-)
10
11diff --git a/lbu.in b/lbu.in
12index dfd7e3c..a0dfe16 100644
13--- a/lbu.in
14+++ b/lbu.in
15@@ -1,7 +1,7 @@
16 #!/bin/sh
17
18 # lbu - utility to create local backups.
19-# Copyright (c) 2006 Natanael Copa
20+# Copyright (c) 2006-2010 Natanael Copa <ncopa@alpinelinux.org>
21 # May be distributed under GPL2
22
23 VERSION=@VERSION@
24@@ -54,6 +54,9 @@ Common options:
25
26 cleanup() {
27 local i
28+ for i in $REMOUNT_RO_LIST; do
29+ mount -o remount,ro $i
30+ done
31 for i in $UMOUNT_LIST; do
32 umount $i
33 done
34@@ -64,9 +67,30 @@ exit_clean() {
35 exit 1
36 }
37
38+# check if given dir is not a mounted mountpoint
39+is_unmounted() {
40+ awk "\$2 == \"$1\" {exit 1}" /proc/mounts
41+}
42+
43 mount_once() {
44- if awk "\$2 == \"$1\" {exit 1}" /proc/mounts; then
45- mount $1 && UMOUNT_LIST="$1 $UMOUNT_LIST"
46+ if is_unmounted "$1"; then
47+ mount $1 && UMOUNT_LIST="$1 $UMOUNT_LIST" || return 1
48+ fi
49+}
50+
51+# check if given dir is read-only
52+is_ro() {
53+ local tmpfile=$(mktemp -p "$1")
54+ [ -z "$tmpfile" ] && return 0
55+ rm -f "$tmpfile"
56+ return 1
57+}
58+
59+mount_once_rw() {
60+ mount_once "$1" || return 1
61+ if is_ro "$1"; then
62+ REMOUNT_RO_LIST="$1 $REMOUNT_RO_LIST"
63+ mount -o remount,rw "$1"
64 fi
65 }
66
67@@ -385,7 +409,7 @@ cmd_commit() {
68 # mount media unles its already mounted
69 mnt=/media/$media
70 [ -d "$mnt" ] || usage
71- mount_once "$mnt" || die "failed to mount $mnt"
72+ mount_once_rw "$mnt" || die "failed to mount $mnt"
73
74 # find the outfile
75 outfile="$mnt/$(hostname).apkovl.tar.gz"
76@@ -538,7 +562,7 @@ cmd_revert() {
77 if [ -n "$ENCRYPTION" ]; then
78 current="$current.$ENCRYPTION"
79 fi
80- mount_once "$mnt" || die "failed to mount $mnt"
81+ mount_once_rw "$mnt" || die "failed to mount $mnt"
82 [ -f "$revertto" ] || die "file not found: $revertto"
83 backup_apkovl "$current"
84 vecho "Reverting to $1"
85--
861.7.3.2
87
diff --git a/main/alpine-conf/APKBUILD b/main/alpine-conf/APKBUILD
index a32c86e434..39056e72e2 100644
--- a/main/alpine-conf/APKBUILD
+++ b/main/alpine-conf/APKBUILD
@@ -1,11 +1,13 @@
1# Maintainer: Natanael Copa <ncopa@alpinelinux.org> 1# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
2pkgname=alpine-conf 2pkgname=alpine-conf
3pkgver=2.5.4 3pkgver=2.5.4
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-lbu-remount-LBU_MEDIA-as-read-write-if-it-was-read-o.patch
10 "
9license="GPL-2" 11license="GPL-2"
10 12
11_builddir="$srcdir"/$pkgname-$pkgver 13_builddir="$srcdir"/$pkgname-$pkgver
@@ -33,4 +35,5 @@ package() {
33 ln -s lbu "$pkgdir"/sbin/lbu_$i 35 ln -s lbu "$pkgdir"/sbin/lbu_$i
34 done 36 done
35} 37}
36md5sums="91a2b8a150917cc06f6c9ec839b70bb0 alpine-conf-2.5.4.tar.bz2" 38md5sums="91a2b8a150917cc06f6c9ec839b70bb0 alpine-conf-2.5.4.tar.bz2
399245a4bc53b24584d43b3a3f1556c500 0001-lbu-remount-LBU_MEDIA-as-read-write-if-it-was-read-o.patch"