Bug#757883: Patch for Loopback cfg support

2014-12-08 Thread adrian15

El 08/12/14 a las 07:28, Daniel Baumann escribió:

On 12/08/14 00:09, jnqnfe wrote:

I believe I'm right in saying that you must
build against live-build 4.x, preferably the debian-next branch


correct, we will not touch live-* 3.x anymore unless there's a security
issue or another bug making the existing, officially built 3.x/wheezy
live images unusable.


I attach the rebased commit for loopback cfg adapted to debian-next as 
requested and with some of your suggestions implemented.


The order in binary file remains the same because, as I explained 
earlier, syslinux renames the kernel filenames.


Just in case you want the detailed commits from debian-old-3.0 to 
debian-next they can be found here:


https://github.com/adrian15/live-build/commit/b907d5ca4cfac5407e4231a202b5b84cfcf8c56c
https://github.com/adrian15/live-build/commit/5c7636f8848b3d1d058bb2ed7fd69e01ad05270d
https://github.com/adrian15/live-build/commit/1dcec1bdc96a9b5eefb3a464b40250738bf3dfec
https://github.com/adrian15/live-build/commit/f08a3bbfeb98faad99643dbf88aead8a98a69b6f
https://github.com/adrian15/live-build/commit/0cd9b26c8697d4eeb5e950546c6e7b9c94b5ac14
https://github.com/adrian15/live-build/commit/77ac5d6acce430b6a1106e0cdb20a177e36a1b48
https://github.com/adrian15/live-build/commit/9afdaf59138392b09fce41bb522d0d0e1ea1ca11

The new patch and the resulting binary_loopback_cfg file can be also 
found here:


https://github.com/adrian15/live-build/commit/9c67d2d05502e03e0c52827a4e0c7d088f361e88

https://github.com/adrian15/live-build/blob/9c67d2d05502e03e0c52827a4e0c7d088f361e88/scripts/build/binary_loopback_cfg

adrian15
--
Support free software. Donate to Super Grub Disk. Apoya el software 
libre. Dona a Super Grub Disk. http://www.supergrubdisk.org/donate/
commit 9c67d2d05502e03e0c52827a4e0c7d088f361e88
Author: Adrian Gibanel Lopez 
Date:   Sun Dec 7 18:20:09 2014 +0100

This is a patch for adding Loopback cfg support.

Development details


* This patch has been based originally on: binary_grub2 . It has been
improved thanks to some binary_syslinux bits.

* This patch ensures that binary_loopback_cfg needs is run before binary_syslinux is run.
The reason is that it reuses some code from binary_syslinux to avoid
problems when binary_syslinux renames the kernel filenames.

* This patch already supports CPU detection

* I haven't tested all the possible scenarios for the script (with the
latest version). When amd64 and 486 Gnu/Linux flavours is used and the
bootloader is syslinux it works ok.

* I have not implemented a disable switch for not generating it.
Usually you always want loopback.cfg to be there.

* Compared to binary_grub2 script I have removed the installation
entries because I did not see any of them in binary_syslinux.

How to test
---

These are some steps to easily test if Looback cfg support is working ok.

0) We assume you have generated an iso
1) Make sure you have a partition that Grub understands. Plain ext4 or
vfat should do it.
2) Create directory: /boot/boot-isos/
3) Put the iso file into that directory making sure it has an ISO or iso
extension.
4) Setup your computer to boot from cdrom and use: Super Grub2 Disk
2.00s2 (Hybrid version recommended)
5) Choose Boot manually...
6) Choose Bootable ISOs (in /boot- ... )
7) Choose (the detected) GRUB Loopback Config
(hdN,msodsN)/boot/boot-ios/name-of-the.iso
8) You will be presented your loopback.cfg. Choose anyone of the entries
(unless it does not match your cpu architecture of course).
9) You should boot into your Debian Live without problems (thanks to
findiso boot parametre).

If you ever wanted to test from your grub2 installation instead from
Super Grub2 Disk check: http://www.supergrubdisk.org/wiki/Loopback.cfg
for an example.

diff --git a/scripts/build/binary b/scripts/build/binary
index c1f9ec6..97d7ebc 100755
--- a/scripts/build/binary
+++ b/scripts/build/binary
@@ -63,6 +63,7 @@ lb binary_linux-image ${@}
 lb binary_memtest ${@}
 lb binary_grub ${@}
 lb binary_grub2 ${@}
