Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: common.sh

Issue 3997001: common.sh: switch out echo -ne for printf and fix incorrect offset (Closed) Base URL: http://git.chromium.org/git/crosutils.git
Patch Set: ugh and fix a last minute bug! Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 # Common constants for build scripts 5 # Common constants for build scripts
6 # This must evaluate properly for both /bin/bash and /bin/sh 6 # This must evaluate properly for both /bin/bash and /bin/sh
7 7
8 # All scripts should die on error unless commands are specifically excepted 8 # All scripts should die on error unless commands are specifically excepted
9 # by prefixing with '!' or surrounded by 'set +e' / 'set -e'. 9 # by prefixing with '!' or surrounded by 'set +e' / 'set -e'.
10 # TODO: Re-enable this once shflags is less prone to dying. 10 # TODO: Re-enable this once shflags is less prone to dying.
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 # [1] 32-bit flag we are modifying: 468 # [1] 32-bit flag we are modifying:
469 # http://git.chromium.org/cgi-bin/gitweb.cgi?p=kernel.git;a=blob;f=include/linu x/ext2_fs.h#l417 469 # http://git.chromium.org/cgi-bin/gitweb.cgi?p=kernel.git;a=blob;f=include/linu x/ext2_fs.h#l417
470 # [2] Mount behavior is enforced here: 470 # [2] Mount behavior is enforced here:
471 # http://git.chromium.org/cgi-bin/gitweb.cgi?p=kernel.git;a=blob;f=fs/ext2/supe r.c#l857 471 # http://git.chromium.org/cgi-bin/gitweb.cgi?p=kernel.git;a=blob;f=fs/ext2/supe r.c#l857
472 # 472 #
473 # N.B., if the high order feature bits are used in the future, we will need to 473 # N.B., if the high order feature bits are used in the future, we will need to
474 # revisit this technique. 474 # revisit this technique.
475 disable_rw_mount() { 475 disable_rw_mount() {
476 local rootfs="$1" 476 local rootfs="$1"
477 local offset="${2-0}" # in bytes 477 local offset="${2-0}" # in bytes
478 local ro_compat_offset=$((0x467 + 3)) # Set 'highest' byte 478 local ro_compat_offset=$((0x464 + 3)) # Set 'highest' byte
479 echo -ne '\xff' | 479 printf '\377' |
480 sudo dd of="$rootfs" seek=$((offset + ro_compat_offset)) \ 480 sudo dd of="$rootfs" seek=$((offset + ro_compat_offset)) \
481 conv=notrunc count=1 bs=1 481 conv=notrunc count=1 bs=1
482 } 482 }
483 483
484 enable_rw_mount() { 484 enable_rw_mount() {
485 local rootfs="$1" 485 local rootfs="$1"
486 local offset="${2-0}" 486 local offset="${2-0}"
487 local ro_compat_offset=$((0x467 + 3)) # Set 'highest' byte 487 local ro_compat_offset=$((0x464 + 3)) # Set 'highest' byte
488 echo -ne '\x00' | 488 printf '\000' |
489 sudo dd of="$rootfs" seek=$((offset + ro_compat_offset)) \ 489 sudo dd of="$rootfs" seek=$((offset + ro_compat_offset)) \
490 conv=notrunc count=1 bs=1 490 conv=notrunc count=1 bs=1
491 } 491 }
492 492
493 # Get current timestamp. Assumes common.sh runs at startup. 493 # Get current timestamp. Assumes common.sh runs at startup.
494 start_time=$(date +%s) 494 start_time=$(date +%s)
495 495
496 # Print time elsapsed since start_time. 496 # Print time elsapsed since start_time.
497 print_time_elapsed() { 497 print_time_elapsed() {
498 end_time=$(date +%s) 498 end_time=$(date +%s)
(...skipping 15 matching lines...) Expand all
514 chroot_hacks_from_outside() { 514 chroot_hacks_from_outside() {
515 # Give args better names. 515 # Give args better names.
516 local chroot_dir="${1}" 516 local chroot_dir="${1}"
517 517
518 # Add root as a sudoer if not already done. 518 # Add root as a sudoer if not already done.
519 if ! sudo grep -q '^root ALL=(ALL) ALL$' "${chroot_dir}/etc/sudoers" ; then 519 if ! sudo grep -q '^root ALL=(ALL) ALL$' "${chroot_dir}/etc/sudoers" ; then
520 info "Upgrading old chroot (pre 2010-10-19) - adding root to sudoers" 520 info "Upgrading old chroot (pre 2010-10-19) - adding root to sudoers"
521 sudo bash -c "echo root ALL=\(ALL\) ALL >> \"${chroot_dir}/etc/sudoers\"" 521 sudo bash -c "echo root ALL=\(ALL\) ALL >> \"${chroot_dir}/etc/sudoers\""
522 fi 522 fi
523 } 523 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698