Skip to content

Commit

Permalink
Merge branch 'master' into drive_scan
Browse files Browse the repository at this point in the history
  • Loading branch information
cristim committed Jun 20, 2017
2 parents 5d99fae + 120f498 commit 5897bc3
Show file tree
Hide file tree
Showing 25 changed files with 300 additions and 82 deletions.
2 changes: 1 addition & 1 deletion Common/sedutil.cpp
Expand Up @@ -38,7 +38,7 @@ int diskScan()
printf("\nScanning for Opal compliant disks\n");
while (TRUE) {
DEVICEMASK;
//snprintf(devname,23,"/dev/sd%c",(char) 0x61+i) Linux
//snprintf(devname,23,"/dev/sd%c",'a'+i) Linux
//sprintf_s(devname, 23, "\\\\.\\PhysicalDrive%i", i) Windows
d = new DtaDevGeneric(devname);
if (d->isPresent()) {
Expand Down
2 changes: 1 addition & 1 deletion LinuxPBA/UnlockSEDs.cpp
Expand Up @@ -37,7 +37,7 @@ uint8_t UnlockSEDs(char * password) {
while (TRUE) {
switch(DtaDevOS::getNextDevice(i)){
case 1 : snprintf(devref,23,"/dev/%s",DtaDevOS::getDeviceName()); break;
case -1 : snprintf(devref,23,"/dev/sd%c",(char) 0xa+i); break;
case -1 : snprintf(devref,23,"/dev/sd%c",'a'+i); break;
default : snprintf(devref,23,"/dev/sdX"); break;
}
i += 1;
Expand Down
16 changes: 8 additions & 8 deletions LinuxPBA/nbproject/Makefile-Debug.mk
Expand Up @@ -11,14 +11,14 @@
MKDIR=mkdir
CP=cp
GREP=grep
NM=nm
NM=i686-linux-nm
CCADMIN=CCadmin
RANLIB=ranlib
CC=gcc
CCC=g++
CXX=g++
FC=gfortran
AS=as
RANLIB=i686-linux-ranlib
CC=i686-linux-gcc
CCC=i686-linux-g++
CXX=i686-linux-g++
FC=i686-linux-gfortran
AS=i686-linux-as

# Macros
CND_PLATFORM=GNU-Linux
Expand Down Expand Up @@ -72,7 +72,7 @@ FFLAGS=
ASFLAGS=

# Link Libraries and Options
LDLIBSOPTIONS=-lcurses
LDLIBSOPTIONS=-lcurses -ltinfo

# Build Targets
.build-conf: ${BUILD_SUBPROJECTS}
Expand Down
16 changes: 8 additions & 8 deletions LinuxPBA/nbproject/Makefile-Debug_x86_64.mk
Expand Up @@ -11,14 +11,14 @@
MKDIR=mkdir
CP=cp
GREP=grep
NM=nm
NM=x86_64-linux-nm
CCADMIN=CCadmin
RANLIB=ranlib
CC=gcc
CCC=g++
CXX=g++
FC=gfortran
AS=as
RANLIB=x86_64-linux-ranlib
CC=x86_64-linux-gcc
CCC=x86_64-linux-g++
CXX=x86_64-linux-g++
FC=x86_64-linux-gfortran
AS=x86_64-linux-as

# Macros
CND_PLATFORM=GNU-Linux
Expand Down Expand Up @@ -72,7 +72,7 @@ FFLAGS=
ASFLAGS=

# Link Libraries and Options
LDLIBSOPTIONS=-lcurses
LDLIBSOPTIONS=-lcurses -ltinfo

# Build Targets
.build-conf: ${BUILD_SUBPROJECTS}
Expand Down
16 changes: 8 additions & 8 deletions LinuxPBA/nbproject/Makefile-Release.mk
Expand Up @@ -11,14 +11,14 @@
MKDIR=mkdir
CP=cp
GREP=grep
NM=nm
NM=i686-linux-nm
CCADMIN=CCadmin
RANLIB=ranlib
CC=gcc
CCC=g++
CXX=g++
FC=gfortran
AS=as
RANLIB=i686-linux-ranlib
CC=i686-linux-gcc
CCC=i686-linux-g++
CXX=i686-linux-g++
FC=i686-linux-gfortran
AS=i686-linux-as

# Macros
CND_PLATFORM=GNU-Linux
Expand Down Expand Up @@ -72,7 +72,7 @@ FFLAGS=
ASFLAGS=

# Link Libraries and Options
LDLIBSOPTIONS=-lcurses
LDLIBSOPTIONS=-lcurses -ltinfo

# Build Targets
.build-conf: ${BUILD_SUBPROJECTS}
Expand Down
16 changes: 8 additions & 8 deletions LinuxPBA/nbproject/Makefile-Release_x86_64.mk
Expand Up @@ -11,14 +11,14 @@
MKDIR=mkdir
CP=cp
GREP=grep
NM=nm
NM=x86_64-linux-nm
CCADMIN=CCadmin
RANLIB=ranlib
CC=gcc
CCC=g++
CXX=g++
FC=gfortran
AS=as
RANLIB=x86_64-linux-ranlib
CC=x86_64-linux-gcc
CCC=x86_64-linux-g++
CXX=x86_64-linux-g++
FC=x86_64-linux-gfortran
AS=x86_64-linux-as

# Macros
CND_PLATFORM=GNU-Linux
Expand Down Expand Up @@ -72,7 +72,7 @@ FFLAGS=
ASFLAGS=

# Link Libraries and Options
LDLIBSOPTIONS=-lcurses
LDLIBSOPTIONS=-lcurses -ltinfo

# Build Targets
.build-conf: ${BUILD_SUBPROJECTS}
Expand Down
1 change: 1 addition & 0 deletions images/.dockerignore
@@ -0,0 +1 @@
scratch
28 changes: 28 additions & 0 deletions images/Dockerfile
@@ -0,0 +1,28 @@
FROM ubuntu:16.04

RUN dpkg --add-architecture i386 && apt update && apt install -y \
bc \
build-essential \
cpio \
dosfstools \
g++-multilib \
gdisk \
git-core \
libncurses5-dev \
libncurses5-dev:i386 \
python \
squashfs-tools \
sudo \
unzip \
wget \
locales \
&& rm -rf /var/lib/apt/lists/*

RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

WORKDIR "/sedutil"

CMD "/sedutil/images/autobuild.sh"
23 changes: 23 additions & 0 deletions images/README.md
@@ -0,0 +1,23 @@
# Images

## Docker

Docker can be used as a repeatable build environment to build the images in an Ubuntu 16.04 container. Steps to reproduce from the `images` directory:


### Step 1 - Build the Docker container

docker build -t sedutil .

### Step 2 - Run the build from within the Docker container

Try the `autobuild.sh` script which runs automatically when no command is
passed:

docker run --rm -it -v $PWD/../:/sedutil --privileged sedutil

Or, refer to `BUILDING` file and run manually in the Docker container by
starting `bash`:

docker run --rm -it -v $PWD/../:/sedutil --privileged sedutil bash

47 changes: 47 additions & 0 deletions images/autobuild.sh
@@ -0,0 +1,47 @@
#!/bin/bash

# Echo commands and abort on error
set -ex

# Optimal MAKEFLAGS argument if not already defined
if [ -z ${MAKEFLAGS+x} ]; then
# Add 1 assuming disk IO will block processes from time to time.
export MAKEFLAGS=$((1 + $(grep processor /proc/cpuinfo | wc -l)))
fi

# Run everything from the path of this script despite how invoked
cd "$( dirname "${BASH_SOURCE[0]}" )"

source conf

# Build buildroot before other tools as it provides the toolchain for linuxpba
# and sedutil-cli.
./getresources
./buildpbaroot

pushd ../LinuxPBA
rm -rf dist build
make CONF=Debug
make CONF=Debug_x86_64
make CONF=Release
make CONF=Release_x86_64
popd

pushd ../linux/CLI
rm -rf dist build
make CONF=Debug_i686
make CONF=Debug_x86_64
make CONF=Release_i686
make CONF=Release_x86_64
popd

# Build BIOS images (untested, probably subtly broken)
#./buildbiospba Release
#./buildbiospba Debug

# Build UEFI images
./buildUEFI64 Release
./buildUEFI64 Debug

# Rescue build
./buildrescue
4 changes: 2 additions & 2 deletions images/buildUEFI64
@@ -1,5 +1,5 @@
#!/bin/bash
set -x
set -ex
# Build a custom UEFI linux based PBA image
## define releases for tools
. conf
Expand All @@ -23,7 +23,7 @@ fi
-f buildroot/syslinux.cfg \
] || { echo " prereqs are not available "; exit 1; }
# recreate the initrd file with the latest PBA
mkdir scratch/buildroot/PBA64/overlay/sbin/
mkdir -p scratch/buildroot/PBA64/overlay/sbin/
cp ../LinuxPBA/dist/${BUILDTYPE}_x86_64/GNU-Linux/linuxpba scratch/buildroot/PBA64/overlay/sbin/linuxpba
cp ../linux/CLI/dist/${BUILDTYPE}_x86_64/GNU-Linux/sedutil-cli scratch/buildroot/PBA64/overlay/sbin/sedutil-cli
cd scratch/buildroot
Expand Down
14 changes: 6 additions & 8 deletions images/buildpbaroot
@@ -1,5 +1,5 @@
#!/bin/bash
set +x
set -ex
function die {
echo An error has occured please fix this and start over
exit 99
Expand All @@ -20,17 +20,15 @@ cp ../../buildroot/ncurses.mk package/ncurses/
# 64 bit system
mkdir PBA64
cp ../../buildroot/PBA64/.config PBA64/
cp ../../buildroot/PBA64/* PBA64/
cp -r ../../buildroot/PBA64/overlay PBA64/
cp -r ../../buildroot/PBA64/* PBA64/

# 32 bit system
mkdir PBA32
cp ../../buildroot/PBA32/.config PBA32/
cp ../../buildroot/PBA32/* PBA32/
cp -r ../../buildroot/PBA32/overlay PBA32/
cp -r ../../buildroot/PBA32/* PBA32/

echo This is going to take a while ..... Press enter to continue
read INOUT
#echo This is going to take a while ..... Press enter to continue
#read INOUT
echo Making the 64bit PBA Linux system
make O=PBA64 2>&1 | tee PBA64/build_output.txt
echo Making the 32bit PBA Linux system
Expand All @@ -41,4 +39,4 @@ grep -i pba PBA*/target/etc/inittab
grep -i libtinfo PBA*/target/etc/ld.so.cache
# back to where we started
cd ../..
exit 0
exit 0
7 changes: 5 additions & 2 deletions images/buildrescue
@@ -1,5 +1,5 @@
#!/bin/bash
set -x
set -ex
# Build a custom tinycore bootable image
## define releases for tools
. conf
Expand All @@ -18,7 +18,7 @@ sudo rm -rf ${BUILDTYPE} ; mkdir ${BUILDTYPE} ; cd ${BUILDTYPE}
-f ${PROGRAM} \
] || { echo " prereqs are not available "; exit 1; }
#
dd if=/dev/zero of=${BUILDIMG} bs=1M count=15
dd if=/dev/zero of=${BUILDIMG} bs=1M count=30
(echo o;echo n;echo p;echo 1;echo "";echo "";echo a;echo 1;echo w) | fdisk -C 100 ${BUILDIMG}
dd if=../scratch/${SYSLINUX}/bios/mbr/mbr.bin of=${BUILDIMG} count=1 conv=notrunc bs=512
LOOPDEV=`sudo losetup --show -f -o 1048576 ${BUILDIMG}`
Expand All @@ -44,6 +44,9 @@ cd ..
sudo mkdir -p core/usr/local/sbin/
sudo unsquashfs -f -li -d core ../scratch/hdparm.tcz
sudo cp ${PROGRAM} core/usr/local/sbin/
## Bundle UEFI images
sudo gunzip -k /sedutil/images/UEFI*/*.gz
sudo cp /sedutil/images/UEFI*/*.img core/
## now repackage it
cd core
sudo find | sudo cpio -o -H newc | gzip -9 > ../image/boot/core.gz
Expand Down
2 changes: 1 addition & 1 deletion images/buildroot/PBA32/kernel.config
Expand Up @@ -711,7 +711,7 @@ CONFIG_BLK_DEV_LOOP_MIN_COUNT=8
#
# DRBD disabled because PROC_FS or INET not selected
#
# CONFIG_BLK_DEV_NVME is not set
CONFIG_BLK_DEV_NVME=y
# CONFIG_BLK_DEV_SKD is not set
# CONFIG_BLK_DEV_SX8 is not set
# CONFIG_BLK_DEV_RAM is not set
Expand Down
2 changes: 1 addition & 1 deletion images/buildroot/PBA64/kernel.config
Expand Up @@ -726,7 +726,7 @@ CONFIG_BLK_DEV_LOOP_MIN_COUNT=8
#
# DRBD disabled because PROC_FS or INET not selected
#
# CONFIG_BLK_DEV_NVME is not set
CONFIG_BLK_DEV_NVME=y
# CONFIG_BLK_DEV_SKD is not set
# CONFIG_BLK_DEV_SX8 is not set
# CONFIG_BLK_DEV_RAM is not set
Expand Down
12 changes: 12 additions & 0 deletions images/conf
Expand Up @@ -6,3 +6,15 @@ SYSLINUX=syslinux-6.03
TCDISTRO=http://distro.ibiblio.org/tinycorelinux/6.x/x86/
BUILDROOT=git://git.buildroot.net/buildroot
BUILDROOT_TAG=2015.11

# Prefix PATH with i686 toolchain path, only once
PATH_TC_32="/sedutil/images/scratch/buildroot/PBA32/host/usr/bin"
if [[ $PATH != ${PATH_TC_32}* ]]; then
export PATH="$PATH_TC_32:$PATH"
fi

# Prefix PATH with x86_64 toolchain path, only once
PATH_TC_64="/sedutil/images/scratch/buildroot/PBA64/host/usr/bin"
if [[ $PATH != ${PATH_TC_64}* ]]; then
export PATH="$PATH_TC_64:$PATH"
fi
2 changes: 2 additions & 0 deletions images/docker-build
@@ -0,0 +1,2 @@
docker build -t sedutil .
docker run --rm -it -v $PWD/../:/sedutil --privileged sedutil $@
2 changes: 1 addition & 1 deletion images/getresources
@@ -1,5 +1,5 @@
#!/bin/bash
set -x
set -ex
## Get version information
. conf
## Make a clean start
Expand Down
14 changes: 7 additions & 7 deletions linux/CLI/nbproject/Makefile-Debug_i686.mk
Expand Up @@ -11,14 +11,14 @@
MKDIR=mkdir
CP=cp
GREP=grep
NM=nm
NM=i686-linux-nm
CCADMIN=CCadmin
RANLIB=ranlib
CC=gcc
CCC=g++
CXX=g++
FC=gfortran
AS=as
RANLIB=i686-linux-ranlib
CC=i686-linux-gcc
CCC=i686-linux-g++
CXX=i686-linux-g++
FC=i686-linux-gfortran
AS=i686-linux-as

# Macros
CND_PLATFORM=GNU-Linux
Expand Down

0 comments on commit 5897bc3

Please sign in to comment.