Content-Security-Policy: default-src 'none'
Content-Type: text/plain; charset=UTF-8
Content-Length: 5169
Content-Disposition: inline; filename="quilt.mk"
Last-Modified: Sun, 27 Oct 2024 07:44:21 GMT
Expires: Wed, 25 Oct 2034 07:44:21 GMT
ETag: "6c4839ba4ac324efc5f226e03c9bf548c6fb8572"

# 
# Copyright (C) 2007-2009 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.

ifneq ($(if $(DUMP),1,$(__quilt_inc)),1)
__quilt_inc:=1

ifeq ($(TARGET_BUILD),1)
  PKG_BUILD_DIR:=$(LINUX_DIR)
endif
PATCH_DIR?=./patches
FILES_DIR?=./files
HOST_PATCH_DIR?=$(PATCH_DIR)
HOST_FILES_DIR?=$(FILES_DIR)

ifeq ($(MAKECMDGOALS),refresh)
  override QUILT=1
endif

QUILT_CMD:=quilt --quiltrc=-

define filter_series
sed -e s,\\\#.*,, $(1) | grep -E \[a-zA-Z0-9\]
endef

define PatchDir/Quilt
	@mkdir -p "$(1)/patches$(if $(3),/$(patsubst %/,%,$(3)))"
	@if [ -s "$(2)/series" ]; then \
		mkdir -p "$(1)/patches/$(3)"; \
		cp "$(2)/series" "$(1)/patches/$(3)"; \
	fi
	@for patch in $$$$( (cd "$(2)" && if [ -f series ]; then $(call filter_series,series); else ls | sort; fi; ) 2>/dev/null ); do ( \
		cp "$(2)/$$$$patch" "$(1)/patches/$(3)"; \
		echo "$(3)$$$$patch" >> "$(1)/patches/series"; \
	); done
	$(if $(3),@echo $(3) >> "$(1)/patches/.subdirs")
endef

define PatchDir/Default
	@if [ -d "$(2)" -a "$$$$(ls $(2) | wc -l)" -gt 0 ]; then \
		if [ -s "$(2)/series" ]; then \
			$(call filter_series,$(2)/series) | xargs -n1 \
				$(PATCH) "$(1)" "$(2)"; \
		else \
			$(PATCH) "$(1)" "$(2)"; \
		fi; \
	fi
endef

define PatchDir
$(call PatchDir/$(if $(strip $(QUILT)),Quilt,Default),$(strip $(1)),$(strip $(2)),$(strip $(3)))
endef

define HostPatchDir
$(call PatchDir/$(if $(strip $(HOST_QUILT)),Quilt,Default),$(strip $(1)),$(strip $(2)),$(strip $(3)))
endef

ifneq ($(PKG_BUILD_DIR),)
  QUILT?=$(if $(wildcard $(PKG_BUILD_DIR)/.quilt_used),y)
  ifneq ($(QUILT),)
    STAMP_CHECKED:=$(PKG_BUILD_DIR)/.quilt_checked
    override CONFIG_AUTOREBUILD=
    quilt-check: $(STAMP_CHECKED)
  endif
endif

ifneq ($(HOST_BUILD_DIR),)
  HOST_QUILT?=$(if $(findstring command,$(origin QUILT)),$(QUILT),$(if $(wildcard $(HOST_BUILD_DIR)/.quilt_used),y))
  ifneq ($(HOST_QUILT),)
    HOST_STAMP_CHECKED:=$(HOST_BUILD_DIR)/.quilt_checked
    override CONFIG_AUTOREBUILD=
    host-quilt-check: $(HOST_STAMP_CHECKED)
  endif
endif

define Host/Patch/Default
	$(if $(HOST_QUILT),rm -rf $(HOST_BUILD_DIR)/patches; mkdir -p $(HOST_BUILD_DIR)/patches)
	$(call HostPatchDir,$(HOST_BUILD_DIR),$(HOST_PATCH_DIR),)
	$(if $(HOST_QUILT),touch $(HOST_BUILD_DIR)/.quilt_used)
endef

