importing base-armhfp and stage3, including in one repository

This commit is contained in:
mudler
2016-01-07 23:20:25 +01:00
parent b6770a83d7
commit f410168b74
10 changed files with 648 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
FROM sabayon/gentoo-stage3-base-armhf
MAINTAINER mudler <mudler@sabayonlinux.org>
# Supporting crossbuilding with binfmt
ADD ext/qemu-arm-static /usr/bin/qemu-arm-binfmt
# Set locales to en_US.UTF-8
RUN echo "en_US.UTF-8 UTF-8 " >> /etc/locale.gen && locale-gen && eselect locale set en_US.utf8 && env-update && source /etc/profile
ENV LC_ALL=en_US.UTF-8
# Upgrading portage and installing necessary packages
RUN rm -rf '/usr/portage/metadata/timestamp.chk' && \
emerge --sync --quiet && \
layman -S && layman -a sabayon && layman -a sabayon-distro
# Configure the sabayon box, installing equo setting up locales
ADD ./script/sabayon-configuration.sh /
RUN /bin/bash /sabayon-configuration.sh && rm -rf /sabayon-configuration.sh
# Generating empty equo db
ADD ./script/generate-equo-db.sh /
ADD ./ext/equo.sql /
RUN /bin/bash /generate-equo-db.sh && rm -rf /equo.sql /generate-equo-db.sh
# Calling equo rescue generate, unfortunately we have to use expect
ADD ./script/equo-rescue-generate.exp /
RUN /usr/bin/expect /equo-rescue-generate.exp && rm -rf /equo-rescue-generate.exp
# Portage configurations
ADD ./script/sabayon-configuration-build.sh /sabayon-configuration-build.sh
RUN /bin/bash /sabayon-configuration-build.sh && rm -rf /sabayon-configuration-build.sh
# Cleanup and applying configs
ADD ./script/post-update.sh /post-update.sh
RUN /bin/bash /post-update.sh && rm -rf /post-update.sh
+77
View File
@@ -0,0 +1,77 @@
# Sabayon base: a Docker Project #
Attention! It's under strong development
State: Alpha
The purpose of this project is to provide an image of Sabayon base.
It is just a gentoo stage3 + entropy
UPDATE: Images are also on Docker Hub [sabayon/base-armhfp](https://registry.hub.docker.com/u/sabayon/base-armhfp/) and the already squashed image,
[sabayon/base-armhfp-squashed](https://registry.hub.docker.com/u/sabayon/base-armhfp-squashed/)
## First steps on docker
Ensure to have the daemon started and running:
sudo systemctl start docker
## Building sabayon-base locally
git clone https://github.com/mudler/docker-sabayon-base-armhfp.git docker-sabayon-base
cd docker-sabayon-base
sudo docker build -t sabayon/base-armhfp .
## Pulling sabayon-base from Docker Hub
sudo docker pull sabayon/base-armhfp
## Converting the image from Docker to use it with [Molecules](https://github.com/Sabayon/molecules)
### Only with undocker, without squashing the layers
After pulling the docker image, install [undocker](https://github.com/larsks/undocker/) and then as root:
docker save sabayon/base-armhfp:latest | undocker -i -o base sabayon/base-armhfp:latest
### Using [docker-squash](https://github.com/jwilder/docker-squash)
You can also squash the image with [docker-squash](https://github.com/jwilder/docker-squash) and then extract your layers.
sudo docker save sabayon/base-armhfp:latest | sudo TMPDIR=/dev/shm docker-squash -t sabayon/base-armhfp:squashed > /your/prefered/path/base.tar
You can replace /dev/shm with your prefered tmpdir
### With undocker, but squashing the layers
The squash can also been accomplished creating a container from the image, exporting it and then importing it back.
sudo docker run -t -i sabayon/base-armhfp:latest /bin/bash
$ exit # You should drop in a shell, exit, you should see a container id, otherwise find it :
sudo docker ps -l
sudo docker export <CONTAINER ID> | docker import - sabayon/base-armhfp:squashed
docker save sabayon/base-armhfp:squashed | undocker -i -o base sabayon/base-armhfp:squashed
Docker will loose the history revision and then you can estract the layer, using as base for chroot.
You now have the tree on the *base/* directory
If you are planning to use the resulting files as a chroot, don't forget to set a nameserver on resolv.conf file
echo "nameserver 208.67.222.222" > base/etc/resolv.conf
## 2 tricks on crosscompiling/building from an alien architecture
### Enabling arm support
Copy ext/qemu-arm-static to /usr/bin/binfmt, then:
echo ':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:' > /proc/sys/fs/binfmt_misc/register
On the stage3, qemu-arm is not exported by default:
docker run -t -i -v /usr/bin/qemu-arm-binfmt:/usr/bin/qemu-arm-binfmt sabayon/gentoo-stage3-base-armhf uname -m
On the base it is
docker run -t -i sabayon/base-armhf uname -m
+300
View File
@@ -0,0 +1,300 @@
BEGIN TRANSACTION;
CREATE TABLE IF NOT EXISTS baseinfo (
idpackage INTEGER PRIMARY KEY AUTOINCREMENT,
atom VARCHAR,
category VARCHAR,
name VARCHAR,
version VARCHAR,
versiontag VARCHAR,
revision INTEGER,
branch VARCHAR,
slot VARCHAR,
license VARCHAR,
etpapi INTEGER,
trigger INTEGER
);
CREATE TABLE IF NOT EXISTS extrainfo (
idpackage INTEGER PRIMARY KEY,
description VARCHAR,
homepage VARCHAR,
download VARCHAR,
size VARCHAR,
chost VARCHAR,
cflags VARCHAR,
cxxflags VARCHAR,
digest VARCHAR,
datecreation VARCHAR,
FOREIGN KEY(idpackage)
REFERENCES baseinfo(idpackage) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS content (
idpackage INTEGER,
file VARCHAR,
type VARCHAR,
FOREIGN KEY(idpackage)
REFERENCES baseinfo(idpackage) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS contentsafety (
idpackage INTEGER,
file VARCHAR,
mtime FLOAT,
sha256 VARCHAR,
FOREIGN KEY(idpackage)
REFERENCES baseinfo(idpackage) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS provide (
idpackage INTEGER,
atom VARCHAR,
is_default INTEGER DEFAULT 0,
FOREIGN KEY(idpackage)
REFERENCES baseinfo(idpackage) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS dependencies (
idpackage INTEGER,
iddependency INTEGER,
type INTEGER,
FOREIGN KEY(idpackage)
REFERENCES baseinfo(idpackage) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS dependenciesreference (
iddependency INTEGER PRIMARY KEY AUTOINCREMENT,
dependency VARCHAR
);
CREATE TABLE IF NOT EXISTS conflicts (
idpackage INTEGER,
conflict VARCHAR,
FOREIGN KEY(idpackage)
REFERENCES baseinfo(idpackage) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS mirrorlinks (
mirrorname VARCHAR,
mirrorlink VARCHAR
);
CREATE TABLE IF NOT EXISTS sources (
idpackage INTEGER,
idsource INTEGER,
FOREIGN KEY(idpackage)
REFERENCES baseinfo(idpackage) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS sourcesreference (
idsource INTEGER PRIMARY KEY AUTOINCREMENT,
source VARCHAR
);
CREATE TABLE IF NOT EXISTS useflags (
idpackage INTEGER,
idflag INTEGER,
FOREIGN KEY(idpackage)
REFERENCES baseinfo(idpackage) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS useflagsreference (
idflag INTEGER PRIMARY KEY AUTOINCREMENT,
flagname VARCHAR
);
CREATE TABLE IF NOT EXISTS keywords (
idpackage INTEGER,
idkeyword INTEGER,
FOREIGN KEY(idpackage)
REFERENCES baseinfo(idpackage) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS keywordsreference (
idkeyword INTEGER PRIMARY KEY AUTOINCREMENT,
keywordname VARCHAR
);
CREATE TABLE IF NOT EXISTS configprotect (
idpackage INTEGER PRIMARY KEY,
idprotect INTEGER,
FOREIGN KEY(idpackage)
REFERENCES baseinfo(idpackage) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS configprotectmask (
idpackage INTEGER PRIMARY KEY,
idprotect INTEGER,
FOREIGN KEY(idpackage)
REFERENCES baseinfo(idpackage) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS configprotectreference (
idprotect INTEGER PRIMARY KEY AUTOINCREMENT,
protect VARCHAR
);
CREATE TABLE IF NOT EXISTS systempackages (
idpackage INTEGER PRIMARY KEY,
FOREIGN KEY(idpackage)
REFERENCES baseinfo(idpackage) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS injected (
idpackage INTEGER PRIMARY KEY,
FOREIGN KEY(idpackage)
REFERENCES baseinfo(idpackage) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS installedtable (
idpackage INTEGER PRIMARY KEY,
repositoryname VARCHAR,
source INTEGER,
FOREIGN KEY(idpackage)
REFERENCES baseinfo(idpackage) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS sizes (
idpackage INTEGER PRIMARY KEY,
size INTEGER,
FOREIGN KEY(idpackage)
REFERENCES baseinfo(idpackage) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS counters (
counter INTEGER,
idpackage INTEGER,
branch VARCHAR,
PRIMARY KEY(idpackage,branch),
FOREIGN KEY(idpackage)
REFERENCES baseinfo(idpackage) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS trashedcounters (
counter INTEGER
);
CREATE TABLE IF NOT EXISTS needed_libs (
idpackage INTEGER,
lib_user_path VARCHAR,
lib_user_soname VARCHAR,
soname VARCHAR,
elfclass INTEGER,
rpath VARCHAR,
FOREIGN KEY(idpackage)
REFERENCES baseinfo(idpackage) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS provided_libs (
idpackage INTEGER,
library VARCHAR,
path VARCHAR,
elfclass INTEGER,
FOREIGN KEY(idpackage)
REFERENCES baseinfo(idpackage) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS treeupdates (
repository VARCHAR PRIMARY KEY,
digest VARCHAR
);
CREATE TABLE IF NOT EXISTS treeupdatesactions (
idupdate INTEGER PRIMARY KEY AUTOINCREMENT,
repository VARCHAR,
command VARCHAR,
branch VARCHAR,
date VARCHAR
);
CREATE TABLE IF NOT EXISTS licensedata (
licensename VARCHAR UNIQUE,
text BLOB,
compressed INTEGER
);
CREATE TABLE IF NOT EXISTS licenses_accepted (
licensename VARCHAR UNIQUE
);
CREATE TABLE IF NOT EXISTS triggers (
idpackage INTEGER PRIMARY KEY,
data BLOB,
FOREIGN KEY(idpackage)
REFERENCES baseinfo(idpackage) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS entropy_misc_counters (
idtype INTEGER PRIMARY KEY,
counter INTEGER
);
CREATE TABLE IF NOT EXISTS categoriesdescription (
category VARCHAR,
locale VARCHAR,
description VARCHAR
);
CREATE TABLE IF NOT EXISTS packagesets (
setname VARCHAR,
dependency VARCHAR
);
CREATE TABLE IF NOT EXISTS packagechangelogs (
category VARCHAR,
name VARCHAR,
changelog BLOB,
PRIMARY KEY (category, name)
);
CREATE TABLE IF NOT EXISTS automergefiles (
idpackage INTEGER,
configfile VARCHAR,
md5 VARCHAR,
FOREIGN KEY(idpackage)
REFERENCES baseinfo(idpackage) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS packagedesktopmime (
idpackage INTEGER,
name VARCHAR,
mimetype VARCHAR,
executable VARCHAR,
icon VARCHAR,
FOREIGN KEY(idpackage)
REFERENCES baseinfo(idpackage) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS packagedownloads (
idpackage INTEGER,
download VARCHAR,
type VARCHAR,
size INTEGER,
disksize INTEGER,
md5 VARCHAR,
sha1 VARCHAR,
sha256 VARCHAR,
sha512 VARCHAR,
gpg BLOB,
FOREIGN KEY(idpackage)
REFERENCES baseinfo(idpackage) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS provided_mime (
mimetype VARCHAR,
idpackage INTEGER,
FOREIGN KEY(idpackage)
REFERENCES baseinfo(idpackage) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS packagesignatures (
idpackage INTEGER PRIMARY KEY,
sha1 VARCHAR,
sha256 VARCHAR,
sha512 VARCHAR,
gpg BLOB,
FOREIGN KEY(idpackage)
REFERENCES baseinfo(idpackage) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS packagespmphases (
idpackage INTEGER PRIMARY KEY,
phases VARCHAR,
FOREIGN KEY(idpackage)
REFERENCES baseinfo(idpackage) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS packagespmrepository (
idpackage INTEGER PRIMARY KEY,
repository VARCHAR,
FOREIGN KEY(idpackage)
REFERENCES baseinfo(idpackage) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS entropy_branch_migration (
repository VARCHAR,
from_branch VARCHAR,
to_branch VARCHAR,
post_migration_md5sum VARCHAR,
post_upgrade_md5sum VARCHAR,
PRIMARY KEY (repository, from_branch, to_branch)
);
CREATE TABLE IF NOT EXISTS preserved_libs (
library VARCHAR,
elfclass INTEGER,
path VARCHAR,
atom VARCHAR,
PRIMARY KEY (library, path, elfclass)
);
CREATE TABLE IF NOT EXISTS xpakdata (
idpackage INTEGER PRIMARY KEY,
data BLOB
);
CREATE TABLE IF NOT EXISTS settings (
setting_name VARCHAR,
setting_value VARCHAR,
PRIMARY KEY(setting_name)
);
INSERT INTO "settings" VALUES('arch', 'armv7l');
INSERT INTO "settings" VALUES('on_delete_cascade', '1');
INSERT INTO "settings" VALUES('_baseinfo_extrainfo_2010', '1');
INSERT INTO "settings" VALUES('schema_revision', '6');
COMMIT;
BIN
View File
Binary file not shown.
@@ -0,0 +1,26 @@
#!/usr/bin/expect -f
# no need for timeout 1
set timeout -1
spawn equo rescue generate
expect {
"*Understood*" { send "Yes\r\n" ; exp_continue }
"*Really*" { send "Yes\r\n" ; exp_continue }
"*Ok*" { send "Yes\r\n" ; exp_continue }
"*generation complete*" { sleep 3; send "exit\r"; exit }
# timeout { puts "timed out during generation"; exit 1 }
}
expect EOF
puts $expect_out(buffer)
lassign [wait] pid spawnid os_error_flag value
if {$os_error_flag == 0} {
puts "exit status: $value"
} else {
puts "errno: $value"
}
+9
View File
@@ -0,0 +1,9 @@
#!/bin/bash
mkdir -p /var/lib/entropy/client/database/armv7l
cd /var/lib/entropy/client/database/armv7l
cat /equo.sql | sqlite3 equo.db
# remove files used to generate a correct equo db
rm -rfv /equo.sql
rm -rfv /generate-equo-db.sh
+68
View File
@@ -0,0 +1,68 @@
#!/bin/bash
PACKAGES_TO_REMOVE=(
)
FILES_TO_REMOVE=(
"/.viminfo"
"/.history"
"/.zcompdump"
"/var/log/emerge.log"
"/var/log/emerge-fetch.log"
"/usr/portage/licenses"
"/etc/entropy/packages/license.accept"
"/equo-rescue-generate.exp"
"/equo.sql"
"/generate-equo-db.sh"
"/post-upgrade.sh"
"/sabayon-configuration-build.sh"
"/sabayon-configuration.sh"
"/post-upgrade.sh"
# Cleaning portage metadata cache
"/usr/portage/metadata/md5-cache/*"
"/var/log/emerge/*"
"/var/log/entropy/*"
"/root/* /root/.*"
"/etc/zsh"
"/post-update.sh"
# cleaning licenses accepted
"/usr/portage/licenses"
)
# removing portage and keeping profiles and metadata)
#ls /usr/portage/ | grep -v 'profiles' | grep -v 'metadata' | xargs rm -rf
mkdir -p /etc/portage/repos.conf/
echo "[DEFAULT]
main-repo = gentoo
[gentoo]
location = /usr/portage
sync-type = rsync
sync-uri = rsync://rsync.europe.gentoo.org/gentoo-portage
" > /etc/portage/repos.conf/gentoo.conf
# Upgrading packages
rsync -av "rsync://rsync.at.gentoo.org/gentoo-portage/licenses/" "/usr/portage/licenses/" && ls /usr/portage/licenses -1 | xargs -0 > /etc/entropy/packages/license.accept && \
echo -5 | equo conf update
# Cleanup
#equo rm --deep --configfiles --force-system "${PACKAGES_TO_REMOVE[@]}"
# Remove compilation tools
#equo rm --nodeps --force-system autoconf automake bison yacc gcc localepurge
# Writing package list file
equo q list installed -qv > /etc/sabayon-pkglist
equo cleanup
# Cleanup
rm -rf "${FILES_TO_REMOVE[@]}"
@@ -0,0 +1,21 @@
#!/bin/bash
# fetch the bits!
cd /opt
git clone git://github.com/Sabayon/build.git sabayon-build
cd /opt/sabayon-build/conf/armhfp/portage
# keep your specific stuff in "myconf" branch:
#git checkout -b myconf
# symlink to your <arch>:
#ln -sf make.conf make.conf
#ln -sf package.env package.env
# add & commit
#git add make.conf package.env
git config --global user.name "root"
git config --global user.email "root@localhost"
#git commit -m "saving my configurations"
# rename the gentoo /etc/make.conf and /etc/portage/:
cd /etc/
mv portage portage-gentoo
#mv make.conf make.conf-gentoo
# symlink to sabayon /etc/make.conf /etc/portage/:
ln -sf /opt/sabayon-build/conf/armhfp/portage portage
@@ -0,0 +1,46 @@
#!/bin/bash
# Setting locale.conf
for f in /etc/env.d/02locale /etc/locale.conf; do
echo LANG=en_US.UTF-8 > "${f}"
echo LANGUAGE=en_US.UTF-8 >> "${f}"
echo LC_ALL=en_US.UTF-8 >> "${f}"
done
# Defyning /usr/local/portage configuration
mkdir /usr/local/portage
mkdir -p /usr/local/portage/metadata/
mkdir -p /usr/local/portage/profiles/
echo "masters = gentoo" > /usr/local/portage/metadata/layout.conf
echo "user_defined" > /usr/local/portage/profiles/repo_name
mkdir -p /etc/portage/package.keywords/
echo "app-admin/equo ~arm
sys-apps/entropy ~arm
" > /etc/portage/package.keywords/00-sabayon.package.keywords
mkdir -p /etc/portage/package.use/
echo "dev-lang/python sqlite
sys-apps/file python
" > /etc/portage/package.use/00-sabayon.package.use
# emerging equo and expect
USE="ncurses" emerge -j -vt equo --autounmask-write || exit 1
emerge -j expect || exit 1
# Enforce choosing only python2.7 for now, cleaning others
eselect python set python2.7
# Specifying a gentoo profile
eselect profile set default/linux/arm/13.0/desktop
# default to opendns for next stage(s)
echo "nameserver 8.8.8.8" > /etc/resolv.conf
# set default shell
chsh -s /bin/bash
rm -rf /etc/make.profile
Executable
+65
View File
@@ -0,0 +1,65 @@
#!/bin/bash
set -e
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
stage3="$(wget -qO- 'http://distfiles.gentoo.org/releases/arm/autobuilds/latest-stage3-armv7a_hardfp.txt' | grep -v '#' | awk '{print $1}')"
if [ -z "$stage3" ]; then
echo >&2 'wtf failure'
exit 1
fi
url="http://distfiles.gentoo.org/releases/arm/autobuilds/$stage3"
name="$(basename "$stage3")"
( set -x; wget -N "$url" )
base="${name%%.*}"
image="gentoo-temp:$base"
container="gentoo-temp-$base"
# bzcat thanks to https://code.google.com/p/go/issues/detail?id=7279
( set -x; bzcat "$name" | docker import - "$image" )
docker rm -f "$container" > /dev/null 2>&1 || true
( set -x; docker run -t -v "$PWD"/artifacts:/usr/portage/packages --name "$container" "$image" bash -exc $'
export MAKEOPTS="-j$(nproc)"
#pythonTarget="$(emerge --info | sed -n \'s/.*PYTHON_TARGETS="\\([^"]*\\)".*/\\1/p\')"
#pythonTarget="${pythonTarget##* }"
pythonTarget="python2_7"
echo \'PYTHON_TARGETS="\'$pythonTarget\'"\' >> /etc/portage/make.conf
echo \'PYTHON_SINGLE_TARGET="\'$pythonTarget\'"\' >> /etc/portage/make.conf
mkdir /usr/portage
mkdir -p /etc/portage/repos.conf/
echo "[DEFAULT]
main-repo = gentoo
[gentoo]
location = /usr/portage
sync-type = rsync
sync-uri = rsync://rsync.europe.gentoo.org/gentoo-portage
" > /etc/portage/repos.conf/gentoo.conf
emerge --sync
eselect profile set default/linux/arm/13.0/desktop
emerge --buildpkg -j 2 --newuse --deep --with-bdeps=y @system @world
emerge -C editor ssh man man-pages openrc e2fsprogs service-manager
emerge --buildpkg -j 2 layman
emerge --depclean
rm -rf /usr/portage/packages
' )
xz="$base.tar"
( set -x; docker export "$container" > "$xz" )
docker rm "$container"
docker rmi "$image"
echo 'FROM scratch' > Dockerfile
echo "ADD $xz /" >> Dockerfile
echo 'CMD ["/bin/bash"]' >> Dockerfile
( set -x; docker build -t "sabayon/gentoo-stage3-base-armhfp" . )