Update all

pull/23/head
johndah4x0r 2017-07-25 20:08:21 +02:00 committed by GitHub
parent 6c0af456e1
commit 284ea76cfa
21 changed files with 1291 additions and 353 deletions

View File

@ -1,13 +1,341 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
License:
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This software is released under GNU GENERAL PUBLIC LICENSE.
Preamble
Warranty:
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
This software is distributed with NO WARRANTY, use it at your own risk.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
Author:
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
This software is written by
Tomas M. <http://www.linux-live.org>
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

View File

@ -1,5 +1,17 @@
You can pass the following boot parameters:
Boot parameters
=====================================================
These are used by the bootloader, the kernel and
the Live Kit system itself.
debug ... start shell prompt several times during live kit startup
You can pass these boot parameters to the bootloader:
from=... load data from given directory (search all drives for it)
Live Kit parameters:
> debug - Start the Live Kit in debugging mode.
> from={n} - Load data from {n}. (will search all devices for the data)
> copy2ram - Boot the Live Kit system just as normal, but also copy data to RAM.
> perch - Activate persistent changes.
Kernel parameters:
> noapic - Disable APIC (if you want, or maybe if your kernel screams about it!)
> acpi=off - Disable ACPI (if you might be still using a legacy system :P)
> init={n} - Execute command {n} instead of the init script itself.

View File

@ -1,31 +1,24 @@
Bundle
------
Bundles
======================================
A bundle is compressed squashfs filesystem, consisting of up-to-the-root
directory structure. Old name for bundle is 'module'. Bundle format
brings some new enhancements over the old modules.
directory structure. The older, but still functional predecessor of the bundle
is called a 'module'. The bundle is an improved version of the 'module'.
File extension for bundles may vary. Currently Slax uses .sb extension,
where 'sb' means 'slax bundle'.
FROM THE MODIFIER/NEW AUTHOR:
> The defaults is 512k, but I opted with 1024k, since
> my system can handle that load, and I will get a smaller bundule size,
> which is a !!HUGE!! advantage!
> And, note: this message is also from the future (2k17!), which means
> that software has also evolved as the years has passed...
> 'mksquashfs' will go nuts if you supply it with '-bs' instead of '-b'...
How to create bundle:
# mksquashfs bundle_rootfs wholefs.sb -comp xz -bs 512k
How to make a bundle:
# mksquashfs bundle_rootfs wholefs.{bext} -comp xz -b 1024k
or
# mksquashfs /usr /usr.sb --keep-as-directory -comp xz -bs 512k
# mksquashfs /usr /usr.{bext} --keep-as-directory -comp xz -b 1024k
or use function in livekitlib:
# . livekitlib; make_bundle bundle_rootfs wholefs.sb
Special files in bundle filesystem structure:
/run/requires
/run/activate.sh
/run/deactivate.sh
/run/startcmd.sh ?
# . livekitlib; mkbund bundle_rootfs wholefs.{bext}

View File

@ -1,14 +1,14 @@
Supported filesystems
---------------------
===========================================================
The Live distro created by Linux Live Kit can be installed
on the following filesystems:
* iso9660 (CD) ..... using isolinux
* FAT32 (vfat) ..... using syslinux or extlinux
* ntfs ............. using syslinux or extlinux
* ext2/3/4,btrfs ... using extlinux
* any other fs ..... using lilo
+ ISO9660 (CD) - using isolinux
+ FAT32 (vfat) - using syslinux or extlinux
+ NTFS - using syslinux or extlinux
+ ext2/3/4,btrfs - using extlinux
+ any other fs - using lilo
Most users will install on FAT32 for compatibility
with the other operating systems (I mean Windows).
Most users will install on FAT32 for
compatibility with any other operating systems.

View File

