~ubuntu-branches/debian/sid/flash-kernel/sid

« back to all changes in this revision

Viewing changes to functions

  • Committer: Package Import Robot
  • Author(s): Ian Campbell
  • Date: 2015-05-08 19:24:06 UTC
  • Revision ID: package-import@ubuntu.com-20150508192406-br4xlm4eaf3eofo0
Tags: 3.37
* Upload changes from 3.30~exp.1..3.36~exp.1 to unstable.
* Improvements to support for PlatHome OpenBlocks AX3-4 board
  (Closes: #783323):
  - Allow armmp-lpae kernel flavour.
  - Remove Boot-Device option since this platform can boot from /boot.
* Handle Boot-Kernel-Image even if none of Dtb-Append, Machine-Id or
  U-Boot-Kernel-Address are specified. Patch from David Lechner.
  (Closes: #783278)
* Log some debug if either the kernel or the initrd is missing. Intended to
  help debug one aspect of #781742.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,
20
20
# USA.
21
21
 
22
 
BOOTSCRIPTS_DIR="${FK_CHECKOUT:-$FK_DIR}/bootscript"
 
22
BOOTSCRIPTS_DIR="${FK_CHECKOUT:-/etc/flash-kernel}/bootscript"
23
23
FK_ETC_MACHINE="${FK_ETC_MACHINE:-/etc/flash-kernel/machine}"
24
24
PROC_CPUINFO="${FK_PROC_CPUINFO:-/proc/cpuinfo}"
25
25
PROC_DTMODEL="${FK_PROC_DRMODEL:-/proc/device-tree/model}"
190
190
        }
191
191
}
192
192
 
 
193
get_dtb_name() {
 
194
        local field="$(get_machine_field "$machine" "DTB-Id")" || :
 
195
        case "$field" in
 
196
        !*)
 
197
                local dir
 
198
                local dtb_script
 
199
                dtb_script_name=${field#!}
 
200
                for dir in /etc/flash-kernel/dtb-probe \
 
201
                           /usr/share/flash-kernel/dtb-probe ; do
 
202
                        if [ -e "$dir/$dtb_script_name" ]; then
 
203
                                dtb_script="$dir/$dtb_script_name"
 
204
                                break
 
205
                        fi
 
206
                done
 
207
 
 
208
                if [ "x$dtb_script" = "x" ]; then
 
209
                        error "dtb-probe $dtb_script_name not found"
 
210
                fi
 
211
 
 
212
                dtb_name=$($dtb_script)
 
213
                if [ $? -ne 0 ] || [ "x$dtb_name" = "x" ]; then
 
214
                        error "dtb-probe $dtb_script failed"
 
215
                fi
 
216
                ;;
 
217
        *)
 
218
                dtb_name="$field"
 
219
                ;;
 
220
        esac
 
221
        if [ -n "$dtb_name" ] ; then
 
222
                echo "DTB: $dtb_name" >&2
 
223
        fi
 
224
}
 
225
 
