[PATCH] Fix USE not "sticking" between stage runs and allow set USE flags just for building - CATALYST_USE. This should fix bug 473332 and avoid the current issue of catalyst-3 stages being built with (fwd)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] Fix USE not "sticking" between stage runs and allow set USE flags just for building - CATALYST_USE. This should fix bug 473332 and avoid the current issue of catalyst-3 stages being built with (fwd)

Jorge Manuel B. S. Vicetto-2
Hi.

Apologies but I "mixed" my mailing lists when I sent this message earlier
today.
Regards,

Jorge Manuel B. S. Vicetto
Gentoo Developer

---------- Forwarded message ----------
Date: Sun,  5 Jun 2016 11:29:13 +0000
From: "Jorge Manuel B. S. Vicetto (jmbsvicetto)" <[hidden email]>
To: [hidden email], [hidden email]
Cc: "Jorge Manuel B. S. Vicetto (jmbsvicetto)" <[hidden email]>
Subject: [PATCH] Fix USE not "sticking" between stage runs and allow set USE
     flags just for building - CATALYST_USE. This should fix bug 473332 and avoid
      the current issue of catalyst-3 stages being built without BINDIST. These
     changes don't allow setting USE flags for stage 1,
     2 and 3 and don't touch other stages (TODO).

Signed-off-by: Jorge Manuel B. S. Vicetto (jmbsvicetto) <[hidden email]>
---
  catalyst/base/stagebase.py        | 13 ++++++++++++-
  catalyst/targets/grp.py           |  7 -------
  catalyst/targets/livecd_stage1.py | 14 +++++---------
  targets/stage1/stage1-chroot.sh   |  9 +++++++--
  targets/stage2/stage2-chroot.sh   | 19 ++++++-------------
  targets/stage3/stage3-chroot.sh   | 10 ++++++++++
  6 files changed, 40 insertions(+), 32 deletions(-)

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 6695ac4..de0fce4 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -173,6 +173,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
  self.set_controller_file()
  self.set_default_action_sequence()
  self.set_use()
+ self.set_catalyst_use()
  self.set_cleanables()
  self.set_iso_volume_id()
  self.set_build_kernel_vars()
@@ -547,9 +548,19 @@ class StageBase(TargetBase, ClearBase, GenBase):
  if isinstance(self.settings['use'], str):
  self.settings["use"]=self.settings["use"].split()

+ def set_catalyst_use(self):
+ if self.settings["spec_prefix"]+"/catalyst_use" in self.settings:
+ self.settings["catalyst_use"]=\
+ self.settings[self.settings["spec_prefix"]+"/catalyst_use"]
+ del self.settings[self.settings["spec_prefix"]+"/catalyst_use"]
+ if "catalyst_use" not in self.settings:
+ self.settings["catalyst_use"]=""
+ if isinstance(self.settings['catalyst_use'], str):
+ self.settings["catalyst_use"]=self.settings["catalyst_use"].split()
+
  # Force bindist when options ask for it
  if "BINDIST" in self.settings:
- self.settings["use"].append("bindist")
+ self.settings["catalyst_use"].append("bindist")

  def set_stage_path(self):
  self.settings["stage_path"]=normpath(self.settings["chroot_path"])
diff --git a/catalyst/targets/grp.py b/catalyst/targets/grp.py
index 049bc55..d47654d 100644
--- a/catalyst/targets/grp.py
+++ b/catalyst/targets/grp.py
@@ -52,13 +52,6 @@ class grp(StageBase):
  raise CatalystError("GRP build aborting due to error.",
  print_traceback=True)

- def set_use(self):
- StageBase.set_use(self)
- if "use" in self.settings:
- self.settings["use"].append("bindist")
- else:
- self.settings["use"]=["bindist"]
-
  def set_mounts(self):
  self.mounts.append("/tmp/grp")
  self.mountmap["/tmp/grp"]=self.settings["target_path"]
diff --git a/catalyst/targets/livecd_stage1.py b/catalyst/targets/livecd_stage1.py
index eea4312..659eb43 100644
--- a/catalyst/targets/livecd_stage1.py
+++ b/catalyst/targets/livecd_stage1.py
@@ -29,16 +29,12 @@ class livecd_stage1(StageBase):
  def set_spec_prefix(self):
  self.settings["spec_prefix"]="livecd"

