Helper NPM package for syncing base project with multiple repos.
This nodejs module was created to substitute repo
tool required to download and update multiple repositories while working with Yocto-based projects.
It also allows to use nodejs package.json
to manage build scripts for your Yocto-based project.
npm install node-reposync --save-dev
# or if you usually yarn:
yarn add node-reposync --dev
repos
is stores all repos that needs to be synchronized;reposDir
defines a directory where all repos will be synchronized;
For example:
{
"reposync": {
"repos": {
"meta-openembedded": {
"url": "https://github.com/openembedded/meta-openembedded.git",
"branch": "kirkstone",
"depth": 1
}
},
"dir": "sources"
}
}
{
"scripts": {
"sources": "reposync"
}
}
npm run sources
First, lets create package.json:
npm init
Second, add repos
and/or reposDir
to package.json.
Minimal package.json should have this:
{
"reposync": {
"repos": {
"meta-openembedded": {
"url": "https://github.com/openembedded/meta-openembedded.git"
}
}
}
}
Practical package.json can have also branch names and depth levels, alone with directory where repos will be synchronized:
{
"reposync": {
"repos": {
"meta-openembedded": {
"url": "https://github.com/openembedded/meta-openembedded.git",
"branch": "kirkstone",
"depth": 1
}
},
"dir": "sources"
}
}
Javascript:
// sources.js
var Reposync = require('node-reposync');
var sync = new Reposync.Sync();
console.log(sync.doSync({}));
Or if you prefer Typescript (you will need to enable Typescript support to run this):
import { Sync } from 'node-reposync';
new Sync().doSync({});
For this example you will need nodejs and NPM installed.
This will also install nodejs
sudo apt install -y npm
Please refer to this link:
https://docs.npmjs.com/downloading-and-installing-node-js-and-npm
Create package.json
in root directory of your project.
{
"name": "your-distro",
"version": "0.0.1",
"description": "",
"scripts": {
"sources": "node sources.js"
},
"dependencies": {
"node-reposync": "^0.0.5"
},
"reposync": {
"dir": "sources",
"repos": {
"poky": {
"url": "git://git.yoctoproject.org/poky",
"branch": "kirkstone",
"depth": 1
},
"meta-openembedded": {
"url": "https://github.com/openembedded/meta-openembedded.git",
"branch": "kirkstone",
"depth": 1
},
"openembedded-core": {
"url": "git://git.openembedded.org/openembedded-core",
"branch": "kirkstone",
"depth": 1
}
}
}
}
Create sources.js
in root directory of your project.
// sources.js
var Reposync = require('node-reposync');
var sync = new Reposync.Sync();
console.log(sync.doSync({}));
Run in terminal from root directory of your project.
npm install
Now you can run sources sync script.
It will git clone
or git fetch
into specified rootDir, depending on existence of repo directory.
npm run sources