code:
<?xml version="1.0" ?>
<!DOCTYPE PISI SYSTEM "http://www.pisilinux.org/projeler/pisi/pisi-spec.dtd">
<PISI>
    <Source>
        <Name>plymouth</Name>
        <Homepage>http://cgit.freedesktop.org/plymouth</Homepage>
        <Packager>
            <Name>PisiLinux Community</Name>
            <Email>admins@pisilinux.org</Email>
        </Packager>
        <License>GPLv2+</License>
        <IsA>app:console</IsA>
        <IsA>library</IsA>
        Graphical Boot Animation and Logger
        <Description>plymouth provides an attractive graphical boot animation in place of the text messages that normally get shown. Text messages are instead redirected to a log file for viewing after boot.</Description>
        <Archive sha1sum="d0b70929bc47899e03019c3fcd681dd043d7fb8c" type="targz">http://source.pisilinux.org/1.0/plymouth-0.8.8.tar.gz</Archive>
        <Archive sha1sum="f12d053f015708646d0871332b4b9465e7b11cef" type="tarxz" target="plymouth-0.8.8/themes">https://sourceforge.net/projects/pisilinux/files/source/plymouth-theme-pisilinux-0.4.tar.xz</Archive>
        <AdditionalFiles>
            <AdditionalFile permission="0755" target="generate-flist">pisilinux/generate-flist.py</AdditionalFile>
        </AdditionalFiles>
        <BuildDependencies>
            <Dependency>kernel-headers</Dependency>
            <Dependency>libdrm-devel</Dependency>
            <Dependency>libpng-devel</Dependency>
            <Dependency>cairo-devel</Dependency>
            <Dependency>pango-devel</Dependency>
            <Dependency>graphite2-devel</Dependency>
            <Dependency>harfbuzz-devel</Dependency>
            <Dependency>glib2-devel</Dependency>
            <Dependency>gtk2-devel</Dependency>
        </BuildDependencies>
        <Patches>

            <Patch level="1">0008-show-delay.patch</Patch>
            <Patch level="1">pisilinux/plymouth-update-initrd.patch</Patch>
            <Patch level="1">pisilinux/disable-source-code-tracing.patch</Patch>
            <Patch level="1">pisilinux/adapt-theme-script.patch</Patch>
            <Patch level="1">pisilinux/add-pisilinux-theme.patch</Patch>

            <Patch level="1">mageia/plymouth-restore-suspend.patch</Patch>
            <Patch level="1">fedora/fix-crash.patch</Patch>
        </Patches>
    </Source>

    <Package>
        <Name>plymouth</Name>
        <RuntimeDependencies>
            <Dependency>libdrm</Dependency>
            <Dependency>plymouth-core-libs</Dependency>
            <Dependency>plymouth-theme-pisilinux</Dependency>
        </RuntimeDependencies>
        <Files>
            <Path fileType="executable">/bin</Path>
            <Path fileType="executable">/sbin</Path>
            <Path fileType="executable">/usr/sbin</Path>
            <Path fileType="executable">/bin/plymouth</Path>
            <Path fileType="executable">/usr/libexec/plymouth</Path>
            <Path fileType="config">/etc/plymouth</Path>
            <Path fileType="library">/usr/lib</Path>
            <Path fileType="library">/lib</Path>
            <Path fileType="library">/usr/lib/plymouth/text.so</Path>
            <Path fileType="library">/usr/lib/plymouth/details.so</Path>
            <Path fileType="library">/usr/lib/plymouth/renderers</Path>
            <Path fileType="data">/usr/share/pixmaps</Path>
            <Path fileType="data">/usr/share/plymouth</Path>
            <Path fileType="data">/usr/share/plymouth/themes</Path>
            <Path fileType="data">/usr/share/plymouth/themes/details</Path>
            <Path fileType="data">/usr/share/plymouth/themes/text</Path>
            <Path fileType="doc">/usr/share/doc</Path>
            <Path fileType="man">/usr/share/man</Path>
            <Path fileType="data">/var/lib/plymouth</Path>
            <Path fileType="data">/run/plymouth</Path>
            <Path fileType="data">/var/spool/plymouth</Path>
            <Path fileType="config">/usr/lib/tmpfiles.d/plymouth.conf</Path>
        </Files>
        <AdditionalFiles>
            <AdditionalFile owner="root" permission="0644" target="/usr/lib/tmpfiles.d/plymouth.conf">tmpfiles.conf</AdditionalFile>
            <AdditionalFile owner="root" permission="0644" target="/var/lib/plymouth/boot-duration">pisilinux/boot-duration</AdditionalFile>
            <AdditionalFile owner="root" permission="0644" target="/lib/initramfs/plymouth.list">pisilinux/initramfs.files</AdditionalFile>
            <AdditionalFile owner="root" permission="0644" target="/usr/share/pixmaps/plymouth-pisilinux.png">pisilinux/images/white-head.png</AdditionalFile>
            <AdditionalFile owner="root" permission="0644" target="/usr/share/plymouth/themes/charge/charge.plymouth">fedora/charge.plymouth</AdditionalFile>
        </AdditionalFiles>
        <Provides>
            <COMAR script="package.py">System.Package</COMAR>
        </Provides>
    </Package>

    <Package>
        <Name>plymouth-core-libs</Name>
        Plymouth core libraries
        <Description>plymouth-core-libs contains the libply and libply-splash-core libraries used by Plymouth.</Description>
        <Files>
            <Path fileType="library">/lib/libply-splash-core.so*</Path>
            <Path fileType="library">/lib/libply.so*</Path>
        </Files>
    </Package>

    <Package>
        <Name>plymouth-graphics-libs</Name>
        Plymouth graphics libraries
        <Description>plymouth-graphics-libs contains the libply-splash-graphics library used by graphics Plymouth splashes.</Description>
        <RuntimeDependencies>
            <Dependency release="current">plymouth-core-libs</Dependency>
            <Dependency>libpng</Dependency>
        </RuntimeDependencies>
        <Files>
            <Path fileType="library">/usr/lib/libply-splash-graphics.so*</Path>
        </Files>
    </Package>

    <Package>
        <Name>plymouth-devel</Name>
        Development headers and files for plymouth
        <RuntimeDependencies>
            <Dependency release="current">plymouth</Dependency>
        </RuntimeDependencies>
        <Files>
            <Path fileType="header">/usr/include</Path>
            <Path fileType="data">/usr/lib/pkgconfig</Path>
        </Files>
    </Package>

    <Package>
        <Name>plymouth-renderer-x11</Name>
        An X11 renderer for debugging purposes
        <RuntimeDependencies>
            <Dependency release="current">plymouth-core-libs</Dependency>
            <Dependency>cairo</Dependency>
            <Dependency>gtk2</Dependency>
            <Dependency>atk</Dependency>
            <Dependency>cairo</Dependency>
            <Dependency>pango</Dependency>
            <Dependency>gdk-pixbuf</Dependency>
            <Dependency>fontconfig</Dependency>
        </RuntimeDependencies>
        <Files>
            <Path fileType="library">/usr/lib/plymouth/renderers/x11*</Path>
        </Files>
    </Package>

    <Package>
        <Name>plymouth-utils</Name>
        Plymouth related utilities
        <Description>plymouth-utils contains utilities that integrate with Plymouth including a boot log viewing application.</Description>
        <RuntimeDependencies>
            <Dependency>pango</Dependency>
            <Dependency>gtk2</Dependency>
        </RuntimeDependencies>
        <Files>
            <Path fileType="executable">/usr/bin/plymouth-log-viewer</Path>
            <Path fileType="data">/usr/share/gdm/autostart/LoginWindow/plymouth-log-viewer.desktop</Path>
        </Files>
    </Package>

    <Package>
        <Name>plymouth-plugin-label</Name>
        Plymouth label plugin
        <Description>plymouth-plugin-label contains the label control plugin for Plymouth. It provides the ability to render text on graphical boot splashes using pango and cairo.</Description>
        <RuntimeDependencies>
            <Dependency>cairo</Dependency>
            <Dependency>pango</Dependency>
            <Dependency release="current">plymouth-core-libs</Dependency>
            <Dependency release="current">plymouth-graphics-libs</Dependency>
        </RuntimeDependencies>
        <Files>
            <Path fileType="library">/usr/lib/plymouth/label.so</Path>
        </Files>
    </Package>

    <Package>
        <Name>plymouth-plugin-fade-throbber</Name>
        Plymouth Fade-Throbber plugin
        <Description>plymouth-plugin-fade-throbber contains the "Fade-In" boot splash plugin for Plymouth. It features a centered image that fades in and out while other images pulsate around during system boot up.</Description>
        <RuntimeDependencies>
            <Dependency release="current">plymouth-graphics-libs</Dependency>
            <Dependency release="current">plymouth-core-libs</Dependency>
        </RuntimeDependencies>
        <Files>
            <Path fileType="library">/usr/lib/plymouth/fade-throbber.so</Path>
        </Files>
    </Package>

    <Package>
        <Name>plymouth-theme-spinner</Name>
        Spinner theme for Plymouth
        <Description>plymouth-theme-spinner contains the "Spinner" boot splash theme for Plymouth. It features a simple theme with a small spinner on a dark background.</Description>
        <RuntimeDependencies>
            <Dependency release="current">plymouth-plugin-two-step</Dependency>
        </RuntimeDependencies>
        <Files>
            <Path fileType="data">/usr/share/plymouth/themes/spinner</Path>
        </Files>
    </Package>

    <Package>
        <Name>plymouth-theme-fade-in</Name>
        Fade-in theme for Plymouth
        <Description>plymouth-theme-fade-in contains the "Fade-In" boot splash theme for Plymouth. It features a centered logo that fades in and out while stars twinkle around the logo during system boot up.</Description>
        <RuntimeDependencies>
            <Dependency release="current">plymouth-plugin-fade-throbber</Dependency>
        </RuntimeDependencies>
        <Files>
            <Path fileType="data">/usr/share/plymouth/themes/fade-in</Path>
        </Files>
    </Package>

    <Package>
        <Name>plymouth-plugin-throbgress</Name>
        Plymouth Throbgress plugin
        <Description>plymouth-plugin-throbgress contains the "throbgress" boot splash plugin for Plymouth. It features a centered logo and animated spinner that spins repeatedly while a progress bar advances at the bottom of the screen.</Description>
        <RuntimeDependencies>
            <Dependency release="current">plymouth-plugin-label</Dependency>
            <Dependency release="current">plymouth-graphics-libs</Dependency>
            <Dependency release="current">plymouth-core-libs</Dependency>
        </RuntimeDependencies>
        <Files>
            <Path fileType="library">/usr/lib/plymouth/throbgress.so</Path>
        </Files>
    </Package>

    <Package>
        <Name>plymouth-theme-spinfinity</Name>
        Plymouth Spinfinity theme
        <Description>plymouth-theme-spinfinity contains the "Spinfinity" boot splash theme for Plymouth. It features a centered logo and animated spinner that spins in the shape of an infinity sign.</Description>
        <RuntimeDependencies>
            <Dependency release="current">plymouth-plugin-throbgress</Dependency>
        </RuntimeDependencies>
        <Files>
            <Path fileType="data">/usr/share/plymouth/themes/spinfinity</Path>
        </Files>
    </Package>

    <Package>
        <Name>plymouth-plugin-space-flares</Name>
        Plymouth space-flares plugin
        <Description>plymouth-plugin-space-flares contains the "space-flares" boot splash plugin for Plymouth. It features a corner image with animated flares.</Description>
        <RuntimeDependencies>
            <Dependency release="current">plymouth-plugin-label</Dependency>
            <Dependency release="current">plymouth-graphics-libs</Dependency>
            <Dependency release="current">plymouth-core-libs</Dependency>
        </RuntimeDependencies>
        <Files>
            <Path fileType="library">/usr/lib/plymouth/space-flares.so</Path>
        </Files>
    </Package>

    <Package>
        <Name>plymouth-theme-solar</Name>
        Plymouth Solar theme
        <Description>plymouth-theme-solar contains the "Solar" boot splash theme for Plymouth. It features a blue flamed sun with animated solar flares.</Description>
        <RuntimeDependencies>
            <Dependency release="current">plymouth-plugin-space-flares</Dependency>
        </RuntimeDependencies>
        <Files>
            <Path fileType="data">/usr/share/plymouth/themes/solar</Path>
        </Files>
    </Package>

    <Package>
        <Name>plymouth-plugin-two-step</Name>
        Plymouth Two-Step plugin
        <Description>plymouth-plugin-two-step contains the "two-step" boot splash plugin for Plymouth. It features a two phased boot process that starts with a progressing animation synced to boot time and finishes with a short, fast one-shot animation.</Description>
        <RuntimeDependencies>
            <Dependency release="current">plymouth-plugin-label</Dependency>
            <Dependency release="current">plymouth-graphics-libs</Dependency>
            <Dependency release="current">plymouth-core-libs</Dependency>
        </RuntimeDependencies>
        <Files>
            <Path fileType="library">/usr/lib/plymouth/two-step.so</Path>
        </Files>
    </Package>

    <Package>
        <Name>plymouth-theme-charge</Name>
        Plymouth Charge plugin
        <Description>plymouth-theme-charge This package contains the "charge" boot splash theme for Plymouth. It features the shadowy hull of a Fedora logo charge up and and finally burst into full form.</Description>
        <RuntimeDependencies>
            <Dependency release="current">plymouth-plugin-two-step</Dependency>
        </RuntimeDependencies>
        <Files>
            <Path fileType="data">/usr/share/plymouth/themes/charge</Path>
        </Files>
    </Package>

    <Package>
        <Name>plymouth-plugin-script</Name>
        Plymouth script plugin
        <Description>plymouth-plugin-script contains "script" boot splash plugin for Plymouth. It features an extensible, scriptable boot splash language that simplifies the process of designing custom boot splash themes.</Description>
        <RuntimeDependencies>
            <Dependency release="current">plymouth-graphics-libs</Dependency>
            <Dependency release="current">plymouth-core-libs</Dependency>
        </RuntimeDependencies>
        <Files>
            <Path fileType="library">/usr/lib/plymouth/script.so</Path>
        </Files>
    </Package>

    <Package>
        <Name>plymouth-theme-script</Name>
        Plymouth Script theme
        <Description>plymouth-theme-script contains the "script" boot splash theme for Plymouth. It it is a simple example theme the uses the "script" plugin.</Description>
        <RuntimeDependencies>
            <Dependency release="current">plymouth-plugin-script</Dependency>
        </RuntimeDependencies>
        <Files>
            <Path fileType="data">/usr/share/plymouth/themes/script</Path>
        </Files>
    </Package>

    <Package>
        <Name>plymouth-theme-pisilinux</Name>
        Plymouth Pisi Linux theme
        <Description>plymouth-theme-pisilinux contains a simple but elegant boot theme for Pisi Linux.</Description>
        <RuntimeDependencies>
            <Dependency release="current">plymouth-plugin-script</Dependency>
        </RuntimeDependencies>
        <Files>
            <Path fileType="data">/usr/share/plymouth/themes/pisilinux</Path>
        </Files>
    </Package>

    <History>
        <Update release="7">
            <Date>2017-03-01</Date>
            <Version>0.8.8</Version>
            <Comment>Rebuild for new toolchain.</Comment>
            <Name>Pisi Linux Community</Name>
            <Email>admin@pisilinux.org</Email>
        </Update>
        <Update release="6">
            <Date>2016-08-25</Date>
            <Version>0.8.8</Version>
            <Comment>script fix.</Comment>
            <Name>Pisi Linux Community</Name>
            <Email>admin@pisilinux.org</Email>
        </Update>
        <Update release="5">
            <Date>2016-08-22</Date>
            <Version>0.8.8</Version>
            <Comment>actions fix</Comment>
            <Name>Pisi Linux Community</Name>
            <Email>admin@pisilinux.org</Email>
        </Update>
        <Update release="4">
            <Date>2016-08-21</Date>
            <Version>0.8.8</Version>
            <Comment>New theme.</Comment>
            <Name>Pisi Linux Community</Name>
            <Email>admin@pisilinux.org</Email>
        </Update>
        <Update release="3">
            <Date>2016-06-08</Date>
            <Version>0.8.8</Version>
            <Comment>Release Bump</Comment>
            <Name>Pisi Linux Community</Name>
            <Email>admin@pisilinux.org</Email>
        </Update>
        <Update release="2">
            <Date>2016-04-21</Date>
            <Version>0.8.8</Version>
            <Comment>Release bump</Comment>
            <Name>Alihan Öztürk</Name>
            <Email>alihan@pisilinux.org</Email>
        </Update>
        <Update release="1">
            <Date>2016-04-21</Date>
            <Version>0.8.8</Version>
            <Comment>First release</Comment>
            <Name>Alihan Öztürk</Name>
            <Email>alihan@pisilinux.org</Email>
        </Update>
    </History>
