mirror of
https://github.com/clearlinux/mixer-tools.git
synced 2026-09-06 21:51:30 +00:00
Because Clear version numbers use numeric digits only, it's possible for the tag names to conflict with the prefix of a git object hash in the repo. To remove the possibility of conflict, use the refs/tags/ prefix when querying the tag names. Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
130 lines
3.1 KiB
Bash
130 lines
3.1 KiB
Bash
#!/bin/bash
|
|
|
|
# Program that builds the actual chroots
|
|
BUILDERSCRIPT="bundle-chroot-builder.py"
|
|
|
|
# Fallback config files for the scripts
|
|
BUILDERCONF=
|
|
LOCALCONF=
|
|
|
|
SIGNING=1
|
|
YUM_TEMPLATE="/usr/share/defaults/mixer/yum.conf.in"
|
|
|
|
STATE_DIR=
|
|
YUM_CONF=
|
|
BUNDLE_DIR=
|
|
CERT=
|
|
CLRVER=
|
|
MIXVER=
|
|
REPODIR=
|
|
RPMDIR=
|
|
INC=0
|
|
|
|
check_dep() {
|
|
set +e
|
|
type $1 &> /dev/null
|
|
if [ $? -ne 0 ]; then
|
|
echo "$1 program not found... Unable to continue"
|
|
exit 1
|
|
fi
|
|
set -e
|
|
}
|
|
|
|
check_deps() {
|
|
check_dep "createrepo_c"
|
|
check_dep "git"
|
|
check_dep "hardlink"
|
|
check_dep "m4"
|
|
check_dep "openssl"
|
|
check_dep "parallel"
|
|
check_dep "rpm"
|
|
check_dep "yum"
|
|
}
|
|
|
|
update_repo() {
|
|
local repo="$1"
|
|
(
|
|
if [ ! -d "$repo" ]; then
|
|
git clone https://github.com/clearlinux/"$repo.git"
|
|
cd "$repo"
|
|
else
|
|
cd "$repo"
|
|
# to force the update of clr-bundles "latest" tag
|
|
git fetch --tags
|
|
git checkout master
|
|
git pull origin master
|
|
fi
|
|
set +e
|
|
# Ensure that CLRVER exists and is a tag
|
|
git rev-parse --verify "refs/tags/${CLRVER}^{tag}" &> /dev/null
|
|
if [ $? -eq 0 ]; then
|
|
# Always reset the _mix branch to be based off the tag
|
|
git checkout -B "${CLRVER}_mix" "refs/tags/${CLRVER}"
|
|
else
|
|
echo "ERROR: invalid CLEAR_VERSION in builder.conf (${CLRVER})"
|
|
exit 1
|
|
fi
|
|
set -e
|
|
cd ..
|
|
)
|
|
}
|
|
|
|
install_cert() {
|
|
if [ ! -z $CERT ]; then
|
|
if [ ! -f $CERT ]; then
|
|
# This generates the private key and self signed certificate
|
|
openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 \
|
|
-keyout private.pem -out $CERT \
|
|
-subj "/C=US/ST=Oregon/L=Portland/O=Company Name/OU=Org/CN=www.example.com/DN=MixerCert" \
|
|
-config /usr/share/defaults/mixer/certattributes.cnf
|
|
fi
|
|
echo -e "Installing certificate\n"
|
|
sudo cp $CERT "$STATE_DIR/image/$MIXVER/os-core-update/usr/share/clear/update-ca/"
|
|
fi
|
|
}
|
|
|
|
sign_manifest_mom() {
|
|
if [ -f "$CERT" ]; then
|
|
sudo openssl smime -sign -binary -in $STATE_DIR/www/$MIXVER/Manifest.MoM \
|
|
-signer $CERT -inkey private.pem \
|
|
-outform DER -out $STATE_DIR/www/$MIXVER/Manifest.MoM.sig
|
|
fi
|
|
}
|
|
|
|
load_builder_conf() {
|
|
if [ -f "$PWD/builder.conf" ]; then
|
|
LOCALCONF="$PWD/builder.conf"
|
|
elif [ -z $BUILDERCONF ]; then
|
|
echo -e "ERROR: Cannot find any builder.conf to use!\n"
|
|
exit
|
|
fi
|
|
}
|
|
|
|
read_builder_conf() {
|
|
STATE_DIR=$(awk -F '=[ ]*' '/^SERVER_STATE_DIR *=/ {print $2; exit}' $1)
|
|
YUM_CONF=$(awk -F '=[ ]*' '/^YUM_CONF *=/ {print $2; exit}' $1)
|
|
BUNDLE_DIR=$(awk -F '=[ ]*' '/^BUNDLE_DIR *=/ {print $2; exit}' $1)
|
|
CERT=$(awk -F '=[ ]*' '/^CERT *=/ {print $2; exit}' $1)
|
|
CLRVER=$(awk -F '=[ ]*' '/^CLEAR_VERSION *=/ {print $2; exit}' $1)
|
|
MIXVER=$(awk -F '=[ ]*' '/^MIX_VERSION *=/ {print $2; exit}' $1)
|
|
REPODIR=$(awk -F '=[ ]*' '/^REPODIR *=/ {print $2; exit}' $1)
|
|
RPMDIR=$(awk -F '=[ ]*' '/^RPMDIR *=/ {print $2; exit}' $1)
|
|
FORMAT=$(awk -F '=[ ]*' '/^FORMAT *=/ {print $2; exit}' $1)
|
|
|
|
if [ -z $MIXVER ]; then
|
|
echo -e "ERROR: Please set the mix version\n"
|
|
exit
|
|
fi
|
|
|
|
if [ -z $CLRVER ]; then
|
|
echo -e "ERROR: Please set the Clear version\n"
|
|
exit
|
|
fi
|
|
}
|
|
|
|
clean_chroots() {
|
|
for BUNDLE in $(ls "$BUNDLE_DIR" | grep -v "^full"); do
|
|
sudo rm -rf "$STATE_DIR/image/$MIXVER/$BUNDLE"
|
|
done
|
|
}
|