define Build/Patch/Default
	$(if $(QUILT),rm -rf $(PKG_BUILD_DIR)/patches; mkdir -p $(PKG_BUILD_DIR)/patches)
	$(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR),)
	$(if $(QUILT),touch $(PKG_BUILD_DIR)/.quilt_used)
endef

kernel_files=$(foreach fdir,$(GENERIC_FILES_DIR) $(FILES_DIR),$(fdir)/.)
define Kernel/Patch/Default
	rm -rf $(PKG_BUILD_DIR)/patches; mkdir -p $(PKG_BUILD_DIR)/patches
	$(if $(kernel_files),$(CP) $(kernel_files) $(LINUX_DIR)/)
	find $(LINUX_DIR)/ -name \*.rej -or -name \*.orig | $(XARGS) rm -f
	$(call PatchDir,$(PKG_BUILD_DIR),$(GENERIC_PATCH_DIR),generic/)
	$(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR),platform/)
endef

define Quilt/RefreshDir
	mkdir -p $(2)
	-rm -f $(2)/* 2>/dev/null >/dev/null
	@( \
		for patch in $$$$($(if $(3),grep "^$(3)",cat) $(1)/patches/series | awk '{print $$$$1}'); do \
			$(CP) -v "$(1)/patches/$$$$patch" $(2); \
		done; \
	)
endef

define Quilt/Refresh/Host
	$(call Quilt/RefreshDir,$(HOST_BUILD_DIR),$(PATCH_DIR))
endef

define Quilt/Refresh/Package
	$(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(PATCH_DIR))
endef

define Quilt/Refresh/Kernel
	@[ -z "$$(grep -v '^generic/' $(PKG_BUILD_DIR)/patches/series | grep -v '^platform/')" ] || { \
		echo "All kernel patches must start with either generic/ or platform/"; \
		false; \
	}
	$(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(GENERIC_PATCH_DIR),generic/)
	$(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(PATCH_DIR),platform/)
endef

define Quilt/Template
  $($(2)STAMP_CONFIGURED): $($(2)STAMP_CHECKED) FORCE
  $($(2)STAMP_CHECKED): $($(2)STAMP_PREPARED)
	if [ -s "$(1)/patches/series" ]; then \
		(cd "$(1)"; \
			if $(QUILT_CMD) next >/dev/null 2>&1; then \
				$(QUILT_CMD) push -a; \
			else \
				$(QUILT_CMD) top >/dev/null 2>&1; \
			fi \
		); \
	fi
	touch "$$@"

  $(3)quilt-check: $($(2)STAMP_PREPARED) FORCE
	@[ -f "$(1)/.quilt_used" ] || { \
		echo "The source directory was not unpacked using quilt. Please rebuild with QUILT=1"; \
		false; \
	}
	@[ -f "$(1)/patches/series" ] || { \
		echo "The source directory contains no quilt patches."; \
		false; \
	}
	@[ -n "$$$$(ls $(1)/patches/series)" -o "$$$$(cat $(1)/patches/series | md5sum)" = "$$(sort $(1)/patches/series | md5sum)" ] || { \
		echo "The patches are not sorted in the right order. Please fix."; \
		false; \
	}

  $(3)refresh: $(3)quilt-check
	@cd "$(1)"; $(QUILT_CMD) pop -a -f >/dev/null 2>/dev/null
	@cd "$(1)"; while $(QUILT_CMD) next 2>/dev/null >/dev/null && $(QUILT_CMD) push; do \
		QUILT_DIFF_OPTS="-p" $(QUILT_CMD) refresh -p ab --no-index --no-timestamps; \
	done; ! $(QUILT_CMD) next 2>/dev/null >/dev/null
	$(Quilt/Refresh/$(4))
	
  $(3)update: $(3)quilt-check
	$(Quilt/Refresh/$(4))
endef

Build/Quilt=$(call Quilt/Template,$(PKG_BUILD_DIR),,,$(if $(TARGET_BUILD),Kernel,Package))
Host/Quilt=$(call Quilt/Template,$(HOST_BUILD_DIR),HOST_,host-,Host)

endif
 background-color: #ffffc0; padding: 0 5px 0 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight { background: #ffffff; }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */</style><div class="highlight"><pre><span></span>getvar<span class="o">()</span> <span class="o">{</span>
	<span class="nb">eval</span> <span class="s2">&quot;echo \&quot;\${</span><span class="nv">$1</span><span class="s2">}\&quot;&quot;</span>
<span class="o">}</span>