@ -1,18 +1,24 @@
Live Kit
--------
Linux Live Kit Improved
=========================================================
* also known as Linux Live Kit. Formely known as Linux Live CD. Nowadays,
people mostly use USB flash drives, cameras, and other devices to run
such 'Live' linuxes, thus Live CD is no longer ideal name for it.
+ This toolkit is based on
the original Linux Live Kit. (http://linux-live.org/)
Meaning of Kit is like a tool, toolkit, or such. Which (I believe) corresponds
with the usage of such Live Linux distribution much better.
Extracted from the original terminology.txt:
> also known as Linux Live Kit. Formely known as Linux Live CD. Nowadays,
> people mostly use USB flash drives, cameras, and other devices to run
> such 'Live' linuxes, thus Live CD is no longer ideal name for it.
> Meaning of Kit is like a tool, toolkit, or such. Which (I believe) corresponds
> with the usage of such Live Linux distribution much better.
Bundles
-------
=========================================================
* compressed squashfs images with some specialities
Read ./bundle.txt for more.
+ a bundle is a compressed SquashFS archive/image
used to expand the system. It makes the system pretty much modular.
Read ./bundle.txt to learn more about bundles.

32
README
View File

@ -10,22 +10,28 @@ Some information you want to know:
as for example: '/tmp/a', and put all the files there.
NOTE:
Make sure to extract and use it on a POSIX-compatible filesystem,
since it will create symlinks and such.
Make sure to extract and use it on a POSIX-compatible
filesystem, since it will create symlinks and such that might
not be compatible in for example: FAT and such other filesystems.
+ Before you start building your Kit, edit the ./.config file
Most importantly change the LIVEKITNAME variable.
+ Before you start building your Kit, please consider
editing the ./.config file, and tweak it to suit your needs.
Most importantly, change the LIVEKITNAME variable.
+ Make sure you are pointing to the right kernel. If in doubt, change the path in ./.config
+ Make sure you are pointing to the right kernel . If in doubt, change the path in ./.config
Your kernel must support squashfs and aufs, or else you will get an error
both while building, and when you actually boot the Live Kit.
PROTIP:
On most Linux distro-s, the kernel is in /vmlinuz, a
symlink to /boot/vmlinuz-* or /boot/vmlinux-*
PROTIP #2:
Debian Jessie's kernel has both supported out-of-the-box.
You might consider using Debian Jessie as a base, but it's not required.
+ You may also wish to replace boot background in ./bootfiles/bootlogo.png
and edit and/or tweak syslinux.cfg to fit your needs.
+ You may also consider to replace boot background in
bootfiles/bootpic.png and edit syslinux.cfg to suit your needs.
NOTE:
When editing the configuration file, make sure to keep all paths
@ -40,21 +46,25 @@ Some information you want to know:
syslinux.bin/isolinux.bin else it won't be able to boot your Live Kit
from directory "/LIVEKITNAME". There is a script prepared for you which
will handle all of the building. Simply go to directory ./tools/ and run
update-isolinux.bin, it will rebuild ./bootfiles/isolinux.bin automatically
isolinux.bin-update, it will rebuild ./bootfiles/isolinux.bin automatically
by downloading SysLinux sources, patching them using your actual LIVEKITNAME and
recompiling. This step is not needed if you plan only need the ZIP archive version.
recompiling. This step is not needed if you only need the ZIP archive version.
+ If you have tmpfs mounted on /tmp, make sure you have enough (or maybe even
a lot of) RAM, since Live Kit will store lots of data to the target.
If you don't have enough (or even went out of) RAM, make sure
that /tmp is a regular on-disk directory.
+ You will need to have the following packages installed:
+ If you want to include your own bundules, the 'include_bund/' directory
might come in handy! Just make sure that the file extension matches
with your chosen .BEXT extension.
You will need to have the following packages installed:
- squashfs-tools
- genisoimage and/or mkisofs
- zip
When you're ready run the ./build script to create your Live Kit.
When you're ready, run the ./build script to build your Live Kit Distro.
The script will:
- Build both ISO and ZIP files for you in /tmp
- Do all the hard work for you.

3
TODO
View File

@ -1,3 +1,4 @@
* copy DOC/* to Live Kit created
* describe meaning of special files in bundles
* PXE should include all possible .ko dependencies else some of the ethernet modules won't work, like b44.ko
* PXE should include all possible .ko dependencies else some of the
networking modules won't work, like b44.ko

View File

@ -0,0 +1,59 @@
@echo off
cls
set DISK=none
set TESTFILE=testfile.tmp
echo This file is used to determine current drive letter. It should be deleted. >\%TESTFILE%
if not exist \%TESTFILE% goto readOnly
echo Determining drive letter...
for %%d in ( C D E F G H I J K L M N O P Q R S T U V W X Y Z ) do if exist %%d:\%TESTFILE% set DISK=%%d
del \%TESTFILE%
if %DISK% == none goto DiskNotFound
rem User prompt
rem ============ BEGIN USER PROMPT ============
cls
echo ===========================================================
echo Boot setup: MyLinux
echo ===========================================================
echo Drive letter: %DISK%
echo ===========================================================
echo Thank you for choosing MyLinux!
echo Just make sure this is not your C: drive, or else
echo your OS (that is, Windows) will not boot!
echo.
echo Press any key to continue or press Ctrl-C to cancel...
pause >nul
rem ============ END USER PROMPT ============
echo.
echo Setting up boot record for %DISK%: Please wait...
if %OS% == Windows_NT goto setupNT
goto setup95
:setupNT
\boot\syslinux.exe -maf -d /boot/ %DISK%:
goto setupDone
:setup95
\boot\syslinux.com -maf -d /boot/ %DISK%:
:setupDone
echo Bootloader installation finished!
goto pauseit
:readOnly
echo Error: BootInstall.bat started from read-only media!
goto pauseit
:DiskNotFound
echo Error: Drive letter is non-existant!
:pauseit
echo Press any key to exit...
pause > nul
:end

View File

@ -0,0 +1,121 @@
#!/bin/sh
# Setup booting from disk (USB or harddrive)
# Requires: fdisk, df, tail, tr, cut, dd, sed
# Make sure that we are root
if [ $(id -u) -ne 0 ]; then
echo "> $(basename $0): Must be root to install bootloader!" >&2
exit 1
fi
# change working directory to dir from which we are started
CWD="$(pwd)"
BOOT="$(dirname "$0")"
cd "$BOOT"
# Program definitions
INST_NAME=`basename $0`
INST_PID=$$
LOGFILE="/tmp/$INST_NAME-$INST_PID.log"
# find out device and mountpoint
PART="$(df . | tail -n 1 | tr -s " " | cut -d " " -f 1)"
DEV="$(echo "$PART" | sed -r "s:[0-9]+\$::" | sed -r "s:([0-9])[a-z]+\$:\\1:i")" #"
# Try to use installed extlinux binary and
# fallback to extlinux.exe only if no installed
# extlinux is not found at all.
EXTLINUX="$(which extlinux 2>/dev/null)"
if [ -z "$EXTLINUX" ]; then
echo "> Falling back to included EXTLinux program..." >&2
EXTLINUX="./extlinux.exe"
fi
# Prompt user
#
clear
echo " +-+-+-+-+-+-+-+-+-+-+============+-+-+-+-+-+-+-+-+-+-+-+ "
echo " Boot setup: MyLinux"
echo " +-+-+-+-+-+-+-+-+-+-+============+-+-+-+-+-+-+-+-+-+-+-+ "
echo " Current device: $DEV"
echo " Current partition: $PART"
echo " +-+-+-+-+-+-+-+-+-=+-+-+-+>--<+-+-+-+=-+-+-+-+-+-+-+-+-+ "
echo " Thank you for choosing MyLinux!"
echo " Are you sure that you wanna install MyLinux on"
echo " this device? Make sure that you are not installing on"
echo " your local drive!"
echo " +-+-+-+-+-+-+-+-+-=+-+-+-+>--<+-+-+-+=-+-+-+-+-+-+-+-+-+ "
echo " Just press 'Enter' to continue or press Ctrl-C"
echo " to cancel the installation..."
read -p ' What are you waiting for... ' junk
# If he/she continues, check which disk are we on
if [ "$DEV" = "/dev/sda" ] || [ "$DEV" = "/dev/hda" ]; then
WARN_DISK=0
else
WARN_DISK=1
fi
if [ $WARN_DISK -eq 0 ]; then
# APT-like danger prompt
CONFIRM_TEXT="Yes, do as I say!"
clear
echo " ===================> DANGER! <======================" >&2
echo " Current device: $DEV" >&2
echo " Current partition: $PART" >&2
echo " ====================================================" >&2
echo " You are about to do something "
echo " dangerous to your system!" >&2
echo " ====================================================" >&2
echo " Type in to continue: 'Yes, do as I say!'"
read -p " ?] " CONFIRM
if test "$CONFIRM" != "$CONFIRM_TEXT"; then
echo "> Incorrect phrase!" >&2
echo "> No changes were made!" >&2
exit 1
fi
fi
echo
# notify user
echo "> WARNING: Do not interrupt at this stage!" >&2
echo "> Installing EXTLinux bootloader: Please wait..." >&2
# install bootloader
"$EXTLINUX" --install "$BOOT" 2>&1 | tee $LOGFILE | cat >&2
if [ $? -ne 0 ]; then
echo "> Failed to install boot loader!" >&2
echo "> Please read the errors above (and/or" >&2
echo "> consult the logfile at /tmp) and press Enter to exit." >&2
read junk
exit 1
else
echo "> Installation of EXTLinux bootloader was successful!"
fi
echo "> Initialising new MBR..." >&2
# MBR
if [ "$DEV" != "$PART" ]; then
# Setup MBR on the first block
dd bs=440 count=1 conv=notrunc if="$BOOT/mbr.bin" of="$DEV" 2>/dev/null
# Toggle a bootable flag
PART="$(echo "$PART" | sed -r "s:.*[^0-9]::")"
(
fdisk -l "$DEV" | fgrep "*" | fgrep "$DEV" | cut -d " " -f 1 \
| sed -r "s:.*[^0-9]::" | xargs -I '{}' echo -ne "a\n{}\n"
echo a
echo $PART
echo w
) | fdisk $DEV >/dev/null 2>&1
fi
echo "Bootloader installation finished."
cd "$CWD"

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

View File

@ -1,18 +1,17 @@
UI /boot/vesamenu.c32
TIMEOUT 140
MENU ROWS 4
TIMEOUT 100
MENU CLEAR
MENU BACKGROUND /boot/bootlogo.png
MENU ROWS 8
MENU BACKGROUND /boot/bootpic.png
DEFAULT main
LABEL default
MENU LABEL Run Linux
LABEL main
MENU LABEL Run MyLinux
KERNEL /boot/vmlinuz
APPEND vga=769 initrd=/boot/initrfs.img load_ramdisk=1 prompt_ramdisk=0 rw printk.time=0
APPEND vga=normal initrd=/boot/initramfs.img load_ramdisk=1 rw printk.time=0
LABEL default
MENU LABEL Run Linux debug
LABEL debug
MENU LABEL Run MyLinux (debug)
KERNEL /boot/vmlinuz
APPEND vga=769 initrd=/boot/initrfs.img load_ramdisk=1 prompt_ramdisk=0 rw printk.time=0 debug
APPEND vga=normal initrd=/boot/initramfs.img load_ramdisk=1 rw printk.time=0 debug

View File

@ -4,6 +4,7 @@
#
# Lines containing # are ignored
#
Thank you for using mylinux!
Steps to make it bootable from your USB device:

224
build
View File

@ -1,87 +1,217 @@
#!/bin/bash
# Linux Live Kit version 7
export PATH=.:./tools:../tools:/usr/sbin:/usr/bin:/sbin:/bin:/
# Linux Live Kit Improved v1.0
# Original version: Linux Live Kit version 7
# Modified/improved by: @johndah4x0r [terencedoesmc12 AT gmail DOT com]
CHANGEDIR=$(dirname $(readlink -f $0))
# Environment path
export PATH="${PATH}:.:./tools:../tools"
CHANGEDIR="$(dirname $0)"
echo "Changing current directory to $CHANGEDIR"
CWD="$(pwd)"
cd $CHANGEDIR
cd "$CHANGEDIR"
. ./.config || exit 1
. ./livekitlib || exit 1
source ./.config || exit 1
source ./livekitlib || exit 1
# only root can continue, because only root can read all files from your system
allow_only_root
# check for mksquashfs with xz compression
if [ "$(mksquashfs 2>&1 | grep "Xdict-size")" = "" ]; then
echo "mksquashfs not found or doesn't support -comp xz, aborting, no changes made"
echo "you may consider installing squashfs-tools package"
# It's building time!
clear
echo_livekit_msg "build: Linux Live Kit version 2.0 Improved"
echo_livekit_msg "build: Doing a self-check..."
# Start with 0 errors
ERRS=0
# Check if mksquashfs supports XZ compression
if [ -z "$(mksquashfs 2>&1 | grep "Xdict-size")" ]; then
echo_err "build: 'mksquashfs': not-avail / not-supported"
(( ERRS+=1 ))
else
echo_livekit_msg "build: 'mksquashfs': avail + supported"
fi
# Check if either 'mkisofs' or 'genisoimage' exists
MKISOFS="$(which mkisofs 2>/dev/null || \
which genisoimage 2>/dev/null)"
if [ -z "$MKISOFS" ]; then
echo_err "build: 'mkisofs' / 'genisoimage': not-avail"
(( ERRS+=1 ))
else
echo_livekit_msg "build: '`basename $MKISOFS`': avail"
fi
# Check if we have 'zip'
ZIP_CMD="$(which zip 2>/dev/null)"
if [ -z "$ZIP_CMD" ]; then
# since a ZIP archive is the core, we have to go to fatal mode!
echo_fatal "build: 'zip': not-avail"
echo_fatal "build: 'zip': Critically needed!"
(( ERRS+= 2 ))
else
echo_livekit_msg "build: 'zip': avail"
fi
if [ $ERRS -eq 0 ]; then
echo_livekit_msg "build: Problems found: $ERRS"
echo_livekit_msg "build: Self-check passed."
else
echo_err "build: Problems found: $ERRS"
echo_err "build: Self-check failed!"
echo_err "build: Please make sure that you have all needed packages installed!"
exit 1
fi
MKISOFS=$(which mkisofs)
if [ "$MKISOFS" = "" ]; then
MKISOFS=$(which genisoimage)
fi
if [ "$MKISOFS" = "" ]; then
echo "Cannot found mkisofs or genisoimage, stop"
exit 3
fi
echo_livekit_msg "build: Preparing to build..."
clear
echo " ==========================================="
echo " Linux Live Kit version 2.0 (improved)"
echo " ==========================================="
echo " Live Kit information:"
echo " > Kernel version: $KERNEL"
echo " > Architecture: $ARCH"
echo " > Live Kit name: $LIVEKITNAME"
echo " > Bundule extension: '.$BEXT'"
read -p "Press Enter to continue or press Ctrl-C to cancel... " junk
# It's time to rock 'n roll!
clear
# Generate initramfs image (cpio-xz archive)
echo_livekit_msg "build: Generating initramfs CPIO-XZ image..."
# build initramfs image
echo "Building intramfs image..."
cd initramfs
INITRAMFS=$(./initramfs_create "$LIVEKITNAME")
INITRAMFS="$(./gen-initramfs "$LIVEKITNAME")"
cd ..
# create live kit filesystem (cpio archive)
# Prepare the Live Kit archive
rm -Rf "$LIVEKITDATA"
echo_livekit_msg "build: Preparing boot files..."
BOOT="$LIVEKITDATA"/"$LIVEKITNAME"/boot
mkdir -p "$BOOT"
mkdir -p "$BOOT"/../changes
mkdir -p "$BOOT"/../modules
mv "$INITRAMFS" $BOOT/initrfs.img
mkdir -p "$BOOT"/../bundules
mv "$INITRAMFS" $BOOT/initramfs.img
cp bootfiles/* $BOOT
cat bootfiles/syslinux.cfg | sed -r "s:/boot/:/$LIVEKITNAME/boot/:" > $BOOT/syslinux.cfg
cat bootfiles/bootinst.bat | sed -r "s:/boot/:/$LIVEKITNAME/boot/:" | sed -r "s:\\\\boot\\\\:\\\\$LIVEKITNAME\\\\boot\\\\:" > $BOOT/bootinst.bat
# do substitution
cat bootfiles/syslinux.cfg | sed -r "s:/boot/:/$LIVEKITNAME/boot/:" | \
sed -r "s:MyLinux:$LIVEKITNAME" > $BOOT/syslinux.cfg
echo_livekit_msg "build: BootInstall.*: Replacing 'MyLinux' with '$LIVEKITNAME'..."
cat bootfiles/BootInstall.bat | sed -r "s:/boot/:/$LIVEKITNAME/boot/:" | \
sed -r "s:\\\\boot\\\\:\\\\$LIVEKITNAME\\\\boot\\\\:" | fgrep -iv "rem" | \
sed -r "s:MyLinux:$LIVEKITNAME:" > $BOOT/BootInstall.bat
cat bootfiles/BootInstall.sh | sed -r "s:MyLinux:$LIVEKITNAME:" > $BOOT/BootInstall.sh
echo_livekit_msg "build: Copying kernel..."
cp $VMLINUZ $BOOT/
if [ -d sb ]; then
cp sb/* $LIVEKITDATA/$LIVEKITNAME/
else
# create compressed bundles
for i in $MKMOD; do
mksquashfs /$i $LIVEKITDATA/$LIVEKITNAME/$i.$BEXT -comp xz -b 512k -keep-as-directory
# Copy files from include_bund/, but
# do not skip bundule creation
#
if [ -n "$(ls -A include_bund/ | grep ".$BEXT")" ]; then
echo_livekit_msg "build: Copying bundles from include_bund/ ..."
ls -A include_bund/ | grep ".$BEXT" | \
while read BUND; do
cp $BUND "$LIVEKITDATA"/"$LIVEKITNAME"/bundules/
done
fi
# create compressed bundles
for i in $MKMOD; do
CMDOPT="$(get_exclude "$EXCLUDE" $i)"
echolog "CMDOPT = $CMDOPT" >&2
mkbund /$i $LIVEKITDATA/$LIVEKITNAME/00-main-$i.$BEXT \
-keep-as-directory $CMDOPT
done
# copy rootcopy folder
if [ -d rootcopy ]; then
cp -a rootcopy $LIVEKITDATA/$LIVEKITNAME/
if [ -d rootcopy/ ]; then
echo_livekit_msg "build: Copying contents of rootcopy/..."
cp -a rootcopy/ $LIVEKITDATA/$LIVEKITNAME/
fi
# create ISO for CD image
echo "Creating ISO file for CD boot..."
cd "$LIVEKITDATA"
TARGET=/mnt/z
if [ ! -d $TARGET ]; then
TARGET=/tmp
TARGET=/tmp/livekit-build/
fi
ARCH=$(uname -m)
if [ ! -d $TARGET ]; then
mkdir -p $TARGET &>/dev/null
fi
$MKISOFS -o "$TARGET/$LIVEKITNAME-$ARCH.iso" -v -J -R -D -A "$LIVEKITNAME" -V "$LIVEKITNAME" \
# Output file
OUT_FILE="$LIVEKITNAME-$ARCH-$PID"
# Checksum file
SUM_FILE="$TARGET/CHECKSUMS-${OUT_FILE}.TXT"
# Go to Live Kit build data
cd "$LIVEKITDATA"
# Create ISO image
echo_livekit_msg "build: Creating ISO file for CD boot..."
# How the F@-- can it be more compact than this!?!?
"$MKISOFS" -o "$TARGET/$OUT_FILE.iso" -v -J \
-R -D -A "$LIVEKITNAME" -V "$LIVEKITNAME" \
-no-emul-boot -boot-info-table -boot-load-size 4 \
-b "$LIVEKITNAME"/boot/isolinux.bin -c "$LIVEKITNAME"/boot/isolinux.boot . \
>/dev/null 2>/dev/null
-b "$LIVEKITNAME"/boot/isolinux.bin -c \
"$LIVEKITNAME"/boot/isolinux.boot . &>/dev/null && \
echo_livekit_msg "build: Output file: $OUT_FILE.iso" || \
echo_err "build: $OUT_FILE.iso: Failed to generate ISO file!"
cat "$CWD/bootinfo.txt" | fgrep -v "#" | sed -r "s/mylinux/$LIVEKITNAME/" | sed -r "s/\$/ /" > readme.txt
echo "Creating ZIP for USB boot..."
rm -f "$TARGET/$LIVEKITNAME-$ARCH.zip"
zip -0 -r "$TARGET/$LIVEKITNAME-$ARCH.zip" *
# Substitute 'mylinux' with $LIVEKITNAME
cat "$CWD/bootinfo.txt" | fgrep -v "#" | \
sed -r "s/mylinux/$LIVEKITNAME/" | sed -r "s/\$//" > readme.txt
# Create ZIP archive for "universal" use
echo_livekit_msg "build: Creating ZIP for USB boot..."
rm -f "$TARGET/$OUT_FILE.zip"
zip -0 -r "$TARGET/$OUT_FILE.zip" * &>/dev/null
echo_livekit_msg "build: Output file: $OUT_FILE.zip"
echo_livekit_msg "build: Cleaning up..."
cd ..
rm -Rf "$LIVEKITDATA"
echo "finished. Find your result in $TARGET"
# just for aesthetics
echo_livekit_msg "build: Process ID: $PID - Your results is in $TARGET"
# Generate checksum(s)
echo_livekit_msg "build: Generating MD5 checksums: Please wait..."
MD5_ISO="$(md5sum $TARGET/$OUT_FILE.iso 2>/dev/null | cut -d ' ' -f 1)"
MD5_ZIP="$(md5sum $TARGET/$OUT_FILE.zip 2>/dev/null | cut -d ' ' -f 1)"
cat >"$SUM_FILE" <<EOF
Linux Live Kit Improved
----------------------------------------
Date: `date`
Process ID: $PID
Live Kit name: $LIVEKITNAME
MD5 Checksums for this build:
+ $OUT_FILE.iso - $MD5_ISO
+ $OUT_FILE.zip - $MD5_ZIP
Have a nice day!
EOF
echo_livekit_msg "build: $OUT_FILE.iso: $MD5_ISO"
echo_livekit_msg "build: $OUT_FILE.zip: $MD5_ZIP"
# Done!
echo_livekit_msg "Build process finished!"
echo "Have a nice day!"
read -p "Press Enter to continue..." junk
cd "$CWD"
clear

View File

@ -0,0 +1,130 @@
#!/bin/bash
# Generate initramfs image
# Original author: Tomas M <http://www.linux-live.org/>
# Modified by: 'JohnDaH4x0r' [terencedoesmc12 AT gmail DOT com]
source ../.config
INITRAMFS=/tmp/$LIVEKITNAME-initramfs-$PID
# copy file to initramfs tree, including
# all library dependencies (as shown by ldd)
# $1 = file to copy (full path)
copy_including_deps()
{
# if source doesn't exist or target exists, do nothing
if [ ! -e "$1" -o -e "$INITRAMFS"/"$1" ]; then
return
fi
cp -R --parents "$1" "$INITRAMFS"
if [ -L "$1" ]; then
DIR="$(dirname "$1")"
LNK="$(readlink "$1")"
copy_including_deps "$(cd "$DIR"; realpath -s "$LNK")"
fi
ldd "$1" 2>/dev/null | sed -r "s/.*=>|[(].*//g" | sed -r "s/^\\s+|\\s+\$//" \
| while read LIB; do
copy_including_deps "$LIB"
done
for MOD in $(find "$1" -type f | grep .ko); do
for DEP in $(cat /$LMK/modules.dep | fgrep /$(basename $MOD):); do
copy_including_deps "/$LMK/$DEP"
done
done
shift
if [ "$1" != "" ]; then
copy_including_deps "$@"
fi
}
rm -Rf $INITRAMFS
mkdir -p $INITRAMFS/{bin,dev,etc,lib,lib64,mnt,proc,root,run,sys,tmp,usr,var/log}
ln -s bin $INITRAMFS/sbin
cd static
./update
cd ..
cp static/{busybox,mount.dynfilefs,mount.ntfs-3g,eject} $INITRAMFS/bin
chmod a+x $INITRAMFS/bin/{busybox,mount.*,eject}
$INITRAMFS/bin/busybox | grep , | grep -v Copyright | tr "," " " | while read LINE; do
for TOOL in $LINE; do
if [ ! -e $INITRAMFS/bin/$TOOL ]; then
ln -s busybox $INITRAMFS/bin/$TOOL
fi
done
done
rm -f $INITRAMFS/{s,}bin/init
mknod $INITRAMFS/dev/console c 5 1
mknod $INITRAMFS/dev/null c 1 3
mknod $INITRAMFS/dev/ram0 b 1 0
mknod $INITRAMFS/dev/tty1 c 4 1
mknod $INITRAMFS/dev/tty2 c 4 2
mknod $INITRAMFS/dev/tty3 c 4 3
mknod $INITRAMFS/dev/tty4 c 4 4
#copy_including_deps /usr/bin/strace
#copy_including_deps /usr/bin/lsof
copy_including_deps /$LMK/kernel/fs # all filesystems
copy_including_deps /$LMK/kernel/drivers/staging/zsmalloc # needed by zram
copy_including_deps /$LMK/kernel/drivers/block/zram
copy_including_deps /$LMK/kernel/drivers/block/loop.*
# usb drivers
copy_including_deps /$LMK/kernel/drivers/usb/storage/usb-storage.*
copy_including_deps /$LMK/kernel/drivers/usb/host
copy_including_deps /$LMK/kernel/drivers/usb/common
copy_including_deps /$LMK/kernel/drivers/usb/core
copy_including_deps /$LMK/kernel/drivers/hid/usbhid
copy_including_deps /$LMK/kernel/drivers/hid/hid.*
copy_including_deps /$LMK/kernel/drivers/hid/uhid.*
copy_including_deps /$LMK/kernel/drivers/hid/hid-generic.*
# disk and cdrom drivers
copy_including_deps /$LMK/kernel/drivers/cdrom
copy_including_deps /$LMK/kernel/drivers/scsi/sr_mod.*
copy_including_deps /$LMK/kernel/drivers/scsi/sd_mod.*
copy_including_deps /$LMK/kernel/drivers/scsi/scsi_mod.*
copy_including_deps /$LMK/kernel/drivers/scsi/sg.*
copy_including_deps /$LMK/kernel/drivers/ata
# copy all custom-built modules
copy_including_deps /$LMK/updates
copy_including_deps /$LMK/modules.*
find $INITRAMFS -name "*.ko.gz" -exec gunzip {} \;
# trim modules.order file. Perhaps we could remove it entirely
MODULEORDER="$(cd "$INITRAMFS/$LMK/"; find -name "*.ko" | sed -r "s:^./::g" | tr "\n" "|" | sed -r "s:[.]:.:g")"
cat $INITRAMFS/$LMK/modules.order | sed -r "s/.ko.gz\$/.ko/" | grep -E "$MODULEORDER"/foo/bar > $INITRAMFS/$LMK/_
mv $INITRAMFS/$LMK/_ $INITRAMFS/$LMK/modules.order
depmod -b $INITRAMFS $KERNEL
echo "root::0:0::/root:/bin/bash" >$INITRAMFS/etc/passwd
touch $INITRAMFS/etc/{m,fs}tab
cp init $INITRAMFS
chmod a+x $INITRAMFS/init
cp cleanup $INITRAMFS/lib
chmod a+x $INITRAMFS/lib/cleanup
ln -s ../init $INITRAMFS/bin/init
cp ../livekitlib $INITRAMFS/lib/
cp ../.config $INITRAMFS/lib/
cd $INITRAMFS
find . -print | cpio -o -H newc 2>/dev/null | xz -f --extreme --check=crc32 >$INITRAMFS.img
echo $INITRAMFS.img
cd ..
rm -Rf $INITRAMFS
#mv $INITRAMFS.img /tmp/initrfs.img

