commit 8d23e5c3514d9dc0d15e756669a37afcb7e48413 Author: alex Date: Sun Feb 24 10:07:31 2019 +0100 add rosa-builder diff --git a/Dockerfile.builder b/Dockerfile.builder new file mode 100644 index 0000000..52bcd29 --- /dev/null +++ b/Dockerfile.builder @@ -0,0 +1,26 @@ +FROM openmandriva/3.0 +#FROM openmandriva/cooker-aarch64 +#FROM openmandriva/cooker-armv7hl +# replace me with armv7hl, aarch64 +ENV RARCH x86_64 + +RUN urpmi --auto --auto-update --no-verify-rpm \ + && rm -f /etc/localtime \ + && ln -s /usr/share/zoneinfo/UTC /etc/localtime \ + && gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 \ + && urpmi --no-suggests --no-verify-rpm --auto mock-urpm git curl sudo builder-c \ + && sed -i -e "s/Defaults requiretty.*/ #Defaults requiretty/g" /etc/sudoers \ + && echo "%mock-urpm ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers \ + && adduser omv \ + && usermod -a -G mock-urpm omv \ + && chown -R omv:mock-urpm /etc/mock-urpm \ + && rm -rf /var/cache/urpmi/rpms/* \ + && rm -rf /usr/share/man/ /usr/share/cracklib /usr/share/doc + +RUN if [ $RARCH = "x86_64" ]; then urpmi --auto --no-verify-rpm qemu-static-aarch64 qemu-static-arm; fi + +## put me in RUN if you have more than 16gb of RAM +# && echo "tmpfs /var/lib/mock-urpm/ tmpfs defaults,size=4096m,uid=$(id -u omv),gid=$(id -g omv),mode=0700 0 0" >> /etc/fstab \ +# + +ENTRYPOINT ["/usr/bin/builder"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..355c0c6 --- /dev/null +++ b/README.md @@ -0,0 +1,54 @@ +## Quickstart + +Clone repository + +```bash +git clone https://github.com/OpenMandrivaSoftware/docker-builder.git +``` +Create builder image: + +```bash +cd docker-builder +docker build --tag=openmandriva/builder --file $HOME/docker-builder/Dockerfile.builder . +``` + +## Remove stopped containers +```bash +docker rm -v $(docker ps -a -q -f status=exited) +``` + +## Run abf builder +```bash +docker run -ti --rm --privileged=true -h .openmandriva.org -e BUILD_TOKEN="your_token" \ + -e BUILD_ARCH="x86_64 armv7hl i586 i686 aarch64" \ + -e BUILD_PLATFORM="cooker" openmandriva/builder +``` + +## Prepare Environment +## ARMv7 + +Add file + +```bash +/etc/binfmt.d/arm.conf +``` +```bash +:arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-arm-binfmt:P +``` +and this file + +## ARM64 (aarch64) +```bash +/etc/binfmt.d/aarch64.conf +``` +```bash +:aarch64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-aarch64-binfmt:P +``` +Then you need to restart binfmt service + +```bash +systemctl restart systemd-binfmt.service +``` +screencast: + +[![demo](https://asciinema.org/a/9c5mzq43h15kmeg4roiq8yvok.png)](https://asciinema.org/a/9c5mzq43h15kmeg4roiq8yvok?autoplay=1) diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..31344e4 --- /dev/null +++ b/build.sh @@ -0,0 +1,510 @@ +#!/bin/bash +set -x + +cleanup() { +echo '--> Cleaning up...' +sudo rm -fv /etc/rpm/platform +rm -fv /etc/mock-urpm/default.cfg +sudo rm -rf /var/lib/mock-urpm/* + +# unmask/mask both, we need to keep logs +#rm -rf ${HOME}/output/ +#rm -fv ~/build_fail_reason.log + +# (tpg) remove package +rm -rf "${HOME}/${PACKAGE}" +# (tpg) remove old files +# in many cases these are leftovers when build fails +# would be nice to remove them to free disk space +find ${HOME} -maxdepth 1 ! -name 'qemu-a*' ! -name 'docker-worker' ! -name '.gem' ! -name 'envfile' -mmin +1500 -exec rm -rf '{}' \; &> /dev/null +} + +# (tpg) Clean build environment +cleanup + +# (tpg) remove these files +[ -e ~/build_fail_reason.log ] && rm -rf ~/build_fail_reason.log +[ -e "${HOME}"/output ] && rm -rf "${HOME}"/output + +MOCK_BIN="/usr/bin/mock-urpm" +config_dir=/etc/mock-urpm/ +# $PACKAGE same as project name +# e.g. github.com/OpenMandrivaAssociation/htop +build_package=${HOME}/"$PACKAGE" +OUTPUT_FOLDER=${HOME}/output + +GREP_PATTERN='error: (.*)$|Segmentation Fault|cannot find (.*)$|undefined reference (.*)$|cp: (.*)$|Hunk #1 FAILED|\(due to unsatisfied(.*)$' + +filestore_url="http://file-store.rosalinux.ru/api/v1/file_stores" +platform_arch="$PLATFORM_ARCH" +platform_name="$PLATFORM_NAME" +uname="$UNAME" +email="$EMAIL" +git_repo="$GIT_REPO" +project_version="$PROJECT_VERSION" +extra_build_rpm_options="$EXTRA_BUILD_RPM_OPTIONS" +extra_build_src_rpm_options="$EXTRA_BUILD_SRC_RPM_OPTIONS" +extra_cfg_options="$EXTRA_CFG_OPTIONS" +extra_cfg_urpm_options="$EXTRA_CFG_URPM_OPTIONS" +save_buildroot="$SAVE_BUILDROOT" +use_extra_tests="$USE_EXTRA_TESTS" +rerun_tests="$RERUN_TESTS" +# list of packages for tests relaunch +packages="$PACKAGES" + +if [ "$(uname -m)" = 'x86_64' ] && echo "$platform_arch" |grep -qE 'i[0-9]86'; then + # Change the kernel personality so build scripts don't think + # we're building for 64-bit + MOCK_BIN="/usr/bin/i386 $MOCK_BIN" +fi + +echo '--> Mounting tmpfs filesystem to builddir' +sudo mount -a + +generate_config() { +# Change output format for mock-urpm +sed '17c/format: %(message)s' $config_dir/logging.ini > ~/logging.ini +mv -f ~/logging.ini $config_dir/logging.ini + +EXTRA_CFG_OPTIONS="$extra_cfg_options" \ + EXTRA_CFG_URPM_OPTIONS="$extra_cfg_urpm_options" \ + UNAME=$uname \ + EMAIL=$email \ + PLATFORM_NAME=$platform_name \ + PLATFORM_ARCH=$platform_arch \ + /bin/bash "/mdv/config-generator.sh" +} + +container_data() { +# Generate data for container + +[ "$rerun_tests" = 'true' ] && return 0 + +c_data=$OUTPUT_FOLDER/container_data.json +project_name=`echo ${git_repo} | sed s%.*/%% | sed s/.git$//` +echo '[' > ${c_data} +comma=0 +for rpm in ${OUTPUT_FOLDER}/*.rpm; do + nevr=(`rpm -qp --queryformat "%{NAME} %{EPOCH} %{VERSION} %{RELEASE}" ${rpm}`) + name=${nevr[0]} + if [ "${name}" != '' ] ; then + if [ $comma -eq 1 ] + then + echo -n "," >> ${c_data} + fi + if [ $comma -eq 0 ] + then + comma=1 + fi + fullname=`basename $rpm` + epoch=${nevr[1]} + version=${nevr[2]} + release=${nevr[3]} + + dep_list="" + [[ ! "${fullname}" =~ ".*src.rpm$" ]] && dep_list=`urpmq --whatrequires ${name} | sort -u | xargs urpmq --sourcerpm | cut -d\ -f2 | rev | cut -f3- -d- | rev | sort -u | grep -v "^${project_name}$" | xargs echo` + sha1=`sha1sum ${rpm} | awk '{ print $1 }'` + + echo "--> dep_list for '${name}':" + echo ${dep_list} + + echo '{' >> ${c_data} + echo "\"dependent_packages\":\"${dep_list}\"," >> ${c_data} + echo "\"fullname\":\"${fullname}\"," >> ${c_data} + echo "\"sha1\":\"${sha1}\"," >> ${c_data} + echo "\"name\":\"${name}\"," >> ${c_data} + echo "\"epoch\":\"${epoch}\"," >> ${c_data} + echo "\"version\":\"${version}\"," >> ${c_data} + echo "\"release\":\"${release}\"" >> ${c_data} + echo '}' >> ${c_data} + fi +done +echo ']' >> ${c_data} + +} + +download_cache() { + +if [ "${CACHED_CHROOT_SHA1}" != '' ]; then +# if chroot not exist download it + if [ ! -f ${HOME}/${CACHED_CHROOT_SHA1}.tar.xz ]; then + curl -L "${filestore_url}/${CACHED_CHROOT_SHA1}" -o "${HOME}/${CACHED_CHROOT_SHA1}.tar.xz" + fi +# unpack in root + echo "Extracting chroot $CACHED_CHROOT_SHA1" + if echo "${CACHED_CHROOT_SHA1} ${HOME}/${CACHED_CHROOT_SHA1}.tar.xz" | sha1sum -c --status &> /dev/null; then + sudo tar -xf ${HOME}/${CACHED_CHROOT_SHA1}.tar.xz -C / + else + echo '--> Building without cached chroot, becasue SHA1 is wrong.' + export CACHED_CHROOT_SHA1="" + fi +fi + +} + +arm_platform_detector(){ +probe_cpu() { +# probe cpu type +cpu="$(uname -m)" +case "$cpu" in + i386|i486|i586|i686|i86pc|BePC|x86_64) + cpu="i386" + ;; + armv[4-9]*) + cpu="arm" + ;; + aarch64) + cpu="aarch64" + ;; +esac + +if [ "$platform_arch" = 'aarch64' ]; then + if [ $cpu != "aarch64" ] ; then +# hack to copy qemu binary in non-existing path + (while [ ! -e /var/lib/mock-urpm/openmandriva-$platform_arch/root/usr/bin/ ] + do sleep 1; done + # rebuild docker builder with qemu packages + sudo cp /usr/bin/qemu-static-aarch64 /var/lib/mock-urpm/openmandriva-$platform_arch/root/usr/bin/) & + subshellpid=$! + fi +# remove me in future + sudo sh -c "echo '$platform_arch-mandriva-linux-gnueabi' > /etc/rpm/platform" +fi + +if [ "$platform_arch" = 'armv7hl' ]; then + if [ $cpu != "arm" ] || [ $cpu != "aarch64" ] ; then +# hack to copy qemu binary in non-existing path + (while [ ! -e /var/lib/mock-urpm/openmandriva-$platform_arch/root/usr/bin/ ] + do sleep 1; done + sudo cp /usr/bin/qemu-static-arm /var/lib/mock-urpm/openmandriva-$platform_arch/root/usr/bin/) & + subshellpid=$! + fi +# remove me in future + sudo sh -c "echo '$platform_arch-mandriva-linux-gnueabi' > /etc/rpm/platform" +fi + +} +probe_cpu +} + +test_rpm() { +# Rerun tests + PACKAGES=${packages} \ + chroot_path=$chroot_path \ + use_extra_tests=$use_extra_tests + + test_code=0 + test_log="$OUTPUT_FOLDER"/tests.log + echo '--> Starting RPM tests.' + + if [ "$rerun_tests" = 'true' ]; then + [ "$packages" = '' ] && echo '--> No packages for testing. Something is wrong. Exiting. !!!' && exit 1 + + [ ! -e "$OUTPUT_FOLDER" ] && mkdir -p "$OUTPUT_FOLDER" + [ ! -e "$build_package" ] && mkdir -p "$build_package" + + test_log="$OUTPUT_FOLDER"/tests-`printf '%(%F-%R)T'.log` + echo "--> Re-running tests on `date -u`" >> $test_log + prefix='rerun-tests-' + arr=($packages) + cd "$build_package" + for package in ${arr[@]} ; do + echo "--> Downloading '$package'..." >> $test_log + wget http://file-store.rosalinux.ru/api/v1/file_stores/$package --content-disposition --no-check-certificate + rc=$? + if [ $rc != 0 ]; then + echo "--> Error on extracting package with sha1 '$package'!!!" + exit $rc + fi + done + cd .. +# (tpg) TODO fix running tests with cached-chroot +# if [ "${CACHED_CHROOT_SHA1}" != '' ]; then +# echo "--> Uses cached chroot with sha1 '$CACHED_CHROOT_SHA1'..." >> $test_log +# $MOCK_BIN --chroot "urpmi.removemedia -a" +# $MOCK_BIN --readdrepo -v --configdir $config_dir --no-cleanup-after --no-clean --update +# else + $MOCK_BIN --init --configdir $config_dir -v --no-cleanup-after +# fi + + OUTPUT_FOLDER="$build_package" + fi + + echo '--> Checking if rpm packages can be installed.' >> $test_log + TEST_CHROOT_PATH=$($MOCK_BIN --configdir=$config_dir --print-root-path) + sudo mkdir -p "${TEST_CHROOT_PATH}"/test_root + sudo cp "$OUTPUT_FOLDER"/*.rpm "${TEST_CHROOT_PATH}"/ + + try_retest=true + retry=0 + while $try_retest + do + sudo chroot "${TEST_CHROOT_PATH}" urpmi --split-length 0 --downloader wget --wget-options --auth-no-challenge -v --debug --no-verify-rpm --fastunsafe --no-suggests --buildrequires --test `ls $TEST_CHROOT_PATH | grep rpm` --root test_root --auto > $test_log.tmp 2>&1 + test_code=$? + try_retest=false + if [[ $test_code != 0 && $retry < $MAX_RETRIES ]] ; then + if grep -q "$RETRY_GREP_STR" $test_log.tmp; then + echo '--> Repository was changed in the middle, will rerun the tests' >> $test_log + sleep ${WAIT_TIME} + sudo chroot "${TEST_CHROOT_PATH}" urpmi.update -a >> $test_log 2>&1 + try_retest=true + (( retry=$retry+1 )) + fi + fi + done + + cat $test_log.tmp >> $test_log + echo "--> Tests finished at `date -u`" >> $test_log + echo 'Test code output: ' $test_code >> $test_log 2>&1 + sudo rm -f "${TEST_CHROOT_PATH}"/*.rpm + sudo rm -rf "${TEST_CHROOT_PATH}"/test_root + rm -f $test_log.tmp + + # Check exit code after testing + if [ $test_code != 0 ]; then + echo '--> Test failed, see: tests.log' + test_code=5 + [ "$rerun_tests" = '' ] && container_data + [ "$rerun_tests" = 'true' ] && cleanup + exit $test_code + else + return $test_code + fi +} + +build_rpm() { +arm_platform_detector + +# We will rerun the build in case when repository is modified in the middle, +# but for safety let's limit number of retest attempts +# (since in case when repository metadata is really broken we can loop here forever) +MAX_RETRIES=10 +WAIT_TIME=60 +RETRY_GREP_STR="You may need to update your urpmi database\|problem reading synthesis file of medium\|retrieving failed: " + +if [ "$rerun_tests" = 'true' ]; then + test_rpm + return 0 +fi + +echo '--> Build src.rpm' +try_rebuild=true +retry=0 +while $try_rebuild +do + rm -rf "$OUTPUT_FOLDER" + if [ "${CACHED_CHROOT_SHA1}" != '' ]; then + echo "--> Uses cached chroot with sha1 '$CACHED_CHROOT_SHA1'..." + $MOCK_BIN --chroot "urpmi.removemedia -a" + $MOCK_BIN --readdrepo -v --configdir $config_dir +# (tpg) catch errors when adding repositories into chroot + rc=${PIPESTATUS[0]} + try_rebuild=false + if [[ $rc != 0 && $retry < $MAX_RETRIES ]]; then + if grep -q "$RETRY_GREP_STR" $OUTPUT_FOLDER/root.log; then + try_rebuild=true + (( retry=$retry+1 )) + echo "--> Repository was changed in the middle, will rerun the build. Next try (${retry} from ${MAX_RETRIES})..." + echo "--> Delay ${WAIT_TIME} sec..." + sleep ${WAIT_TIME} + fi + fi + $MOCK_BIN -v --configdir=$config_dir --buildsrpm --spec=$build_package/${PACKAGE}.spec --sources=$build_package --no-cleanup-after --no-clean $extra_build_src_rpm_options --resultdir=$OUTPUT_FOLDER + else + $MOCK_BIN -v --configdir=$config_dir --buildsrpm --spec=$build_package/${PACKAGE}.spec --sources=$build_package --no-cleanup-after $extra_build_src_rpm_options --resultdir=$OUTPUT_FOLDER + fi + + rc=${PIPESTATUS[0]} + try_rebuild=false + if [[ $rc != 0 && $retry < $MAX_RETRIES ]]; then + if grep -q "$RETRY_GREP_STR" $OUTPUT_FOLDER/root.log; then + try_rebuild=true + (( retry=$retry+1 )) + echo "--> Repository was changed in the middle, will rerun the build. Next try (${retry} from ${MAX_RETRIES})..." + echo "--> Delay ${WAIT_TIME} sec..." + sleep ${WAIT_TIME} + fi + fi +done + +# Check exit code after build +if [ $rc != 0 ] || [ ! -e $OUTPUT_FOLDER/*.src.rpm ]; then + echo '--> Build failed: mock-urpm encountered a problem.' + # 99% of all build failures at src.rpm creation is broken deps + # m1 show only first match -oP show only matching + grep -m1 -oP "\(due to unsatisfied(.*)$" $OUTPUT_FOLDER/root.log >> ~/build_fail_reason.log + [ -n $subshellpid ] && kill $subshellpid + cleanup + exit 1 +fi + +echo '--> src.rpm build has been done successfully.' + +echo '--> Building rpm' +try_rebuild=true +retry=0 +while $try_rebuild +do + $MOCK_BIN -v --configdir=$config_dir --rebuild $OUTPUT_FOLDER/*.src.rpm --no-cleanup-after --no-clean $extra_build_rpm_options --resultdir=$OUTPUT_FOLDER + rc=${PIPESTATUS[0]} + try_rebuild=false + if [[ $rc != 0 && $retry < $MAX_RETRIES ]] ; then + if grep -q "$RETRY_GREP_STR" $OUTPUT_FOLDER/root.log; then + try_rebuild=true + (( retry=$retry+1 )) + echo "--> Repository was changed in the middle, will rerun the build. Next try (${retry} from ${MAX_RETRIES})..." + echo "--> Delay ${WAIT_TIME} sec..." + sleep ${WAIT_TIME} + fi + fi +done + +# Check exit code after build +if [ $rc != 0 ]; then + echo '--> Build failed: mock-urpm encountered a problem.' +# clean all the rpm files because build was not completed + grep -m1 -i -oP "$GREP_PATTERN" $OUTPUT_FOLDER/root.log >> ~/build_fail_reason.log + rm -rf $OUTPUT_FOLDER/*.rpm + [ -n $subshellpid ] && kill $subshellpid + cleanup + exit 1 +fi +echo '--> Done.' + +# Extract rpmlint logs into separate file +echo "--> Grepping rpmlint logs from $OUTPUT_FOLDER/build.log to $OUTPUT_FOLDER/rpmlint.log" +sed -n "/Executing \"\/usr\/bin\/rpmlint/,/packages and.*specfiles checked/p" $OUTPUT_FOLDER/build.log > $OUTPUT_FOLDER/rpmlint.log +echo '--> Create rpm -qa list' +rpm --root=/var/lib/mock-urpm/openmandriva-$platform_arch/root/ -qa >> $OUTPUT_FOLDER/rpm-qa.log + +# (tpg) Save build chroot +if [ "${rc}" != 0 ] && [ "${save_buildroot}" = 'true' ]; then + sudo tar --exclude=root/dev -zcvf "${OUTPUT_FOLDER}"/rpm-buildroot.tar.gz /var/lib/mock-urpm/openmandriva-$platform_arch/root/ +fi + +# Test RPM files +test_rpm +# End tests + +} + +find_spec() { + +[ "$rerun_tests" = 'true' ] && return 0 + +# Check count of *.spec files (should be one) +x=$(ls -1 | grep -c '.spec$' | sed 's/^ *//' | sed 's/ *$//') +if [ "$x" -eq "0" ] ; then + echo '--> There are no spec files in repository.' + exit 1 +else + if [ "$x" -ne "1" ] ; then + echo '--> There are more than one spec file in repository.' + exit 1 + fi +fi +} + +validate_arch() { +# check if spec file have set ExcludeArch or ExclusiveArch against build arch target + BUILD_TYPE=`grep -i '^excludearch:.*$\|^exclusivearch:.*$' *.spec | awk -F'[:]' '{print $1}'` + +# check if spec file have both ExcludeArch and ExclusiveArch set up + [[ ${#BUILD_TYPE} -gt 15 ]] && echo "Spec file has set ExcludeArch and ExclusiveArch. Exiting!" && exit 1 + + SPEC_ARCH=(`grep -i '^excludearch:.*$\|^exclusivearch:.*$' *.spec | awk -F'[[:blank:]]' '{$1="";print $0}' | sort -u`) + +# validate platform against spec file settings + validate_build() { + local _PLATFORM=($1) +# count for occurences + for item in ${SPEC_ARCH[@]}; do + if [[ "${_PLATFORM[@]}" =~ "${item}" ]] ; then + FOUND_MATCH=1 + echo "--> Found match of ${item} in ${_PLATFORM[@]} for ${BUILD_TYPE}" + fi + done + + if [ -n "${FOUND_MATCH}" -a "${BUILD_TYPE,,}" = "excludearch" ]; then + echo "--> Build for this architecture is forbidden because of ${BUILD_TYPE} set in spec file!" + exit 6 + elif [ -z "${FOUND_MATCH}" -a "${BUILD_TYPE,,}" = "exclusivearch" ]; then + echo "--> Build for this architecture is forbidden because of ${BUILD_TYPE} set in spec file!" + exit 6 + else + echo "--> Spec validated for ExcludeArch and ExclusiveArch. Continue building." + fi + +} + +# translate arch into various options that may be set up in spec file + case ${PLATFORM_ARCH,,} in + armv7hl) + validate_build "armx %armx %{armx} armv7hl" + ;; + aarch64) + validate_build "armx %armx %{armx} aarch64" + ;; + i386|i586|i686) + validate_build "ix86 %ix86 %{ix86} i686 %i686 %{i686} i586 %i586 %{i586} i386 %i386 %{i386}" + ;; + x86_64) + validate_build "x86_64 %x86_64 %{x86_64}" + ;; + *) + echo "--> ${BUILD_TYPE} validated." + ;; + esac +} + +clone_repo() { + +[ "$rerun_tests" = 'true' ] && return 0 + +MAX_RETRIES=5 +WAIT_TIME=60 +try_reclone=true +retry=0 +while $try_reclone +do + rm -rf ${HOME}/${PACKAGE} +# checkout specific branch/tag if defined + if [ ! -z "$project_version" ]; then +# (tpg) clone only history of 100 commits to reduce bandwith + git clone --depth 100 -b $project_version $git_repo ${HOME}/${PACKAGE} + pushd ${HOME}/${PACKAGE} + git rev-parse HEAD > ${HOME}/commit_hash + popd + else + git clone --depth 100 $git_repo ${HOME}/${PACKAGE} + fi + rc=$? + try_reclone=false + if [[ $rc != 0 && $retry < $MAX_RETRIES ]] ; then + try_reclone=true + (( retry=$retry+1 )) + echo "--> Something wrong with git repository, next try (${retry} from ${MAX_RETRIES})..." + echo "--> Delay ${WAIT_TIME} sec..." + sleep ${WAIT_TIME} + fi +done + +pushd ${HOME}/${PACKAGE} +# count number of specs (should be 1) +find_spec +# check for excludearch or exclusivearch +validate_arch +# download sources from .abf.yml +/bin/bash /mdv/download_sources.sh +popd + +# build package +} + +generate_config +clone_repo +download_cache +build_rpm +container_data +# wipe package +rm -rf ${HOME}/${PACKAGE} diff --git a/cachedchroot.sh b/cachedchroot.sh new file mode 100755 index 0000000..2147e92 --- /dev/null +++ b/cachedchroot.sh @@ -0,0 +1,151 @@ +#!/bin/sh +set -x +echo '--> docker-builder/cachedchroot.sh' + +MOCK_BIN=/usr/bin/mock-urpm +config_dir=/etc/mock-urpm/ +OUTPUT_FOLDER=/home/omv/iso_builder/results +filestore_url="http://file-store.openmandriva.org/api/v1/file_stores" +distro_release=${DISTRO_RELEASE:-"cooker"} +platform_name=${PLATFORM_NAME:-"openmandriva"} +token="$TOKEN" +arches=${ARCHES:-"i586 i686 x86_64 aarch64 armv7hl"} + +chroot_path="/var/lib/mock-urpm" + +cleanup() { + echo '--> Cleaning up...' + sudo rm -fv /etc/rpm/platform + rm -fv /etc/mock-urpm/default.cfg + sudo rm -rf ${chroot_path}/* +} + +# wipe all +cleanup + +if [ "$(uname -m)" = 'x86_64' ] && echo "$platform_arch" |grep -qE 'i[0-9]86'; then + # Change the kernel personality so build scripts don't think + # we're building for 64-bit + MOCK_BIN="/usr/bin/i386 $MOCK_BIN" +fi + +generate_config() { +# Change output format for mock-urpm +sed '17c/format: %(message)s' $config_dir/logging.ini > ~/logging.ini +mv -f ~/logging.ini $config_dir/logging.ini + +if [[ ${distro_release,,} = cooker ]]; then + repo_names="main" + repo_url="http://abf-downloads.openmandriva.org/$distro_release/repository/$arch/main/release/" +else + repo_names="main main_updates" + repo_url="http://abf-downloads.openmandriva.org/$distro_release/repository/$arch/main/release/ http://abf-downloads.openmandriva.org/$distro_release/repository/$arch/main/updates/" +fi + +DISTRO_RELEASE=$distro_release \ + PLATFORM_ARCH=$arch \ + REPO_NAMES=$repo_names REPO_URL=$repo_url \ + /bin/bash "/home/omv/iso_builder/config-generator.sh" +} + +arm_platform_detector(){ +probe_cpu() { +# probe cpu type +cpu="$(uname -m)" +case "$cpu" in + i386|i486|i586|i686|i86pc|BePC|x86_64) + cpu="i386" + ;; + armv[4-9]*) + cpu="arm" + ;; + aarch64) + cpu="aarch64" + ;; +esac + +if [ "$arch" = 'aarch64' ]; then + if [ $cpu != 'aarch64' ]; then +# this string responsible for "cannot execute binary file" +# hack to copy qemu binary in non-existing path + (while [ ! -e ${chroot_path}/$platform_name-$arch/root/usr/bin/ ] + do sleep 1;done + sudo cp /usr/bin/qemu-static-aarch64 ${chroot_path}/$platform_name-$arch/root/usr/bin/) & + subshellpid=$! + fi +# remove me in future + sudo sh -c "echo '$arch-mandriva-linux-gnueabi' > /etc/rpm/platform" +fi + +if [ "$arch" = 'armv7hl' ]; then + if [ $cpu != 'arm' ] ; then +# this string responsible for "cannot execute binary file" +# change path to qemu +# hack to copy qemu binary in non-existing path + (while [ ! -e ${chroot_path}/$platform_name-$arch/root/usr/bin/ ] + do sleep 1;done + sudo cp /usr/bin/qemu-static-arm ${chroot_path}/$platform_name-$arch/root/usr/bin/) & + subshellpid=$! + fi +# remove me in future + sudo sh -c "echo '$arch-mandriva-linux-gnueabi' > /etc/rpm/platform" +fi + +} +probe_cpu +} + +if [ ! -d "$OUTPUT_FOLDER" ]; then + mkdir -p "$OUTPUT_FOLDER" +else + rm -f "$OUTPUT_FOLDER"/* +fi + +for arch in $arches ; do + # init mock-urpm config + generate_config + arm_platform_detector + + $MOCK_BIN --init --configdir $config_dir -v --no-cleanup-after + # Save exit code + rc=$? + echo '--> Done.' + + # Check exit code after build + if [ $rc != 0 ] ; then + echo '--> Build failed: mock-urpm encountered a problem.' + cleanup + exit 1 + fi + + chroot=`ls -1 ${chroot_path} | grep ${arch} | head -1` + + if [ "${chroot}" == '' ] ; then + echo '--> Build failed: chroot does not exist.' + cleanup + exit 1 + fi + + # Remove any stray lockfiles and make sure rpmdb is clean... + /bin/rm /var/lib/mock-urpm/openmandriva-"$arch"/root/var/lib/rpm/.RPMLOCK + /bin/rm /var/lib/mock-urpm/openmandriva-"$arch"/root/var/lib/urpmi/.LOCK + $MOCK_BIN --chroot "/usr/bin/db52_recover" + + # xz options -7e is 7th extreme level of compression, and -T0 is to use all available threads to speedup compress + # need sudo to pack root:root dirs + sudo XZ_OPT="-7 -T0" tar --format=gnutar --no-xattrs --no-acls --absolute-paths -Jcvf "${OUTPUT_FOLDER}"/"${chroot}".tar.xz "${chroot_path}"/"${chroot}" + + # Save exit code + rc=$? + + # Check exit code after build + if [ $rc != 0 ] ; then + echo '--> Build failed: tar encountered a problem.' + cleanup + exit 1 + fi + sudo rm -rf "${chroot_path}"/"${chroot}" +done + +echo '--> Build has been done successfully!' +exit 0 diff --git a/config-generator.sh b/config-generator.sh new file mode 100755 index 0000000..02945aa --- /dev/null +++ b/config-generator.sh @@ -0,0 +1,72 @@ +#!/bin/bash +echo 'OpenMandriva platform config generator' + +extra_cfg_options="$EXTRA_CFG_OPTIONS" +extra_cfg_urpm_options="$EXTRA_CFG_URPM_OPTIONS" +uname="$UNAME" +email="$EMAIL" +platform_arch="$PLATFORM_ARCH" +platform_name=${PLATFORM_NAME:-"rosa2016.1"} +repo_url="$REPO_URL" +repo_names="$REPO_NAMES" + +default_cfg=/etc/mock-urpm/default.cfg +gen_included_repos() { + +names_arr=($repo_names) +urls_arr=($repo_url) + +for (( i=0; i<${#names_arr[@]}; i++ )); +do + echo '"'${names_arr[i]}'"': '"'${urls_arr[i]}'"', >> $default_cfg +done +# close urpmi repos section +echo '}' >> $default_cfg +} + +if [ "$platform_arch" = 'aarch64' ]; then +cat < $default_cfg +config_opts['target_arch'] = '$platform_arch --without check --without uclibc --without dietlibc' +config_opts['legal_host_arches'] = ('i586', 'i686', 'x86_64', 'aarch64') +config_opts['urpmi_options'] = '--no-suggests --no-verify-rpm --ignoresize --ignorearch --excludedocs --downloader wget --fastunsafe --nolock $extra_cfg_options' +config_opts['urpm_options'] = '--xml-info=never $extra_cfg_urpm_options' +EOF + +elif [ "$platform_arch" = 'armv7hl' ]; then +cat < $default_cfg +config_opts['target_arch'] = '$platform_arch --without check --without uclibc' +config_opts['legal_host_arches'] = ('i586', 'i686', 'x86_64', 'armv7hl', 'armv7l', 'aarch64') +config_opts['urpmi_options'] = '--no-suggests --no-verify-rpm --ignoresize --ignorearch --excludedocs --downloader wget --fastunsafe --nolock $extra_cfg_options' +config_opts['urpm_options'] = '--xml-info=never $extra_cfg_urpm_options' +EOF +else + +cat < $default_cfg +config_opts['target_arch'] = '$platform_arch --without uclibc' +config_opts['legal_host_arches'] = ('i586', 'i686', 'x86_64') +config_opts['urpmi_options'] = '--no-suggests --no-verify-rpm --ignoresize --excludedocs --downloader wget --fastunsafe --nolock $extra_cfg_options' +config_opts['urpm_options'] = '$extra_cfg_urpm_options' +EOF +fi + +cat <> $default_cfg +config_opts['root'] = '$platform_name-$platform_arch' +config_opts['chroot_setup'] = 'basesystem-minimal locales locales-en gnupg rpm-build urpmi wget task-devel' +#config_opts['urpm_options'] = '--xml-info=never $extra_cfg_urpm_options' + +# If it's True - current urpmi configs will be copied to the chroot. +# Ater that other media will be added. +# config_opts['use_system_media'] = True + +config_opts['plugin_conf']['root_cache_enable'] = False +config_opts['plugin_conf']['ccache_enable'] = False +config_opts['use_system_media'] = False +config_opts['basedir'] = '/var/lib/mock-urpm/' +config_opts['cache_topdir'] = '/var/cache/mock-urpm/' + +config_opts['dist'] = 'cooker' # only useful for --resultdir variable subst +config_opts['macros']['%packager'] = '$uname <$email>' +config_opts["urpmi_media"] = { +EOF + +gen_included_repos diff --git a/docker-brew-rosa/.febootstrap-minimize b/docker-brew-rosa/.febootstrap-minimize new file mode 100755 index 0000000..8a71f5e --- /dev/null +++ b/docker-brew-rosa/.febootstrap-minimize @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +set -e + +rootfsDir="$1" +shift + +( + cd "$rootfsDir" + + # effectively: febootstrap-minimize --keep-zoneinfo --keep-rpmdb --keep-services "$target" + # locales + rm -rf usr/{{lib,share}/locale,{lib,lib64}/gconv,bin/localedef,sbin/build-locale-archive} + # docs + rm -rf usr/share/{man,doc,info,gnome/help} + # cracklib + rm -rf usr/share/cracklib + # i18n + rm -rf usr/share/i18n + # yum cache + rm -rf var/cache/yum + mkdir -p --mode=0755 var/cache/yum + # sln + rm -rf sbin/sln + # ldconfig + #rm -rf sbin/ldconfig + rm -rf etc/ld.so.cache var/cache/ldconfig + mkdir -p --mode=0755 var/cache/ldconfig +) diff --git a/docker-brew-rosa/2014/Dockerfile b/docker-brew-rosa/2014/Dockerfile new file mode 100644 index 0000000..db78db4 --- /dev/null +++ b/docker-brew-rosa/2014/Dockerfile @@ -0,0 +1,7 @@ +# Dockerfile to create OpenMandriva linux 2014 base images +# Create base image with mkimage-urpmi.sh script +# + +FROM scratch +MAINTAINER "Alexander Stefanov-Khryukin" +ADD rootfs-2014.1.tar.xz / diff --git a/docker-brew-rosa/3.0/Dockerfile b/docker-brew-rosa/3.0/Dockerfile new file mode 100644 index 0000000..6cd927a --- /dev/null +++ b/docker-brew-rosa/3.0/Dockerfile @@ -0,0 +1,7 @@ +# Dockerfile to create OpenMandriva linux LX3 base images +# Create base image with mkimage-urpmi.sh script +# + +FROM scratch +MAINTAINER "Alexander Stefanov-Khryukin" +ADD rootfs-3.0.tar.xz / diff --git a/docker-brew-rosa/3.0/README.md b/docker-brew-rosa/3.0/README.md new file mode 100644 index 0000000..a424221 --- /dev/null +++ b/docker-brew-rosa/3.0/README.md @@ -0,0 +1,5 @@ +Build image + +```bash +docker build --tag=openmandriva/3.0 --file Dockerfile . +``` diff --git a/docker-brew-rosa/LICENSE b/docker-brew-rosa/LICENSE new file mode 100644 index 0000000..d7f1051 --- /dev/null +++ b/docker-brew-rosa/LICENSE @@ -0,0 +1,339 @@ +GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {description} + Copyright (C) {year} {fullname} + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + {signature of Ty Coon}, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/docker-brew-rosa/README.md b/docker-brew-rosa/README.md new file mode 100644 index 0000000..5c528e2 --- /dev/null +++ b/docker-brew-rosa/README.md @@ -0,0 +1,9 @@ +docker-brew-openmandriva +================== + +Scripts and files to create OpenMandriva official docker base images. + +https://www.openmandriva.org/ + +# Build base chroot +sudo sh mkimage-urpmi.sh --rootfs=/tmp/ --version=cooker --arch=x86_64 diff --git a/docker-brew-rosa/cooker/Dockerfile b/docker-brew-rosa/cooker/Dockerfile new file mode 100644 index 0000000..25ffcae --- /dev/null +++ b/docker-brew-rosa/cooker/Dockerfile @@ -0,0 +1,7 @@ +# Dockerfile to create OpenMandriva linux 2014/cooker base images +# Create base image with mkimage-urpmi.sh script +# + +FROM scratch +MAINTAINER "Alexander Stefanov-Khryukin" +ADD rootfs-cooker.tar.xz / diff --git a/docker-brew-rosa/cooker/README.md b/docker-brew-rosa/cooker/README.md new file mode 100644 index 0000000..4ae1246 --- /dev/null +++ b/docker-brew-rosa/cooker/README.md @@ -0,0 +1,5 @@ +Build image + +```bash +docker build --tag=openmandriva/cooker --file Dockerfile . +``` diff --git a/docker-brew-rosa/mkimage-urpmi.sh b/docker-brew-rosa/mkimage-urpmi.sh new file mode 100755 index 0000000..7e198d9 --- /dev/null +++ b/docker-brew-rosa/mkimage-urpmi.sh @@ -0,0 +1,187 @@ +#!/usr/bin/env bash +# +set -e + +mkimg="$(basename "$0")" + +usage() { + echo >&2 "usage: $mkimg --rootfs=rootfs_path --version=openmandriva_version [--mirror=url]" + echo >&2 " $mkimg --rootfs=/tmp/rootfs --version=3.0 --arch=x86_64 --with-updates" + echo >&2 " $mkimg --rootfs=/tmp/rootfs --version=openmandriva2014.0 --arch=x86_64" + echo >&2 " $mkimg --rootfs=. --version=cooker --mirror=http://abf-downloads.openmandriva.org/cooker/repository/x86_64/main/release/" + echo >&2 " $mkimg --rootfs=. --version=cooker" + exit 1 +} + +optTemp=$(getopt --options '+d,v:,m:,a:,s,u,U,p,h,+x' --longoptions 'rootfs:,version:,mirror:,arch:,with-systemd,with-updates,without-user,with-passwd,help,extra-package:' --name mkimage-urpmi -- "$@") +eval set -- "$optTemp" +unset optTemp + +extra_packages="" + +while true; do + case "$1" in + -d|--rootfs) rootfsdir=$2 ; shift 2 ;; + -v|--version) installversion="$2" ; shift 2 ;; + -m|--mirror) mirror="$2" ; shift 2 ;; + -a|--arch) arch="$2" ; shift 2 ;; + -s|--with-systemd) systemd=systemd ; shift ;; + -u|--with-updates) updates=true ; shift ;; + -u|--with-passwd) passwd=true ; shift ;; + -U|--without-user) without_user=true ; shift ;; + -h|--help) usage ;; + -x|--extra-package) extra_packages="$extra_packages $2" ; shift 2 ;; + --) shift ; break ;; + esac +done + +target_dir="$rootfsdir/rootfs" + +errorCatch() { + echo "Error catched. Exiting" + rm -rf $target_dir + exit 1 +} + +trap errorCatch ERR SIGHUP SIGINT SIGTERM + +if [ -z $installversion ]; then +# Attempt to match host version + if [ -r /etc/distro-release ]; then + installversion="$(rpm --eval %distro_release)" + else + echo "Error: no version supplied and unable to detect host openmandriva version" + exit 1 + fi +fi + +if [ -z $mirror ]; then +# No repo provided, use main + mirror=http://abf-downloads.openmandriva.org/$installversion/repository/$arch/main/release/ + update_mirror=http://abf-downloads.openmandriva.org/$installversion/repository/$arch/main/updates/ +fi + + +# run me here +install_chroot(){ + urpmi.addmedia main_release $mirror --urpmi-root "$target_dir"; +if [ ! -z $updates ]; then + urpmi.addmedia main_updates $update_mirror --urpmi-root "$target_dir"; +fi + urpmi basesystem-minimal passwd urpmi distro-release-OpenMandriva locales locales-en $systemd \ + --auto \ + --no-suggests \ + --no-verify-rpm \ + --urpmi-root "$target_dir" \ + --root "$target_dir" + + if [[ $? != 0 ]]; then + echo "Creating urpmi chroot failed." + errorCatch + fi +} + +arm_platform_detector(){ + +filestore_url="http://file-store.openmandriva.org/api/v1/file_stores" + +probe_cpu() { +cpu="$(uname -m)" +case "$cpu" in + i386|i486|i586|i686|i86pc|BePC|x86_64) + cpu="i386" + ;; + armv[4-9]*) + cpu="arm" + ;; + aarch64) + cpu="aarch64" + ;; +esac + +# create path +if [[ "$arch" == "aarch64" ]]; then + if [ $cpu != "aarch64" ] ; then + mkdir -p $target_dir/usr/bin/ + sudo sh -c "echo '$arch-mandriva-linux-gnueabi' > /etc/rpm/platform" + cp /usr/bin/qemu-static-aarch64 $target_dir/usr/bin/ + fi +fi + +if [[ "$arch" == "armv7hl" ]]; then + if [ $cpu != "arm" ] ; then + mkdir -p $target_dir/usr/bin/ + sudo sh -c "echo '$arch-mandriva-linux-gnueabi' > /etc/rpm/platform" + cp /usr/bin/qemu-static-arm $target_dir/usr/bin/ + fi +fi +} +probe_cpu +} + +arm_platform_detector +install_chroot + +if [ ! -z $systemd ]; then + echo -e "--------------------------------------" + echo -e "Creating image with systemd support." + echo -e "--------------------------------------\n" + systemd="systemd" +fi + +if [ ! -z $systemd ]; then +# Prevent systemd from starting unneeded services + (cd $target_dir/lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \ + rm -f $target_dir/lib/systemd/system/multi-user.target.wants/*;\ + rm -f $target_dir/etc/systemd/system/*.wants/*;\ + rm -f $target_dir/lib/systemd/system/local-fs.target.wants/*; \ + rm -f $target_dir/lib/systemd/system/sockets.target.wants/*udev*; \ + rm -f $target_dir/lib/systemd/system/sockets.target.wants/*initctl*; \ + rm -f $target_dir/lib/systemd/system/basic.target.wants/*;\ + rm -f $target_dir/lib/systemd/system/anaconda.target.wants/*; +fi + +if [ -d "$target_dir/etc/sysconfig" ]; then +# allow networking init scripts inside the container to work without extra steps + echo 'NETWORKING=yes' > "$target_dir/etc/sysconfig/network" +fi + +# make sure /etc/resolv.conf has something useful in it +mkdir -p "$target_dir/etc" +cat > "$target_dir/etc/resolv.conf" <<'EOF' +nameserver 8.8.8.8 +nameserver 8.8.4.4 +EOF + +if [ ! -z "$without_user" ]; then + # Create user omv, password omv + echo 'omv:x:1001:1001::/home/omv:/bin/bash' >>"$target_dir"/etc/passwd + echo 'omv:$6$rG3bQ92hkTNubV1p$5qPB9FoXBhNcSE1FOklCoEDowveAgjSf2cHYVwCENZaWtgpFQaRRRN5Ihwd8nuaKMdA1R1XouOasJ7u5dbiGt0:17302:0:99999:7:::' >>"$target_dir"/etc/shadow + echo 'omv:x:1001:' >>"$target_dir"/etc/group + sed -i -e 's,wheel:x:10:$,wheel:x:10:omv,' "$target_dir"/etc/group +fi + +if [ ! -z "$passwd" ]; then + ROOT_PASSWD="root" + echo "change password to $ROOT_PASSWD" + sudo chroot $target_dir /bin/bash -c "echo '$ROOT_PASSWD' |passwd root --stdin" + + cat << EOF > "$target_dir"/README.omv +OpenMandriva $installversion distro +default login\password is root:root +You must change it! +EOF +fi + +if [ ! -z $systemd ]; then + tarFile="$rootfsdir/rootfs-${arch}-systemd.tar.xz" +else + tarFile="$rootfsdir/rootfs-${arch}.tar.xz" +fi + +pushd $target_dir +rm -fv usr/bin/qemu-* +tar --numeric-owner -caf $tarFile -c . +popd +rm -rf $target_dir +rm -fv /etc/rpm/platform diff --git a/download_sources.sh b/download_sources.sh new file mode 100755 index 0000000..135e017 --- /dev/null +++ b/download_sources.sh @@ -0,0 +1,39 @@ +#!/bin/bash +do_restore() { +abfyml=.abf.yml + +local file sha +if [ -e "${abfyml}" ]; then + echo "parsing file '${abfyml}'" + sed -ne '/^[Ss]ources\:.*$/,$p' ${abfyml} | \ + sed -rn '$G;s/^[\"'\''[:space:]]*([^[:space:]:\"'\'']+)[\"'\''[:space:]]*.*[\"'\''[:space:]]*([0-9a-fA-F]{40})[\"'\''[:space:]]*$/\1 \2/p' | \ + + while read -r file sha; do + echo -n "found entry: file=${file} ... " + if [ -e "${file}" ]; then + if echo "${sha} ${file}" | sha1sum -c --status; then + echo "sha1sum correct" + else + echo "sha1sum INCORRECT! skipping..." + fi + else + echo -n "try to download... " + if curl -L "http://file-store.openmandriva.org/download/${sha}" -o "${file}"; then + echo "ok" + echo -n "check sum... " + if echo "${sha} ${file}" | sha1sum -c --status; then + echo "ok" + else + echo "sha1sum INCORRECT! skipping..." + echo "remove file ${file}" + rm -f "${file}" + fi + else + echo "filed! skipping..." + fi + fi + done +fi +} + +do_restore