Skip to content
This repository has been archived by the owner on May 17, 2020. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Build: Incorporate ShellCheck to DuetPkg (#1)
  • Loading branch information
dakanji committed May 9, 2020
1 parent 646c73b commit a701849
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 28 deletions.
2 changes: 2 additions & 0 deletions .shellcheckrc
@@ -0,0 +1,2 @@
# Ignore sourced files if any
disable=SC1091
7 changes: 7 additions & 0 deletions .travis.yml
Expand Up @@ -5,6 +5,13 @@ env:

matrix:
include:
- os: osx
name: "Check Shell Scripts"

script:
- HOMEBREW_NO_AUTO_UPDATE=1 brew install shellcheck
- find . \( -name "*.tool" -o -name "*.command" -o -name "*.sh" \) -exec shellcheck --severity=info {} \;

- os: osx
name: "Build macOS XCODE5"
osx_image: xcode10.2
Expand Down
47 changes: 25 additions & 22 deletions BootLoader/bin/QemuBuild.command
Expand Up @@ -4,9 +4,9 @@
# qemu-system-x86_64 -drive file=$QEMU_IMAGE/OpenCore.RO.raw -serial stdio \
# -usb -device usb-kbd -device usb-mouse -s -m 8192

cd "$(dirname "$0")"
cd "$(dirname "$0")" || exit 1

if [ "$(which qemu-img)" = "" ]; then
if [ "$(command v qemu-img)" = "" ]; then
echo "QEMU installation missing"
exit 1
fi
Expand All @@ -19,25 +19,25 @@ fi
rm -f OpenCore.dmg.sparseimage OpenCore.RO.raw OpenCore.RO.dmg
hdiutil create -size 200m -layout "UNIVERSAL HD" -type SPARSE -o OpenCore.dmg
newDevice=$(hdiutil attach -nomount OpenCore.dmg.sparseimage )
newDevice=$(echo $newDevice | awk '{print $1}')
echo $newDevice
newDevice=$(echo "${newDevice}" | awk '{print $1}')
echo "${newDevice}"

diskutil partitionDisk $newDevice 1 MBR fat32 TEST R
diskutil partitionDisk "${newDevice}" 1 MBR fat32 TEST R

# boot install script
diskutil list
N=$(echo $newDevice | tr -dc '0-9')
echo $N
N=$(echo "${newDevice}" | tr -dc '0-9')
echo "$N"


if [[ ! $(diskutil info disk${N} | sed -n 's/.*Device Node: *//p') ]]
if [[ ! $(diskutil info "disk${N}" | sed -n 's/.*Device Node: *//p') ]]
then
echo Disk $N not found
echo Disk "$N" not found
exit
fi

FS=$(diskutil info disk${N}s1 | sed -n 's/.*File System Personality: *//p')
echo $FS
FS=$(diskutil info "disk${N}s1" | sed -n 's/.*File System Personality: *//p')
echo "$FS"

if [ "$FS" != "MS-DOS FAT32" ]
then
Expand All @@ -46,22 +46,25 @@ then
fi

# Write MBR
sudo fdisk -f boot0 -u /dev/rdisk${N}
sudo fdisk -f boot0 -u "/dev/rdisk${N}"

diskutil umount disk${N}s1
sudo dd if=/dev/rdisk${N}s1 count=1 of=origbs
diskutil umount "disk${N}s1"
sudo dd if="/dev/rdisk${N}s1" count=1 of=origbs
cp -v boot1f32 newbs
sudo dd if=origbs of=newbs skip=3 seek=3 bs=1 count=87 conv=notrunc
dd if=/dev/random of=newbs skip=496 seek=496 bs=1 count=14 conv=notrunc
sudo dd if=newbs of=/dev/rdisk${N}s1
diskutil mount disk${N}s1
sudo dd if=newbs of="/dev/rdisk${N}s1"
diskutil mount "disk${N}s1"

cp -v boot "$(diskutil info disk${N}s1 | sed -n 's/.*Mount Point: *//p')"
cp -rv ROOT/* "$(diskutil info disk${N}s1 | sed -n 's/.*Mount Point: *//p')"
cp -v boot "$(diskutil info "disk${N}s1" | sed -n 's/.*Mount Point: *//p')"
cp -rv ROOT/* "$(diskutil info "disk${N}s1" | sed -n 's/.*Mount Point: *//p')"

if [ $(diskutil info disk${N} | sed -n 's/.*Content (IOContent): *//p') == "FDisk_partition_scheme" ]
## ShellCheck Exception(s)
## https://github.com/koalaman/shellcheck/wiki/SC2046
# shellcheck disable=SC2046
if [ $(diskutil info "disk${N}" | sed -n 's/.*Content (IOContent): *//p') == "FDisk_partition_scheme" ]
then
sudo fdisk -e /dev/rdisk$N <<-MAKEACTIVE
sudo fdisk -e "/dev/rdisk$N" <<-MAKEACTIVE
p
f 1
w
Expand All @@ -70,6 +73,6 @@ q
MAKEACTIVE
fi

hdiutil detach $newDevice
hdiutil convert -format UDRO OpenCore.dmg.sparseimage -o OpenCore.RO.dmg
hdiutil detach "${newDevice}"
hdiutil convert -format UDRO OpenCore.dmg.sparseimage -o OpenCore.RO.dmg
qemu-img convert -f dmg -O raw OpenCore.RO.dmg OpenCore.RO.raw
24 changes: 18 additions & 6 deletions macbuild.tool
Expand Up @@ -28,9 +28,13 @@ imgbuild() {
EL_SIZE=$(stat -f "%z" "${BUILD_DIR}/FV/Efildr${TARGETARCH}")
else
EL_SIZE=$(stat --printf="%s\n" "${BUILD_DIR}/FV/Efildr${TARGETARCH}")
fi
export PAGE_TABLE_OFF=$(printf "0x%x" $(((${EL_SIZE} + 0x2000 + 0xFFF) & ~0xFFF)))
export PAGE_TABLE=$(printf "0x%x" $((${PAGE_TABLE_OFF} + 0x20000)))
fi
PAGE_TABLE_OFF=$( printf "0x%x" $(( (EL_SIZE + 0x2000 + 0xFFF) & ~0xFFF )) )
PAGE_TABLE=$( printf "0x%x" $(( PAGE_TABLE_OFF + 0x20000 )) )

export PAGE_TABLE_OFF
export PAGE_TABLE

BOOTSECTOR_SUFFIX="_${PAGE_TABLE}"
else
BOOTSECTOR_SUFFIX=""
Expand Down Expand Up @@ -63,7 +67,7 @@ package() {
echo "Missing package directory $1"
exit 1
fi

if [ ! -d "$1"/../FV ]; then
echo "Missing FV directory $1/../FV"
exit 1
Expand All @@ -79,7 +83,7 @@ package() {
imgbuild
}

cd $(dirname "$0")
cd "$(dirname "$0")" || exit 1

BOOTSECTORS="$(pwd)/BootSector/bin"
FV_TOOLS="$(pwd)/BaseTools/bin.$(uname)"
Expand All @@ -102,7 +106,7 @@ if [ "${INTREE}" != "" ]; then
cd .. || exit 1

build -a "${TARGETARCH}" -b "${TARGET}" -t XCODE5 -p DuetPkg/DuetPkg.dsc || exit 1

BUILD_DIR="${WORKSPACE}/Build/DuetPkg/${TARGET}_XCODE5"
BUILD_DIR_ARCH="${BUILD_DIR}/${TARGETARCH}"
imgbuild
Expand All @@ -113,5 +117,13 @@ else
DEPNAMES=('EfiPkg')
DEPURLS=('https://github.com/acidanthera/EfiPkg')
DEPBRANCHES=('master')

export TARGETS
export ARCHS
export SELFPKG
export DEPNAMES
export DEPURLS
export DEPBRANCHES

src=$(/usr/bin/curl -Lfs https://raw.githubusercontent.com/acidanthera/ocbuild/master/efibuild.sh) && eval "$src" || exit 1
fi

0 comments on commit a701849

Please sign in to comment.