</PISI>


code:
<?xml version="1.0" ?>
<PISI>
    <Source>
        <Name>plymouth</Name>
        Açılış animasyonu ve oturum açma altyapısı
        <Description xml:lang="tr">plymouth, sistemin açılışı esnasında estetik ve ilgi çekici bir grafiksel animasyon altyapısı sunan bir uygulamadır.</Description>
    </Source>

    <Package>
        <Name>plymouth-theme-charge</Name>
        plymouth için Charge teması
    </Package>

    <Package>
        <Name>plymouth-theme-spinner</Name>
        plymouth için Spinner teması
    </Package>

    <Package>
        <Name>plymouth-theme-solar</Name>
        plymouth için Solar teması
    </Package>

    <Package>
        <Name>plymouth-theme-spinfinity</Name>
        plymouth için Spinfinity teması
    </Package>

    <Package>
        <Name>plymouth-theme-glow</Name>
        plymouth için Glow teması
    </Package>

    <Package>
        <Name>plymouth-theme-pisilinux</Name>
        plymouth için Pisi Linux teması
    </Package>

    <Package>
        <Name>plymouth-theme-fadein</Name>
        plymouth için Fade-in teması
    </Package>

</PISI>

repo_name: ayhanyalcinsoy/main


code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Licensed under the GNU General Public License, version 3.
# See the file http://www.gnu.org/licenses/gpl.txt

from pisi.actionsapi import pisitools

WorkDir = "."

def install():
    pisitools.insinto("/", "./usr")
    pisitools.insinto("/", "./etc")


code:
#!/usr/bin/python

import os

def postInstall(fromVersion, fromRelease, toVersion, toRelease):
    os.system("refind-install")
    os.system("rm -rf /boot/efi/EFI/boot")

def preRemove():
    pass


code:
<?xml version="1.0" ?>
<!DOCTYPE PISI SYSTEM "http://www.pisilinux.org/projeler/pisi/pisi-spec.dtd">
<PISI>
    <Source>
        <Name>refind</Name>
        <Homepage>https://sourceforge.net/projects/refind/</Homepage>
        <Packager>
            <Name>Ergün Salman</Name>
            <Email>poyraz76@pisilinux.org</Email>
        </Packager>
        <License>rEFIt</License>
        <IsA>library</IsA>
        <Summary>refind uefi multi boot</Summary>
        <Description>refind uefi multi boot</Description>
        <Archive sha1sum="4316f4cf99fa2578e5a102b8e75f1af4be601357" type="targz">https://sourceforge.net/projects/pisi-source/files/refind-0.10.3.tar.gz</Archive>
    </Source>

    <Package>
        <Name>refind</Name>
        <Files>
            <Path fileType="library">/usr/*</Path>
            <Path fileType="data">/etc/*</Path>
        </Files>
        <Provides>
            <COMAR script="package.py">System.Package</COMAR>
        </Provides>
    </Package>

    <History>
        <Update release="2">
            <Date>2017-04-20</Date>
            <Version>0.10.3</Version>
            <Comment>Relase bump</Comment>
            <Name>Ayhan Yalçınsoy</Name>
            <Email>ayhanyalcinsoy@pisilinux.org</Email>
        </Update>
        <Update release="1">
            <Date>2016-07-30</Date>
            <Version>0.10.3</Version>
            <Comment>Relase Frist</Comment>
            <Name>Ergün Salman</Name>
            <Email>poyraz76@pisilinux.org</Email>
        </Update>
    </History>
</PISI>


code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Licensed under the GNU General Public License, version 3.
# See the file http://www.gnu.org/copyleft/gpl.txt.

from pisi.actionsapi import get
from pisi.actionsapi import autotools
from pisi.actionsapi import pisitools
from pisi.actionsapi import shelltools

#tools = ["sha1pass", "md5pass", "mkdiskimage*", "keytab-lilo", "syslinux2ansi", "lss16toppm","pxelinux-options"]
datadir = "/usr/lib/syslinux"

NoStrip = ["/sbin", "/usr/lib"]

def build():
    shelltools.export("CFLAGS", get.CFLAGS())
    shelltools.export("LDFLAGS", "")
    # do not swallow efi compilation output to make debugging easier
    shelltools.system("sed 's|> /dev/null 2>&1||' -i efi/check-gnu-efi.sh")

    # disable debug and development flags to reduce bootloader size
    shelltools.system("truncate --size 0 mk/devel.mk")

    autotools.make("-j1 PYTHON=python bios efi64 efi32")

def install():
    autotools.rawInstall('INSTALLROOT=%s MANDIR="/usr/share/man" AUXDIR="/usr/lib/syslinux"' % get.installDIR())

    #pisitools.removeDir("/usr/lib/syslinux/com32")
    #pisitools.removeDir("/usr/lib/syslinux/dosutil")
    #pisitools.remove("/usr/lib/syslinux/syslinux.com")

    # pisitools.dodir("/usr/lib/syslinux/bios")

    # pisitools.domove("/usr/lib/syslinux/*.c32", "/usr/lib/syslinux/bios")
    # pisitools.domove("/usr/lib/syslinux/*.bin", "/usr/lib/syslinux/bios")
    # pisitools.domove("/usr/lib/syslinux/*.0", "/usr/lib/syslinux/bios")
    # pisitools.domove("/usr/lib/syslinux/memdisk", "/usr/lib/syslinux/bios")

    #for f in tools:
    #    pisitools.insinto(datadir, "utils/"+f)

    pisitools.dodoc("README", "NEWS", "doc/*.txt", "doc/logo/LICENSE")
    pisitools.remove("/usr/bin/gethostip")


code:
From ca745cdfc27b83b6bcef9f856d858a68c64429de Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Tue, 8 Apr 2014 15:28:12 -0400
Subject: [PATCH] Add "install-all target" to top side of HAVE_FIRMWARE.

---
 Makefile | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/Makefile b/Makefile
index fb387c5..3429058 100644
--- a/Makefile
+++ b/Makefile
@@ -273,6 +273,16 @@ efi64:
 		FIRMWARE=EFI64 \
 		$(MAKECMDGOALS)

+install-all:
+
+install:
+
+netinstall:
+
+clean:
+
+all:
+
 else # ifeq($(HAVE_FIRMWARE),)

 all: all-local subdirs
--
1.9.3


code:
From 3106dcd19061b4443c5beba4f0e09412e8d37fbe Mon Sep 17 00:00:00 2001
From: Dany St-Amant <dany.ephemeral.2014@icloud.com>
Date: Fri, 28 Nov 2014 13:48:32 -0500
Subject: [PATCH 35/74] SYSAPPEND: Fix space stripping

The description of SYSAPPEND for the DMI information states that the spaces
are replaced by underscores, but this replacement does not occur in 6.03.

Signed-off-by: Dany St-Amant <dany.ephemeral.2014@icloud.com>
Signed-off-by: Gene Cumm <gene.cumm@gmail.com>
---
 com32/elflink/ldlinux/readconfig.c | 2 +-
 com32/menu/readconfig.c            | 2 +-
 core/sysappend.c                   | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/com32/elflink/ldlinux/readconfig.c b/com32/elflink/ldlinux/readconfig.c
index 347f826..24f1cc9 100644
--- a/com32/elflink/ldlinux/readconfig.c
+++ b/com32/elflink/ldlinux/readconfig.c
@@ -330,7 +330,7 @@ static char *copy_sysappend_string(char *dst, const char *src)
     char c;

     while ((c = *src++)) {
-	if (c <= ' ' && c == '\x7f') {
+	if (c <= ' ' || c == '\x7f') {
 	    if (!was_space)
 		*dst++ = '_';
 	    was_space = true;
diff --git a/com32/menu/readconfig.c b/com32/menu/readconfig.c
index b7814be..257b042 100644
--- a/com32/menu/readconfig.c
+++ b/com32/menu/readconfig.c
@@ -299,7 +299,7 @@ static char *copy_sysappend_string(char *dst, const char *src)
     char c;

     while ((c = *src++)) {
-	if (c <= ' ' && c == '\x7f') {
+	if (c <= ' ' || c == '\x7f') {
 	    if (!was_space)
 		*dst++ = '_';
 	    was_space = true;
diff --git a/core/sysappend.c b/core/sysappend.c
index 5c3f650..758703e 100644
--- a/core/sysappend.c
+++ b/core/sysappend.c
@@ -35,7 +35,7 @@ static char *copy_and_mangle(char *dst, const char *src)
     char c;

     while ((c = *src++)) {
-	if (c <= ' ' && c == '\x7f') {
+	if (c <= ' ' || c == '\x7f') {
 	    if (!was_space)
 		*dst++ = '_';
 	    was_space = true;
--
2.4.5


code:
From 548386049cd41e887079cdb904d3954365eb28f3 Mon Sep 17 00:00:00 2001
From: Paulo Alcantara <pcacjr@zytor.com>
Date: Thu, 24 Dec 2015 01:48:13 -0200
Subject: [PATCH 1/1] btrfs: Fix logical to physical block address mapping

The current btrfs support did not handled multiple stripes stored in
chunk items, hence skipping the physical addresses that were needed to
do the mapping.

Besides, the chunk tree may contain DEV_ITEM keys which store
information on all of the underlying block devices, so we must skip them
instead of finishing lookup.

The bug was reproduced with btrfs-progs v4.2.2.

Cc: Gene Cumm <gene.cumm@gmail.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Paulo Alcantara <pcacjr@zytor.com>
---
v1 -> v2:
 * Do not set ignore_key multiple times. Set it before parsing chunk
   tree.
v2 -> v3:
 * Replace an unnecessary goto with a continue statement.
---
 core/fs/btrfs/btrfs.c | 49 +++++++++++++++++++++++++++++++++----------------
 core/fs/btrfs/btrfs.h |  2 ++
 2 files changed, 35 insertions(+), 16 deletions(-)

diff --git a/core/fs/btrfs/btrfs.c b/core/fs/btrfs/btrfs.c
index 53e1105..58e1fe6 100644
--- a/core/fs/btrfs/btrfs.c
+++ b/core/fs/btrfs/btrfs.c
@@ -81,7 +81,8 @@ static int btrfs_comp_chunk_map(struct btrfs_chunk_map_item *m1,
 }

 /* insert a new chunk mapping item */
