1

When building a project with Petalinux (a type of Yocto), it needs Internet for fetching packages from server (git serve or others).

My working machine does not have permission for accessing Internet (just only have LAN), so I have a plan to set up a machine in this LAN that can access to Internet to become a mirror server for Yocto.

Does anyone have any idea for setting up a server like this? Please help.

Nayfe
  • 2,130
  • 13
  • 18
Micheal XIV
  • 495
  • 1
  • 5
  • 8

2 Answers2

4

You can check the following pages to setup a source mirror:

Basically, you launch a build on source mirror machine with those options:

 SOURCE_MIRROR_URL ?= "file:///source_mirror/sources/"
 INHERIT += "own-mirrors" 
 BB_GENERATE_MIRROR_TARBALLS = "1" 

You can only fetch source with following command: bitbake -c target runall="fetch". Then you launch an ftp server that serves ./source_mirror/sources/ folder on http://example.com/my-source-mirror.

Then on offline machine, you set

 INHERIT += "own-mirrors"
 SOURCE_MIRROR_URL = "http://example.com/my-source-mirror"
 BB_NO_NETWORK = "1" # or BB_FETCH_PREMIRRORONLY = "1"

If you have access to a proxy you can check those:

Nayfe
  • 2,130
  • 13
  • 18
1

Copy'n'paste shortcut: Below’s a working configuration you can just copy’n’paste without investing the time to understand every little detail :)

Architecture: In this example there are two types of machine. The "build server" and several instances of "developer pc“.

Machine Preparation: Install a shared folder on all machines (server and developer) giving access to any kind of file server (e.g. nfs) mapping its storage to /mnt/mirror. Example for NFS in case this is new for you, skip if you have NFS already mounted: https://pelux.io/2017/06/19/How-to-create-a-shared-sstate-dir.html (Stop reading at the caption „Yocto“ and proceed as below)

Overall Configuration: Add the code I pasted to the end of this ticket to the file conf/local.conf and remove all prior lines that conflict (i.e. mess with any of the variables we defined like DL_DIR)

Machine configuration: For the developer machines use A (outcomment B) and for the build server use B (outcomment A).

Hit it: When the server PC bitbakes for the first time it populates the mirror folders. After the first server build finished the clients will use the mirror. (source-mirror to bypass internet dependencies and sstate-cache to speed up build speed).

local.conf:

# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Activate either A or B depending on it this is a developer pc or the build server
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MIRROR_SERVER = "file:///mnt/mirror/"

# ########################################################
# A) Settings for developer PC operation
# ########################################################
BB_FETCH_PREMIRRORONLY = "1"
SOURCE_MIRROR_URL = "${MIRROR_SERVER}/source-mirror"
UNINATIVE_URL = "${SOURCE_MIRROR_URL}"
INHERIT += "own-mirrors"
SSTATE_MIRRORS = "\
file://.* ${MIRROR_SERVER}/sstate-cache/PATH;\
downloadfilename=PATH \n \
"

# ########################################################
# B) SETTINGS FOR BUILDSERVER OPERATION
# ########################################################
#SSTATE_DIR = "/mnt/remux/sstate-cache"
#BB_GENERATE_MIRROR_TARBALLS = "1"
##To populate the source mirror start a normal server build or run: bitbake --runall=fetch <image>

# ########################################################
# SETTINGS FOR BOTH, A and B
# ########################################################
DL_DIR = "/mnt/mirror/source-mirror“
Roelof
  • 864
  • 5
  • 12