Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
Loading items

Target

Select target project
  • firmware/gluon
  • 0x4A6F/gluon
  • patrick/gluon
3 results
Select Git revision
Loading items
Show changes
Showing
with 656 additions and 243 deletions
#!/bin/bash
#!/usr/bin/env bash
set -e
......@@ -11,7 +11,7 @@ rm -rf openwrt/feeds
rm -rf openwrt/package/feeds
(
echo 'src-link gluon_base ../../package'
echo "$GLUON_BASE_FEEDS"
for feed in $FEEDS; do
echo "src-link $feed ../../packages/$feed"
done
......
#!/bin/sh
check_command() {
which "$1" >/dev/null 2>&1
command -v "$1" >/dev/null
}
if check_command gnustat; then
......
......@@ -20,11 +20,8 @@ local function generate_line(model, dir, filename, filesize)
end
local file256sum = strip(lib.exec_capture {'scripts/sha256sum.sh', dir..'/'..filename})
local file512sum = strip(lib.exec_capture {'scripts/sha512sum.sh', dir..'/'..filename})
io.stdout:write(string.format('%s %s %s %s %s\n', model, env.GLUON_RELEASE, file256sum, filesize, filename))
io.stdout:write(string.format('%s %s %s %s\n', model, env.GLUON_RELEASE, file256sum, filename))
io.stdout:write(string.format('%s %s %s %s\n', model, env.GLUON_RELEASE, file512sum, filename))
end
local function generate(image)
......@@ -48,8 +45,10 @@ local function generate(image)
end
end
for _, image in ipairs(lib.images) do
for _, images in pairs(lib.images) do
for _, image in ipairs(images) do
if image.subdir == 'sysupgrade' then
generate(image)
end
end
end
#!/bin/sh
if [ $# -ne 1 ]; then
echo >&2 "Usage: getversion.sh <directory>"
exit 1
fi
cd "$1" || exit 1
cat .scmversion 2>/dev/null && exit 0
git --git-dir=.git describe --tags --always --abbrev=7 --dirty=+ 2>/dev/null && exit 0
echo unknown
local M = {
customization_file = nil,
}
local function evaluate_device(env, dev)
local selections = {
features = {},
packages = {},
}
local funcs = {}
local device_overrides = {}
local function add_elements(element_type, element_list)
-- We depend on the fact both feature and package
-- are already initialized as empty tables
for _, element in ipairs(element_list) do
table.insert(selections[element_type], element)
end
end
local function add_override(ovr_key, ovr_value)
device_overrides[ovr_key] = ovr_value
end
function funcs.features(features)
add_elements('features', features)
end
function funcs.packages(packages)
add_elements('packages', packages)
end
function funcs.broken(broken)
assert(
type(broken) == 'boolean',
'Incorrect use of broken(): has to be a boolean value')
add_override('broken', broken)
end
function funcs.disable()
add_override('disabled', true)
end
function funcs.disable_factory()
add_override('disable_factory', true)
end
function funcs.device(device_names)
assert(
type(device_names) == 'table',
'Incorrect use of device(): pass a list of device names as argument')
for _, device_name in ipairs(device_names) do
if device_name == dev.image then
return true
end
end
return false
end
function funcs.target(target, subtarget)
assert(
type(target) == 'string',
'Incorrect use of target(): pass a target name as first argument')
if target ~= env.BOARD then
return false
end
if subtarget and subtarget ~= env.SUBTARGET then
return false
end
return true
end
function funcs.device_class(class)
return dev.options.class == class
end
-- Evaluate the feature definition files
setfenv(M.customization_file, funcs)
M.customization_file()
return {
selections = selections,
device_overrides = device_overrides,
}
end
function M.get_selections(dev)
local eval_result = evaluate_device(M.env, dev)
return eval_result.selections
end
function M.device_overrides(dev)
local eval_result = evaluate_device(M.env, dev)
return eval_result.device_overrides
end
function M.init(env)
local filename = env.GLUON_SITEDIR .. '/image-customization.lua'
M.env = env
M.customization_file = assert(loadfile(filename))
end
return M
#!/bin/sh
set -e
editorconfig-checker .github contrib docs package scripts targets tests ./*.* .luacheckrc .editorconfig
#!/bin/sh
set -e
luacheck package scripts targets
#!/bin/sh
set -e
is_scriptfile() {
echo "$1" | grep -q '\.sh$' || head -n1 "$1" | grep -qE '^#!(.*\<bash|/bin/sh)$'
}
is_initscript() {
head -n1 "$1" | grep -qxF '#!/bin/sh /etc/rc.common'
}
find contrib -type f | while read -r file; do
is_scriptfile "$file" || continue
echo "Checking $file"
shellcheck -f gcc "$file"
done
find package -type f | while read -r file; do
if is_scriptfile "$file"; then
echo "Checking $file"
shellcheck -f gcc -x -s sh -e SC2039,SC3043,SC3037,SC3057 "$file"
elif is_initscript "$file"; then
echo "Checking $file (initscript)"
shellcheck -f gcc -x -s sh -e SC2034,SC2039,SC3043,SC3037,SC3057 "$file"
fi
done
find scripts -type f | while read -r file; do
is_scriptfile "$file" || continue
echo "Checking $file"
shellcheck -f gcc -x "$file"
done
#!/usr/bin/env bash
set -e
. scripts/modules.sh
GLUONDIR="$(pwd)"
if [ ! -d "$GLUONDIR/openwrt" ]; then
echo "You don't seem to have obtained the external repositories needed by Gluon; please call \`make update\` first!"
exit 1
fi
need_sync=false
for module in $GLUON_MODULES; do
echo "Checking module '$module'"
var=${module//\//_}
_remote_commit=${var^^}_COMMIT
commit_expected=${!_remote_commit}
prefix=invalid
cd "$GLUONDIR/$module" 2>/dev/null && prefix="$(git rev-parse --show-prefix 2>/dev/null)"
if [ "$prefix" ]; then
echo "*** No Git repository found at '$module'."
need_sync=true
continue
fi
commit_actual="$(git rev-parse heads/base 2>/dev/null)"
if [ -z "$commit_actual" ]; then
echo "*** No base branch found at '$module'."
need_sync=true
continue
fi
if [ "$commit_expected" != "$commit_actual" ]; then
echo "*** base branch at '$module' did not match module file (expected: ${commit_expected}, actual: ${commit_actual})"
need_sync=true
continue
fi
# Use git status instead of git diff -q, as the latter doesn't
# check for untracked files
if [ "$(git status --porcelain 2>/dev/null | wc -l)" -ne 0 ]; then
echo "*** Module '$module' has uncommitted changes:"
git status --short
fi
done
if $need_sync; then
echo
# shellcheck disable=SC2016
echo 'Run `make update` to sync dependencies.'
echo
fi
#!/bin/sh
# shellcheck source=./modules
. ./modules
[ ! -f "$GLUON_SITEDIR"/modules ] || . "$GLUON_SITEDIR"/modules
FEEDS="$(echo $GLUON_FEEDS $GLUON_SITE_FEEDS | tr ' ' '\n')"
# shellcheck disable=SC2086
FEEDS="$(echo $GLUON_SITE_FEEDS $GLUON_FEEDS | tr ' ' '\n')"
GLUON_MODULES=openwrt
......
#!/bin/bash
#!/usr/bin/env bash
# shellcheck enable=check-unassigned-uppercase
set -e
shopt -s nullglob
[ "$GLUON_TMPDIR" -a "$GLUON_PATCHESDIR" ] || exit 1
[ "$GLUON_TMPDIR" ] && [ "$GLUON_PATCHESDIR" ] || exit 1
. scripts/modules.sh
......
#!/bin/sh
check_command() {
which "$1" >/dev/null 2>&1
command -v "$1" >/dev/null 2>&1
}
if check_command sha256sum; then
......@@ -15,6 +15,7 @@ else
exit 1
fi
# shellcheck disable=SC2181
[ "$?" -eq 0 ] || exit 1
echo "$ret" | awk '{ print $1 }'
#!/bin/sh
check_command() {
which "$1" >/dev/null 2>&1
}
if check_command sha512sum; then
ret="$(sha512sum "$@")"
elif check_command shasum; then
ret="$(shasum -a 512 "$@")"
elif check_command cksum; then
ret="$(cksum -q -a sha512 "$@")"
else
echo "$0: no suitable sha512sum implementation was found" >&2
exit 1
fi
[ "$?" -eq 0 ] || exit 1
echo "$ret" | awk '{ print $1 }'
local funcs = {}
local lib = dofile('scripts/target_config_lib.lua')
function funcs.config_message(config, _, ...)
config(...)
end
function funcs.config_package(config, pkg, value)
config('CONFIG_PACKAGE_%s=%s', pkg, value)
end
local lib = dofile('scripts/target_config_lib.lua')(funcs)
local output = {}
for config in pairs(lib.configs) do
table.insert(output, config)
end
-- The sort will make =y entries override =m ones
table.sort(output)
for _, line in ipairs(output) do
io.stdout:write(line, '\n')
for _, config in pairs(lib.configs) do
io.stdout:write(config:format(), '\n')
end
local ret = 0
local errors = false
local function fail(...)
if ret == 0 then
ret = 1
local function fail(msg)
if not errors then
errors = true
io.stderr:write('Configuration failed:', '\n')
end
io.stderr:write(' * ', string.format(...), '\n')
io.stderr:write(' * ', msg, '\n')
end
local function match_config(f)
for line in io.lines('openwrt/.config') do
if f(line) then
local function match_config(expected, actual)
if expected == actual then
return true
end
end
return false
end
local function check_config(pattern)
return match_config(function(line) return line == pattern end)
if expected:gsub('=m$', '=y') == actual then
return true
end
local function check_config_prefix(pattern)
return match_config(function(line) return string.sub(line, 1, -2) == pattern end)
return false
end
local funcs = {}
function funcs.config_message(_, message, ...)
local pattern = string.format(...)
if not check_config(pattern) then
fail('%s', message)
local function check_config(config)
for line in io.lines('openwrt/.config') do
if match_config(config, line) then
return true
end
end
function funcs.config_package(_, pkg, value)
local pattern = string.format('CONFIG_PACKAGE_%s=%s', pkg, value)
local res
if value == 'y' then
res = check_config(pattern)
else
res = check_config_prefix(string.sub(pattern, 1, -2))
return false
end
if not res then
fail("unable to enable package '%s'", pkg)
end
end
local lib = dofile('scripts/target_config_lib.lua')(funcs)
local lib = dofile('scripts/target_config_lib.lua')
for config, v in pairs(lib.configs) do
if v == 2 then
if not check_config(config) then
fail("unable to set '%s'", config)
for _, config in pairs(lib.configs) do
if config.required then
if not check_config(config:format()) then
fail(config.required)
end
end
end
os.exit(ret)
if errors then
os.exit(1)
end
return function(funcs)
local lib = dofile('scripts/target_lib.lua')
local feature_lib = dofile('scripts/feature_lib.lua')
local image_customization_lib = dofile('scripts/image_customization_lib.lua')
local env = lib.env
local target = env.GLUON_TARGET
assert(target)
assert(env.BOARD)
assert(env.SUBTARGET)
local target = arg[1]
local extra_packages = arg[2]
local openwrt_config_target
if env.SUBTARGET ~= '' then
openwrt_config_target = env.BOARD .. '_' .. env.SUBTARGET
......@@ -15,68 +16,189 @@ return function(funcs)
openwrt_config_target = env.BOARD
end
-- Initialize image-customization
image_customization_lib.init(env)
local function site_packages(profile)
return lib.exec_capture_raw(string.format([[
MAKEFLAGS= make print PROFILE=%s --no-print-directory -s -f - <<'END_MAKE'
include $(GLUON_SITEDIR)/site.mk
-- Split a string into words
local function split(s)
local ret = {}
for w in string.gmatch(s, '%S+') do
table.insert(ret, w)
end
return ret
end
print:
echo -n '$(GLUON_$(PROFILE)_SITE_PACKAGES)'
END_MAKE
]], lib.escape(profile)))
local feeds = split(lib.exec_capture_raw('. scripts/modules.sh; echo "$FEEDS"'))
-- Strip leading '-' character
local function strip_neg(s)
if string.sub(s, 1, 1) == '-' then
return string.sub(s, 2)
else
return s
end
end
lib.include('generic')
for pkg in string.gmatch(extra_packages, '%S+') do
lib.packages {pkg}
-- Add an element to a list, removing duplicate entries and handling negative
-- elements prefixed with a '-'
local function append_to_list(list, item, keep_neg)
local match = strip_neg(item)
local ret = {}
for _, el in ipairs(list) do
if strip_neg(el) ~= match then
table.insert(ret, el)
end
end
if keep_neg ~= false or string.sub(item, 1, 1) ~= '-' then
table.insert(ret, item)
end
return ret
end
lib.include(target)
lib.check_devices()
local function concat_list(a, b, keep_neg)
local ret = a
for _, el in ipairs(b) do
ret = append_to_list(ret, el, keep_neg)
end
return ret
end
local function compact_list(list, keep_neg)
return concat_list({}, list, keep_neg)
end
local function file_exists(file)
local f = io.open(file)
if not f then
return false
end
f:close()
return true
end
local function feature_packages(features)
local files = {'package/features'}
for _, feed in ipairs(feeds) do
local path = string.format('packages/%s/features', feed)
if file_exists(path) then
table.insert(files, path)
end
end
return feature_lib.get_packages(files, features)
end
local function site_specific_packages(dev_info)
local site_selections
local site_packages
local feature_inherited_pkgs
local site_features
-- Get all enabled selections from image-customization.lua
site_selections = image_customization_lib.get_selections(dev_info)
if not lib.opkg then
lib.config '# CONFIG_SIGNED_PACKAGES is not set'
lib.config 'CONFIG_CLEAN_IPKG=y'
lib.packages {'-opkg'}
-- First read enabled features from site
site_features = site_selections['features']
site_features = compact_list(site_features, false)
-- Create List from packages inherited from features
feature_inherited_pkgs = feature_packages(site_features)
-- Read list of packages from site
site_packages = site_selections['packages']
-- Concat feature-packages with site-packages
local pkgs = concat_list(feature_inherited_pkgs, site_packages)
-- Negations for the resulting package-list are dealt with in the calling function
return pkgs
end
local enabled_packages = {}
-- Arguments: package name and config value (true: y, nil: m, false: unset)
-- Ensures precedence of y > m > unset
local function config_package(pkg, v)
-- HACK: Handle virtual default packages
local subst = {
nftables = 'nftables-nojson'
}
if subst[pkg] then
pkg = subst[pkg]
end
local default_pkgs = ''
for _, pkg in ipairs(lib.target_packages) do
default_pkgs = default_pkgs .. ' ' .. pkg
if v == false then
if not enabled_packages[pkg] then
lib.try_config('PACKAGE_' .. pkg, false)
end
return
end
if v == true or not enabled_packages[pkg] then
lib.config('PACKAGE_' .. pkg, v, string.format("unable to enable package '%s'", pkg))
enabled_packages[pkg] = true
end
end
local function handle_target_pkgs(pkgs)
for _, pkg in ipairs(pkgs) do
if string.sub(pkg, 1, 1) == '-' then
lib.try_config('# CONFIG_PACKAGE_%s is not set', string.sub(pkg, 2))
config_package(string.sub(pkg, 2), false)
else
funcs.config_package(lib.config, pkg, 'y')
config_package(pkg, true)
end
end
end
for _, dev in ipairs(lib.devices) do
local profile = dev.options.profile or dev.name
local device_pkgs = default_pkgs
local function get_default_pkgs()
local targetinfo_target = string.gsub(openwrt_config_target, '_', '/', 1)
local target_matches = false
for line in io.lines('openwrt/tmp/.targetinfo') do
local target_match = string.match(line, '^Target: (.+)$')
if target_match then
target_matches = (target_match == targetinfo_target)
end
local function handle_pkg(pkg)
if string.sub(pkg, 1, 1) ~= '-' then
funcs.config_package(lib.config, pkg, 'm')
local default_packages_match = string.match(line, '^Default%-Packages: (.+)$')
if target_matches and default_packages_match then
return split(default_packages_match)
end
device_pkgs = device_pkgs .. ' ' .. pkg
end
for _, pkg in ipairs(dev.options.packages or {}) do
handle_pkg(pkg)
io.stderr:write('Error: unable to get default packages for OpenWrt target ', targetinfo_target, '\n')
os.exit(1)
end
lib.include('generic')
lib.include(target)
lib.check_devices()
handle_target_pkgs(concat_list(get_default_pkgs(), lib.target_packages))
for _, dev in ipairs(lib.devices) do
local device_pkgs = {}
local function handle_pkgs(pkgs)
for _, pkg in ipairs(pkgs) do
if string.sub(pkg, 1, 1) ~= '-' then
config_package(pkg, nil)
end
device_pkgs = append_to_list(device_pkgs, pkg)
end
for pkg in string.gmatch(site_packages(profile), '%S+') do
handle_pkg(pkg)
end
funcs.config_message(lib.config, string.format("unable to enable device '%s'", profile),
'CONFIG_TARGET_DEVICE_%s_DEVICE_%s=y', openwrt_config_target, profile)
lib.config('CONFIG_TARGET_DEVICE_PACKAGES_%s_DEVICE_%s="%s"',
openwrt_config_target, profile, device_pkgs)
handle_pkgs(lib.target_packages)
handle_pkgs(dev.options.packages or {})
handle_pkgs(site_specific_packages(dev))
local profile_config = string.format('%s_DEVICE_%s', openwrt_config_target, dev.name)
lib.config(
'TARGET_DEVICE_' .. profile_config, true,
string.format("unable to enable device '%s'", dev.name)
)
lib.config(
'TARGET_DEVICE_PACKAGES_' .. profile_config,
table.concat(device_pkgs, ' ')
)
end
return lib
end
local image_customization_lib = dofile('scripts/image_customization_lib.lua')
-- Functions for use in targets/*
local F = {}
......@@ -15,27 +17,24 @@ local env = setmetatable({}, {
})
F.env = env
local envtrue = setmetatable({}, {
__index = function(_, k) return (tonumber(os.getenv(k)) or 0) > 0 end
})
F.envtrue = envtrue
assert(env.GLUON_SITEDIR)
assert(env.GLUON_TARGETSDIR)
assert(env.GLUON_RELEASE)
assert(env.GLUON_DEPRECATED)
M.site_code = assert(assert(dofile('scripts/site_config.lua')('site.conf')).site_code)
M.site_code = assert(
dofile('scripts/site_config.lua')('site.conf').site_code, 'site_code missing in site.conf'
)
M.target_packages = {}
M.configs = {}
M.devices = {}
M.images = {}
M.opkg = true
-- Initialize image-customization
image_customization_lib.init(env)
local default_options = {
profile = false,
factory = '-squashfs-factory',
factory_ext = '.bin',
sysupgrade = '-squashfs-sysupgrade',
......@@ -44,6 +43,7 @@ local default_options = {
aliases = {},
manifest_aliases = {},
packages = {},
class = 'standard',
deprecated = false,
broken = false,
}
......@@ -55,24 +55,47 @@ for dev in string.gmatch(env.GLUON_DEVICES or '', '%S+') do
unknown_devices[dev] = true
end
local function want_device(dev, options)
if options.broken and not envtrue.BROKEN then
return false
function F.istrue(v)
return (tonumber(v) or 0) > 0
end
if options.deprecated and env.GLUON_DEPRECATED == '0' then
local function device_broken(device_info, overrides)
if F.istrue(env.BROKEN) then
return false
end
if (env.GLUON_DEVICES or '') == '' then
if overrides['broken'] ~= nil then
return overrides['broken'] == true
elseif device_info.options.broken then
return true
end
unknown_devices[dev] = nil
return gluon_devices[dev]
return false
end
local full_deprecated = env.GLUON_DEPRECATED == 'full'
local function want_device(device_info)
local overrides = image_customization_lib.device_overrides(device_info)
-- Check if device is disabled via image-customization.lua in site
if overrides['disabled'] then
return false
end
if device_broken(device_info, overrides) then
return false
end
if device_info.options.deprecated and env.GLUON_DEPRECATED == '0' then
return false
end
if (env.GLUON_DEVICES or '') == '' then
return true
end
unknown_devices[device_info.image] = nil
return gluon_devices[device_info.image]
end
local function merge(a, b)
local ret = {}
......@@ -98,7 +121,10 @@ function F.escape(s)
end
local function escape_command(command, raw)
local ret = 'exec'
local ret = ''
if not raw then
ret = 'exec'
end
for _, arg in ipairs(command) do
ret = ret .. ' ' .. F.escape(arg)
end
......@@ -142,17 +168,56 @@ local image_mt = {
}
local function add_image(image)
table.insert(M.images, setmetatable(image, image_mt))
local device = image.image
M.images[device] = M.images[device] or {}
table.insert(M.images[device], setmetatable(image, image_mt))
end
function F.try_config(...)
M.configs[string.format(...)] = 1
local function format_config(k, v)
local format
if type(v) == 'string' then
format = '%s=%q'
elseif v == true then
format = '%s=y'
elseif v == nil then
format = '%s=m'
elseif v == false then
format = '# %s is not set'
else
format = '%s=%d'
end
return string.format(format, 'CONFIG_' .. k, v)
end
function F.config(...)
M.configs[string.format(...)] = 2
local config_mt = {
__index = {
format = function(config)
return format_config(config.key, config.value)
end,
}
}
local function do_config(k, v, required)
M.configs[k] = setmetatable({
key = k,
value = v,
required = required,
}, config_mt)
end
function F.try_config(k, v)
do_config(k, v)
end
function F.config(k, v, message)
if not message then
message = string.format("unable to set '%s'", format_config(k, v))
end
do_config(k, v, message)
end
function F.packages(pkgs)
for _, pkg in ipairs(pkgs) do
table.insert(M.target_packages, pkg)
......@@ -160,18 +225,41 @@ function F.packages(pkgs)
end
M.packages = F.packages
function F.device(image, name, options)
options = merge(default_options, options)
local function as_table(v)
if type(v) == 'table' then
return v
else
return {v}
end
end
if not want_device(image, options) then
return
local function disable_factory_image(device_info)
if device_info.options.deprecated and env.GLUON_DEPRECATED ~= 'full' then
return true
end
local overrides = image_customization_lib.device_overrides(device_info)
if overrides["disable_factory"] then
return true
end
return false
end
table.insert(M.devices, {
function F.device(image, name, options)
options = merge(default_options, options)
local device_info = {
image = image,
name = name,
options = options,
})
}
if not want_device(device_info) then
return
end
table.insert(M.devices, device_info)
if options.sysupgrade then
add_image {
......@@ -186,22 +274,23 @@ function F.device(image, name, options)
}
end
if options.deprecated and not full_deprecated then
if disable_factory_image(device_info) then
return
end
if options.factory then
for _, ext in ipairs(as_table(options.factory_ext)) do
add_image {
image = image,
name = name,
subdir = 'factory',
in_suffix = options.factory,
out_suffix = '',
extension = options.factory_ext,
extension = ext,
aliases = options.aliases,
manifest_aliases = options.manifest_aliases,
}
end
end
for _, extra_image in ipairs(options.extra_images) do
add_image {
image = image,
......@@ -211,55 +300,8 @@ function F.device(image, name, options)
out_suffix = extra_image[2],
extension = extra_image[3],
aliases = options.aliases,
manifest_aliases = options.manifest_aliases,
}
end
end
function F.factory_image(image, name, ext, options)
options = merge(default_options, options)
if not want_device(image, options) then
return
end
if options.deprecated and not full_deprecated then
return
end
add_image {
image = image,
name = name,
subdir = 'factory',
in_suffix = '',
out_suffix = '',
extension = ext,
aliases = options.aliases,
manifest_aliases = options.manifest_aliases,
}
end
function F.sysupgrade_image(image, name, ext, options)
options = merge(default_options, options)
if not want_device(image, options) then
return
end
add_image {
image = image,
name = name,
subdir = 'sysupgrade',
in_suffix = '',
out_suffix = '-sysupgrade',
extension = ext,
aliases = options.aliases,
manifest_aliases = options.manifest_aliases,
}
end
function F.no_opkg()
M.opkg = false
end
function F.defaults(options)
......
#!/bin/sh -e
make --no-print-directory list-targets BROKEN=1 | ./contrib/actions/generate-target-filters.py > .github/filters.yml
#!/usr/bin/env bash
# shellcheck enable=check-unassigned-uppercase
set -eo pipefail
# move to basedir, in case the script is not executed via `make update-modules`
cd "$(dirname "$0")/.." || exit 1
# shellcheck source=./modules
source ./modules
git diff --quiet ./modules || {
1>&2 echo "Your modules file is dirty, aborting."
exit 1
}
LOCAL_BRANCH=$(git branch --show-current)
[[ $LOCAL_BRANCH != *-updates ]] && LOCAL_BRANCH+=-updates
for MODULE in "OPENWRT" ${GLUON_FEEDS}; do
if [[ $MODULE != "OPENWRT" ]]; then
MODULE=PACKAGES_${MODULE^^}
fi
_REMOTE_URL=${MODULE}_REPO
_REMOTE_BRANCH=${MODULE}_BRANCH
_LOCAL_HEAD=${MODULE}_COMMIT
REMOTE_URL="${!_REMOTE_URL}"
REMOTE_BRANCH="${!_REMOTE_BRANCH}"
LOCAL_HEAD="${!_LOCAL_HEAD}"
# get default branch name if none is set
[ -z "${REMOTE_BRANCH}" ] && {
REMOTE_BRANCH=$(git ls-remote --symref "${REMOTE_URL}" HEAD | awk '/^ref:/ { sub(/refs\/heads\//, "", $2); print $2 }')
}
# fetch the commit id for the HEAD of the module
REMOTE_HEAD=$(git ls-remote "${REMOTE_URL}" "${REMOTE_BRANCH}" | awk '{ print $1 }')
# skip ahead if the commit id did not change
[ "$LOCAL_HEAD" == "$REMOTE_HEAD" ] && continue 1
# switch to local working branch, if we found changes
[ "$(git branch --show-current)" != "${LOCAL_BRANCH}" ] && {
git switch -c "${LOCAL_BRANCH}" || git switch "${LOCAL_BRANCH}"
}
CHECKOUT=$(mktemp -d)
# clone the target branch
git clone --bare "${REMOTE_URL}" --branch="${REMOTE_BRANCH}" "${CHECKOUT}"
# prepare the commit message
# shellcheck disable=SC2001
MODULE=$(echo "${MODULE,,}" | sed 's/packages_//')
TITLE="modules: update ${MODULE}"
MESSAGE="$(mktemp)"
{
echo "${TITLE}"
printf '\n\n'
git -C "${CHECKOUT}" log --oneline --no-decorate --no-merges "${LOCAL_HEAD}..${REMOTE_HEAD}" | cat
} > "$MESSAGE"
# modify modules file
sed -i "s/${LOCAL_HEAD}/${REMOTE_HEAD}/" ./modules
git add ./modules
git commit -F "${MESSAGE}"
# remove the checkout
rm -fr "${CHECKOUT}"
done
#!/bin/bash
#!/usr/bin/env bash
# shellcheck enable=check-unassigned-uppercase
set -e
shopt -s nullglob
......@@ -13,14 +14,15 @@ GLUONDIR="$(pwd)"
for module in $GLUON_MODULES; do
echo "--- Updating patches for module '$module' ---"
rm -rf "${GLUON_PATCHESDIR}/$module"
rm -rf "${GLUON_PATCHESDIR:?}/$module"
cd "$GLUONDIR"/"$module"
n=0
for commit in $(git rev-list --reverse --no-merges base..patched); do
let n=n+1
(( ++n ))
mkdir -p "${GLUON_PATCHESDIR}/$module"
git -c core.abbrev=40 show --pretty=format:'From: %an <%ae>%nDate: %aD%nSubject: %B' --no-renames --binary "$commit" > "${GLUON_PATCHESDIR}/$module/$(printf '%04u' $n)-$(git show -s --pretty=format:%f "$commit").patch"
echo "Updating: $(git log --format=%s -n 1 "$commit")"
git -c core.abbrev=40 show --pretty=format:'From: %an <%ae>%nDate: %aD%nSubject: %B' --no-renames --binary "$commit" > "${GLUON_PATCHESDIR}/$module/$(printf '%04u' "$n")-$(git show -s --pretty=format:%f "$commit").patch"
done
done