+lb binary_loopback_cfg ${@}
 lb binary_syslinux ${@}
 lb binary_disk ${@}
 lb binary_loadlin ${@}
diff --git a/scripts/build/binary_loopback_cfg b/scripts/build/binary_loopback_cfg
new file mode 100755
index 000..64958c4
--- /dev/null
+++ b/scripts/build/binary_loopback_cfg
@@ -0,0 +1,311 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2014 Daniel Baumann 
+##
+## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
+## This is free software, and you are welcome to redistribute it
+## under certain conditions; see COPYING for details.
+
+
+set -e
+
+# Including common functions
+[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh
+
+# Setting static var

Bug#757883: Patch for Loopback cfg support

2014-12-08 Thread adrian15

El 08/12/14 a las 00:09, jnqnfe escribió:

I had a quick look over your patch. You're building it against
live-build 3.x, but since it's a feature improvement not a "critical
bug  in core functionality", I believe I'm right in saying that you must
build against live-build 4.x, preferably the debian-next branch, if you
want to get it accepted (http://live.debian.net/project/lifespan/).
I actually do not know which are the differences between live-build 3.x 
and debian-next but I will try to cherry-pick the commit there and try 
it. I'll try to the tests on a new Debian Unstable chroot then.



Some small issues I have with your binary_loopback_cfg script besides
being built against the wrong version:
  - It would be nice to have a brief comment preceding the big if
structure beginning on line 165 to explain why you're branching based on
syslinux, so it's there for future people reading the code, saving them
a hunt through git commit logs or staring at the code trying to make
sense of it.


Yes, ok, I can do that. The explanation is that binary_syslinux 
implementation breaks other bootloader configuration because it renames 
kernel filenames.


So you have to take care of this problem ahead so that it does not 
happen as when I first was doing my tests. Back then even if I was using 
the same code as in binary_grub2 the kernel was not being found (after 
binary_syslinux was run).



  - Unless I've overlooked something, all the script is doing is
generating a grub config file, the template for which it retrieves from
live-build. It's not actually using or copying any grub binaries, unlike
the grub script. If that's correct, and I think it is, the dependency on
the grub-pc package is unnecessary and should be removed. You can strip
out the dependency itself in lines 48-49, along with the supporting code
in lines 51-55 and 298-302.
Yes, you are right. Grub2 is supposed to be loaded from another media, 
not the live cd itself. I will remove them.



  - Don't forget to update the copyright heading in your new script when
you rebase onto 4.x.

I'll also check that.


  - I don't agree with the sequence you've inserted it in within the
binary script, I think that it should come after the bootloaders
(between syslinux and disk in 4.x). My primary reason being, mandatory
or otherwise, and although related to grub, loopback support is an
entirely separate component from the choice between grub, grub2 and
syslinux. The three lines of code executing the grub/grub2/syslinux
scripts (more in LB 3.x I believe) collectively represent the step of
implementing our chose (primary) bootloader in the overall sequence.
This should not be broken up unless absolutely necessary, otherwise
you're muddling things up.
If I have to run binary_loopback_cfg support after binary_syslinux that 
means reworking a new algorithm that somehow infers kernel architecture 
from its renamed filenames and that it works for only one x86 kernel, or 
only one amd64 kernel or both kernels.


If binary_loopback_cfg is run before binary_syslinux I don't have to 
write from an scratch an algorithm I just have to reuse the 
binary_syslinux one making sure that I do not rename the kernel 
filenames. That's what it's currently implemented.


Any thoughts on how to approach the binary_syslinux renaming the kernel 
filenames or is it ok the way I'm doing it?


Thank you.

adrian15
--
Support free software. Donate to Super Grub Disk. Apoya el software 
libre. Dona a Super Grub Disk. http://www.supergrubdisk.org/donate/



--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Bug#757883: Patch for Loopback cfg support

2014-12-07 Thread Daniel Baumann
On 12/08/14 00:09, jnqnfe wrote:
> I believe I'm right in saying that you must
> build against live-build 4.x, preferably the debian-next branch

correct, we will not touch live-* 3.x anymore unless there's a security
issue or another bug making the existing, officially built 3.x/wheezy
live images unusable.

> My primary reason being [...] loopback support is an
> entirely separate component from the choice between grub, grub2 and
> syslinux.

ack.

-- 
Address:Daniel Baumann, Donnerbuehlweg 3, CH-3012 Bern
Email:  daniel.baum...@progress-technologies.net
Internet:   http://people.progress-technologies.net/~daniel.baumann/


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Bug#757883: Patch for Loopback cfg support

2014-12-07 Thread jnqnfe
I had a quick look over your patch. You're building it against
live-build 3.x, but since it's a feature improvement not a "critical
bug  in core functionality", I believe I'm right in saying that you must
build against live-build 4.x, preferably the debian-next branch, if you
want to get it accepted (http://live.debian.net/project/lifespan/).

Some small issues I have with your binary_loopback_cfg script besides
being built against the wrong version:
 - It would be nice to have a brief comment preceding the big if
structure beginning on line 165 to explain why you're branching based on
syslinux, so it's there for future people reading the code, saving them
a hunt through git commit logs or staring at the code trying to make
sense of it.
 - Unless I've overlooked something, all the script is doing is
generating a grub config file, the template for which it retrieves from
live-build. It's not actually using or copying any grub binaries, unlike
the grub script. If that's correct, and I think it is, the dependency on
the grub-pc package is unnecessary and should be removed. You can strip
out the dependency itself in lines 48-49, along with the supporting code
in lines 51-55 and 298-302.
 - Don't forget to update the copyright heading in your new script when
you rebase onto 4.x.
 - I don't agree with the sequence you've inserted it in within the
binary script, I think that it should come after the bootloaders
(between syslinux and disk in 4.x). My primary reason being, mandatory
or otherwise, and although related to grub, loopback support is an
entirely separate component from the choice between grub, grub2 and
syslinux. The three lines of code executing the grub/grub2/syslinux
scripts (more in LB 3.x I believe) collectively represent the step of
implementing our chose (primary) bootloader in the overall sequence.
This should not be broken up unless absolutely necessary, otherwise
you're muddling things up.


On 07/12/2014 17:38, adrian15 wrote:
> Just in case it's easier for you to accept my patch you can also find
> it in this git repo commit based on live-build git repo:
>
> https://github.com/adrian15/live-build/commit/c6da5ff61bb46cb66b23fcb66daa83e23fc8a36b
>
>
> adrian15


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Bug#757883: Patch for Loopback cfg support

2014-12-07 Thread adrian15

I know that:

git push --force

is kind of forbidden when working in public with other people.

As this is my kind of personal repo I did it.

So the replaced commit (which only fixes file permissions) is found at:

https://github.com/adrian15/live-build/commit/32fc1ddcd01f092933d19d0cc04bf2583aca7e71

El 07/12/14 a las 18:38, adrian15 escribió:

Just in case it's easier for you to accept my patch you can also find it
in this git repo commit based on live-build git repo:

https://github.com/adrian15/live-build/commit/c6da5ff61bb46cb66b23fcb66daa83e23fc8a36b


adrian15


adrian15
--
Support free software. Donate to Super Grub Disk. Apoya el software 
libre. Dona a Super Grub Disk. http://www.supergrubdisk.org/donate/



--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Bug#757883: Patch for Loopback cfg support

2014-12-07 Thread adrian15
Just in case it's easier for you to accept my patch you can also find it 
in this git repo commit based on live-build git repo:


https://github.com/adrian15/live-build/commit/c6da5ff61bb46cb66b23fcb66daa83e23fc8a36b

adrian15
--
Support free software. Donate to Super Grub Disk. Apoya el software 
libre. Dona a Super Grub Disk. http://www.supergrubdisk.org/donate/



--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Bug#757883: Patch for Loopback cfg support

2014-08-16 Thread adrian15

I attach a patch for adding Loopback cfg support.

Development details


A) This patch has been based originally on: binary_grub2 . It has been 
improved thanks to some binary_syslinux bits.


B) binary_loopback_cfg needs to be run before binary_syslinux is run. 
The reason is that it reuses some code from binary_syslinux to avoid 
problems when binary_syslinux renames the kernel filenames.


C) This patch already supports CPU detection

