From Mageia wiki
Jump to: navigation, search
(Creation and traduction of the english page)
 
m (Remaniement des numérotations des chapites)
Line 20: Line 20:
 
* access to a Mageia mirror, either remote (http/ftp/rsync...) or local (nfs/cdrom/file...)
 
* access to a Mageia mirror, either remote (http/ftp/rsync...) or local (nfs/cdrom/file...)
  
=== Installation d'un chroot ===
+
== Installation d'un chroot ==
  
 
You need to create your working directory. ({{File|/mnt/chroot/cauldron}} for eg). This directory will host your chrooted Mageia system
 
You need to create your working directory. ({{File|/mnt/chroot/cauldron}} for eg). This directory will host your chrooted Mageia system
Line 41: Line 41:
 
A list of mirrors is available at https://mirrors.mageia.org/
 
A list of mirrors is available at https://mirrors.mageia.org/
  
=== Installer un système de base ===
+
== Installer un système de base ==
  
 
The minimum required packages for an operational chroot are:
 
The minimum required packages for an operational chroot are:
Line 53: Line 53:
 
     urpmi  --urpmi-root /mnt/chroot/cauldron basesystem urpmi locales-fr syslinux
 
     urpmi  --urpmi-root /mnt/chroot/cauldron basesystem urpmi locales-fr syslinux
  
=== Accédez au chroot ===
+
== Accédez au chroot ==
  
 
To access the chroot;
 
To access the chroot;
Line 61: Line 61:
 
Inside the self-contained chroot, you can work with it as a regular system. You can ''exit'' the chroot with the {{Cmd|exit}} command.
 
Inside the self-contained chroot, you can work with it as a regular system. You can ''exit'' the chroot with the {{Cmd|exit}} command.
  
== Configuration minimale ==
+
= Configuration minimale =
  
 
* DNS Setup: In order to have a working network connection within our chroot, you have to fill in {{File|/mnt/chroot/cauldron/etc/resolv.conf}}, the dns ip address of your provider. You can simply copy your working {{File|/etc/resolv.conf}} into the chroot {{File|/mnt/chroot/cauldron/etc/resolv.conf}}
 
* DNS Setup: In order to have a working network connection within our chroot, you have to fill in {{File|/mnt/chroot/cauldron/etc/resolv.conf}}, the dns ip address of your provider. You can simply copy your working {{File|/etc/resolv.conf}} into the chroot {{File|/mnt/chroot/cauldron/etc/resolv.conf}}
Line 71: Line 71:
 
     mount -o bind /proc /mnt/chroot/cauldron/proc
 
     mount -o bind /proc /mnt/chroot/cauldron/proc
  
== Construire des paquets ==
+
= Construire des paquets =
  
 
In the chroot environment, you should now install the following packages:
 
In the chroot environment, you should now install the following packages:
Line 83: Line 83:
 
You can now follow the [[Packagers_RPM_tutorial]] guide while using the chroot environment.
 
You can now follow the [[Packagers_RPM_tutorial]] guide while using the chroot environment.
  
== Bonus ==
+
= Bonus =
=== Accédez à votre système chrooté via SSH ===
+
== Accédez à votre système chrooté via SSH ==
  
 
Enter into your chrooted system
 
Enter into your chrooted system
Line 129: Line 129:
 
     mount /dev/pts
 
     mount /dev/pts
  
=== Accédez à d'autre partitions ===
+
== Accédez à d'autre partitions ==
  
 
Any other available partitions can also be shared to the chroot by binding them to a mount the same way as we did with {{File|/proc}}.
 
Any other available partitions can also be shared to the chroot by binding them to a mount the same way as we did with {{File|/proc}}.

Revision as of 06:57, 31 July 2018

Template:Bandeau multi-langues-fr

Accueil [en] Accueil Équipes Packageurs Les outils d'empaquetage Mageiachroot pour empaqueteur


Pourquoi utiliser chroot ?

Often when building or rebuilding packages you will need to install various libraries and development headers, many of which you won't want on your regular day-to-day installation.

A self-contained chroot environment which can contain all needed development packages is an excellent solution. It can easily be backed up and used as a test environment as well as a build environment; all without cluttering up your main install.

And of course if you do manage to kill the chroot environment, it's as easy to fix as restoring the backup from a tarball or even starting it again from scratch.

Créer un chroot

Note: Mageia has a tool, iurt which is able to do auto-builds using a clean chroot environment each time and also enables the ability to cross-compile to other architectures. You will require high bandwidth to use this tool efficiently.

