- Most of my major changes were documented here: http://fossjon.wordpress.com/2012/09/18/bootstrapping-fedora-arm-for-a-new-arch-v6hl/
Note: These steps assume you have a gcc
compiler capable of producing the correct assembly instructions for the intended new arch
Step 1: Add the necessary architecture definitions
/usr/lib/rpm/platform/armv6hl-linux/macros
... %optflags -O2 -g -march=armv6 -mfloat-abi=hard -mfpu=vfp %__isa_name armv6hl ...
/usr/lib/rpm/{,redhat}/{rpmrc,macros}
... optflags: armv6hl -O2 -g -march=armv6 -mfloat-abi=hard -mfpu=vfp arch_canon: armv6hl: armv6hl 12 buildarchtranslate: armv6hl: armv6hl arch_compat: armv6hl: armv7hnl buildarch_compat: armv6hl: armv7hnl ... %arm armv3l armv4b armv4l armv4tl armv5tel armv5tejl armv6l armv6hl armv7l armv7hl armv7hnl ... optflags: armv6hl %{__global_cflags} -march=armv6 -mfloat-abi=hard -mfpu=vfp buildarchtranslate: armv6hl: armv7hnl ...
/usr/lib/python2.7/site-packages/rpmUtils/arch.py
... "armv6hl": "armv7hnl", ...
Step 2: Compile the latest version of gcc for your related arch using rpmbuild (--target armv6hl)
Step 3: Modify mock to hijack && inject these new files into all future build roots
/usr/sbin/mock
... def do_rebuild(config_opts, chroot, srpms): ... chroot.init() ldst = (chroot.basedir+"/root"+"/usr/lib/rpm/platform") import shutil shutil.copytree("/usr/lib/rpm/platform/armv6hl-linux",ldst+"/armv6hl-linux") os.system("for f in /usr/lib/rpm/{,redhat}/{rpmrc,macros} ; do cp -fv \"$f\" \""+chroot.basedir+"/root/$f\" ; done") lcmd = ("/bin/rpm --force --ignorearch --nodeps --root "+chroot.basedir+"/root/ -i /repo/gcc-4.7.0-5.fc17/*.rpm") os.system(lcmd) chroot.build(srpm, timeout=config_opts['rpmbuild_timeout']) ...
Step 4: Build glibc and all other needed packages using mock (use a helper shell script loop && make sure to patch rpm/yum/redhat-rpm-config later)
/etc/mock/f17v6.cfg
... config_opts['target_arch'] = 'armv6hl' ...
Step 4.5.0: rpm C code (unified diff patch)
rpm-x.x/lib/rpmrc.c
... +# if defined(__linux__) && defined(__arm__) + { + if (strcmp(un.machine, "armv7l") == 0 ) { + if (has_neon() && has_hfp()) + strcpy(un.machine, "armv7hnl"); + else if (has_hfp()) + strcpy(un.machine, "armv7hl"); + } + if (strcmp(un.machine, "armv6l") == 0 ) { + if (has_neon() && has_hfp()) + strcpy(un.machine, "armv6hnl"); + else if (has_hfp()) + strcpy(un.machine, "armv6hl"); + strcpy(un.machine, "armv6hl"); + } + } +# endif /* arm*-linux */ + ...
Step 4.5.1: yum Python script (mod)
yum-x.x/{yum/misc.py,rpmUtils/arch.py}
... os.uname().replace("armv6l","armv6hl").replace("armv7l","armv6hl").replace("armv7hl","armv6hl") ...
Step 5: Install a core set of packages needed for a minimal boot (use a capable host/arch)
compose.sh
#!/bin/bash #Repo var is the path to a repo folder #root var is the path to the chroot folder if [ "$repo" == "" -o "$root" == "" ] ; then exit 1 ; fi setenforce 0 # search through repo folder for all files chooses which files and places those files in a list text file for pkgn in 'acl' 'attr' 'audit' 'authconfig' 'basesystem' 'bash' 'binutil' 'bzip' 'ca-certificate' 'chkconfig' 'cpio' 'coreutil' 'cracklib' 'cryptsetup' 'curl' '.*curses' 'cyrus-sasl' 'db4' 'dbus' 'dbus-glib' 'diffutil' 'dracut' 'e2fsprog' 'elfutil' 'expat' 'fedora-release' '/file' 'findutil' 'fipscheck' 'gamin' 'gawk' 'gcc' 'gdbm' 'generic-release' 'glib' 'gmp' 'gnupg2' 'gpgme' 'grep' 'gzip' 'hardlink' 'hostname' 'hwdata' 'initscript' 'iproute' 'iptable' 'iputil' '.*kernel' 'keyutil' 'kmod' 'krb5' 'libassuan' 'libcap.*' 'libdb' 'libedit' 'libffi' 'libgcrypt' 'libgpg-error' 'libidn' 'libpwquality' 'libse' 'libssh2' 'libus' 'libut' 'libxml2' 'linux-atm' 'logrotate' 'lua' 'lvm2' 'mingetty' 'net-tool' 'newt' 'nspr' '/nss.*' '/openss' 'openldap' 'pam' 'passwd' 'pcre' 'pinentry' 'pkgconfig' 'popt' 'procps' 'psmisc' 'pth' 'pygpgme' 'python' 'python-chardet' 'python-iniparse' 'python-kitchen' 'python-pycurl' 'python-urlgrabber' 'readline' '/rpm' 'sed' '/setup' 'shadow-util' 'shared-mime-info' 'slang' 'sqlite' 'syslog' 'systemd' 'sysvinit' 'tcp_wrapper' 'texinfo' 'tzdata' 'udev' 'ustr' 'util-linux' 'xz' 'yum' 'yum-metadata-parser' 'yum-util' 'zlib' ; do fill=`find $repo -type f | grep -i "/[^/-]*$pkgn[^/-]*-[^/-]*-[^/-]*/[^/]*.rpm$" | grep -Eiv '(-debuginfo-|.src.rpm)'` ; if [ "$fill" == "" ] ; then echo "FOF $pkgn" 1>&2 ; continue ; fi ; echo "$fill" ; done | sort | uniq | grep -Eiv '/(audispd-plugins|audit-libs-devel|audit-libs-static|cmirror|cpp|cryptsetup-devel|cryptsetup-python|cyrus-sasl-sql|dbus-glib-devel|dracut-fips|emacs-libidn|gcc|glib2-devel|glib2-static|glibc-devel|glibc-headers|glibc-static|glibc-utils|gnupg2-smime|krb5-server|libcap-ng-devel|libgcrypt-devel|libgcj|libgfortran|libgudev1-devel|libitm|libmudflap|libselinux-python|libsemanage-python|libuser-devel|linux-atm-libs-devel|lvm2-cluster|newt-devel|newt-static|openldap-devel|openldap-servers|openldap-servers-sql|openssh-askpass|openssh-ldap|openssl-devel|openssl-perl|openssl-static|pam_|passwdqc|policycoreutils-python|policycoreutils-sandbox|python[0-9]*-debug|python[0-9]*-devel|python[0-9]*-test|python[0-9]*-tkinter|python[0-9]*-tools|rpm-build-[0-9]|rpm-cron|rpm-devel|rpm-sign|rpmdevtools|rpmlint|rsyslog-gnutls|rsyslog-libdbi|rsyslog-mysql|rsyslog-pgsql|rsyslog-relp|rsyslog-snmp|rsyslog-udpspoof|setuptool|slang-slsh|sqlite-tcl|systemd-analyze|texinfo-tex|tkinter|yum-cron|yum-plugin-changelog|yum-plugin-local|yum-plugin-puppetverify|yum-plugin-refresh-updatesd|yum-plugin-tmprepo)[^/-]*-[^/]*$' > pkglist.txt #for p in $(rpm --force --ignorearch --root $root/ -i $(cat pkglist.txt | grep -Eiv '(gtk|gui|qt|x11)') 2>&1 | awk '{ print $1","$NF }' | sort | uniq) ; do a=$(echo "$p" | cut -d ',' -f 1) ; b=$(echo "$p" | cut -d ',' -f 2) ; q=$(repoquery --whatprovides "$a" | head -n 1) ; r=$(repoquery -qi "$q" | grep -i '^source') ; echo "[$b] -> [$a] -> [$q] -> [$r]" ; done rpm --force --ignorearch --nodeps --root $root/ -i $(cat pkglist.txt | grep -Eiv '(gtk|gui|qt|x11)') x2 rm -frv $root/usr/share/*doc* cat << EOF > $root/etc/fstab LABEL="rootfs" / ext4 defaults,noatime 1 1 LABEL="boot" /boot vfat noauto,comment=systemd.automount 1 2 EOF cat << EOF > $root/etc/sysconfig/network HOSTNAME=raspiv6hl.local EOF cat << EOF > $root/etc/resolv.conf nameserver 4.2.2.1 EOF echo 'utmp:x:22:' >> $root/etc/group echo 'PS1="[\u@\h: \w]# "' > $root/root/.bashrc chmod 755 $root/root/.bashrc ln -s .bashrc $root/root/.profile #raspberrypi sed -i 's|root:.*:|root:$6$KW0GGbE5$zlEB9.PbHVh8kmXj1WMFGLJGwwthhU4oXn2oNxHZllbUSzTsVhTZ9jts8RC7uicuUCWyrsZ1e2yEj4ErDLOHQ/:15525:0:99999:7:::|' $root/etc/shadow rm -fv $root/etc/systemd/system/default.target && ln -s /usr/lib/systemd/system/multi-user.target $root/etc/systemd/system/default.target
Step 6: Boot the new Fedora ARM Linux system
<a href="http://fossjon.files.wordpress.com/2012/09/photo.jpg"><img src="http://fossjon.files.wordpress.com/2012/09/photo.jpg?w=630" alt="" /></a>