<commit_before># Makefile: OperWrt image generator for cwnmyr

devices := $(notdir $(wildcard device/*))

BUILDER := $(shell dirname "$(realpath $(lastword $(MAKEFILE_LIST)))")
OPENWRT ?= openwrt

.PHONY: default clean prepare all $(devices)

default: all

clean:
	rm -rf image

distclean: clean
	rm -rf "$(OPENWRT)"

fetch:
	@# Get the configurator
	@# TODO: point back to personaltelco repo after PR is merged
	[ -d "files" ] && \
		(cd "files"; git fetch -q origin) || \
		git clone -q \
		git://github.com/keeganquinn/ptp-openwrt-files.git \
		"files"
	(cd "files"; git checkout -q `cat "$(BUILDER)/rev/files"`)

	@# Make sure we have the correct OpenWrt tree
	[ -d "$(OPENWRT)" ] && \
		(cd "$(OPENWRT)"; git fetch -q origin) || \
		git clone -q https://git.openwrt.org/openwrt/openwrt.git \
		"$(OPENWRT)"
	(cd "$(OPENWRT)"; git checkout -q `cat "$(BUILDER)/rev/openwrt"`)

	@# Symlink dl subdirectory, to avoid unneeded redownloading
	mkdir -p dl
	rm -rf "$(OPENWRT)/dl"
	ln -s "$(BUILDER)/dl" "$(OPENWRT)/dl"

	mkdir -p "$(OPENWRT)/feeds"
	cp feeds.conf "$(OPENWRT)/feeds.conf"

prepare: fetch
	@# Make sure we have the right feeds trees. openwrt/scripts/feeds does
	@# not support retrieving a specific git revision, so we have to do
	@# this ourselves.
	cat feeds.conf | while read line; do \
		feed=`echo $$line | cut -f2 -d' ' -`; \
		url=`echo $$line | cut -f3 -d' ' - | cut -f1 -d';' -`; \
		[ -d "$(OPENWRT)/feeds/$$feed" ] && \
			(cd "$(OPENWRT)/feeds/$$feed"; \
				git remote set-url origin $$url; \
				git fetch -q origin) || \<commit_msg>Patch is merged, point repo back.<commit_after># Makefile: OperWrt image generator for cwnmyr

devices := $(notdir $(wildcard device/*))

BUILDER := $(shell dirname "$(realpath $(lastword $(MAKEFILE_LIST)))")
OPENWRT ?= openwrt

.PHONY: default clean prepare all $(devices)

default: all

clean:
	rm -rf image

distclean: clean
	rm -rf "$(OPENWRT)"

fetch:
	@# Get the configurator
	[ -d "files" ] && \
		(cd "files"; git fetch -q origin) || \
		git clone -q \
		git://github.com/personaltelco/ptp-openwrt-files.git \
		"files"
	(cd "files"; git checkout -q `cat "$(BUILDER)/rev/files"`)

	@# Make sure we have the correct OpenWrt tree
	[ -d "$(OPENWRT)" ] && \
		(cd "$(OPENWRT)"; git fetch -q origin) || \
		git clone -q https://git.openwrt.org/openwrt/openwrt.git \
		"$(OPENWRT)"
	(cd "$(OPENWRT)"; git checkout -q `cat "$(BUILDER)/rev/openwrt"`)

	@# Symlink dl subdirectory, to avoid unneeded redownloading
	mkdir -p dl
	rm -rf "$(OPENWRT)/dl"
	ln -s "$(BUILDER)/dl" "$(OPENWRT)/dl"

	mkdir -p "$(OPENWRT)/feeds"
	cp feeds.conf "$(OPENWRT)/feeds.conf"

prepare: fetch
	@# Make sure we have the right feeds trees. openwrt/scripts/feeds does
	@# not support retrieving a specific git revision, so we have to do
	@# this ourselves.
	cat feeds.conf | while read line; do \
		feed=`echo $$line | cut -f2 -d' ' -`; \
		url=`echo $$line | cut -f3 -d' ' - | cut -f1 -d';' -`; \
		[ -d "$(OPENWRT)/feeds/$$feed" ] && \
			(cd "$(OPENWRT)/feeds/$$feed"; \
				git remote set-url origin $$url; \
				git fetch -q origin) || \
{'fraction_non_alphanumeric': 0.18344155844155843, 'fraction_numerical': 0.001948051948051948, 'mean_word_length': 3.297071129707113, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '149601', 'n_tokens_mistral': 1255, 'n_tokens_neox': 1165, 'n_words': 353}