pub2yocto 0.3.1
pub2yocto: ^0.3.1 copied to clipboard
A Dart package to convert pubspec.lock file to Yocto recipes.
pub2yocto #
Introduction #
pub2yocto is a tool that generates a detailed source URL list based on the pubspec.lock
file.
The generated result is for the Yocto build recipe. It should manage dependent packages through the do_fetch and do_unpack stages.
For details on Dart's pubspec.yaml
file, follow this link:
Dart - pubspec
To understand how to configure fetching in BitBake for the Yocto Project, you can refer to the following documentation: BitBake User Manual - Fetching
Installing #
Adding the package name to dev_dependencies
; not to dependencies
because the package does nothing on runtime.
flutter pub add --dev pub2yocto
Or manually add it to your pubspec.yaml
under dev_dependencies
:
dev_dependencies:
pub2yocto: ^0.3.0
Generate recipe #
Before executing the command, you must update your pubspec.lock
using pub get
(or pub upgrade
if you want).
flutter pub get
dart run pub2yocto
You can specify an input file (pubspec.lock
by default) and an output file for the generated recipe using command-line options:
dart run pub2yocto -i path/to/pubspec.lock -o path/to/output.bbappend
Options: #
-i, --input
: Specify the input file. Defaults topubspec.lock
.-o, --output
: Specify the output file name for the generated recipe. If not provided,pub2yocto
generates a.bbappend
file named after the project defined inpubspec.yaml
.-d, --download-prefix
: Specify the download directory prefix for hosted dependencies. This is useful for customizing the directory structure of downloaded packages.
In Your Flutter App Recipe #
pub2yocto
generates Yocto recipes that assume a PUB_CACHE_LOCAL
environment variable. This variable is a relative path from ${WORK_DIR}
that specifies the pub_cache
path used by individual recipes. If not set, it defaults to ${WORK_DIR}/pub_cache
.
Ensure this setup aligns with your Yocto project's configuration for smooth integration.
For integraty with your pubspec.lock file #
This is optional environment variable PUBSPEC_LOCK_SHA256
that his generated to output file.
PUBSPEC_LOCK_SHA256 = "<pubspec-lock-sha256sum>"
To ensure that the generated SRU_URIs match exactly, compare the actual SHA-256 checksum of your pubspec.lock file at build time.
Translation Example: From pubspec.yaml
to .bbappend
#
pubspec.yaml
dependencies:
args: ^2.7.0
dev_dependencies:
pub2yocto:
git:
url: https://github.com/SeungkyunKim/pub2yocto.git
ref: main
pubspec.lock
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
args:
dependency: "direct main"
description:
name: args
sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04
url: "https://pub.dev"
source: hosted
version: "2.7.0"
pub2yocto:
dependency: "direct dev"
description:
path: "."
ref: main
resolved-ref: "6ca590ceeb9977b727a6b014160b33c0df1e9845"
url: "https://github.com/SeungkyunKim/pub2yocto.git"
source: git
version: "0.2.0"
pub2yocto.bbappend
# Do not edit. This file is generated by pub2yocto.
# "PUB_CACHE_LOCAL is a relative path starting from ${WORK_DIR} that specifies the pub_cache
# path used in each individual recipe. The default path is ${WORK_DIR}/pub_cache."
PUB_CACHE_LOCAL ?= "pub_cache"
SRC_URI:append = " https://pub.dev/api/archives/args-2.7.0.tar.gz;name=args;subdir=${PUB_CACHE_LOCAL}/hosted/pub.dev/args-2.7.0;downloadfilename=pub-cache/args-2.7.0.tar.gz"
SRC_URI[args.sha256sum] = "d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04"
SRC_URI:append = " git://github.com/SeungkyunKim/pub2yocto.git;name=pub2yocto;protocol=https;destsuffix=${PUB_CACHE_LOCAL}/git/pub2yocto-6ca590ceeb9977b727a6b014160b33c0df1e9845;nobranch=1"
SRCREV_pub2yocto = "6ca590ceeb9977b727a6b014160b33c0df1e9845"
SRCREV_FORMAT:append = " pub2yocto"