-#!/bin/sh
-
-# Must be defined before sourcing other files.
-LFS_STAGE="stage4"
-
-# Reading system configuration informations, functions and package versions.
-source ../functions
-source ../functions-update
-source ../packages-list
-
-update_packages_init
-
-# Begin
-
-# Gnome 2 core packages
-fpkg_gnome ${ORBIT2}
-fpkg_gnome ${LIBBONOBO}
-fpkg_gnome ${GCONF}
-fpkg_gnome ${GNOME_MIME_DATA}
-fpkg_gnome ${GNOME_VFS}
-fpkg_gnome ${GNOME_VFS_MONIKERS}
-fpkg_gnome ${LIBGNOME}
-fpkg_gnome ${LIBGNOMECANVAS}
-fpkg_gnome ${LIBBONOBOUI}
-fpkg_gnome ${GNOME_ICON_THEME}
-fpkg_gnome ${GNOME_KEYRING}
-fpkg_gnome ${LIBGNOMEUI}
-fpkg_gnome ${GNOME_THEMES}
-fpkg_gnome ${SCROLLKEEPER}
-fpkg_gnome ${GNOME_DOC_UTILS}
-fpkg_gnome ${GNOME_DESKTOP}
-fpkg_gnome ${GNOME_BACKGROUNDS}
-fpkg_gnome ${GNOME_MENUS}
-fpkg_gnome ${GNOME_PANEL}
-fpkg_gnome ${GNOME_SESSION}
-fpkg_gnome ${VTE}
-fpkg_gnome ${GNOME_TERMINAL}
-fpkg_gnome ${LIBGTOP}
-fpkg_gnome ${LIBGNOMEKBD}
-fpkg_gnome ${GAIL}
-fpkg_gnome ${GNOME_APPLETS}
-fpkg_gnome ${EEL}
-fpkg_gnome ${NAUTILUS}
-fpkg_gnome ${YELP}
-fpkg_gnome ${METACITY}
-fpkg_gnome ${GNOME_CONTROL_CENTER}
-fpkg_gnome ${GNOME_USER_DOCS}
-
-# Gnome 2 additional packages - Libraries
-fpkg_gnome ${LIBGNOMECUPS}
-fpkg_gnome ${LIBGNOMEPRINT}
-fpkg_gnome ${LIBGNOMEPRINTUI}
-fpkg_gnome ${GTKHTML}
-fpkg_gnome ${EVOLUTION_DATA_SERVER}
-fpkg_gnome ${GTKSOURCEVIEW}
-fpkg_gnome ${SYSTEM_TOOLS_BACKENDS}
-fpkg_gnome ${GNOME_AUDIO}
-
-# Gnome 2 additional packages - Utilities
-fpkg_gnome ${GEDIT}
-fpkg_gnome ${EOG}
-fpkg_gnome ${EVINCE}
-fpkg_gnome ${GGV} # Gnome Ghostview
-fpkg_gnome ${FILE_ROLLER}
-fpkg_gnome ${GCONF_EDITOR}
-fpkg_gnome ${GNOME_UTILS}
-fpkg_gnome ${GNOME_SYSTEM_MONITOR}
-fpkg_gnome ${NAUTILUS_CD_BURNER}
-fpkg_gnome ${GSTREAMER}
-fpkg_gnome ${GST_PLUGINS_BASE}
-fpkg ${GST_PLUGINS_GOOD} "http://gstreamer.freedesktop.org/src/gst-plugins-good"
-fpkg ${GST_PLUGINS_UGLY} "http://gstreamer.freedesktop.org/src/gst-plugins-ugly"
-fpkg ${GST_FFMPEG} "http://gstreamer.freedesktop.org/src/gst-ffmpeg"
-fpkg_gnome ${GNOME_MEDIA}
-fpkg_gnome ${GNOME_NETSTATUS}
-fpkg_gnome ${GCALCTOOL}
-fpkg_gnome ${GUCHARMAP}
-fpkg_gnome ${ZENITY}
-
-fpkg_gnome ${GNOME_KEYRING_MANAGER}
-fpkg_gnome ${GNOME_VOLUME_MANAGER}
-fpkg ${LIBMUSICBRAINZ} "http://ftp.musicbrainz.org/pub/musicbrainz"
-fpkg_gnome ${GNOME_SOUND_JUICER}
-fpkg ${ISO_CODES} "ftp://pkg-isocodes.alioth.debian.org/pub/pkg-isocodes"
-
-fpkg_gnome ${GNOME_TOTEM}
-fpkg_gnome ${GDM}
-fpkg ${LIBNOTIFY} "http://www.galago-project.org/files/releases/source/libnotify"
-fpkg ${GNOME_MOUNT} "http://people.freedesktop.org/~david/dist"
-
-fpkg_gnome ${LIBGSF}
-fpkg ${PCRE} "ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre" # Needed by goffice
-fpkg_gnome ${GOFFICE}
-fpkg_gnome ${GNUMERIC}
-fpkg_sf ${WV}
-fpkg ${ABIWORD} "http://www.abisource.com/downloads/abiword/$(get_pkg_ver ${ABIWORD})/source"
-
-fpkg_gnome ${EVOLUTION_EXCHANGE}
-fpkg_gnome ${EVOLUTION}
-
-fpkg ${LIBGPG_ERROR} "http://ftp.gnupg.org/gcrypt/libgpg-error"
-fpkg ${LIBGCRYPT} "http://ftp.gnupg.org/gcrypt/libgcrypt"
-fpkg ${GNUTLS} "http://ftp.gnupg.org/gcrypt/gnutls"
-fpkg_sf ${PIDGIN}
-
-# Return last error
+#!/bin/bash
+
+USE_LFS_PATCHES=1
+USE_BLFS_PATCHES=1
+USE_HV_PATCHES=1
+
+source ../functions/main
+
+update_packages_init ${*}
+
+lpkg 3 ${PYTHON}
+
+XORG_MODULES_LIST="${XORG_APP} ${XORG_DRIVER} ${XORG_FONT} ${XORG_LIB} ${XORG_PROTO} ${XORG_UTIL}"
+
+for module in ${XORG_MODULES_LIST}; do
+ MOD_NAME=$(get_pkg_name ${module})
+ DEST_DIR=${LFS_PKG_DIR}/${MOD_NAME}
+
+ fpkg -d ${DEST_DIR} -e wget ${module} ${BLFS_XORG_URL}
+ fpkg -d ${DEST_DIR} -e md5 ${module} ${BLFS_XORG_URL}
+
+ if [ "${MOD_NAME}" = "driver" ]; then
+ if [ -n "${XORG_VIDEO_DRIVER}" ]; then
+ # Install only specific driver
+ for ext in wget md5; do
+ sed -i -e "/xf86-video-${XORG_VIDEO_DRIVER}/!d" ${LFS_PKG_DIR}/${MOD_NAME}/${module}.${ext}
+ done
+ else
+ # Remove unwanted drivers
+ for ext in wget md5; do
+ for excldrv in vmware newport xgixp geode; do
+ sed -i -e "/.*xf86-video-${excldrv}.*/d" ${LFS_PKG_DIR}/${MOD_NAME}/${module}.${ext}
+ done
+ done
+ fi
+ fi
+ if [ "${MOD_NAME}" = "app" ]; then
+ # Remove unneeded apps
+ for ext in wget md5; do
+ sed -i -e '/.*twm-.*/d' ${LFS_PKG_DIR}/${MOD_NAME}/${module}.${ext}
+ sed -i -e '/.*xclock-.*/d' ${LFS_PKG_DIR}/${MOD_NAME}/${module}.${ext}
+ done
+ fi
+
+ SUBMODS="$(grep -v '^#' ${LFS_PKG_DIR}/${MOD_NAME}/${module}.wget | sed 's!\.tar\.bz2$!!')"
+
+ for submod in ${SUBMODS}; do
+ fpkg -m xorg -s ${MOD_NAME} ${submod}
+ done
+
+ pushd ${DEST_DIR} >> ${LFS_LOG_FILE}
+ # The "driver" md5 file maybe empty if the nouveau driver was selected
+ if cat ${LFS_PKG_DIR}/${MOD_NAME}/${module}.md5 | grep "[0-9]" 1> /dev/null 2>&1; then
+ md5sum -c ${LFS_PKG_DIR}/${MOD_NAME}/${module}.md5 >> ${LFS_LOG_FILE}
+ if [ $? -ne 0 ]; then
+ echo " md5sum error for ${module}"
+ fi
+ fi
+ popd >> ${LFS_LOG_FILE}
+done
+
+fpkg -m xorg -s lib ${LIBXAU}
+fpkg -m xorg -s lib ${LIBXDMCP}
+fpkg -m sf ${LESSTIF}
+fpkg -m xorg -s data ${XBITMAPS}
+
+fpkg -m fd -o "dist" -s "xcb" ${LIBPTHREAD_STUBS}
+fpkg -m fd -o "dist" -s "xcb" ${XCB_PROTO}
+fpkg -m fd -o "dist" -s "xcb" ${XCB_UTIL}
+fpkg -m gnu ${GPERF}
+
+fpkg -m hv ${LIBDRM}
+fpkg -e "tar.gz" ${TALLOC} "http://samba.org/ftp/talloc"
+fpkg -s "$(get_pkg_ver ${MESALIB})" ${MESALIB} \
+ ftp://ftp.freedesktop.org/pub/mesa
+fpkg -m xorg -s data ${XCURSOR_THEMES}
+fpkg -m fd -o "xlibs" -s "xkbdesc" ${XKEYBOARD_CONFIG}
+
+fpkg -m xorg -s app ${LUIT}
+fpkg -e "tar.gz" ${PIXMAN} ${CAIRO_URL}
+fpkg -e "tar.gz" ${LIBFFI} "ftp://sourceware.org/pub/libffi"
+
+fpkg -m fd -o "releases/dbus" ${DBUS}
+fpkg -m gnome ${GLIB}
+fpkg -m gnome ${GOBJECT_INSTROSPECTION}
+fpkg -m fd -o "dbus" ${DBUS_GLIB}
+fpkg -m fd -o "hal" ${EGGDBUS}
+fpkg -m fd -o "hal" ${POLKIT}
+fpkg ${CONSOLEKIT} "http://www.freedesktop.org/software/ConsoleKit/dist"
+fpkg -m fd -o "hal" ${POLICYKIT}
+fpkg -m fd ${HAL}
+fpkg -m fd -o "hal" ${HAL_INFO}
+
+fpkg -m hv ${XORG_VIDEO_NOUVEAU}
+fpkg -m xorg -s xserver ${XORG_SERVER}
+fpkg -m xorg -s app ${XDM}
+
+fpkg -e "tgz" ${XTERM} "ftp://invisible-island.net/xterm"
+fpkg -e "tar.gz" ${T1LIB} "http://www.ibiblio.org/pub/Linux/libs/graphics"
+
+fpkg -m sf -s "tcl" ${TK}
+fpkg -m gnu ${EMACS}
+fpkg ${WINDOWMAKER} ${WMAKER_URL}
+fpkg -e "tar.gz" ${WINDOWMAKER_EXTRA} ${WMAKER_URL}
+