D) Be sure to include the new binary_loopback_cfg file in package definition

E) I haven't tested all the possible scenarios for the script (with the 
latest version). When amd64 and 486 Gnu/Linux flavours is used and the 
bootloader is syslinux it works ok.


F) I have not implemented a disable switch for not generating it. 
Usually you always want loopback.cfg to be there.


G) Compared to binary_grub2 script I have removed the installation 
entries because I did not see any of them in binary_syslinux.


H) Please advise how to improve it so that it gets accepted upstream.

How to test
---

These are some steps to easily test if Looback cfg support is working ok.

0) We assume you have generated an iso
1) Make sure you have a partition that Grub understands. Plain ext4 or 
vfat should do it.

2) Create directory: /boot/boot-isos/
3) Put the iso file into that directory making sure it has an ISO or iso 
extension.
4) Setup your computer to boot from cdrom and use: Super Grub2 Disk 
2.00s2 (Hybrid version recommended)

5) Choose Boot manually...
6) Choose Bootable ISOs (in /boot- ... )
7) Choose (the detected) GRUB Loopback Config 
(hdN,msodsN)/boot/boot-ios/name-of-the.iso
8) You will be presented your loopback.cfg. Choose anyone of the entries 
(unless it does not match your cpu architecture of course).
9) You should boot into your Debian Live without problems (thanks to 
findiso boot parametre).