Prérequis

  • Root access to a running Mageia system
  • urpmi
  • access to a Mageia mirror, either remote (http/ftp/rsync...) or local (nfs/cdrom/file...)

Installation d'un chroot

You need to create your working directory. (/mnt/chroot/cauldron for eg). This directory will host your chrooted Mageia system

   mkdir -p /mnt/chroot/cauldron

Setup urpmi with the urpmi.addmedia command. urpmi allows you to install any version of Mageia in a chroot without modifying the urpmi configuration of your running system. We choose here to install Mageia cauldron system into the chroot. We will use the --distrib option of urpmi.addmedia which automatically configures the repository[1] for urpmi:

  • "Core"
  • "Core Updates"
  • "Non-free"
  • "Non-free Updates"

For 32bit systems

   urpmi.addmedia --distrib --urpmi-root /mnt/chroot/cauldron ftp://distrib-coffee.ipsl.jussieu.fr/pub/linux/Mageia/distrib/cauldron/i586

For 64bit systems

   urpmi.addmedia --distrib --urpmi-root /mnt/chroot/cauldron ftp://distrib-coffee.ipsl.jussieu.fr/pub/linux/Mageia/distrib/cauldron/x86_64

A list of mirrors is available at https://mirrors.mageia.org/

Installer un système de base

The minimum required packages for an operational chroot are:

  • Template:Pkg (required)
  • Template:Pkg (required for self contained chroot)
  • Template:Pkg (strongly recommended): where <XX> stands for the ISO code of the locale you usually use within your running system [1] In our example, locales-fr or locales-en.

You can also install additional packages during the initial setup. For example; syslinux

   urpmi  --urpmi-root /mnt/chroot/cauldron basesystem urpmi locales-fr syslinux

Accédez au chroot

To access the chroot;

   chroot /mnt/chroot/cauldron

Inside the self-contained chroot, you can work with it as a regular system. You can exit the chroot with the exit command.

Configuration minimale

  • DNS Setup: In order to have a working network connection within our chroot, you have to fill in /mnt/chroot/cauldron/etc/resolv.conf, the dns ip address of your provider. You can simply copy your working /etc/resolv.conf into the chroot /mnt/chroot/cauldron/etc/resolv.conf
   cp /etc/resolv.conf /mnt/chroot/cauldron/etc/resolv.conf
  • Mount /proc filesystem: outside the chroot, mount the /proc virtual filesystem of your running system inside your chroot
   mount -o bind /proc /mnt/chroot/cauldron/proc

Construire des paquets

In the chroot environment, you should now install the following packages:

  • rpm: our patched version of Red Hat's.
  • rpm-build: scripts used to build packages.
  • spec-helper: a tool to minimalize the specfiles by doing automatic things such as stripping the binaries and compressing the man pages.
  • libtool: used by some configure scripts to build shared libraries.
  • rpmlint: used to check the validity of the generated rpm.

You can now follow the Packagers_RPM_tutorial guide while using the chroot environment.

Bonus

Accédez à votre système chrooté via SSH

Enter into your chrooted system

   chroot /mnt/chroot/cauldron

Install the Template:Pkg package inside your chroot

   urpmi openssh-server

Change the default port (port 22), which will be used by the ssh server of your chrooted system to to some other port, 2222 for example, so it doesn't conflict with the real ssh server that might be running on the host machine. You'll have to edit /etc/ssh/sshd_config

   # $OpenBSD: sshd_config,v 1.74 2006/07/19 13:07:10 dtucker Exp $
   
   # This is the sshd server system-wide configuration file.  See
   # sshd_config(5) for more information.
   (...)
   Port 2222
   (...)

Launch the ssh server of your chrooted system

   systemctl start sshd

Add a user inside your chroot with useradd

   useradd jdoe
   passwd jdoe

Exit the chroot

   exit

Now, as long as the /proc filesystem is mounted inside your chroot and that your chrooted sshd server is running, you should be able to log in your chrooted system via ssh like this

   ssh jdoe@localhost -p 2222

If you don't get a shell after typing the password, you may need to add this to /etc/fstab in the chroot :

   none /dev/pts devpts defaults 0 0

And then, of course, mount it.

   mount /dev/pts

Accédez à d'autre partitions

Any other available partitions can also be shared to the chroot by binding them to a mount the same way as we did with /proc.

For example, if your /home is a separate partition;

   mount -o bind /home /mnt/chroot/cauldron/home

or for external media;

   mount -o bind /path/to/media /mnt/chroot/cauldron/media/external