View File

@ -1,6 +1,6 @@
#!/bin/sh
# Initial script for Linux Live Kit
# Author: Tomas M <http://www.linux-live.org/>
# Initial script for Linux Live Kit / Linux Live Kit Improved
# Modifier: "JohnDaH4x0r"
export PATH=.:/:/usr/sbin:/usr/bin:/sbin:/bin
@ -15,12 +15,19 @@ UNION=$MEMORY/union
DATAMNT=$MEMORY/data
BUNDLES=$MEMORY/bundles
header "Live Kit init <http://www.linux-live.org/>"
clear
echo_bold "Live Kit Improved v1.0 - INIT"
init_proc_sysfs
# initialise debugging
debug_start
debug_shell
dbg_shell_start
# 1st round debug shell (do not touch!)
debug_shell
# load some modules manually first, then modprobe everything we have
init_devs
init_aufs
@ -29,27 +36,42 @@ modprobe_everything
# find data dir with filesystem bundles
DATA="$(find_data 60 "$DATAMNT")"
debug_shell
# 2nd round debug shell (do not touch!)
debug_shell
# setup persistent changes, if possible
persistent_changes "$DATA" "$CHANGES"
debug_shell
# 3rd round debugg shell
debug_shell
# copy to RAM if needed
DATA="$(copy_to_ram "$DATA" "$CHANGES")"
debug_shell
# init aufs union
init_union "$CHANGES" "$UNION"
debug_shell
# 4th debug shell round
debug_shell
# add data to union
union_append_bundles "$DATA" "$BUNDLES" "$UNION"
debug_shell
# 5th debug shell round
debug_shell
# rootcopy
copy_rootcopy_content "$DATA" "$UNION"
# create empty fstab
fstab_create "$UNION"
debug_shell
header "Live Kit done, starting $LIVEKITNAME"
# 6th debug shell round
debug_shell
clear
echo_bold "Live Kit Improved v1.0 - INIT-DONE"
change_root "$UNION"
header "!!ERROR occured, you shouldn't be here.!!"
/bin/sh
# If everything fails, panic immidiately
fatal "Unknown error!"

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,13 +1,40 @@
#!/bin/sh
# Functions library :: for Linux Live Kit scripts
# Author: Tomas M. <http://www.linux-live.org>
#
# Original author: Tomas M. <http://www.linux-live.org>
# Modified by: 'JohnDaH4x0r' <terencedoesmc12 AT gmail DOT com>
# =================================================================
# debug and output functions
# =================================================================
# related to build script
# get_exclude: Generate exclude arguments for 'mksquashfs'
# $1: the exclude list ("$EXCLUDE", if you use .config)
get_exclude()
{
EXCLUDE_LIST="$1"
PARENT_DIR="$(echo "$2" | tr -s "/")"
if [ -z "$PARENT_DIR" ]; then
return 1
elif [ "$PARENT_DIR" = "/" ]; then
return 1
fi
echo "$EXCLUDE_LIST" | tr " " "\n" | grep "$PARENT_DIR" | \
cut -d ":" -f 2 | while read KEY; do
echo -n "-e $KEY "
done
}
# Output functions
BLUE="\x1b[1;34m"
YELLOW="\x1b[1;33m"
ORANGE="\x1b[0;33m"
GREEN="\x1b[1;32m"
BOLD="\x1b[0;1m"
RED="\x1b[1;31m"
NC="\x1b[0m"
# echo-related
debug_start()
{
if grep -q debug /proc/cmdline; then
@ -17,49 +44,79 @@ debug_start()
fi
}
debug_log()
{
if [ "$DEBUG_IS_ENABLED" ]; then
echo "- debug: $*" >&2
log "- debug: $*"
dbg_shell_start()
if grep -q 'dbg_shell' /proc/cmdline; then
DBG_SHELL=1
else
DBG_SHELL=
fi
}
# header
# $1 = text to show
#
header()
debug_log()
{
echo """$@"""
if [ "$DBG_SHELL" ]; then
echo -e "[ ${GREEN}"'debug'"${NC} ]: $@" >&2
log "debug_log: $*"
fi
}
# echo green star
#
echo_green_star()
# echo fatal tag
# $1 = text to show
echo_fatal()
{
echo -ne """* """
echo -e "[${RED}"' fatal '"${NC}] $@" >&2
}
# echo bold
# $1 = text to show
#
echo_bold()
{
echo -e "$BOLD""$@""$NC"
}
# echo livekit tag
echo_livekit()
{
echo -ne "[${BLUE}"'livekit'"${NC}] "
}
echo_livekit_msg()
{
echo -e "[${BLUE}"'livekit'"${NC}] $@"
}
# echo error
echo_err()
{
echo -e "[${RED}"' error '"${NC}] $@" >&2
}
# echo warn
echo_warn()
{
echo -e "[${YELLOW}"' warn! '"${NC}] $@" >&2
}
# log - store given text in /var/log/livedbg
log()
{
echo "$@" 2>/dev/null >>/var/log/livedbg
echo "$@" 2>/dev/null >>/var/log/livekit-log
}
echolog()
{
echo "$@"
log "$@"
log "echolog: $@"
}
# show information about the debug shell
show_debug_banner()
{
echo
echo "====="
echo ": Debugging started. Here is the root shell for you."
echo ": Type your desired commands or hit Ctrl+D to continue booting."
echo_livekit >&2
echo "Debugging shell started." >&2
echo "The root shell is prepared for you!" >&2
echo "Type your desired commands or press Ctrl-D to continue booting." >&2
echo
}
@ -77,43 +134,57 @@ debug_shell()
fatal()
{
echolog
header "Fatal error occured - $1"
echolog "Something went wrong and we can't continue. This should never happen."
echolog "Please reboot your computer with Ctrl+Alt+Delete ..."
echolog
log "FatalError: $@"
echo_fatal "$@"
echo -e "${RED}"'Please reboot this system now!'"${NC}"
echo -e "${BOLD}"'Live Kig Log: /var/log/livekit-log'"${NC}"
echo -e "${BOLD}"'To get more information, please consult Live Kit Log for more info.'"${NC}"
setsid sh -c 'exec sh < /dev/tty1 >/dev/tty1 2>&1'
}
# get value of commandline parameter $1
# $1 = parameter to search for
#
cmdline_value()
{
cat /proc/cmdline | egrep -o "(^|[[:space:]])$1=[^[:space:]]+" | tr -d " " | cut -d "=" -f 2- | tail -n 1
}
# test if the script is started by root user. If not, exit
#
allow_only_root()
{
if [ "0$UID" -ne 0 ]; then
echo "Only root can run $(basename $0)"; exit 1
echo_err "Only root can run `basename $0`"; exit 1
fi
}
# Create bundle
# Make bundule
# call mksquashfs with apropriate arguments
# $1 = directory which will be compressed to squashfs bundle
# $2 = output file
# $3..$9 = optional arguments like -keep-as-directory or -b 123456789
#
create_bundle()
mkbund()
{
debug_log "create_module" "$*"
rm -f "$2" # overwrite, never append to existing file
mksquashfs "$1" "$2" -comp xz -b 512K $3 $4 $5 $6 $7 $8 $9>/dev/null
debug_log "mkbund" "$*"
if [ -e "$2" ]; then
echo_warn "mkbund: `basename $2`: File already exists!"
echo_warn "mkbund: `basemane $2`: Deleting file..."
rm -f "$2"
else
echo_livekit_msg "mkbund: `basename $2`: Making new bundle..."
fi
echo_livekit_msg "mkbund: SquashFS compression: 1024k - XZ" >&2
echo_livekit_msg "mkbund: `basename $2`: Compressing bundle..." >&2
mksquashfs "$1" "$2" -comp xz -b 1024k $3 $4 $5 $6 $7 $8 $9 >/dev/null || \
(echo_err "mkbund: Failed to make bundle!" && exit 1)
}
# Now, for the Live Kit system-related stuff
# get value of kernel cmdline parameter $1
# $1 = parameter to search for
#
cmdline_value()
{
cat /proc/cmdline | egrep -o "(^|[[:space:]])$1=[^[:space:]]+" | \
tr -d " " | cut -d "=" -f 2- | tail -n 1
}
@ -124,7 +195,8 @@ create_bundle()
transfer_initramfs()
{
if [ ! -r /lib/initramfs_escaped ]; then
echo "switch root from initramfs to ramfs"
echo_livekit
echo "Switching from initramfs to tmpfs..."
SWITCH=/m # one letter directory
mkdir -p $SWITCH
mount -t tmpfs -o size="100%" tmpfs $SWITCH
@ -154,10 +226,9 @@ modprobe_everything()
{
debug_log "modprobe_everything" "$*"
echo_green_star >&2
echo "Probing for hardware" >&2
echo_livekit_msg "Probing for hardware..." >&2
find /lib/modules/ | fgrep .ko | xargs -n 1 modprobe 2>/dev/null
find /lib/modules/ | fgrep '.ko' | xargs -n 1 modprobe 2>/dev/null
refresh_devs
}
@ -171,7 +242,6 @@ refresh_devs()
mdev -s
}
# make sure some devices are there
init_devs()
{
@ -190,8 +260,7 @@ init_devs()
init_zram()
{
debug_log "init_zram" "$*"
echo_green_star
echo "Setting dynamic RAM compression using ZRAM if available"
echo_livekit_msg "Setting up ZRAM as swap if available..."
if [ -r /sys/block/zram0/disksize ]; then
echo 536870912 > /sys/block/zram0/disksize # 512MB
mkswap /dev/zram0 >/dev/null
@ -208,6 +277,13 @@ init_aufs()
# TODO maybe check here if aufs support is working at all
# and produce useful error message if user has no aufs
modprobe aufs 2>/dev/null
# if aufs module failed to load, panic immidiately
if [ $? -ne 0 ]; then
fatal "Failed to load AUFS module!"
fi
# finally, refresh all devices
refresh_devs
}
@ -219,8 +295,7 @@ init_union()
{
debug_log "init_union" "$*"
echo_green_star
echo "Setting up union using AUFS 3"
echo_livekit_msg "Initialising AUFS union..."
mkdir -p "$1"
mkdir -p "$2"
mount -t aufs -o xino="/.xino",trunc_xino,br="$1" aufs "$2"
@ -272,8 +347,8 @@ device_bestfs()
debug_log "device_bestfs" "$*"
local FS
FS="$(blkid "$1" | sed -r "s/.*TYPE=//" | tr -d '"' | tr [A-Z] [a-z])"
if [ "$FS" = "msdos" -o "$FS" = "fat" -o "$FS" = "vfat" ]; then
FS="$(blkid "$1" | sed -r "s/.*TYPE=//" | tr -d '"' | tr [A-Z] [a-z] | cut -d ' ' -f 1)"
if [ "$FS" = "msdos" -o "$FS" = "fat" ]; then
FS="vfat"
elif [ "$FS" = "ntfs" ]; then
FS="ntfs-3g"
@ -306,6 +381,7 @@ fs_options()
init_network_dev()
{
debug_log "init_network_dev" "$*"
echo_livekit_msg "Preparing networking device(s)..." >&2
local MODULE ETH
for MODULE in 3c59x acenic de4x5 e1000 e1000e e100 epic100 hp100 \
@ -325,6 +401,7 @@ init_network_dev()
# If we are here, none of the above specified modules worked.
# As a last chance, try to modprobe everything.
echo_warn "No networking kernel module found!"
modprobe_everything
cat /proc/net/dev | grep : | grep -v lo: | cut -d : -f 1 | tr -d " " | head -n 1
}
@ -341,8 +418,7 @@ download_data_pxe()
mkdir -p "$1/$LIVEKITNAME"
cmdline_value ip | while IFS=":" read CLIENT SERVER GW MASK PORT; do
echo_green_star >&2
echo "Downloading files from $SERVER ..." >&2
echo_livekit_msg "Downloading files from $SERVER ..." >&2
ETH=$(init_network_dev)
if [ "$PORT" = "" ]; then PORT="7529"; fi
@ -362,7 +438,7 @@ download_data_pxe()
PROTOCOL=http
wget -q -O "$1/PXEFILELIST" "http://$SERVER:$PORT/PXEFILELIST?$(uname -r):$(uname -m)"
if [ $? -ne 0 ]; then
echo "Error downloading from http://$SERVER:$PORT, trying TFTP" >&2
echo_warn "Failed to download from http://$SERVER:$PORT, trying TFTP..."
PROTOCOL=tftp
tftp -g -r PXEFILELIST -l "$1/PXEFILELIST" $SERVER
fi
@ -371,7 +447,7 @@ download_data_pxe()
if [ "$PROTOCOL" = "http" ]; then
wget -O "$1/$LIVEKITNAME/$FILE" "http://$SERVER:$PORT/$FILE"
else
echo "* $FILE ..." >&2
echo_livekit_msg "PXE: ${FILE}..." >&2
tftp -g -r $FILE -l "$1/$LIVEKITNAME/$FILE" $SERVER
fi
done
@ -438,16 +514,15 @@ find_data()
FROM="$(cmdline_value from)"
if [ "$FROM" = "" ]; then FROM="$LIVEKITNAME"; fi
echo_green_star >&2
echo -n "Looking for $LIVEKITNAME data in /$FROM .." | tr -s "/" >&2
echo_livekit >&2
echo "Looking for $LIVEKITNAME data in /$FROM .." | tr -s "/" >&2
for timeout in $(seq 1 $1); do
echo -n "." >&2
refresh_devs
DATA="$(find_data_try "$2" "$FROM")"
if [ "$DATA" != "" ]; then
echo "" >&2
echo "* Found on $(mounted_device "$2")" >&2
echo
echo_livekit_msg "$LIVEKITNAME data found on $(mounted_device "$2")" >&2
echo "$DATA"
return
fi
@ -472,8 +547,8 @@ persistent_changes()
local CHANGES T1 T2
CHANGES="$1/$(basename "$2")"
T1="$CHANGES/.empty"
T2="$T1"2
T1="$CHANGES/.perch-test.dat"
T2="${T1}-clone.dat"
# Setup the directory anyway, it will be used in all cases
mkdir -p "$2"
@ -488,19 +563,18 @@ persistent_changes()
# if not, simply return back
if [ $? -ne 0 ]; then
echo "* Persistent changes not writable or not used"
echo_warn "Persistent changes not writable or not used."
return
fi
echo_green_star
echo "Testing persistent changes for posix compatibility"
echo_livekit_msg "Testing persistent changes for POSIX compatibility..." >&2
touch "$T1" && ln -sf "$T1" "$T2" 2>/dev/null && \
chmod +x "$T1" 2>/dev/null && test -x "$T1" && \
chmod -x "$T1" 2>/dev/null && test ! -x "$T1" && \
rm "$T1" "$T2" 2>/dev/null
if [ $? -ne 0 ]; then
echo "* Activating dynamic sized storage for persistent changes"
echo_warn "File system is not POSIX-compatible!" >&2
echo_livekit_msg "Activating DynFileFS persistent changes..." >&2
rm "$T1" "$T2" 2>/dev/null
mount.dynfilefs "$CHANGES/changes.dat" 4000 "$2"
@ -510,7 +584,7 @@ persistent_changes()
mount -o loop,sync "$2/loop.fs" "$2"
rmdir "$2/lost+found" 2>/dev/null
else
echo "* Activating native persistent changes"
echo_livekit_msg "Activating native persistent changes..." >&2
mount --bind "$CHANGES" "$2"
fi
}
@ -523,7 +597,7 @@ copy_rootcopy_content()
debug_log "copy_rootcopy_content" "$*"
if [ "$(ls -1 "$1/rootcopy/" 2>/dev/null)" != "" ]; then
echo_green_star
echo_livekit
echo "Copying content of rootcopy directory..."
cp -a "$1"/rootcopy/* "$2"
fi
@ -539,13 +613,13 @@ copy_to_ram()
local MDIR MDEV RAM CHANGES
if grep -vq toram /proc/cmdline; then
if grep -vq 'copy2ram' /proc/cmdline; then
echo "$1"
return
fi
echo "* Copying $LIVEKITNAME data to RAM..." >&2
RAM="$(dirname "$2")"/toram
echo_livekit_msg "Copying $LIVEKITNAME data to RAM..." >&2
RAM="$(dirname "$2")"/copy_to_ram
mkdir -p "$RAM"
cp -a "$1"/* "$RAM"
echo "$RAM"
@ -606,12 +680,20 @@ union_append_bundles()
local BUN
echo_green_star
echo "Adding bundles to union"
( ls -1 "$1" | sort -n ; cd "$1" ; find modules/ 2>/dev/null | sortmod | filter_load) | grep '[.]'$BEXT'$' | filter_noload | while read BUNDLE; do
echo "* $BUNDLE"
echo_livekit >&2
echo "Appending bundles to union..." >&2
# Just tell me why! Why be compact?!?
( ls -1 "$1" | sort -n ; cd "$1" ; find modules/ 2>/dev/null | \
sortmod | filter_load) | grep '[.]'$BEXT'$' |\
filter_noload | \
while read BUNDLE; do
echo_livekit_msg "Appending: $BUNDLE" >&2
BUN="$(basename "$BUNDLE")"
mkdir -p "$2/$BUN"
# It now depends on your kernel!
mount -o loop -t squashfs "$1/$BUNDLE" "$2/$BUN"
mount -o remount,add:1:"$2/$BUN" aufs "$3"
done
@ -640,7 +722,7 @@ fstab_create()
change_root()
{
debug_log "change_root" "$*"
echo_livekit_msg "Changing root..." >&2
umount /proc
umount /sys
@ -661,11 +743,11 @@ change_root()
if [ -x sbin/chroot -o -L sbin/chroot ]; then CHROOT=sbin/chroot; fi
if [ -x usr/bin/chroot -o -L usr/bin/chroot ]; then CHROOT=usr/bin/chroot; fi
if [ -x usr/sbin/chroot -o -L usr/sbin/chroot ]; then CHROOT=usr/sbin/chroot; fi
if [ "$CHROOT" = "" ]; then fatal "Can't find executable chroot command"; fi
if [ "$CHROOT" = "" ]; then fatal "chroot: Executable not found!"; fi
if [ -x bin/init -o -L bin/init ]; then INIT=bin/init; fi
if [ -x sbin/init -o -L sbin/init ]; then INIT=sbin/init; fi
if [ "$INIT" = "" ]; then fatal "Can't find executable init command"; fi
if [ "$INIT" = "" ]; then fatal "init: Executable not found!"; fi
mkdir -p mnt/live
mount -n -o remount,ro aufs .

View File

@ -0,0 +1,44 @@
#!/bin/bash
# This script will update the file ../bootfiles/isolinux.bin to match
# your LiveKit name used in ../.config
#
# Requires: wget, tar, gzip, make, gcc, nasm, perl, glibc-devel, libuuid-devel (e2fsprogs)
#
# On minimal debian, you can get deps like this:
# apt-get install make binutils gcc nasm uuid-dev
set -e
PKG=syslinux-4.06
PKGTGZ=$PKG.tar.gz
DL="http://www.kernel.org/pub/linux/utils/boot/syslinux/$PKGTGZ"
. ../.config
# download, unpack, and patch syslinux
if [ ! -d $PKG ]; then
rm -rf $PKG
wget --no-check-certificate -c "$DL"
tar -xf $PKGTGZ
fi
cd $PKG
sed -i -r "s:/boot/syslinux:/$LIVEKITNAME/boot:" core/fs/iso9660/iso9660.c
sed -i -r "s:/boot/syslinux:/$LIVEKITNAME/boot:" core/fs/lib/loadconfig.c
make \
${CC:+CC="$CC"}
echo
echo "Copying isolinux.bin to $(readlink -f '../../bootfiles/isolinux.bin')"
cp -p core/isolinux.bin ../../bootfiles/isolinux.bin
echo "Cleaning up..."
cd ..
rm -Rf $PKG
rm -f $PKGTGZ
echo "Done!"