If you ever wanted to test from your grub2 installation instead from 
Super Grub2 Disk check: http://www.supergrubdisk.org/wiki/Loopback.cfg 
for an example.



adrian15
--
Support free software. Donate to Super Grub Disk. Apoya el software 
libre. Dona a Super Grub Disk. http://www.supergrubdisk.org/donate/
diff -urN original/usr/lib/live/build/binary 
fork_loopback_cfg/usr/lib/live/build/binary
--- original/usr/lib/live/build/binary  2014-08-16 03:09:01.512575406 +
+++ fork_loopback_cfg/usr/lib/live/build/binary 2014-08-16 03:09:37.377196377 
+
@@ -64,6 +64,7 @@
 lb binary_memtest ${@}
 lb binary_grub ${@}
 lb binary_grub2 ${@}
+lb binary_loopback_cfg ${@}
 lb binary_syslinux ${@}
 lb binary_yaboot ${@}
 lb binary_silo ${@}
diff -urN original/usr/lib/live/build/binary_loopback_cfg 
fork_loopback_cfg/usr/lib/live/build/binary_loopback_cfg
--- original/usr/lib/live/build/binary_loopback_cfg 1970-01-01 
00:00:00.0 +
+++ fork_loopback_cfg/usr/lib/live/build/binary_loopback_cfg2014-08-16 
23:12:21.746935266 +
@@ -0,0 +1,305 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2013 Daniel Baumann 
+##
+## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
+## This is free software, and you are welcome to redistribute it
+## under certain conditions; see COPYING for details.
+
+
+set -e
+
+# Including common functions
+[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" 
|| . /usr/lib/live/build.sh
+
+# Setting static variables
+DESCRIPTION="$(Echo 'installs loopback.cfg into binary')"
+HELP=""
+USAGE="${PROGRAM} [--force]"
+
+Arguments "${@}"
+
+# Reading configuration files
+Read_conffiles config/all config/common config/bootstrap config/chroot 
config/binary config/source
+Set_defaults
+
+Echo_message "Begin installing loopback.cfg..."
+
+# Requiring stage file
+Require_stagefile .build/config .build/bootstrap
+
+# Checking stage file
+Check_stagefile .build/binary_loopback_cfg
+
+# Checking grub2 templates
+Check_templates grub2
+
+# Checking lock file
+Check_lockfile .lock
+
+# Creating lock file
+Create_lockfile .lock
+
+# Check architecture
+Check_architectures amd64 i386
+Check_crossarchitectures
+
+# Checking depends
+#Check_package chroot/usr/bin/grub-mkimage grub-pc
+
+# Restoring cache
+Restore_cache cache/packages.binary
+
+# Installing depends
+Install_package
+
+# Local functions
+Grub_live_entry_commands ()
+{
+   local KERNEL="${1}"
+   local INITRD="${2}"
+   local APPEND="${3}"
+
+   LINUX_LIVE="${LINUX_LIVE}\nlinux\t\t/${KERNEL} ${INITFS:+boot=${INITFS} 
}config LB_BOOTAPPEND_LIVE ${APPEND}"
+   LINUX_LIVE="${LINUX_LIVE}\ninitrd\t\t/${INITRD}"
+}
+
+Grub_live_entry ()
+{
+   local LABEL="${1}"
+   local KERNEL="${2}"
+   local INITRD="${3}"
+   local APPEND="${4}"
+
+   LINUX_LIVE="${LINUX_LIVE}\nmenuentry \"Debian GNU/Linux - ${LABEL}\" {"
+   Grub_live_entry_commands "${KERNEL}" "${INITRD}" "${APPEND} 
findiso=\${iso_path}"
+   LINUX_LIVE="${LINUX_LIVE}\n}"
+}
+
+Grub_live_autode