Skip to main content
The scripts/ directory contains shell scripts, Perl scripts, and Python scripts used by the OpenWrt build system for package management, image generation, source downloading, and development utilities.

Feed Management

scripts/feeds

The primary tool for managing OpenWrt package feeds (external package repositories).
# Update all configured feeds (download/refresh)
./scripts/feeds update -a

# Update a specific feed
./scripts/feeds update packages

# Install all packages from all feeds into the package tree
./scripts/feeds install -a

# Install a specific package
./scripts/feeds install luci-app-firewall

# Search for a package across all feeds
./scripts/feeds search luci

# List all available feeds
./scripts/feeds list

# Clean feed directories
./scripts/feeds clean
Feed sources are configured in feeds.conf (or feeds.conf.default if feeds.conf doesn’t exist):
src-git packages https://git.openwrt.org/feed/packages.git
src-git luci https://git.openwrt.org/project/luci.git
src-git routing https://git.openwrt.org/feed/routing.git
src-git telephony https://git.openwrt.org/feed/telephony.git

Configuration Utilities

scripts/diffconfig.sh

Generates a minimal diff of the current .config against the default configuration. The output contains only the options that differ from defaults and can be used to reproduce the configuration on a clean tree.
# Generate a minimal config diff
./scripts/diffconfig.sh > my-minimal-config

# Apply it on another tree
cp my-minimal-config .config
make defconfig
This is the recommended way to store configurations in version control, as the full .config changes frequently with new packages.

scripts/getver.sh

Outputs the current OpenWrt version string derived from git tags.
./scripts/getver.sh
# Output: r23809+1-c0e3a4b

Code Quality

scripts/checkpatch.pl

A port of the Linux kernel’s checkpatch.pl script. Checks patch files or source files for coding style issues.
# Check a patch file
./scripts/checkpatch.pl my-feature.patch

# Check a C source file directly
./scripts/checkpatch.pl --no-tree -f package/myapp/src/main.c

Image Generation

scripts/json_overview_image_info.py

Generates the profiles.json file from device metadata. Called automatically by the image build step.
# Regenerate profiles.json manually
python3 ./scripts/json_overview_image_info.py \
  --metadata bin/targets/ath79/generic/.metadata.json \
  --output bin/targets/ath79/generic/profiles.json

scripts/json_add_image_info.py

Adds individual image entries to profiles.json as images are built. Called per-device during make target/install.

scripts/gen_image_generic.sh

Generic image generation helper script used by target image Makefiles. Handles common image assembly steps.

scripts/ubinize-image.sh

Creates UBI (Unsorted Block Images) from rootfs and kernel for NAND flash targets.
./scripts/ubinize-image.sh <ubinize.cfg> <output.ubi>

Package and Source Management

scripts/download.pl

The package source downloader. Downloads source archives and verifies their integrity against expected hashes.
# Called internally by the build system:
./scripts/download.pl <url> <hash-type> <hash-value> <destination>
Supports HTTP, FTP, and git downloads. Integrates with OpenWrt’s mirror network.

scripts/metadata.pm

Perl library providing functions to parse and manipulate OpenWrt package metadata. Used by scripts/feeds and other tools.

scripts/ipkg-build

Builds .ipk package archives from a staged install directory.
./scripts/ipkg-build [-c] <pkg-directory> <output-directory>
Called by the build system’s BuildPackage infrastructure; not typically invoked directly.

scripts/ipkg-make-index.sh

Generates a Packages index file from a directory of .ipk files, used when creating a package repository.
./scripts/ipkg-make-index.sh /path/to/packages/ > Packages
gzip -9c Packages > Packages.gz

Kernel Utilities

scripts/patch-kernel.sh

Applies a series of patches to the Linux kernel source. Called automatically during the kernel prepare step.
./scripts/patch-kernel.sh <linux-src-dir> <patches-dir> [<patch-file-name-pattern>]

scripts/kconfig.pl

Merges multiple Kconfig fragment files into a single configuration. Used to combine generic and target-specific kernel configs.

scripts/kernel_bump.sh

Helper script for updating the kernel version in a target Makefile and managing kernel patches across version bumps.

Toolchain

scripts/ext-toolchain.sh

Configures OpenWrt to use an external (pre-built) cross-toolchain instead of building its own.
./scripts/ext-toolchain.sh --toolchain /opt/my-toolchain \
  --with-libc musl \
  --config mips_24kc

scripts/check-toolchain-clean.sh

Verifies that the toolchain was built in a clean environment without host library contamination.

Testing

scripts/qemustart

Launches a QEMU virtual machine to test OpenWrt x86 or ARM images without physical hardware.
# Start an x86-64 image in QEMU
./scripts/qemustart --arch x86_64 \
  bin/targets/x86/64/openwrt-x86-64-generic-ext4-combined.img

scripts/remote-gdb

Helper script for attaching GDB to a remote OpenWrt process over the network for debugging.

Miscellaneous

scripts/get_source_date_epoch.sh

Returns the SOURCE_DATE_EPOCH (UNIX timestamp) for reproducible builds, derived from the most recent git commit timestamp.

scripts/bundle-libraries.sh

Bundles shared library dependencies into a package, used for packages that need to ship their own copies of libraries.

scripts/size_compare.sh

Compares package sizes between two builds or branches to identify size regressions.