var2file<span class="o">()</span> <span class="o">{</span>
	<span class="nb">local</span> var
	<span class="nb">eval</span> <span class="s2">&quot;var=\&quot;\${</span><span class="nv">$1</span><span class="s2">}\&quot;&quot;</span>
	<span class="k">if</span> <span class="o">[</span> -n <span class="s2">&quot;</span><span class="nv">$var</span><span class="s2">&quot;</span> <span class="o">]</span><span class="p">;</span> <span class="k">then</span> <span class="nb">echo</span> <span class="s2">&quot;</span><span class="nv">$var</span><span class="s2">&quot;</span> &gt; <span class="s2">&quot;</span><span class="nv">$2</span><span class="s2">&quot;</span><span class="p">;</span> <span class="k">fi</span>
<span class="o">}</span>

isset<span class="o">()</span> <span class="o">{</span>
	<span class="nb">local</span> var
	<span class="nb">eval</span> <span class="s2">&quot;var=\&quot;\${</span><span class="nv">$1</span><span class="s2">}\&quot;&quot;</span>
	<span class="o">[</span> -n <span class="s2">&quot;</span><span class="nv">$var</span><span class="s2">&quot;</span> <span class="o">]</span>
<span class="o">}</span>

trapret<span class="o">()</span> <span class="o">{(</span>
	<span class="nb">local</span> <span class="nv">retvals</span><span class="o">=</span><span class="s2">&quot;</span><span class="nv">$1</span><span class="s2">&quot;</span><span class="p">;</span> <span class="nb">shift</span>
	<span class="nb">local</span> <span class="nv">cmd</span><span class="o">=</span><span class="s2">&quot;</span><span class="nv">$1</span><span class="s2">&quot;</span><span class="p">;</span> <span class="nb">shift</span>
	<span class="k">for</span> retval in <span class="k">$(</span><span class="nb">echo</span> <span class="nv">$retvals</span><span class="k">)</span><span class="p">;</span> <span class="k">do</span>
		<span class="nb">local</span> trap_<span class="nv">$retval</span><span class="o">=</span><span class="m">1</span>
	<span class="k">done</span>
	<span class="s2">&quot;</span><span class="nv">$cmd</span><span class="s2">&quot;</span> <span class="s2">&quot;</span><span class="nv">$@</span><span class="s2">&quot;</span> <span class="o">||</span> <span class="o">{</span>
		<span class="nb">local</span> <span class="nv">retval</span><span class="o">=</span><span class="s2">&quot;</span><span class="nv">$?</span><span class="s2">&quot;</span>
		<span class="nb">eval</span> <span class="s2">&quot;trapped=\${trap_</span><span class="nv">$retval</span><span class="s2">}&quot;</span>
		<span class="o">[</span> -n <span class="s2">&quot;</span><span class="nv">$trapped</span><span class="s2">&quot;</span> <span class="o">]</span> <span class="o">||</span> <span class="o">{</span>
			<span class="k">return</span> <span class="nv">$retval</span>
		<span class="o">}</span>
	<span class="o">}</span>
<span class="o">)}</span>

md5s<span class="o">()</span> <span class="o">{</span>
	cat <span class="s2">&quot;</span><span class="nv">$@</span><span class="s2">&quot;</span> <span class="p">|</span> <span class="o">(</span>
		md5sum <span class="m">2</span>&gt;/dev/null <span class="o">||</span>
		md5 
	<span class="o">)</span> <span class="p">|</span> awk <span class="s1">&#39;{print $1}&#39;</span>
<span class="o">}</span>
</pre></div>
</code></pre></td></tr></table>
</div> <!-- class=content -->
<div class='footer'>generated by <a href='https://git.zx2c4.com/cgit/about/'>cgit v1.2.3</a> (<a href='https://git-scm.com/'>git 2.25.1</a>) at 2024-10-27 07:44:21 +0000</div>
</div> <!-- id=cgit -->
</body>
</html>