- def set_use(self):
- StageBase.set_use(self)
- if "use" in self.settings:
- self.settings["use"].append("livecd")
- if "BINDIST" in self.settings:
- self.settings["use"].append("bindist")
+ def set_catalyst_use(self):
+ StageBase.set_catalyst_use(self)
+ if "catalyst_use" in self.settings:
+ self.settings["catalyst_use"].append("livecd")
  else:
- self.settings["use"]=["livecd"]
- if "BINDIST" in self.settings:
- self.settings["use"].append("bindist")
+ self.settings["catalyst_use"]=["livecd"]

  def set_packages(self):
  StageBase.set_packages(self)
diff --git a/targets/stage1/stage1-chroot.sh b/targets/stage1/stage1-chroot.sh
index fbda84b..291614b 100755
--- a/targets/stage1/stage1-chroot.sh
+++ b/targets/stage1/stage1-chroot.sh
@@ -53,7 +53,8 @@ sed -i "/USE=\"${USE} -build\"/d" ${clst_make_conf}

  # Now, we install our packages
  if [ -e ${clst_make_conf} ]; then
- echo "USE=\"-* build ${BOOTSTRAP_USE} ${clst_HOSTUSE}\"" >> ${clst_make_conf}
+ echo "CATALYST_USE=\"-* build ${clst_CATALYST_USE}\"" >> ${clst_make_conf}
+ echo "USE=\"${CATALYST_USE} ${BOOTSTRAP_USE} ${clst_HOSTUSE}\"" >> ${clst_make_conf}
  for useexpand in ${clst_HOSTUSEEXPAND}; do
  x="clst_${useexpand}"
  echo "${useexpand}=\"${!x}\"" \
@@ -62,8 +63,12 @@ if [ -e ${clst_make_conf} ]; then
  fi

  run_merge "--oneshot ${clst_buildpkgs}"
-sed -i "/USE=\"-* build ${BOOTSTRAP_USE} ${clst_HOSTUSE}\"/d" \
+sed -i "/USE=\"/s/\${CATALYST_USE} //" \
  ${clst_make_conf}
+sed -i "/CATALYST_USE/d" \
+ ${clist_make_conf}
+
+# Why are we removing these? Don't we need them for final make.conf?
  for useexpand in ${clst_HOSTUSEEXPAND}; do
  x="clst_${useexpand}"
  sed -i "/${useexpand}=\"${!x}\"/d" \
diff --git a/targets/stage2/stage2-chroot.sh b/targets/stage2/stage2-chroot.sh
index 38dfea3..1667ffd 100755
--- a/targets/stage2/stage2-chroot.sh
+++ b/targets/stage2/stage2-chroot.sh
@@ -5,21 +5,14 @@ source /tmp/chroot-functions.sh
  # Setup the environment
  export FEATURES="${clst_myfeatures} nodoc noman noinfo -news"

-# Set bindist USE flag if clst_BINDIST is set
-# The bindist functions have been taken from support/chroot-functions.sh
-if [ -e "${clst_make_conf}" ] && [ -n "${clst_BINDIST}" ]; then
- if grep -q ^USE "${clst_make_conf}"; then
- echo "USE=\"\${USE} bindist\"" >> "${clst_make_conf}"
- else
- echo "USE=\"bindist\"" >> "${clst_make_conf}"
- fi
-fi
-
-
+echo "CATALYST_USE=\"${clst_CATALYST_USE}\"" >> ${clst_make_conf}
+sed -i -e "/USE=\"/s/\${CATALYST_USE} " ${clst_make_conf}

  ## START BUILD
  ${clst_repo_basedir}/${clst_repo_name}/scripts/bootstrap.sh ${bootstrap_opts} || exit 1

  # Clean-up USE again
-sed -i "/USE=\"\${USE} bindist\"/d" "${clst_make_conf}"
-sed -i "/USE=\"bindist\"/d" "${clst_make_conf}"
+sed -i "/USE=\"/s/\${CATALYST_USE} //" \
+ ${clst_make_conf}
+sed -i "/CATALYST_USE/d" \
+ ${clist_make_conf}
diff --git a/targets/stage3/stage3-chroot.sh b/targets/stage3/stage3-chroot.sh
index 6cf9106..d010d5e 100755
--- a/targets/stage3/stage3-chroot.sh
+++ b/targets/stage3/stage3-chroot.sh
@@ -2,7 +2,17 @@

  source /tmp/chroot-functions.sh