-static void insert_map(struct fs_info *fs, struct btrfs_chunk_map_item *item)
+static void insert_chunk_item(struct fs_info *fs,
+			      struct btrfs_chunk_map_item *item)
 {
 	struct btrfs_info * const bfs = fs->fs_info;
 	struct btrfs_chunk_map *chunk_map = &bfs->chunk_map;
@@ -113,6 +114,22 @@ static void insert_map(struct fs_info *fs, struct btrfs_chunk_map_item *item)
 	chunk_map->cur_length++;
 }

+static inline void insert_map(struct fs_info *fs, struct btrfs_disk_key *key,
+			      struct btrfs_chunk *chunk)
+{
+	struct btrfs_stripe *stripe = &chunk->stripe;
+	struct btrfs_stripe *stripe_end = stripe + chunk->num_stripes;
+	struct btrfs_chunk_map_item item;
+
+	item.logical = key->offset;
+	item.length = chunk->length;
+	for ( ; stripe < stripe_end; stripe++) {
+		item.devid = stripe->devid;
+		item.physical = stripe->offset;
+		insert_chunk_item(fs, &item);
+	}
+}
+
 /*
  * from sys_chunk_array or chunk_tree, we can convert a logical address to
  * a physical address we can not support multi device case yet
@@ -330,7 +347,6 @@ static int next_slot(struct fs_info *fs, struct btrfs_disk_key *key,
 static void btrfs_read_sys_chunk_array(struct fs_info *fs)
 {
 	struct btrfs_info * const bfs = fs->fs_info;
-	struct btrfs_chunk_map_item item;
 	struct btrfs_disk_key *key;
 	struct btrfs_chunk *chunk;
 	int cur;
@@ -342,12 +358,7 @@ static void btrfs_read_sys_chunk_array(struct fs_info *fs)
 		cur += sizeof(*key);
 		chunk = (struct btrfs_chunk *)(bfs->sb.sys_chunk_array + cur);
 		cur += btrfs_chunk_item_size(chunk->num_stripes);
-		/* insert to mapping table, ignore multi stripes */
-		item.logical = key->offset;
-		item.length = chunk->length;
-		item.devid = chunk->stripe.devid;
-		item.physical = chunk->stripe.offset;/*ignore other stripes */
-		insert_map(fs, &item);
+		insert_map(fs, key, chunk);
 	}
 }

