updated on Thu Jan 12 04:00:44 UTC 2012
[aur-mirror.git] / convertfs / convertfs-quote-variables.patch
blobe33b5dfca8bc55366ad7bb99ede47bdc798c49d6
1 --- contrib/convertfs.old 2005-01-13 14:27:35.000000000 +0200
2 +++ contrib/convertfs 2009-09-03 19:33:35.065808508 +0300
3 @@ -39,8 +39,8 @@
5 minix_convert() {
6 if [ "$1" = "minix" ]; then
7 - hd_dev=`echo $2 | cut -b 1-8`
8 - blocks=`fdisk -l $hd_dev | grep $2 | tr -d + | tr -s " " | cut -d ' ' -f 4`
9 + hd_dev=`echo "$2" | cut -b 1-8`
10 + blocks=`fdisk -l "$hd_dev" | grep "$2" | tr -d + | tr -s " " | cut -d ' ' -f 4`
11 if [ "$blocks" -gt "2048287" ]; then
12 echo "The \`minix' partition on \`$2' is more than 2GB."
13 echo "It's probably to big to convert."
14 @@ -76,7 +76,7 @@
15 exit 1
18 -if ! type $3 1>/dev/null 2>/dev/null; then
19 +if ! type "$3" 1>/dev/null 2>/dev/null; then
20 echo "Can't find \`$3' on the system."
21 exit 1
23 @@ -103,36 +103,36 @@
25 mk_fs() {
26 if [ "$1" = "ext2" ]; then
27 - mke2fs $2
28 + mke2fs "$2"
29 elif [ "$1" = "ext3" ]; then
30 - mke2fs -j $2
31 + mke2fs -j "$2"
32 elif [ "$1" = "reiserfs" ]; then
33 - echo -e "y\ny" | mkreiserfs $reiserfs_version $2
34 + echo -e "y\ny" | mkreiserfs $reiserfs_version "$2"
35 elif [ "$1" = "jfs" ]; then
36 - mkfs.jfs -f $2
37 + mkfs.jfs -f "$2"
38 elif [ "$1" = "xfs" ]; then
39 - mkfs.xfs -f $2
40 + mkfs.xfs -f "$2"
41 elif [ "$1" = "minix" ]; then
42 - hd_dev=`echo $dev | cut -b 1-8`
43 - blocks=`fdisk -l $hd_dev | grep $dev | tr -d + | tr -s " " | cut -d ' ' -f 4`
44 - mkfs.minix -v $2 $blocks
45 + hd_dev=`echo "$dev" | cut -b 1-8`
46 + blocks=`fdisk -l "$hd_dev" | grep "$dev" | tr -d + | tr -s " " | cut -d ' ' -f 4`
47 + mkfs.minix -v "$2" "$blocks"
51 error() {
52 - umount $loopdev 2>/dev/null
53 - losetup -d $loopdev 2>/dev/null
54 - umount $dev 2>/dev/null
55 - rm -rf $tmp
56 + umount "$loopdev" 2>/dev/null
57 + losetup -d "$loopdev" 2>/dev/null
58 + umount "$dev" 2>/dev/null
59 + rm -rf "$tmp"
60 exit 1
63 # device to convert
64 -dev=$1
65 +dev="$1"
66 # filesystem to convert from
67 -from_fs_type=$2
68 +from_fs_type="$2"
69 # filesystem to convert to
70 -to_fs_type=$3
71 +to_fs_type="$3"
73 if [ "$dev" = "" ]; then
74 usage
75 @@ -144,24 +144,24 @@
76 if [ "$from_fs_type" = "" -o "$to_fs_type" = "" ]; then
77 usage
78 else
79 - ext2_convert $from_fs_type $to_fs_type $dev
80 - minix_convert $from_fs_type $dev
81 - fs_types $from_fs_type
82 - fs_types $to_fs_type
83 + ext2_convert "$from_fs_type" "$to_fs_type" "$dev"
84 + minix_convert "$from_fs_type" "$dev"
85 + fs_types "$from_fs_type"
86 + fs_types "$to_fs_type"
89 if [ "$to_fs_type" = "ext2" ]; then
90 - find_mkfs $from_fs_type $to_fs_type mke2fs
91 + find_mkfs "$from_fs_type" "$to_fs_type" mke2fs
92 elif [ "$to_fs_type" = "ext3" ]; then
93 - find_mkfs $from_fs_type $to_fs_type mke2fs
94 + find_mkfs "$from_fs_type" "$to_fs_type" mke2fs
95 elif [ "$to_fs_type" = "reiserfs" ]; then
96 - find_mkfs $from_fs_type $to_fs_type mkreiserfs
97 + find_mkfs "$from_fs_type" "$to_fs_type" mkreiserfs
98 elif [ "$to_fs_type" = "jfs" ]; then
99 - find_mkfs $from_fs_type $to_fs_type mkfs.jfs
100 + find_mkfs "$from_fs_type" "$to_fs_type" mkfs.jfs
101 elif [ "$to_fs_type" = "xfs" ]; then
102 - find_mkfs $from_fs_type $to_fs_type mkfs.xfs
103 + find_mkfs "$from_fs_type" "$to_fs_type" mkfs.xfs
104 elif [ "$to_fs_type" = "minix" ]; then
105 - find_mkfs $from_fs_type $to_fs_type mkfs.minix
106 + find_mkfs "$from_fs_type" "$to_fs_type" mkfs.minix
109 if ! grep -q "loop" /proc/devices; then
110 @@ -177,33 +177,33 @@
111 loopdev=/dev/loop7
113 tmp=/tmp/convertfs
114 -fs1root=$tmp/fs1root
115 -fs2root=$tmp/fs2root
116 +fs1root="$tmp/fs1root"
117 +fs2root="$tmp/fs2root"
119 fsimage_name=fsimage
120 fsindex_name=fsindex
121 fssuper_name=fssuper
122 -fsimage=$fs1root/$fsimage_name
123 -fsindex=$fs1root/$fsindex_name
124 -fssuper=$tmp/$fssuper_name
125 +fsimage="$fs1root/$fsimage_name"
126 +fsindex="$fs1root/$fsindex_name"
127 +fssuper="$tmp/$fssuper_name"
129 -mkdir -p $fs1root || exit
130 -mkdir -p $fs2root || exit
131 +mkdir -p "$fs1root" || exit
132 +mkdir -p "$fs2root" || exit
134 echo "== Creating clone of \`$from_fs_type' filesystem that's on \`$dev'. =="
135 -umount $dev 2>/dev/null
136 -mount -t $from_fs_type $dev $fs1root || error
137 -./devclone $dev $fsimage || error
138 +umount "$dev" 2>/dev/null
139 +mount -t "$from_fs_type" "$dev" "$fs1root" || error
140 +devclone "$dev" "$fsimage" || error
142 echo "===== Creating destination \`$to_fs_type' filesystem. ====="
143 -umount $loopdev 2>/dev/null
144 -losetup -d $loopdev 2>/dev/null
145 -losetup $loopdev $fsimage || error
146 -mk_fs $to_fs_type $loopdev || error
147 +umount "$loopdev" 2>/dev/null
148 +losetup -d "$loopdev" 2>/dev/null
149 +losetup "$loopdev" "$fsimage" || error
150 +mk_fs "$to_fs_type" "$loopdev" || error
152 echo "============== Copying files =============="
153 -mount -t $to_fs_type $loopdev $fs2root || error
154 -ls -1A $fs1root | while read file; do
155 +mount -t "$to_fs_type" "$loopdev" "$fs2root" || error
156 +ls -1A "$fs1root" | while read file; do
157 if [ "x$file" != "x$fsimage_name" ] &&
158 [ "x$file" != "x$fsindex_name" ] &&
159 [ "x$file" != "xlost+found" ] &&
160 @@ -211,22 +211,22 @@
161 mv -f "$fs1root/$file" "$fs2root/" || error
163 done
164 -ls -lA $fs2root
165 -df -h $fs2root
166 -umount $loopdev || error
167 -losetup -d $loopdev 2>/dev/null
168 +ls -lA "$fs2root"
169 +df -h "$fs2root"
170 +umount "$loopdev" || error
171 +losetup -d "$loopdev" 2>/dev/null
173 echo "=== Preparing info for block relocation ==="
174 -./prepindex $fsimage $fsindex $fssuper || error
175 -umount $dev || error
176 -dd if=$fssuper of=$dev || exit
177 +prepindex "$fsimage" "$fsindex" "$fssuper" || error
178 +umount "$dev" || error
179 +dd if="$fssuper" of="$dev" || exit
180 sync
182 echo "============ Relocating blocks ============"
183 -./devremap $dev || exit
184 +devremap "$dev" || exit
186 echo "=== Filesystem conversion accomplished! ==="
187 -rm -rf $tmp
188 +rm -rf "$tmp"
189 echo "NOTE: If you want to boot the new filesystem on \`$dev' you"
190 echo " should edit \`/etc/fstab' and add something like this."
191 echo " $dev / $to_fs_type defaults 1 1"