+echo "CATALYST_USE=\"${clst_CATALYST_USE}\"" >> ${clst_make_conf}
+sed -i -e "/USE=\"/s/\${CATALYST_USE} " ${clst_make_conf}
+
  ## START BUILD
  setup_pkgmgr

  run_merge "-e @system"
+
+# Clean-up USE again
+sed -i "/USE=\"/s/\${CATALYST_USE} //" \
+ ${clst_make_conf}
+sed -i "/CATALYST_USE/d" \
+ ${clist_make_conf}
+
--
2.8.2


Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Fix USE not "sticking" between stage runs and allow set USE flags just for building - CATALYST_USE. This should fix bug 473332 and avoid the current issue of catalyst-3 stages being built with (fwd)

Mike Frysinger
On 05 Jun 2016 20:00, Jorge Manuel B. S. Vicetto wrote:
> Subject: [PATCH] Fix USE not "sticking" between stage runs and allow set USE
>      flags just for building - CATALYST_USE. This should fix bug 473332 and avoid
>       the current issue of catalyst-3 stages being built without BINDIST. These
>      changes don't allow setting USE flags for stage 1,
>      2 and 3 and don't touch other stages (TODO).

looks like the commit message was crammed into one line.  when making
a commit in git, it should look something like:
==================
some short summary of the issue

A longer explanation down here with multiple sentences.
==================

> --- a/catalyst/base/stagebase.py
> +++ b/catalyst/base/stagebase.py
> @@ -173,6 +173,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
>   self.set_controller_file()
>   self.set_default_action_sequence()
>   self.set_use()
> + self.set_catalyst_use()

looks like leading whitespace is broken here, or at least weird.
maybe use `git send-email` instead ?

> + def set_catalyst_use(self):
> + if self.settings["spec_prefix"]+"/catalyst_use" in self.settings:
> + self.settings["catalyst_use"]=\
> + self.settings[self.settings["spec_prefix"]+"/catalyst_use"]
> + del self.settings[self.settings["spec_prefix"]+"/catalyst_use"]

create a variable named "key" to hold this string so you don't have to
copy & paste it three times.

> + if "catalyst_use" not in self.settings:
> + self.settings["catalyst_use"]=""
> + if isinstance(self.settings['catalyst_use'], str):
> + self.settings["catalyst_use"]=self.settings["catalyst_use"].split()

there should be spaces around the assignment.
        self.settings['catalyst_use'] = ''

the code base might not do this everywhere, but it's moving that way


> --- a/targets/stage1/stage1-chroot.sh
> +++ b/targets/stage1/stage1-chroot.sh
> @@ -53,7 +53,8 @@ sed -i "/USE=\"${USE} -build\"/d" ${clst_make_conf}
>
>   # Now, we install our packages
>   if [ -e ${clst_make_conf} ]; then
> - echo "USE=\"-* build ${BOOTSTRAP_USE} ${clst_HOSTUSE}\"" >> ${clst_make_conf}
> + echo "CATALYST_USE=\"-* build ${clst_CATALYST_USE}\"" >> ${clst_make_conf}
> + echo "USE=\"${CATALYST_USE} ${BOOTSTRAP_USE} ${clst_HOSTUSE}\"" >> ${clst_make_conf}
>   for useexpand in ${clst_HOSTUSEEXPAND}; do
>   x="clst_${useexpand}"
>   echo "${useexpand}=\"${!x}\"" \
> @@ -62,8 +63,12 @@ if [ -e ${clst_make_conf} ]; then
>   fi
>
>   run_merge "--oneshot ${clst_buildpkgs}"
> -sed -i "/USE=\"-* build ${BOOTSTRAP_USE} ${clst_HOSTUSE}\"/d" \
> +sed -i "/USE=\"/s/\${CATALYST_USE} //" \
>   ${clst_make_conf}
> +sed -i "/CATALYST_USE/d" \
> + ${clist_make_conf}
rather than run sed twice on the same file, use the -e option to
specify multiple expressions

that said, rather than mess with CATALYST_USE, how about just white
it out ?
        sed -i \
                -e '/^CATALYST_USE=/s:=.*:="":' \
                ${clist_make_conf}

> +# Why are we removing these? Don't we need them for final make.conf?

not a big fan of doing this ...
-mike

signature.asc (836 bytes) Download Attachment