193
226
machine_uses_flash() {
194
227
        local machine="$1"
195
228
 
251
284
        local dtb="$2"
252
285
        local output="$3"
253
286
 
 
287
        echo "flash-kernel: appending $dtb to kernel" >&2
 
288
 
254
289
        {
255
290
                cat "$kernel"
256
291
                cat "$dtb"
269
304
                        kreqsize=$(($kreqsize + 8))
270
305
                fi
271
306
                check_mtd_size "$mtd_kernel" $kreqsize $kmtdsize kernel
272
 
                use=" ($kreqsize/$kmtdsize bytes)"
 
307
                use=" (using $kreqsize/$kmtdsize bytes)"
273
308
        fi
274
309
 
275
310
        printf "Flashing kernel$use... " >&2
284
319
        local use
285
320
 
286
321
        if [ -n "$imtdsize" ]; then
287
 
                use=" ($ireqsize/$imtdsize bytes)"
 
322
                use=" (using $ireqsize/$imtdsize bytes)"
288
323
        fi
289
324
 
290
325
        printf "Flashing initramfs$use... " >&2
412
447
        echo "done." >&2
413
448
}
414
449
 
 
450
find_dtb_file() {
 
451
        case "$dtb_name" in
 
452
        /*)
 
453
                echo "$dtb_name"
 
454
                ;;
 
455
        *)
 
456
                if [ -e "/etc/flash-kernel/dtbs/$dtb_name" ] ; then
 
457
                        echo "/etc/flash-kernel/dtbs/$dtb_name"
 
458
                else
 
459
                        echo "/usr/lib/linux-image-$kvers/$dtb_name"
 
460
                fi
 
461
                ;;
 
462
        esac
 
463
}
 
464
 
415
465
handle_dtb() {
416
 
        local dtb_id="$(get_machine_field "$machine" "DTB-Id")" || :
417
 
        if [ "x$dtb_id" = "x" ]; then
 
466
        if [ "x$dtb_name" = "x" ]; then
418
467
                return
419
468
        fi
420
469
 
421
 
        local dtb="/usr/lib/linux-image-$kvers/$dtb_id"
 
470
        local dtb=$(find_dtb_file)
422
471
        if [ "x$FK_KERNEL_HOOK_SCRIPT" = "xpostrm.d" ] ; then
423
472
                rm -f "/boot/dtb-$kvers"
424
473
        else
425
474
                if [ -e $dtb ]; then
426
 
                        echo "Installing $dtb_id into /boot/dtb-$kvers" >&2
 
475
                        echo "Installing $dtb_name into /boot/dtb-$kvers" >&2
427
476
                        cp "$dtb" "/boot/dtb-$kvers.new"
428
477
                        backup_and_install "/boot/dtb-$kvers.new" "/boot/dtb-$kvers"
429
478
                        ln -nfs "dtb-$kvers" "/boot/dtb"
430
 
                else
431
 
                        echo "$dtb not found" >&2
432
479
                fi
433
480
        fi
434
481
}
461
508
 
462
509
kvers="$1"
463
510
 
 
511
get_dtb_name
 
512
 
464
513
# Install/remove any DTB from postinst, regardless of version
465
514
if [ -n "$kvers" ] ; then
466
515
        handle_dtb
520
569
idesc="ramdisk $kvers"
521
570
 
522
571
if [ ! -e $kfile ] || [ ! -e $ifile ]; then
523
 
        error "Can't find $kfile or $ifile"
 
572
        # installation-report #781742 included:
 
573
        #     Can't find /boot/vmlinuz-[...] or /boot/initrd.img-[...]
 
574
        #
 
575
        # It's unclear how this can have happened or what state the
 
576
        # system was in, so log some additional information in the
 
577
        # hopes of catching it in the act next time.
 
578
        (
 
579
                set -x
 
580
                ls -l $kfile*
 
581
                ls -l $ifile*
 
582
        ) >> /tmp/flash-kernel-no-kernel-error.log
 
583
        error "Can't find $kfile or $ifile (see /tmp/flash-kernel-no-kernel-error.log)"
524
584
fi
525
585
kfilesize=$(stat -c '%s' "$kfile")
526
586
ifilesize=$(stat -c '%s' "$ifile")
555
615
method="$(get_machine_field "$machine" "Method")" || method="generic"
556
616
mtd_kernel="$(get_machine_field "$machine" "Mtd-Kernel")" || :
557
617
mtd_initrd="$(get_machine_field "$machine" "Mtd-Initrd")" || :
558
 
dtb_name="$(get_machine_field "$machine" "DTB-Id")" || :
559
618
dtb_append="$(get_machine_field "$machine" "DTB-Append")" || :
560
619
dtb_append_from="$(get_machine_field "$machine" "DTB-Append-From")" || :
561
620
ukaddr="$(get_machine_field "$machine" "U-Boot-Kernel-Address")" || :
647
706
                kernel="$kfile"
648
707
                initrd="$ifile"
649
708
                if [ "$dtb_append" = "yes" ]; then
650
 
                        dtb="/usr/lib/linux-image-$kvers/$dtb_name"
 
709
                        dtb=$(find_dtb_file)
651
710
                        if [ ! -f "$dtb" ]; then
652
711
                                error "Couldn't find $dtb"
653
712
                        fi
684
743
                if [ -n "$boot_kernel_path" ]; then
685
744
                        boot_kernel_path="$boot_mnt_dir/$boot_kernel_path"
686
745
                        # don't mv the original kernel
687
 
                        if [ "$kernel" != "$kfile" ]; then
688
 
                                backup_and_install "$kernel" \
689
 
                                        "$boot_kernel_path"
690
 
                        else
691
 
                                # TODO add support for kernel symlink
692
 
                                :
 
746
                        if [ "$kernel" = "$kfile" ]; then
 
747
                                cp "$kernel" "$tmpdir/kernel"
 
748
                                kernel="$tmpdir/kernel"
693
749
                        fi
 
750
                        backup_and_install "$kernel" "$boot_kernel_path"
694
751
                elif [ -n "$kmtd" ]; then
695
752
                        flash_kernel "$tmpdir/uImage" "$kmtd" ""
696
753
                        rm -f "$tmpdir/uImage"
706
763
                if [ -n "$boot_initrd_path" ]; then
707
764
                        boot_initrd_path="$boot_mnt_dir/$boot_initrd_path"
708
765
                        # don't mv the original initrd
709
 
                        if [ "$initrd" != "$ifile" ]; then
710
 
                                backup_and_install "$initrd" \
711
 
                                        "$boot_initrd_path"
712
 
                        else
713
 
                                # TODO add support for initrd symlink
714
 
                                :
 
766
                        if [ "$initrd" = "$ifile" ]; then
 
767
                                cp "$initrd" "$tmpdir/initrd"
 
768
                                initrd="$tmpdir/initrd"
715
769
                        fi
 
770
                        backup_and_install "$initrd" "$boot_initrd_path"
716
771
                elif [ -n "$imtd" ]; then
717
772
                        ipad=0
718
773
                        # padding isn't needed for U-Boot images
732
787
                fi
733
788
                if [ -n "$boot_dtb_path" ]; then
734
789
                        boot_dtb_path="$boot_mnt_dir/$boot_dtb_path"
735
 
                        boot_dtb="/usr/lib/linux-image-$kvers/$dtb_name"
 
790
                        boot_dtb=$(find_dtb_file)
736
791
                        if [ ! -f "$boot_dtb" ]; then
737
792
                                error "Couldn't find $boot_dtb"
738
793
                        fi