@@ -355,14 +366,18 @@ static void btrfs_read_sys_chunk_array(struct fs_info *fs)
 static void btrfs_read_chunk_tree(struct fs_info *fs)
 {
 	struct btrfs_info * const bfs = fs->fs_info;
+	struct btrfs_disk_key ignore_key;
 	struct btrfs_disk_key search_key;
 	struct btrfs_chunk *chunk;
-	struct btrfs_chunk_map_item item;
 	struct btrfs_path path;

 	if (!(bfs->sb.flags & BTRFS_SUPER_FLAG_METADUMP)) {
 		if (bfs->sb.num_devices > 1)
 			printf("warning: only support single device btrfs\n");
+
+		ignore_key.objectid = BTRFS_DEV_ITEMS_OBJECTID;
+		ignore_key.type = BTRFS_DEV_ITEM_KEY;
+
 		/* read chunk from chunk_tree */
 		search_key.objectid = BTRFS_FIRST_CHUNK_TREE_OBJECTID;
 		search_key.type = BTRFS_CHUNK_ITEM_KEY;
@@ -371,16 +386,18 @@ static void btrfs_read_chunk_tree(struct fs_info *fs)
 		search_tree(fs, bfs->sb.chunk_root, &search_key, &path);
 		do {
 			do {
+				/* skip information about underlying block
+				 * devices.
+				 */
+				if (!btrfs_comp_keys_type(&ignore_key,
+							  &path.item.key))
+					continue;
 				if (btrfs_comp_keys_type(&search_key,
-							&path.item.key))
+							 &path.item.key))
 					break;
+
 				chunk = (struct btrfs_chunk *)(path.data);
-				/* insert to mapping table, ignore stripes */
-				item.logical = path.item.key.offset;
-				item.length = chunk->length;
-				item.devid = chunk->stripe.devid;
-				item.physical = chunk->stripe.offset;
-				insert_map(fs, &item);
+				insert_map(fs, &path.item.key, chunk);
 			} while (!next_slot(fs, &search_key, &path));
 			if (btrfs_comp_keys_type(&search_key, &path.item.key))
 				break;
diff --git a/core/fs/btrfs/btrfs.h b/core/fs/btrfs/btrfs.h
index 8f519a9..32e7c70 100644
--- a/core/fs/btrfs/btrfs.h
+++ b/core/fs/btrfs/btrfs.h
@@ -56,6 +56,8 @@ typedef u64 __le64;
 #define BTRFS_MAX_LEVEL 8
 #define BTRFS_MAX_CHUNK_ENTRIES 256

+#define BTRFS_DEV_ITEMS_OBJECTID 1ULL
+
 #define BTRFS_FT_REG_FILE	1
 #define BTRFS_FT_DIR		2
 #define BTRFS_FT_SYMLINK	7
--
2.5.5.GIT


code:
From 0cc9a99e560a2f52bcf052fd85b1efae35ee812f Mon Sep 17 00:00:00 2001
From: Sylvain Gault <sylvain.gault@gmail.com>
Date: Tue, 29 Sep 2015 04:45:09 +0200
Subject: [PATCH 1/1] bios: Don't try to guess the sections alignment

For the compression / decompression to succeed, the sections layout must
be the same between the virtual memory and load memory. The section
alignment was kept in sync by introducing aligment that should be
greater or equal to the actual section alignment.

This patch compute the load memory addresses of the sections so that
the layout is the same as the virtual memory addresses.

Signed-off-by: Sylvain Gault <sylvain.gault@gmail.com>
Tested-by: poma <pomidorabelisima@gmail.com>
Signed-off-by: Paulo Alcantara <pcacjr@zytor.com>
---
 core/i386/syslinux.ld   | 63 ++++++++++---------------------------------------
 core/x86_64/syslinux.ld | 63 ++++++++++---------------------------------------
 2 files changed, 24 insertions(+), 102 deletions(-)

diff --git a/core/i386/syslinux.ld b/core/i386/syslinux.ld
index 7390451..92b75b1 100644
--- a/core/i386/syslinux.ld
+++ b/core/i386/syslinux.ld
@@ -255,10 +255,9 @@ SECTIONS
 	. = 0x100000;

 	__pm_code_start = .;
+	__vma_to_lma = __pm_code_lma - __pm_code_start;

-	__text_vma = .;
-	__text_lma = __pm_code_lma;
-	.text : AT(__text_lma) {
+	.text : AT(ADDR(.text) + __vma_to_lma) {
 		FILL(0x90909090)
 		__text_start = .;
 		*(.text)
@@ -266,106 +265,68 @@ SECTIONS
 		__text_end = .;
 	}

-	. = ALIGN(32);
-
-	__rodata_vma = .;
-	__rodata_lma = __rodata_vma + __text_lma - __text_vma;
-	.rodata : AT(__rodata_lma) {
+	.rodata : AT(ADDR(.rodata) + __vma_to_lma) {
 		__rodata_start = .;
 		*(.rodata)
 		*(.rodata.*)
 		__rodata_end = .;
 	}

-	. = ALIGN(4);
-
-	__ctors_vma = .;
-	__ctors_lma = __ctors_vma + __text_lma - __text_vma;
-	.ctors : AT(__ctors_lma) {
+	.ctors : AT(ADDR(.ctors) + __vma_to_lma) {
 		__ctors_start = .;
 		KEEP (*(SORT(.ctors.*)))
 		KEEP (*(.ctors))
 		__ctors_end = .;
 	}

-	__dtors_vma = .;
-	__dtors_lma = __dtors_vma + __text_lma - __text_vma;
-	.dtors : AT(__dtors_lma) {
+	.dtors : AT(ADDR(.dtors) + __vma_to_lma) {
 		__dtors_start = .;
 		KEEP (*(SORT(.dtors.*)))
 		KEEP (*(.dtors))
 		__dtors_end = .;
 	}

-	. = ALIGN(4);
-
-	__dynsym_vma = .;
-	__dynsym_lma = __dynsym_vma + __text_lma - __text_vma;
-	.dynsym : AT(__dynsym_lma) {
+	.dynsym : AT(ADDR(.dynsym) + __vma_to_lma) {
 		__dynsym_start = .;
 		*(.dynsym)
 		__dynsym_end = .;
 	}
 	__dynsym_len = __dynsym_end - __dynsym_start;

-	. = ALIGN(4);
-
-	__dynstr_vma = .;
-	__dynstr_lma = __dynstr_vma + __text_lma - __text_vma;
-	.dynstr : AT(__dynstr_lma) {
+	.dynstr : AT(ADDR(.dynstr) + __vma_to_lma) {
 		__dynstr_start = .;
 		*(.dynstr)
 		__dynstr_end = .;
 	}
 	__dynstr_len = __dynstr_end - __dynstr_start;

-	. = ALIGN(4);
-
-	__gnu_hash_vma = .;
-	__gnu_hash_lma = __gnu_hash_vma + __text_lma - __text_vma;
-	.gnu.hash : AT(__gnu_hash_lma) {
+	.gnu.hash : AT(ADDR(.gnu.hash) + __vma_to_lma) {
 		__gnu_hash_start = .;
 		*(.gnu.hash)
 		__gnu_hash_end = .;
 	}

-	. = ALIGN(4);
-
-	__dynlink_vma = .;
-	__dynlink_lma = __dynlink_vma + __text_lma - __text_vma;
-	.dynlink : AT(__dynlink_lma) {
+	.dynlink : AT(ADDR(.dynlink) + __vma_to_lma) {
 		__dynlink_start = .;
 		*(.dynlink)
 		__dynlink_end = .;
 	}

-	. = ALIGN(4);
-
-	__got_vma = .;
-	__got_lma = __got_vma + __text_lma - __text_vma;
-	.got : AT(__got_lma) {
+	.got : AT(ADDR(.got) + __vma_to_lma) {
 		__got_start = .;
 		KEEP (*(.got.plt))
 		KEEP (*(.got))
 		__got_end = .;
 	}

-	. = ALIGN(4);
-
-	__dynamic_vma = .;
-	__dynamic_lma = __dynamic_vma + __text_lma - __text_vma;
-	.dynamic : AT(__dynamic_lma) {
+	.dynamic : AT(ADDR(.dynamic) + __vma_to_lma) {
 		__dynamic_start = .;
 		*(.dynamic)
 		__dynamic_end = .;
 	}

-	. = ALIGN(32);
-
-	__data_vma = .;
-	__data_lma = __data_vma + __text_lma - __text_vma;
-	.data : AT(__data_lma) {
+	.data : AT(ADDR(.data) + __vma_to_lma) {
 		__data_start = .;
 		*(.data)
 		*(.data.*)
diff --git a/core/x86_64/syslinux.ld b/core/x86_64/syslinux.ld
index bf815c4..70c6e00 100644
--- a/core/x86_64/syslinux.ld
+++ b/core/x86_64/syslinux.ld
@@ -255,10 +255,9 @@ SECTIONS
 	. = 0x100000;

 	__pm_code_start = .;
+	__vma_to_lma = __pm_code_lma - __pm_code_start;

-	__text_vma = .;
-	__text_lma = __pm_code_lma;
-	.text : AT(__text_lma) {
+	.text : AT(ADDR(.text) + __vma_to_lma) {
 		FILL(0x90909090)
 		__text_start = .;
 		*(.text)
@@ -266,106 +265,68 @@ SECTIONS
 		__text_end = .;
 	}

-	. = ALIGN(32);
-
-	__rodata_vma = .;
-	__rodata_lma = __rodata_vma + __text_lma - __text_vma;
-	.rodata : AT(__rodata_lma) {
+	.rodata : AT(ADDR(.rodata) + __vma_to_lma) {
 		__rodata_start = .;
 		*(.rodata)
 		*(.rodata.*)
 		__rodata_end = .;
 	}

-	. = ALIGN(4);
-
-	__ctors_vma = .;
-	__ctors_lma = __ctors_vma + __text_lma - __text_vma;
-	.ctors : AT(__ctors_lma) {
+	.ctors : AT(ADDR(.ctors) + __vma_to_lma) {
 		__ctors_start = .;
 		KEEP (*(SORT(.ctors.*)))
 		KEEP (*(.ctors))
 		__ctors_end = .;
 	}

-	__dtors_vma = .;
-	__dtors_lma = __dtors_vma + __text_lma - __text_vma;
-	.dtors : AT(__dtors_lma) {
+	.dtors : AT(ADDR(.dtors) + __vma_to_lma) {
 		__dtors_start = .;
 		KEEP (*(SORT(.dtors.*)))
 		KEEP (*(.dtors))
 		__dtors_end = .;
 	}

-	. = ALIGN(4);
-
-	__dynsym_vma = .;
-	__dynsym_lma = __dynsym_vma + __text_lma - __text_vma;
-	.dynsym : AT(__dynsym_lma) {
+	.dynsym : AT(ADDR(.dynsym) + __vma_to_lma) {
 		__dynsym_start = .;
 		*(.dynsym)
 		__dynsym_end = .;
 	}
 	__dynsym_len = __dynsym_end - __dynsym_start;

-	. = ALIGN(4);
-
-	__dynstr_vma = .;
-	__dynstr_lma = __dynstr_vma + __text_lma - __text_vma;
-	.dynstr : AT(__dynstr_lma) {
+	.dynstr : AT(ADDR(.dynstr) + __vma_to_lma) {
 		__dynstr_start = .;
 		*(.dynstr)
 		__dynstr_end = .;
 	}
 	__dynstr_len = __dynstr_end - __dynstr_start;

-	. = ALIGN(4);
-
-	__gnu_hash_vma = .;
-	__gnu_hash_lma = __gnu_hash_vma + __text_lma - __text_vma;
-	.gnu.hash : AT(__gnu_hash_lma) {
+	.gnu.hash : AT(ADDR(.gnu.hash) + __vma_to_lma) {
 		__gnu_hash_start = .;
 		*(.gnu.hash)
 		__gnu_hash_end = .;
 	}

-	. = ALIGN(4);
-
-	__dynlink_vma = .;
-	__dynlink_lma = __dynlink_vma + __text_lma - __text_vma;
-	.dynlink : AT(__dynlink_lma) {
+	.dynlink : AT(ADDR(.dynlink) + __vma_to_lma) {
 		__dynlink_start = .;
 		*(.dynlink)
 		__dynlink_end = .;
 	}

-	. = ALIGN(4);
-
-	__got_vma = .;
-	__got_lma = __got_vma + __text_lma - __text_vma;
-	.got : AT(__got_lma) {
+	.got : AT(ADDR(.got) + __vma_to_lma) {
 		__got_start = .;
 		KEEP (*(.got.plt))
 		KEEP (*(.got))
 		__got_end = .;
 	}

-	. = ALIGN(4);
-
-	__dynamic_vma = .;
-	__dynamic_lma = __dynamic_vma + __text_lma - __text_vma;
-	.dynamic : AT(__dynamic_lma) {
+	.dynamic : AT(ADDR(.dynamic) + __vma_to_lma) {
 		__dynamic_start = .;
 		*(.dynamic)
 		__dynamic_end = .;
 	}

-	. = ALIGN(32);
-
-	__data_vma = .;
-	__data_lma = __data_vma + __text_lma - __text_vma;
-	.data : AT(__data_lma) {
+	.data : AT(ADDR(.data) + __vma_to_lma) {
 		__data_start = .;
 		*(.data)
 		*(.data.*)
--
2.5.5.GIT


code:
From: Sylvain Gault <sylvain.gault at gmail.com>

For the compression / decompression to succeed, the sections layout must
be the same between the virtual memory and load memory. The section
alignment was kept in sync by introducing aligment that should be
greater or equal to the actual section alignment.

This patch compute the load memory addresses of the sections so that
the layout is the same as the virtual memory addresses.

Signed-off-by: Sylvain Gault <sylvain.gault at gmail.com>
---
 core/i386/syslinux.ld   | 63 ++++++++++---------------------------------------
 core/x86_64/syslinux.ld | 63 ++++++++++---------------------------------------
 2 files changed, 24 insertions(+), 102 deletions(-)

diff --git a/core/i386/syslinux.ld b/core/i386/syslinux.ld
index 7390451..92b75b1 100644
--- a/core/i386/syslinux.ld
+++ b/core/i386/syslinux.ld
@@ -255,10 +255,9 @@ SECTIONS
 	. = 0x100000;

 	__pm_code_start = .;
+	__vma_to_lma = __pm_code_lma - __pm_code_start;

-	__text_vma = .;
-	__text_lma = __pm_code_lma;
-	.text : AT(__text_lma) {
+	.text : AT(ADDR(.text) + __vma_to_lma) {
 		FILL(0x90909090)
 		__text_start = .;
 		*(.text)
@@ -266,106 +265,68 @@ SECTIONS
 		__text_end = .;
 	}

-	. = ALIGN(32);
-
-	__rodata_vma = .;
-	__rodata_lma = __rodata_vma + __text_lma - __text_vma;
-	.rodata : AT(__rodata_lma) {
+	.rodata : AT(ADDR(.rodata) + __vma_to_lma) {
 		__rodata_start = .;
 		*(.rodata)
 		*(.rodata.*)
 		__rodata_end = .;
 	}

-	. = ALIGN(4);
-
-	__ctors_vma = .;
-	__ctors_lma = __ctors_vma + __text_lma - __text_vma;
-	.ctors : AT(__ctors_lma) {
+	.ctors : AT(ADDR(.ctors) + __vma_to_lma) {
 		__ctors_start = .;
 		KEEP (*(SORT(.ctors.*)))
 		KEEP (*(.ctors))
 		__ctors_end = .;
 	}

-	__dtors_vma = .;
-	__dtors_lma = __dtors_vma + __text_lma - __text_vma;
-	.dtors : AT(__dtors_lma) {
+	.dtors : AT(ADDR(.dtors) + __vma_to_lma) {
 		__dtors_start = .;
 		KEEP (*(SORT(.dtors.*)))
 		KEEP (*(.dtors))
 		__dtors_end = .;
 	}

-	. = ALIGN(4);
-
-	__dynsym_vma = .;
-	__dynsym_lma = __dynsym_vma + __text_lma - __text_vma;
-	.dynsym : AT(__dynsym_lma) {
+	.dynsym : AT(ADDR(.dynsym) + __vma_to_lma) {
 		__dynsym_start = .;
 		*(.dynsym)
 		__dynsym_end = .;
 	}
 	__dynsym_len = __dynsym_end - __dynsym_start;

-	. = ALIGN(4);
-
-	__dynstr_vma = .;
-	__dynstr_lma = __dynstr_vma + __text_lma - __text_vma;
-	.dynstr : AT(__dynstr_lma) {
+	.dynstr : AT(ADDR(.dynstr) + __vma_to_lma) {
 		__dynstr_start = .;
 		*(.dynstr)
 		__dynstr_end = .;
 	}
 	__dynstr_len = __dynstr_end - __dynstr_start;

-	. = ALIGN(4);
-
-	__gnu_hash_vma = .;
-	__gnu_hash_lma = __gnu_hash_vma + __text_lma - __text_vma;
-	.gnu.hash : AT(__gnu_hash_lma) {
+	.gnu.hash : AT(ADDR(.gnu.hash) + __vma_to_lma) {
 		__gnu_hash_start = .;
 		*(.gnu.hash)
 		__gnu_hash_end = .;
 	}

-	. = ALIGN(4);
-
-	__dynlink_vma = .;
-	__dynlink_lma = __dynlink_vma + __text_lma - __text_vma;
-	.dynlink : AT(__dynlink_lma) {
+	.dynlink : AT(ADDR(.dynlink) + __vma_to_lma) {
 		__dynlink_start = .;
 		*(.dynlink)
 		__dynlink_end = .;
 	}

-	. = ALIGN(4);
-
-	__got_vma = .;
-	__got_lma = __got_vma + __text_lma - __text_vma;
-	.got : AT(__got_lma) {
+	.got : AT(ADDR(.got) + __vma_to_lma) {
 		__got_start = .;
 		KEEP (*(.got.plt))
 		KEEP (*(.got))
 		__got_end = .;
 	}

-	. = ALIGN(4);
-
-	__dynamic_vma = .;
-	__dynamic_lma = __dynamic_vma + __text_lma - __text_vma;
-	.dynamic : AT(__dynamic_lma) {
+	.dynamic : AT(ADDR(.dynamic) + __vma_to_lma) {
 		__dynamic_start = .;
 		*(.dynamic)
 		__dynamic_end = .;
 	}

-	. = ALIGN(32);
-
-	__data_vma = .;
-	__data_lma = __data_vma + __text_lma - __text_vma;
-	.data : AT(__data_lma) {
+	.data : AT(ADDR(.data) + __vma_to_lma) {
 		__data_start = .;
 		*(.data)
 		*(.data.*)
diff --git a/core/x86_64/syslinux.ld b/core/x86_64/syslinux.ld
index bf815c4..70c6e00 100644
--- a/core/x86_64/syslinux.ld
+++ b/core/x86_64/syslinux.ld
@@ -255,10 +255,9 @@ SECTIONS
 	. = 0x100000;

 	__pm_code_start = .;
+	__vma_to_lma = __pm_code_lma - __pm_code_start;

-	__text_vma = .;
-	__text_lma = __pm_code_lma;
-	.text : AT(__text_lma) {
+	.text : AT(ADDR(.text) + __vma_to_lma) {
 		FILL(0x90909090)
 		__text_start = .;
 		*(.text)
@@ -266,106 +265,68 @@ SECTIONS
 		__text_end = .;
 	}

-	. = ALIGN(32);
-
-	__rodata_vma = .;
-	__rodata_lma = __rodata_vma + __text_lma - __text_vma;
-	.rodata : AT(__rodata_lma) {
+	.rodata : AT(ADDR(.rodata) + __vma_to_lma) {
 		__rodata_start = .;
 		*(.rodata)
 		*(.rodata.*)
 		__rodata_end = .;
 	}

-	. = ALIGN(4);
-
-	__ctors_vma = .;
-	__ctors_lma = __ctors_vma + __text_lma - __text_vma;
-	.ctors : AT(__ctors_lma) {
+	.ctors : AT(ADDR(.ctors) + __vma_to_lma) {
 		__ctors_start = .;
 		KEEP (*(SORT(.ctors.*)))
 		KEEP (*(.ctors))
 		__ctors_end = .;
 	}

-	__dtors_vma = .;
-	__dtors_lma = __dtors_vma + __text_lma - __text_vma;
-	.dtors : AT(__dtors_lma) {
+	.dtors : AT(ADDR(.dtors) + __vma_to_lma) {
 		__dtors_start = .;
 		KEEP (*(SORT(.dtors.*)))
 		KEEP (*(.dtors))
 		__dtors_end = .;
 	}

-	. = ALIGN(4);
-
-	__dynsym_vma = .;
-	__dynsym_lma = __dynsym_vma + __text_lma - __text_vma;
-	.dynsym : AT(__dynsym_lma) {
+	.dynsym : AT(ADDR(.dynsym) + __vma_to_lma) {
 		__dynsym_start = .;
 		*(.dynsym)
 		__dynsym_end = .;
 	}
 	__dynsym_len = __dynsym_end - __dynsym_start;

-	. = ALIGN(4);
-
-	__dynstr_vma = .;
-	__dynstr_lma = __dynstr_vma + __text_lma - __text_vma;
-	.dynstr : AT(__dynstr_lma) {
+	.dynstr : AT(ADDR(.dynstr) + __vma_to_lma) {
 		__dynstr_start = .;
 		*(.dynstr)
 		__dynstr_end = .;
 	}
 	__dynstr_len = __dynstr_end - __dynstr_start;

-	. = ALIGN(4);
-
-	__gnu_hash_vma = .;
-	__gnu_hash_lma = __gnu_hash_vma + __text_lma - __text_vma;
-	.gnu.hash : AT(__gnu_hash_lma) {
+	.gnu.hash : AT(ADDR(.gnu.hash) + __vma_to_lma) {
 		__gnu_hash_start = .;
 		*(.gnu.hash)
 		__gnu_hash_end = .;
 	}

-	. = ALIGN(4);
-
-	__dynlink_vma = .;
-	__dynlink_lma = __dynlink_vma + __text_lma - __text_vma;
-	.dynlink : AT(__dynlink_lma) {
+	.dynlink : AT(ADDR(.dynlink) + __vma_to_lma) {
 		__dynlink_start = .;
 		*(.dynlink)
 		__dynlink_end = .;
 	}

-	. = ALIGN(4);
-
-	__got_vma = .;
-	__got_lma = __got_vma + __text_lma - __text_vma;
-	.got : AT(__got_lma) {
+	.got : AT(ADDR(.got) + __vma_to_lma) {
 		__got_start = .;
 		KEEP (*(.got.plt))
 		KEEP (*(.got))
 		__got_end = .;
 	}

-	. = ALIGN(4);
-
-	__dynamic_vma = .;
-	__dynamic_lma = __dynamic_vma + __text_lma - __text_vma;
-	.dynamic : AT(__dynamic_lma) {
+	.dynamic : AT(ADDR(.dynamic) + __vma_to_lma) {
 		__dynamic_start = .;
 		*(.dynamic)
 		__dynamic_end = .;
 	}

-	. = ALIGN(32);
-
-	__data_vma = .;
-	__data_lma = __data_vma + __text_lma - __text_vma;
-	.data : AT(__data_lma) {
+	.data : AT(ADDR(.data) + __vma_to_lma) {
 		__data_start = .;
 		*(.data)
 		*(.data.*)
--
2.5.3


code:
From: Sylvain Gault <sylvain.gault at gmail.com>

The section aligment specified in the ld scripts have to be greater or
equal to those in the .o files generated by gcc.

Signed-off-by: Sylvain Gault <sylvain.gault at gmail.com>
---
 core/i386/syslinux.ld   | 6 +++---
 core/x86_64/syslinux.ld | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/core/i386/syslinux.ld b/core/i386/syslinux.ld
index 7b4e012..7390451 100644
--- a/core/i386/syslinux.ld
+++ b/core/i386/syslinux.ld
@@ -266,7 +266,7 @@ SECTIONS
 		__text_end = .;
 	}

-	. = ALIGN(16);
+	. = ALIGN(32);

 	__rodata_vma = .;
 	__rodata_lma = __rodata_vma + __text_lma - __text_vma;
@@ -361,7 +361,7 @@ SECTIONS
 		__dynamic_end = .;
 	}

-	. = ALIGN(16);
+	. = ALIGN(32);

 	__data_vma = .;
 	__data_lma = __data_vma + __text_lma - __text_vma;
@@ -377,7 +377,7 @@ SECTIONS
 	__pm_code_dwords = (__pm_code_len + 3) >> 2;

 	. = ALIGN(128);
-
+
 	__bss_vma = .;
 	__bss_lma = .;		/* Dummy */
 	.bss (NOLOAD) : AT (__bss_lma) {
diff --git a/core/x86_64/syslinux.ld b/core/x86_64/syslinux.ld
index 1057112..bf815c4 100644
--- a/core/x86_64/syslinux.ld
+++ b/core/x86_64/syslinux.ld
@@ -266,7 +266,7 @@ SECTIONS
 		__text_end = .;
 	}

-	. = ALIGN(16);
+	. = ALIGN(32);

 	__rodata_vma = .;
 	__rodata_lma = __rodata_vma + __text_lma - __text_vma;
@@ -361,7 +361,7 @@ SECTIONS
 		__dynamic_end = .;
 	}

-	. = ALIGN(16);
+	. = ALIGN(32);

 	__data_vma = .;
 	__data_lma = __data_vma + __text_lma - __text_vma;
@@ -377,7 +377,7 @@ SECTIONS
 	__pm_code_dwords = (__pm_code_len + 3) >> 2;

 	. = ALIGN(128);
-
+
 	__bss_vma = .;
 	__bss_lma = .;		/* Dummy */
 	.bss (NOLOAD) : AT (__bss_lma) {
--
2.5.3


code:
--- syslinux-5.00-orig/utils/isohybrid.pl	2012-12-06 21:51:22.000000000 +0200
+++ syslinux-5.00/utils/isohybrid.pl	2013-02-07 18:55:28.423760149 +0200
@@ -44,6 +44,7 @@
     'id'     => [0, 0xffffffff],
     'hd0'    => [0, 2],
     'partok' => [0, 1],
+    'fat'    => [0, 1],
 );

 # Boolean options just set other options
@@ -53,6 +54,7 @@
     'ctrlhd0'  => ['hd0', 2],
     'nopartok' => ['partok', 0],
     'partok'   => ['partok', 1],
+    'fatfirst' => ['fat', 1],
 );

 sub usage() {
@@ -66,7 +68,8 @@
     "  -id         Specify MBR ID (default random)\n",
     "  -forcehd0   Always assume we are loaded as disk ID 0\n",
     "  -ctrlhd0    Assume disk ID 0 if the Ctrl key is pressed\n",
-    "  -partok     Allow booting from within a partition\n";
+    "  -partok     Allow booting from within a partition\n",
+    "  -fatfirst   Create a small fat partition first\n";
     exit 1;
 }

@@ -221,9 +224,9 @@

 # Print partition table
 $offset  = $opt{'offset'};
-$psize   = $c*$h*$s - $offset;
+$psize   = $c*$h*$s - $offset - 1;
 $bhead   = int($offset/$s) % $h;
-$bsect   = ($offset % $s) + 1;
+$bsect   = ($offset % $s) + 1 + 1;
 $bcyl    = int($offset/($h*$s));
 $bsect  += ($bcyl & 0x300) >> 2;
 $bcyl   &= 0xff;
@@ -233,10 +236,29 @@
 $fstype  = $opt{'type'};	# Partition type
 $pentry  = $opt{'entry'};	# Partition slot

+$offset += $psize;
+$psize1   = $cylsize/512;
+$bhead1   = int(($offset+1)/$s) % $h;
+$bsect1   = (($offset+1) % $s) + 1;
+$bcyl1    = int(($offset+1)/($h*$s));
+$bsect1  += ($bcyl1 & 0x300) >> 2;
+$bcyl1   &= 0xff;
+$ehead1   = $h-1;
+$esect1   = $s;
+$ecyl1   = $bcyl1;
+print "ehead1=$ehead1 esect1=$esect1 ecyl1=$ecyl1\n";
+
+if ( $opt{'fat'} == 1 ) {
+       $pentry = 2;
+}
+
 for ( $i = 1 ; $i <= 4 ; $i++ ) {
-    if ( $i == $pentry ) {
+    if ( $opt{'fat'} == 1 && $i == 1 ) {
+       $mbr .= pack("CCCCCCCCVV", 0x00, $bhead1, $bsect1, $bcyl1, 0xc,
+                    $ehead1, $esect1, $ecyl1, $offset+1, $psize1);
+    } elsif ( $i == $pentry ) {
 	$mbr .= pack("CCCCCCCCVV", 0x80, $bhead, $bsect, $bcyl, $fstype,
-		     $ehead, $esect, $ecyl, $offset, $psize);
+		     $ehead, $esect, $ecyl, $offset + 1, $psize);
     } else {
 	$mbr .= "\0" x 16;
     }
@@ -251,6 +273,18 @@
     print FILE "\0" x $padding;
 }

+# Create fat image and put it into the file
+if($opt{'fat'}) {
+    open(FATFILE, "> $file.fat") or die "$0: cannot open $file.fat: $!\n";
+    print FATFILE "\0" x ($psize1*512);
+    close(FATFILE);
+    system("/usr/sbin/mkfs.vfat -n RESIZE_ME $file.fat") and die "$0: cannot format fat\n";
+    open(FATFILE, "< $file.fat");
+    print FILE <FATFILE>;
+    close(FATFILE);
+    unlink("$file.fat");
+}
+
 # Done...
 close(FILE);

--- syslinux-5.00-orig/utils/isohybrid.in	2012-12-06 21:51:22.000000000 +0200
+++ syslinux-5.00/utils/isohybrid.in	2013-02-07 18:55:28.423760149 +0200
@@ -44,6 +44,7 @@
     'id'     => [0, 0xffffffff],
     'hd0'    => [0, 2],
     'partok' => [0, 1],
+    'fat'    => [0, 1],
 );

 # Boolean options just set other options
@@ -53,6 +54,7 @@
     'ctrlhd0'  => ['hd0', 2],
     'nopartok' => ['partok', 0],
     'partok'   => ['partok', 1],
+    'fatfirst' => ['fat', 1],
 );

 sub usage() {
@@ -66,7 +68,8 @@
     "  -id         Specify MBR ID (default random)\n",
     "  -forcehd0   Always assume we are loaded as disk ID 0\n",
     "  -ctrlhd0    Assume disk ID 0 if the Ctrl key is pressed\n",
-    "  -partok     Allow booting from within a partition\n";
+    "  -partok     Allow booting from within a partition\n",
+    "  -fatfirst   Create a small fat partition first\n";
     exit 1;
 }

@@ -221,9 +224,9 @@

 # Print partition table
 $offset  = $opt{'offset'};
-$psize   = $c*$h*$s - $offset;
+$psize   = $c*$h*$s - $offset - 1;
 $bhead   = int($offset/$s) % $h;
-$bsect   = ($offset % $s) + 1;
+$bsect   = ($offset % $s) + 1 + 1;
 $bcyl    = int($offset/($h*$s));
 $bsect  += ($bcyl & 0x300) >> 2;
 $bcyl   &= 0xff;
@@ -233,10 +236,29 @@
 $fstype  = $opt{'type'};	# Partition type
 $pentry  = $opt{'entry'};	# Partition slot

+$offset += $psize;
+$psize1   = $cylsize/512;
+$bhead1   = int(($offset+1)/$s) % $h;
+$bsect1   = (($offset+1) % $s) + 1;
+$bcyl1    = int(($offset+1)/($h*$s));
+$bsect1  += ($bcyl1 & 0x300) >> 2;
+$bcyl1   &= 0xff;
+$ehead1   = $h-1;
+$esect1   = $s;
+$ecyl1   = $bcyl1;
+print "ehead1=$ehead1 esect1=$esect1 ecyl1=$ecyl1\n";
+
+if ( $opt{'fat'} == 1 ) {
+	$pentry = 2;
+}
+
 for ( $i = 1 ; $i <= 4 ; $i++ ) {
-    if ( $i == $pentry ) {
+    if ( $opt{'fat'} == 1 && $i == 1 ) {
+	$mbr .= pack("CCCCCCCCVV", 0x00, $bhead1, $bsect1, $bcyl1, 0xc,
+		     $ehead1, $esect1, $ecyl1, $offset+1, $psize1);
+    } elsif ( $i == $pentry ) {
 	$mbr .= pack("CCCCCCCCVV", 0x80, $bhead, $bsect, $bcyl, $fstype,
-		     $ehead, $esect, $ecyl, $offset, $psize);
+		     $ehead, $esect, $ecyl, $offset + 1, $psize);
     } else {
 	$mbr .= "\0" x 16;
     }
@@ -251,6 +273,18 @@
     print FILE "\0" x $padding;
 }

+# Create fat image and put it into the file
+if($opt{'fat'}) {
+    open(FATFILE, "> $file.fat") or die "$0: cannot open $file.fat: $!\n";
+    print FATFILE "\0" x ($psize1*512);
+    close(FATFILE);
+    system("/usr/sbin/mkfs.vfat -n RESIZE_ME $file.fat") and die "$0: cannot format fat\n";
+    open(FATFILE, "< $file.fat");
+    print FILE <FATFILE>;
+    close(FATFILE);
+    unlink("$file.fat");
+}
+
 # Done...
 close(FILE);


code:
From e5f2b577ded109291c9632dacb6eaa621d8a59fe Mon Sep 17 00:00:00 2001
From: Sylvain Gault <sylvain.gault@gmail.com>
Date: Tue, 29 Sep 2015 02:38:25 +0200
Subject: [PATCH 1/1] bios: Fix alignment change with gcc 5

The section aligment specified in the ld scripts have to be greater or
equal to those in the .o files generated by gcc.

Signed-off-by: Sylvain Gault <sylvain.gault@gmail.com>
Tested-by: poma <pomidorabelisima@gmail.com>
Signed-off-by: Paulo Alcantara <pcacjr@zytor.com>
---
 core/i386/syslinux.ld   | 6 +++---
 core/x86_64/syslinux.ld | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/core/i386/syslinux.ld b/core/i386/syslinux.ld
index 7b4e012..7390451 100644
--- a/core/i386/syslinux.ld
+++ b/core/i386/syslinux.ld
@@ -266,7 +266,7 @@ SECTIONS
 		__text_end = .;
 	}

-	. = ALIGN(16);
+	. = ALIGN(32);

 	__rodata_vma = .;
 	__rodata_lma = __rodata_vma + __text_lma - __text_vma;
@@ -361,7 +361,7 @@ SECTIONS
 		__dynamic_end = .;
 	}

-	. = ALIGN(16);
+	. = ALIGN(32);

 	__data_vma = .;
 	__data_lma = __data_vma + __text_lma - __text_vma;
@@ -377,7 +377,7 @@ SECTIONS
 	__pm_code_dwords = (__pm_code_len + 3) >> 2;

 	. = ALIGN(128);
-
+
 	__bss_vma = .;
 	__bss_lma = .;		/* Dummy */
 	.bss (NOLOAD) : AT (__bss_lma) {
diff --git a/core/x86_64/syslinux.ld b/core/x86_64/syslinux.ld
index 1057112..bf815c4 100644
--- a/core/x86_64/syslinux.ld
+++ b/core/x86_64/syslinux.ld
@@ -266,7 +266,7 @@ SECTIONS
 		__text_end = .;
 	}

-	. = ALIGN(16);
+	. = ALIGN(32);

 	__rodata_vma = .;
 	__rodata_lma = __rodata_vma + __text_lma - __text_vma;
@@ -361,7 +361,7 @@ SECTIONS
 		__dynamic_end = .;
 	}

-	. = ALIGN(16);
+	. = ALIGN(32);

 	__data_vma = .;
 	__data_lma = __data_vma + __text_lma - __text_vma;
@@ -377,7 +377,7 @@ SECTIONS
 	__pm_code_dwords = (__pm_code_len + 3) >> 2;

 	. = ALIGN(128);
-
+
 	__bss_vma = .;
 	__bss_lma = .;		/* Dummy */
 	.bss (NOLOAD) : AT (__bss_lma) {
--
2.5.5.GIT


code:
diff -ur a/mk/com32.mk b/mk/com32.mk
--- a/mk/com32.mk	2011-12-09 19:28:17.000000000 +0100
+++ b/mk/com32.mk	2011-12-18 18:22:11.032342645 +0100
@@ -24,6 +24,8 @@
 GCCOPT += $(call gcc_ok,-freg-struct-return,)
 GCCOPT += -mregparm=3 -DREGPARM=3 -march=i386 -Os
 GCCOPT += $(call gcc_ok,-fPIE,-fPIC)
+GCCOPT += $(call gcc_ok,-nopie,)
+GCCOPT += $(call gcc_ok,-fno-pie,)
 GCCOPT += $(call gcc_ok,-fno-exceptions,)
 GCCOPT += $(call gcc_ok,-fno-asynchronous-unwind-tables,)
 GCCOPT += $(call gcc_ok,-fno-strict-aliasing,)


code:
UI vesamenu.c32
timeout 0
menu background backgound.png

MENU RESOLUTION 1024 768
menu clear
menu vshift 8
menu vshift 8
menu rows 20
menu title Pisi GNU/Linux
menu margin 8
menu width 70
menu helpmsgrow 15
#menu tabmsgrow 13

menu color border * #00000000 #00000000 none
menu color sel 0 #ffffffff #00000000 none
menu color title 0 #ff7ba3d0 #00000000 none
menu color tabmsg 0 #ff3a6496 #00000000 none
menu color unsel 0 #84b8ffff #00000000 none
menu color hotsel 0 #84b8ffff #00000000 none
menu color hotkey 0 #ffffffff #00000000 none
menu color help 0 #ffffffff #00000000 none
menu color scrollbar 0 #ffffffff #ff355594 none
menu color timeout 0 #ffffffff #00000000 none
menu color timeout_msg 0 #ffffffff #00000000 none
menu color cmdmark 0 #84b8ffff #00000000 none
menu color cmdline 0 #ffffffff #00000000 none

label installation
  menu label Pisi Linux installation (default)
  kernel  /isolinux/boot/kernel
  append initrd=/isolinux/boot/initrd  yali=default mudur=language:en splash quiet
  text help
      Pisi Linux Installation with default settings
  endtext

label safe
  menu label Pisi Linux Installation (safe)
  kernel  /isolinux/boot/kernel
  append initrd=/isolinux/boot/initrd  yali=default mudur=language:en xorg=safe nomodeset
  text help
      Pisi Linux Installation with safe video settings
  endtext

label rescue
  menu label Pisi Linux System Rescue
  kernel  /isolinux/boot/kernel
  append initrd=/isolinux/boot/initrd  yali=rescue mudur=language:en xorg=safe nomodeset
  text help
      Pisi Linux bootloader rescue and password reset utility
  endtext

label memory
  menu label Check System Memory
  text help
   Use this utility to see if the memory is working correctly
  endtext
  kernel /isolinux/boot/memtest

label hardware
  menu label  Hardware Information
  text help
   Use this utility to see your system information
  endtext
  kernel /isolinux/hdt.c32

menu separator
label local
  menu label Boot from local drive
  text help
      Boot your system from local drive
  endtext
  localboot 0xffff


code:
diff -Naur syslinux-6.02/mk/efi.mk syslinux-6.02-hardened/mk/efi.mk
--- syslinux-6.02/mk/efi.mk	2013-10-13 13:59:03.000000000 -0400
+++ syslinux-6.02-hardened/mk/efi.mk	2014-02-09 12:56:47.036409135 -0500
@@ -23,6 +23,7 @@
 	EFI_SUBARCH = $(ARCH)
 endif

+GCCOPT := $(call gcc_ok,-fno-stack-protector,)
 EFIINC = $(shell $(topdir)/efi//find-gnu-efi.sh include $(EFI_SUBARCH))
 $(if $(EFIINC),, \
 	$(error Missing $(EFI_SUBARCH) gnu-efi header files))
@@ -42,7 +43,7 @@
 		-DELF_DEBUG -DSYSLINUX_EFI -I$(objdir) \
 		$(GCCWARN) -D__COM32__ -mno-red-zone \
 		-DLDLINUX=\"$(LDLINUX)\" -fvisibility=hidden \
-		-Wno-unused-parameter
+		-Wno-unused-parameter $(GCCOPT)

 # gnuefi sometimes installs these under a gnuefi/ directory, and sometimes not
 CRT0 := $(shell find $(LIBDIR) -name crt0-efi-$(EFI_SUBARCH).o 2>/dev/null | tail -n1)


code:
https://bugs.gentoo.org/579928

From d84db34dbe39d55b4d7e868764c056689aa0793b Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Tue, 19 Apr 2016 01:56:41 -0400
Subject: [PATCH] extlinux: pull in sys/sysmacros.h for major/minor/makedev

These functions are defined in sys/sysmacros.h, so add the include to
main.c.  This is already handled correctly in mountinfo.c.  Otherwise
we get build failures like:

main.o: In function 'find_device_sysfs':
extlinux/main.c:1131: undefined reference to 'minor'

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 extlinux/main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/extlinux/main.c b/extlinux/main.c
index a7ebd49..ebff7ea 100644
--- a/extlinux/main.c
+++ b/extlinux/main.c
@@ -38,6 +38,7 @@
 #include <sysexits.h>
 #include <sys/ioctl.h>
 #include <sys/stat.h>
+#include <sys/sysmacros.h>
 #include <sys/types.h>
 #include <sys/mount.h>
 #include <sys/vfs.h>
--
2.7.4


code:
#!/usr/bin/bash
#
# Syslinux Installer / Updater Script (for BIOS only)
# Copyright (C) 2011-2013  Matthew Gyurgyik <pyther@pyther.net>
# Copyright (C) 2013  Keshav Padram Amburay <(the) (ddoott) (ridikulus) (ddoott) (rat) (aatt) (gemmaeiil) (ddoott) (ccoomm)>
#
# 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
#
#-----------------
# ChangeLog:
# 2013-10-23 : Keshav Padram Amburay : Updated script to work with Syslinux 6.02 Arch Linux pkg
#-----------------
# Exit Codes:
#   1 - get_boot_device or other function failed
#   2 - install/update failed
#   3 - set_active failed
#   4 - install_mbr failed
#-----------------

shopt -s nullglob

bios_libpath="/usr/lib/syslinux/bios"
bios_bootpath="/boot/syslinux"
EXTLINUX="/usr/bin/extlinux"

bios_autoupdate_file="/boot/syslinux/SYSLINUX_AUTOUPDATE"
pciids_file="/usr/share/hwdata/pci.ids"

## Helper functions ##
# Taken from libui-sh
# $1 needle
# $2 set (array) haystack
check_is_in() {
    local needle="$1" element
    shift
    for element; do
        [[ $element = $needle ]] && return 0
    done
    return 1
}

get_disk() {
    local part=$1
    if [[ ! -b "${part}" ]]; then
        echo >&2 "error: '$part' is not a valid block device!"
        exit 1
    fi

    case "$part" in
        *[[:digit:]]p[[:digit:]]*)
            local disk="${part%%p$partnum}" # get everything before p1
            ;;
        *)
            local disk="${part%%[[:digit:]]*}"
            ;;
    esac
    if [[ ! -b "${disk}" ]]; then
        echo >&2 "error: '$disk' is not a valid block device!"
        exit 1
    fi
    echo $disk
}

# return true when blockdevice is an md raid, otherwise return a unset value
# get all devices that are part of raid device $1
device_is_raid() {
    [[ $1 && -f /proc/mdstat ]] || return 1
    local devmajor=$(stat -c %t "$1")
    (( devmajor == 9 ))
}

mdraid_all_slaves() {
    local slave slaves
    for slave in /sys/class/block/${1##*/}/slaves/*; do
        source "$slave/uevent"
        slaves="$slaves/dev/$DEVNAME "
        unset DEVNAME
    done
    echo $slaves
}

# Check /sys/block to see if device is partitioned
# If we have a partitioned block device (sda1) /sys/block/sda1/dev will not exist
# However, if we have an unpartitioned block device (sda) /sys/block/sda/dev will exist
dev_is_part() {
    # $1 - blockdevice
    local dev=$1

    # If block device uevent file should be found
    # If a partition is passed in path shouldn't exist
    if [[ $dev = *cciss* ]]; then
        [[ -f /sys/block/cciss\!${dev##*/}/dev ]] && return 1
    elif [[ $dev = *ida* ]]; then
        [[ -f /sys/block/ida\!${dev##*/}/dev ]] && return 1
    else
        [[ -f /sys/block/${dev##*/}/dev ]] && return 1
    fi

    return 0
}

# If EFI PART is present in the first 8 bytes then it must be a GPT disk
device_is_gpt() {
    local partsig=$(dd if="$1" skip=64 bs=8 count=1 2>/dev/null)
    [[ $partsig = "EFI PART" ]]
}

clear_gpt_attr2() {
    # $1 - Block Device, no partitions
    local disk=$1

    # Special Exception for cciss controllers
    if [[ $disk = *cciss* ]]; then
        for part in /dev/cciss/${disk##*/}*p*; do
            local partnum="${part##*[[:alpha:]]}"
            sgdisk "$disk" --attributes="$partnum":clear:2 &>/dev/null
        done
    # Smart 2 Controllers
    elif [[ $disk = *ida* ]]; then
        for part in /dev/ida/${disk##*/}*p*; do
            local partnum="${part##*[[:alpha:]]}"
            sgdisk "$disk" --attributes="$partnum":clear:2 &>/dev/null
        done
    else
        for part in  /sys/block/${disk##*/}/${disk##*/}*; do
            local partnum="${part##*[[:alpha:]]}"
            sgdisk "$disk" --attributes="$partnum":clear:2 &>/dev/null
        done
    fi
    return 0
}

usage() {
cat << EOF
usage: $0 options

This script will install or upgrade Syslinux (for BIOS only)

OPTIONS:
  -h    Show this message
  -i    Install Syslinux
  -u    Update Syslinux
  -a    Set Boot flag on boot partiton
  -m    Install Syslinux MBR
  -s    Updates Syslinux if /boot/syslinux/SYSLINUX_AUTOUPDATE exists

 Arguments Required:
  -c    Chroot install (ex: -c /mnt)

Example Usage: $0 -i -a -m     # (install, set boot flag, install mbr)
               $0 -u           # (update)
EOF
}

# Trys to find the partition that /boot resides on
# This will either be on /boot or / (root)
getBoot() {
    if [[ ! -d "$bios_bootpath" ]]; then
        echo "Could not find $bios_bootpath"
        echo "Is boot mounted? Is Syslinux installed?"
        exit 1
    fi

    syslinux_fs=(ext2 ext3 ext4 btrfs vfat)

    # Use DATA from findmnt see rc.sysint for more info
    if [[ -f /proc/self/mountinfo ]]; then
        read rootdev rootfs < <(findmnt -run -t noautofs -o SOURCE,FSTYPE "$CHROOT/")
        read bootdev bootfs < <(findmnt -run -t noautofs -o SOURCE,FSTYPE "$CHROOT/boot")
    else
        echo "Could not find /proc/self/mountinfo"
        echo "Are you running a kernel greater than 2.6.24?"
        exit 1
    fi

    if [[ $bootfs ]]; then
        if ! check_is_in "$bootfs" "${syslinux_fs[@]}"; then
            echo "/boot file system is not supported by Syslinux"
            exit 1
        fi
        boot="boot"
        bootpart="$(readlink -f "$bootdev")"
    elif [[ $rootfs ]]; then
        if ! check_is_in "$rootfs" "${syslinux_fs[@]}"; then
            echo "/ (root) file system is not supported by Syslinux"
            exit 1
        fi
        boot="root"
        bootpart="$(readlink -f "$rootdev")"
    else
        echo "Could not find filesystem on / (root) or /boot."
        exit 1
    fi
}

# We store the partition table type either gpt or mbr in var ptb
# In rare cases a user could have one raid disk using mbr and another using gpt
# In such cases we accept that the output may be incomplete

# Calls get_ptb() for $bootpart or for all device in RAID
declare -A bootdevs
get_boot_devices() {
    if device_is_raid "$bootpart"; then
        slaves=$(mdraid_all_slaves "$bootpart")

        for slave in ${slaves[@]}; do
            local disk=$(get_disk "$slave")
            device_is_gpt "$disk" && local ptb="GPT" || local ptb="MBR"
            bootdevs[$slave]="$ptb"
        done
    else
        local disk=$(get_disk "$bootpart")
        device_is_gpt "$disk" && local ptb="GPT" || local ptb="MBR"
        bootdevs[$bootpart]="$ptb"
    fi
}

# Function Assumes the boot partition should be marked as active
# All other partitions should not have the boot flag set
set_active() {
    # If any bootdev is a block device without partitions bail
    # we want to set the boot flag on partitioned disk
    for dev in "${!bootdevs[@]}"; do
        dev_is_part $dev || { echo "$dev - is a block device. Aborting set_active!"; return 1; }
    done

    # Clear BIOS Bootable Legacy Attribute for GPT drives
    # In rare cases where a RAID device has slaves on the same block device
    # Attribute 2 will be cleared for each partition multiple times
    for dev in "${!bootdevs[@]}"; do
        local ptb="${bootdevs[$dev]}"
        if [[ "$ptb" = GPT ]]; then
            local disk=$(get_disk "$dev")
            clear_gpt_attr2 "$disk"
        fi
    done

    # Set the boot flag on bootdevs (generated from get_boot_devices)
    for part in "${!bootdevs[@]}"; do
        local ptb="${bootdevs[$part]}"
        local partnum="${part##*[[:alpha:]]}"
        local disk=$(get_disk "$part")

        if [[ "$ptb" = MBR ]]; then
            if sfdisk "$disk" --activate "$partnum" &>/dev/null; then
                echo "Boot Flag Set - $part"
            else
                echo "FAILED to Set the boot flag on $part"
                exit 3
            fi
        elif [[ "$ptb" = GPT ]]; then
            if [[ ! -e /usr/bin/sgdisk ]]; then
                echo "FAILED to set attribute Legacy BIOS Bootable. sgdisk is not found - please install 'gptfdisk' package."
                exit 3
            fi

            if sgdisk "$disk" --attributes="$partnum":set:2 &>/dev/null; then
                echo "Attribute Legacy Bios Bootable Set - $part"
            else
                echo "FAILED to set attribute Legacy BIOS Bootable on $part"
                exit 3
            fi
        fi
    done
    return 0
}

install_mbr() {
    # If any bootdev is a block device without partitions bail
    # we want to install the mbr to a partitioned disk
    for dev in "${!bootdevs[@]}"; do
        dev_is_part "$dev" || { echo "$dev - is a block device. Aborting MBR install"; return 1; }
    done

    for part in "${!bootdevs[@]}"; do
        local partnum="${part##*[[:alpha:]]}"
        local disk=$(get_disk "$part")
        local ptb="${bootdevs[$part]}"

        # We want to install to the root of the block device
        # If the device is a partition - ABORT!
        dev_is_part "$disk" && \
        { echo "ABORT! MBR installation to partition ($disk)!"; exit 4;}

        if [[ "$ptb" = MBR ]]; then
            mbrfile="$bios_libpath/mbr.bin"
        elif [[ "$ptb" = GPT ]]; then
            mbrfile="$bios_libpath/gptmbr.bin"
        fi

        if dd bs=440 count=1 conv=notrunc if="$mbrfile" of="$disk" &> /dev/null; then
            echo "Installed MBR ($mbrfile) to $disk"
        else
            echo "Error Installing MBR ($mbrfile) to $disk"
            exit 4
        fi
    done
    return 0
}

install_modules() {
    # Copy all syslinux *.c32 modules to /boot
    rm "$bios_bootpath"/*.c32 &> /dev/null
    cp "$bios_libpath"/*.c32 "$bios_bootpath"/ &> /dev/null

    # Copy / Symlink pci.ids if pci.ids exists on the FS
    if [[ -f "$pciids_file" ]]; then
        rm "$bios_bootpath/pci.ids" &> /dev/null
        cp "$pciids_file" "$bios_bootpath/pci.ids" &> /dev/null
    fi
}

_install() {
    install_modules

    if device_is_raid "$bootpart" ; then
        echo "Detected RAID on /boot - installing Syslinux with --raid"
        "$EXTLINUX" --install "$bios_bootpath" --raid &> /dev/null
    else
        "$EXTLINUX" --install "$bios_bootpath" &> /dev/null
    fi

    if (( $? )); then
        echo "Syslinux BIOS install failed"
        exit 2
    else
        echo "Syslinux BIOS install successful"
    fi

    touch "$CHROOT/$bios_autoupdate_file"
}

update() {
    install_modules

    if device_is_raid "$bootpart" ; then
        echo "Detected RAID on /boot - updating Syslinux with --raid"
        "$EXTLINUX" --update "$bios_bootpath" --raid &> /dev/null
    else
        "$EXTLINUX" --update "$bios_bootpath" &> /dev/null
    fi

    if (($?)); then
        echo "Syslinux BIOS update failed"
        exit 2
    else
        echo "Syslinux BIOS update successful"
    fi
}

if (( $# == 0 )); then
    usage
    exit 1
fi

while getopts "c:uihmas" opt; do
    case $opt in
        c)
            CHROOT=$(readlink -e "$OPTARG")
            if [[ -z $CHROOT ]]; then
                echo "error: chroot path ``$OPTARG does not exist";
                exit 1
            fi
            ;;
        h)
            USAGE="True"
            ;;
        i)
            INSTALL="True"
            ;;
        u)
            UPDATE="True"
            ;;
        m)
            MBR="True"
            ;;
        a)
            SET_ACTIVE="True"
            ;;
        s)
            # If AUTOUPDATE_FILE does not exist exit the script
            if [[ -f $bios_autoupdate_file ]]; then
                UPDATE="True"
            else
                exit 0
            fi
            ;;
        *)
            usage
            exit 1
            ;;
    esac
done

if [[ $USAGE ]]; then
    usage
    exit 0
fi

# Display Usage Information if both Install and Update are passed
if [[ $INSTALL && $UPDATE ]]; then
    usage
    exit 1
fi

# Make sure only root can run our script
if (( $(id -u) != 0 )); then
    echo "This script must be run as root" 1>&2
    exit 1
fi

# If a chroot dir is path set variables to reflect chroot
if [[ "$CHROOT" ]]; then
    bios_libpath="$CHROOT$bios_libpath"
    bios_bootpath="$CHROOT$bios_bootpath"
    EXTLINUX="$CHROOT$EXTLINUX"
fi

# Exit if no /boot path exists
if ( f=("$bios_bootpath"/*); (( ! ${#f[@]} )) ); then
    echo "Error: $bios_bootpath is empty!"
    echo "Is /boot mounted?"
    exit 1
fi

# Get the boot device if any of these options are passed
if [[ $INSTALL || $UPDATE || $SET_ACTIVE || $MBR ]]; then
    getBoot
fi

# Install or Update
if [[ $INSTALL ]]; then
    _install || exit
elif [[ $UPDATE ]]; then
    update || exit
fi

# SET_ACTIVE and MBR
if [[ $SET_ACTIVE ]] || [[ $MBR ]]; then
    get_boot_devices

    if [[ $SET_ACTIVE ]]; then
        set_active || exit
    fi

    if [[ $MBR ]]; then
        install_mbr || exit
    fi
fi

exit 0


code:
From 0a2dbb3392ee710838bea6bda80d4daad6b54780 Mon Sep 17 00:00:00 2001
From: Scot Doyle <lkml14@scotdoyle.com>
Date: Sat, 18 Apr 2015 07:11:07 -0400
Subject: [PATCH] com32/lib/syslinux/load_linux.c: update prot_mode_base

If the kernel is relocatable and the protected mode code will not fit
in the initially determined location, that code will be moved to the
next available location. However, beginning with commit 8f470e7b, the
code is moved to the initially determined location instead of the next
available location because prot_mode_base is no longer updated to the
correct location. Since whdr->code32_start is updated, it is pointing
to the wrong execution start location, random code is executed and
the machine is rebooted.

Restore the old behavior by assigning prot_mode_base the value of
base. Tested on a machine that exposed this behavior.

Signed-off-by: Scot Doyle <lkml14@scotdoyle.com>
Signed-off-by: Gene Cumm <gene.cumm@gmail.com>
---
 com32/lib/syslinux/load_linux.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/com32/lib/syslinux/load_linux.c b/com32/lib/syslinux/load_linux.c
index ac73729..fc7f04f 100644
--- a/com32/lib/syslinux/load_linux.c
+++ b/com32/lib/syslinux/load_linux.c
@@ -323,6 +323,7 @@ int bios_boot_linux(void *kernel_buf, size_t kernel_size,
     }

     whdr->code32_start += base - prot_mode_base;
+    prot_mode_base = base;

     /* Real mode code */
     if (syslinux_memmap_find(amap, &real_mode_base,
--
2.7.4.GIT


code:
From 138e850fab106b5235178848b3e0d33e25f4d3a2 Mon Sep 17 00:00:00 2001
From: Olivier Brunel <jjk@jjacky.com>
Date: Wed, 2 Mar 2016 17:52:23 -0500
Subject: [PATCH] keytab-lilo: update to support kbd 2.0.3 format

Since kbd 2.0.3 (commit 6ff47cf2) the format generated by 'loadkeys -m' has
changed slightly, using "unsigned short" instead of "u_short"

Signed-off-by: Olivier Brunel <jjk@jjacky.com>
---
 utils/keytab-lilo | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/utils/keytab-lilo b/utils/keytab-lilo
index 9e34160..337a869 100755
--- a/utils/keytab-lilo
+++ b/utils/keytab-lilo
@@ -48,9 +48,9 @@ sub load_map
     $empty = 1;
     while (<FILE>) {
 	chop;
-	if (/^(static\s+)?u_short\s+(\S+)_map\[\S*\]\s+=\s+{\s*$/) {
+	if (/^(static\s+)?(u_|unsigned )short\s+(\S+)_map\[\S*\]\s+=\s+{\s*$/) {
 	    die "active at beginning of map" if defined $current;
-	    $current = $pfx.":".$2;
+	    $current = $pfx.":".$3;
 	    next;
 	}
 	undef $current if /^};\s*$/;
--
2.7.4.GIT


code:
From 83aad4f69065509ba5b1c080edccfed316a4cff0 Mon Sep 17 00:00:00 2001
From: Scot Doyle <lkml14@scotdoyle.com>
Date: Sat, 7 Feb 2015 13:52:05 -0500
Subject: [PATCH] load_linux: correct a type

Correct base's type to match its initialization from prot_mode_base and
passage to syslinux_memmap_find(). Tested with extlinux.

Signed-off-by: Scot Doyle <lkml14@scotdoyle.com>
Signed-off-by: Gene Cumm <gene.cumm@gmail.com>
---
 com32/lib/syslinux/load_linux.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/com32/lib/syslinux/load_linux.c b/com32/lib/syslinux/load_linux.c
index 06ae2a9..ac73729 100644
--- a/com32/lib/syslinux/load_linux.c
+++ b/com32/lib/syslinux/load_linux.c
@@ -155,8 +155,8 @@ int bios_boot_linux(void *kernel_buf, size_t kernel_size,
 		    char *cmdline)
 {
     struct linux_header hdr, *whdr;
-    size_t real_mode_size, prot_mode_size, base;
-    addr_t real_mode_base, prot_mode_base, prot_mode_max;
+    size_t real_mode_size, prot_mode_size;
+    addr_t real_mode_base, prot_mode_base, prot_mode_max, base;
     addr_t irf_size;
     size_t cmdline_size, cmdline_offset;
     struct setup_data *sdp;
--
2.7.4.GIT


code:
<?xml version="1.0" ?>
<!DOCTYPE PISI SYSTEM "http://www.pisilinux.org/projeler/pisi/pisi-spec.dtd">
<PISI>
    <Source>
        <Name>syslinux</Name>
        <Homepage>http://syslinux.zytor.com/</Homepage>
        <Packager>
            <Name>PisiLinux Community</Name>
            <Email>admins@pisilinux.org</Email>
        </Packager>
        <License>GPLv2</License>
        <IsA>app:console</IsA>
        <Summary>SysLinux, IsoLinux and PXELinux bootloader</Summary>
        <Description>Lightweight bootloaders for floppy media (SYSLINUX), network booting (PXELINUX), and bootable "El Torito" CD-ROMs (ISOLINUX). The project also includes MEMDISK, a tool to boot legacy operating systems (such as DOS) from nontraditional media; it is usually used in conjunction with PXELINUX and ISOLINUX.</Description>
        <Archive sha1sum="1bea76b97b4e32a017dd4168e819934b7c6592cc" type="tarxz">https://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-6.03.tar.xz</Archive>
        <BuildDependencies>
            <Dependency>nasm</Dependency>
            <Dependency>asciidoc</Dependency>
            <Dependency>dosfstools</Dependency>
            <Dependency>mtools</Dependency>
            <Dependency>efibootmgr-devel</Dependency>
            <Dependency>gptfdisk</Dependency>
            <Dependency>upx</Dependency><!--1-->
            <Dependency>libutil-linux-devel</Dependency>
            <Dependency>util-linux</Dependency>
        </BuildDependencies>
        <Patches>
            <!--Patch level="1">0001-Add-install-all-target-to-top-side-of-HAVE_FIRMWARE.patch</Patch>
            <Patch level="1">0035-SYSAPPEND-Fix-space-stripping.patch</Patch-->
            <Patch level="1">gcc-fix-alignment.patch</Patch>
            <Patch level="1">dont-guess-alignment.patch</Patch>
            <Patch level="1">btrfs-fix.patch</Patch>
            <Patch>syslinux.git-138e850fab106b5235178848b3e0d33e25f4d3a2.patch</Patch><!--kbd patch-->
            <Patch>syslinux.git-83aad4f.patch</Patch><!--set-base patch-->
            <Patch>syslinux.git-0a2dbb3.patch</Patch><!--set-mod patch-->
            <Patch>syslinux-6.03-sysmacros.patch</Patch>
<!--             <Patch>syslinux-6.02-add-fno-stack-protector.patch</Patch> -->
        </Patches>
    </Source>

    <Package>
        <Name>syslinux</Name>
        <RuntimeDependencies>
            <Dependency>mtools</Dependency>
            <Dependency>libutil-linux</Dependency>
            <Dependency>mtools</Dependency>
            <Dependency>efibootmgr</Dependency>
            <Dependency>util-linux</Dependency>
            <Dependency>dosfstools</Dependency>
            <Dependency>gptfdisk</Dependency>
            <Dependency>perl-Crypt-PasswdMD5</Dependency>
            <Dependency>perl-Digest-SHA1</Dependency>
        </RuntimeDependencies>
        <Files>
            <Path fileType="executable">/sbin</Path>
            <Path fileType="executable">/usr/bin</Path>
            <Path fileType="library">/usr/lib/syslinux</Path>
            <Path fileType="doc">/usr/share/doc</Path>
            <Path fileType="man">/usr/share/man</Path>
        </Files>
        <AdditionalFiles>
            <AdditionalFile target="/usr/lib/syslinux/isolinux.cfg" permission="0644" owner="root">pisi-iso/isolinux.cfg</AdditionalFile>
            <AdditionalFile target="/usr/lib/syslinux/background.png" permission="0644" owner="root">pisi-iso/background.png</AdditionalFile>
            <!--AdditionalFile target="/usr/bin/syslinux-install_update" permission="0755" owner="root">syslinux-install_update</AdditionalFile-->
        </AdditionalFiles>
    </Package>

    <History>
        <Update release="3">
            <Date>2017-03-29</Date>
            <Version>6.03</Version>
            <Comment>Release Bump</Comment>
            <Name>Ayhan Yalçınsoy</Name>
            <Email>ayhanyalcinsoy@pisilinux.org</Email>
        </Update>
        <Update release="2">
            <Date>2016-06-08</Date>
            <Version>6.03</Version>
            <Comment>Release Bump</Comment>
            <Name>Pisi Linux Community</Name>
            <Email>admin@pisilinux.org</Email>
        </Update>
        <Update release="1">
            <Date>2016-04-02</Date>
            <Version>6.03</Version>
            <Comment>First release</Comment>
            <Name>Alihan Öztürk</Name>
            <Email>alihan@pisilinux.org</Email>
        </Update>
    </History>
</PISI>


code:
<?xml version="1.0" ?>
<PISI>
    <Source>
        <Name>syslinux</Name>
        <Summary xml:lang="tr">SysLinux, IsoLinux ve PXELinux önyükleyicileri</Summary>
        <Description xml:lang="tr">Disket sürücüden (SYSLINUX), ağ üzerinden (PXELINUX) ve açılabilir "El Torito" CD-ROM'lardan (ISOLINUX) açılışı sağlayan hafif önyükleyici araçları. Bu proje ayrıca sık kullanılmayan ya da çok eski işletim sistemlerinin açılışı için genellikle PXELINUX ve ISOLINUX ile ortak kullanılabilen MEMDISK aracını da içermektedir.</Description>
    </Source>
</PISI>


code:
<PISI>
    <Name>system</Name>
</PISI>


code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Licensed under the GNU General Public License, version 3.
# See the file http://www.gnu.org/licenses/gpl.txt

from pisi.actionsapi import pisitools
from pisi.actionsapi import cmaketools
from pisi.actionsapi import shelltools
from pisi.actionsapi import get

def setup():
    shelltools.makedirs("build")
    shelltools.cd("build")

    cmaketools.configure("-DCMAKE_BUILD_TYPE=Debug \
                          -DCMAKE_INSTALL_PREFIX=/usr \
                          -DCMAKE_INSTALL_LIBDIR=lib \
                          -DWITH_CRASHREPORTER=ON", \
                          sourceDir=".." )

def build():
    shelltools.makedirs("build")
    shelltools.cd("build")

    cmaketools.make()

def install():
    shelltools.makedirs("build")
    shelltools.cd("build")

    cmaketools.install()

    #dbus configuration for pisi
    pisitools.dosed("%s/usr/share/calamares/modules/machineid.conf" % get.installDIR(), "systemd: true", "systemd: false")
    pisitools.dosed("%s/usr/share/calamares/modules/machineid.conf" % get.installDIR(), "symlink: true", "symlink: false")

    pisitools.dodoc("../README.*")


code:
[Desktop Entry]
Type=Application
Version=1.0
Name=Pisi Linux — System Installer
Name[tr_TR]=Pisi Linux Sistem Yükleyici
Comment=Pisi Linux — System Installer
Comment[tr_TR]=Pisi Linux Sistem Yükleyici
Exec=sudo LC_ALL=en_US calamares %f
Icon=calamares
Terminal=false
StartupNotify=true
Type=Application
Categories=Qt;System;