We have moved to a new Sailfish OS Forum. Please start new discussions there.
13

HowTo: Install a chroot for building apps

asked 2014-02-10 21:48:19 +0200

AL13N gravatar image

updated 2014-02-11 01:39:58 +0200

jgr gravatar image

I've been looking for a way to install a chroot on the device in order to build the apps and not destroy your phone.

Since there's btrfs, a subvolume looks handy (to snapshot from) and pkcon is based on zypper, which has a --root option...

edit retag flag offensive close delete

Comments

So maybe a stupid question, but why would building apps in the main filesystem destroy the phone? I know some devel packages have broken dependencies (due to opengl conflicts between libhybris and mesa), but is that really a problem? I currently build in the main fs on the phone...

mornfall ( 2014-03-15 13:02:19 +0200 )edit
2

depending on conflicts, packages could be removed, or sometimes replaced (by something that might not work). otoh, i would keep the phone system as clean as possible so that later upgrades and stuff don't fail, or well, just to minimize deviation from the well-tested basic system.

but the main advantages of chroot building, is to be able to snapshot for each package, so that you can accurately find the buildrequires (if you want to upstream your work). and remove snapshots that you don't need etc...

AL13N ( 2014-03-15 19:18:52 +0200 )edit

2 Answers

Sort by » oldest newest most voted
15

answered 2014-02-10 22:15:05 +0200

AL13N gravatar image

updated 2014-03-30 01:08:44 +0200

as root:

pkcon install zypper
mkdir /chroot
btrfs subvolume create /chroot/base
mkdir /chroot/base/dev
cp -a /dev/zero /chroot/base/dev/zero
mkdir /chroot/base/etc
cp -ar /etc/zypp /chroot/base/etc/
cp -a /etc/boardname /chroot/base/etc/
zypper --root /chroot/base refresh
zypper --root /chroot/base install basesystem rpm rpm-build curl vim-enhanced PackageKit tar make gcc gcc-c++ meego-rpm-config libstdc++-devel
cp /etc/rpm/platform /chroot/base/etc/rpm/

After this, you can chroot and install other stuff... though i usually leave this and snapshot from the base for each package independantly: btrfs subvolume snapshot /chroot/base /chroot/packages/package

NOTE: for some reason, the ssu commands in the chroot are only partly working... the authenticated ones seem not there... mount --bind the store OTP key doesn't help... for now i'm installing packages from outside chroot

apparently using --target armv7hl-meego-linux (in the rpmbuild --rebuild ) works, but you can't install in the chroot itself... this leads me to believe, i'm missing one part... there's a /etc/rpm/platform file in regular setups, maybe it's related to that...

building packages:

  • it seems the best way is to use rpmbuild --target armv7hl-meego-linux --rebuild file.src.rpm to avoid building for the wrong target (it seems odd that the default build target isn't for it's own device though)
  • start by installing src.rpm or putting source in ~/rpmbuild/SOURCES/ and writing a ~/rpmbuild/SPECS/package.spec
  • then, build the source rpm thusly: rpmbuild -bs ~/rpmbuild/SPECS/file.spec
  • finally, rebuild the resulting ~/rpmbuild/SRPMS/package-version.src.rpm with
  • rpmbuild --target armv7hl-meego-linux --rebuild ~/rpmbuild/SRPMS/package-version.src.rpm
  • resulting files will be in ~/rpmbuild/RPMS/noarch/ or ~/rpmbuild/RPMS/armv7hl/
  • profit!!!

(too bad there is no find-file-in-package option in zypper or pkcon ... fedora & opensuse handle this by adding all files to the provides section... talk about dirty stuff... i guess this could be a reason why the resolver does some odd things...)

edit flag offensive delete publish link more

Comments

Many thanks for the instructions. I had to copy the /etc/rpm/platform file into my chroot and install meego-rpm-config into it. Now packaging works fine, tested with gcl and maxima, which refused to build in scratchbox.

Eierkopp ( 2014-03-22 14:21:30 +0200 )edit

@Eierkopp thanks for the help, i adjusted the post accordingly. meego-rpm-config had already been in there, did you miss that from the instructions?

AL13N ( 2014-03-23 13:56:23 +0200 )edit

I had to add rpm-build to the list of packages for zypper to install in order to get rpmbuild in the chroot

gcobb ( 2014-03-29 01:44:58 +0200 )edit

indeed, i forgot the most obvious one in the list :-)

AL13N ( 2014-03-30 01:08:15 +0200 )edit

@ALI3N Will you use chroot environment on sdcard?

Daeto ( 2016-07-31 14:53:32 +0200 )edit
1

answered 2015-04-21 16:47:32 +0200

antsuke gravatar image

i found a script called JuJu that makes arch linux chroot. github entry

edit flag offensive delete publish link more
Login/Signup to Answer

Question tools

Follow
8 followers

Stats

Asked: 2014-02-10 21:48:19 +0200

Seen: 2,172 times

Last updated: Apr 21 '15