Commit 57696c0f authored by Daniel Bissani Furlin's avatar Daniel Bissani Furlin

SCRUM#263: Using long options

parent b11f231d
......@@ -3,7 +3,7 @@
SCRIPT_NAME="exec.sh"
cleanTmpFiles() {
rm -rf ${TMP}
rm --recursive --force ${TMP}
closeChroot
}
......@@ -21,7 +21,6 @@ function log() {
}
initChroot() {
#set -x
local chrootdir="$1"
local logfile="$2"
......@@ -55,7 +54,6 @@ initChroot() {
}
closeChroot() {
#set -x
local chrootdir="$1"
local logfile="$2"
......@@ -78,7 +76,6 @@ EOF
}
addToChrootFile() {
#set -x
local chrootfile="$1"
local cmd="$2"
......@@ -87,17 +84,14 @@ addToChrootFile() {
fi
echo $cmd >> $chrootfile
#read a
}
execChroot() {
#set -x
local chrootdir="$1"
#read a
[ ! -x "$chrootdir/tmp/$SCRIPT_NAME" ] && chmod +x "$chrootdir/tmp/$SCRIPT_NAME"
chroot "$chrootdir" "/tmp/$SCRIPT_NAME"
rm -rf "$chrootdir/tmp/$SCRIPT_NAME" &>/dev/null
rm --recursive --force "$chrootdir/tmp/$SCRIPT_NAME" &>/dev/null
return $?
}
......@@ -110,6 +104,6 @@ function cleanup() {
umount --lazy "${chrootdir/$LOG_FILE"
umount --lazy "${chrootdir}/{dev/pts,proc,sys,dev}"
rm -rf "$chrootdir"
rm -rf "$tmp"
rm --recursive --force "$chrootdir"
rm --recursive --force "$tmp"
}
......@@ -80,7 +80,7 @@ source "${PREFIX}/conf/$_DIST/create-iso.conf" \
TIME_STAMP="`date +'%Y-%m-%dT%H:%M:%S'`"
export LOG_FILE="${LOG_PATH}/create-iso-${TIME_STAMP}.log"
mkdir -p ${TMP}
mkdir --parents ${TMP}
source common.sh
source lib/mktmpfs.sh
......@@ -92,7 +92,7 @@ mountTmpfs ${TMPFS}
mountOverlay ${CHROOTDIR} ${TMPFS}
for script in `ls ${SCRIPTSDIR}`; do
if [ -x "$SCRIPTSDIR/$script" ] && egrep -q '^[0-9]{2}-[A-Za-z]+' <<< "$script"; then
if [ -x "$SCRIPTSDIR/$script" ] && egrep --quiet '^[0-9]{2}-[A-Za-z]+' <<< "$script"; then
echo "Running `basename $script`..."
if ! "${SCRIPTSDIR}/${script}"\
${_DIST} \
......@@ -123,14 +123,12 @@ for script in `ls ${SCRIPTSDIR}`; do
if [[ "$script" =~ [0-9]+\-chroot\.* ]]; then
initChroot "${CHROOTDIR}" "${LOG_FILE}"
execChroot "$CHROOTDIR"
#read a
closeChroot "${CHROOTDIR}" "${LOG_FILE}"
#read a
fi
fi
done
NAME="LinuxEducacional6-$(echo ${_DIST} | cut -d'/' -f2).iso"
NAME="LinuxEducacional6-$(echo ${_DIST} | cut --delimiter='/' --fields=f2).iso"
cd ${TMP}/image
xorriso -as mkisofs -isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin -c isolinux/boot.cat -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot -no-emul-boot -isohybrid-gpt-basdat -o ${PREFIX}/iso/${NAME} \
......@@ -139,7 +137,7 @@ xorriso -as mkisofs -isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin -c isolinux/bo
cd -
#cleanTmpFiles
#umountOverlay ${CHROOTDIR} ${TMPFS}
#umountOverlay ${CHROOTDIR} ${TMPFS}
#umountTmpfs ${TMPFS}
exit 0
......@@ -64,6 +64,6 @@ fi
mksquashfs $CHROOTDIR ${TMP}/image/casper/filesystem.squashfs -b 1M -no-recovery -processors $(nproc) ||\
log ERROR "Failed to compress ${CHROOTDIR}."
(cd ${TMP}/image && find . -type f -print0 | xargs -0 md5sum | grep -v "\./md5sum.txt" > md5sum.txt) ||\
(cd ${TMP}/image && find . -type f -print0 | xargs -0 md5sum | grep --invert-match "\./md5sum.txt" > md5sum.txt) ||\
log ERROR "Failed to generate md5sum."
exit 0
......@@ -46,23 +46,23 @@ PREFIX=$PWD
source ${PREFIX}/common.sh
mount --bind "/etc/resolv.conf" "${CHROOTDIR}/etc/resolv.conf"
fingerprint=$(gpg --list-keys --with-colons 'C3SL Live' | grep -m 1 'fpr' | cut -d':' -f10)
fingerprint=$(gpg --list-keys --with-colons 'C3SL Live' | grep --max-count=1 'fpr' | cut --delimiter=':' --fields=10)
if test -z ${fingerprint}; then
gpg --batch --no-tty --gen-key ${PREFIX}/src/gpg-key/gen-key-script
fingerprint=$(gpg --list-keys --with-colons 'C3SL Live' | grep -m 1 'fpr' | cut -d':' -f10)
fingerprint=$(gpg --list-keys --with-colons 'C3SL Live' | grep --max-count=1 'fpr' | cut --delimiter=':' --fields=10)
fi
cp -Ra ${PREFIX}/src/local-repository/ ${PREFIX}/repo/
cp --recursive --archive ${PREFIX}/src/local-repository/ ${PREFIX}/repo/
sed -i "s/##ARCH##/ ${_ARCH}/" ${PREFIX}/repo/conf/distributions
sed -i "s/##GPGKEY##/ ${fingerprint}/" ${PREFIX}/repo/conf/distributions
sed -i "s/##CODENAME##/ ${_REPO}/" ${PREFIX}/repo/conf/distributions
chroot ${CHROOTDIR} apt-get clean
chroot ${CHROOTDIR} apt-get --download-only --yes install $(cat ${REPOPKGS} | grep -v '^#' | tr '\n' ' ')
chroot ${CHROOTDIR} apt-get --download-only --yes install $(cat ${REPOPKGS} | grep --invert-match '^#' | tr '\n' ' ')
reprepro --basedir ${PREFIX}/repo/ includedeb ${_REPO} ${CHROOTDIR}/var/cache/apt/archives/*.deb
chroot ${CHROOTDIR} apt-get clean
mv repo/{dists,pool} ${TMP}/image/
rm -rf ${PREFIX}/repo/
rm --recursive --force ${PREFIX}/repo/
gpg --armor --export 'C3SL Live' > ${CHROOTDIR}/tmp/public.key
chroot ${CHROOTDIR} apt-key add /tmp/public.key
......
......@@ -20,8 +20,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
#set -x
type addToChrootFile >/dev/null 2>&1 || . common.sh
_DIST=$1
......@@ -47,8 +45,9 @@ PREFIX=$PWD
addToChrootFile $CHROOTFILE 'export PATH=/fakebin:${PATH}'
cat ${DPLIST} | grep -v '^#' | tr '\n' ' '
cat ${DPLIST} | grep --invert-match '^#' | tr '\n' ' '
addToChrootFile $CHROOTFILE "export PATH='/fakebin:${PATH}'"
addToChrootFile $CHROOTFILE "export DEBIAN_FRONTEND=noninteractive"
addToChrootFile $CHROOTFILE "apt-get update && apt-get -q -y install $(cat ${DPLIST} | grep -v '^#' | tr '\n' ' ')"
addToChrootFile $CHROOTFILE "apt-get update && apt-get --quiet --yes install $(cat ${DPLIST} | grep --invert-match '^#' | tr '\n' ' ')"
exit 0
......@@ -20,8 +20,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
#set -x
_DIST=$1
_ARCH=$2
_REPO=$3
......@@ -47,7 +45,7 @@ source ${PREFIX}/common.sh
addToChrootFile $CHROOTFILE "export PATH='/fakebin:${PATH}'"
addToChrootFile $CHROOTFILE "export DEBIAN_FRONTEND=noninteractive"
#addToChrootFile $CHROOTFILE "apt-get update && apt-get -q -y -t ${_REPO} install le-live-all"
#addToChrootFile $CHROOTFILE "apt-get update && apt-get -q -y -t ${_REPO} install $(cat ${INSTLIST} | grep -v '^#' | tr '\n' ' ')"
#addToChrootFile $CHROOTFILE "apt-get update && apt-get --quiet --yes --target-release ${_REPO} install le-live-all"
#addToChrootFile $CHROOTFILE "apt-get update && apt-get --quiet --yes --target-release ${_REPO} install $(cat ${INSTLIST} | grep --invert-match '^#' | tr '\n' ' ')"
exit 0
......@@ -43,19 +43,18 @@ PREFIX=$PWD
source ${PREFIX}/common.sh
echo "CHROOTDIR = '${CHROOTDIR}'"
cp ${PREFIX}/vmlinuz-*-generic ${TMP}/image/casper/vmlinuz || exit 1
if ! test -f initrd.lz; then
initname=$(ls "${PREFIX}/" | grep "initrd.*-generic")
if [ ! -d ${PREFIX}/initrd ]; then
mkdir ${PREFIX}/initrd
else
rm -rf ${PREFIX}/initrd/*
rm --recursive --force ${PREFIX}/initrd/*
fi
echo "initname = '${initname}'"
cd ${PREFIX}/initrd
gzip -dc ${PREFIX}/${initname} | cpio -i
find . | cpio --quiet -o -H newc | lzma -7 > ../initrd.lz
gzip --decompress --stdout ${PREFIX}/${initname} | cpio --extract
find . | cpio --quiet --create -H newc | lzma -7 > ../initrd.lz
cd ..
fi
cp initrd.lz ${TMP}/image/casper/initrd.lz || exit 1
......
......@@ -41,18 +41,15 @@ TMPFS=${18}
REPOPKGS=${19}
PREFIX=$PWD
#set -x
source common.sh
#This packages must not appear in the manifest
cp ${TMP}/image/casper/filesystem.manifest ${TMP}/image/casper/filesystem.manifest-desktop
IFS_OLD=$IFS
IFS=$'\n'
for package in $(cat ${RMDSKT})
do
sed -i "/${package}/d" ${TMP}/image/casper/filesystem.manifest-desktop
sed --in-place "/${package}/d" ${TMP}/image/casper/filesystem.manifest-desktop
done
IFS=$IFS_OLD
exit 0
......@@ -43,6 +43,6 @@ export PREFIX=$PWD
source common.sh
chroot $CHROOTDIR dpkg-query -W --showformat='${Package} ${Version}\n' > ${TMP}/image/casper/filesystem.manifest
chroot $CHROOTDIR dpkg-query --show --showformat='${Package} ${Version}\n' > ${TMP}/image/casper/filesystem.manifest
exit 0
......@@ -43,7 +43,7 @@ PREFIX=$PWD
source ${PREFIX}/common.sh
addToChrootFile $CHROOTFILE "apt-get -y purge $(cat ${RMLIST} | grep -v "^#")"
addToChrootFile $CHROOTFILE "apt-get -y autoremove"
addToChrootFile $CHROOTFILE "apt-get --yes purge $(cat ${RMLIST} | grep --invert-match "^#")"
addToChrootFile $CHROOTFILE "apt-get --yes autoremove"
exit 0
......@@ -46,16 +46,16 @@ if test -z ${CHROOTDIR}; then
echo "CHROOTDIR=\"${CHROOTDIR}\""
exit 1
fi
mkdir -p ${TMP}/image/{casper,isolinux,install,preseed}
mkdir --parents ${TMP}/image/{casper,isolinux,install,preseed}
cp /usr/lib/ISOLINUX/isolinux.bin ${TMP}/image/isolinux/ || exit 1
cp /usr/lib/syslinux/modules/bios/ldlinux.c32 ${TMP}/image/isolinux/ || exit 1
cp src/isolinux/* ${TMP}/image/isolinux/ || exit 1
cp src/preseed/preseed.cfg ${TMP}/image/preseed/
cp src/keyboard ${CHROOTDIR}/etc/default/
du -sx --block-size=1 ${CHROOTDIR} | cut -f1 > "${TMP}/image/casper/filesystem.size"
du --summarize --one-file-system --block-size=1 ${CHROOTDIR} | cut --fields=1 > "${TMP}/image/casper/filesystem.size"
cp src/README.diskdefines-${_ARCH} ${TMP}/image/README.diskdefines || exit 1
pushd ${TMP}/image/
ln -s . ubuntu
ln --symbolic . ubuntu
popd
mkdir ${TMP}/image/.disk
touch ${TMP}/image/.disk/base_installable || exit 1
......@@ -64,12 +64,12 @@ echo "Linux-Educacional 6.1.0" > ${TMP}/image/.disk/info || exit 1
echo "https://linuxeducacional.c3sl.ufpr.br" > ${TMP}/image/.disk/release_notes_url || exit 1
#Change label on grub menu
sed -i "s/GRUB_DISTRIBUTOR=.*/GRUB_DISTRIBUTOR=\"${DISTRO//_/ }\"/" ${CHROOTDIR}/etc/default/grub
sed --in-place "s/GRUB_DISTRIBUTOR=.*/GRUB_DISTRIBUTOR=\"${DISTRO//_/ }\"/" ${CHROOTDIR}/etc/default/grub
sed -i "s/PRETTY_NAME=.*/PRETTY_NAME=\"${DISTRO//_/ }\"/" ${CHROOTDIR}/usr/lib/os-release
sed --in-place "s/PRETTY_NAME=.*/PRETTY_NAME=\"${DISTRO//_/ }\"/" ${CHROOTDIR}/usr/lib/os-release
cp src/lsb-release ${CHROOTDIR}/etc/
# Disable apport
sed -i 's/enabled=.*/enabled=0/' ${CHROOTDIR}/etc/default/apport
sed --in-place 's/enabled=.*/enabled=0/' ${CHROOTDIR}/etc/default/apport
exit 0
......@@ -19,7 +19,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
set -x
_DIST=$1
_ARCH=$2
_REPO=$3
......@@ -48,10 +48,10 @@ if [ ! -d "${CHROOTDIR}/etc/apt/sources.list.d" ]; then
mkdir "${CHROOTDIR}/etc/apt/sources.list.d"
fi
cp ${OURSOURCESLIST} ${CHROOTDIR}/etc/apt/sources.list.d/
sed -i "s/##CODENAME##/${_REPO}/g" ${CHROOTDIR}/etc/apt/sources.list.d/$(basename ${OURSOURCESLIST})
sed --in-place "s/##CODENAME##/${_REPO}/g" ${CHROOTDIR}/etc/apt/sources.list.d/$(basename ${OURSOURCESLIST})
addToChrootFile $CHROOTFILE "wget -O- http://repo.c3sl.ufpr.br/le6/le.c3sl.ufpr.br.key | apt-key add -"
addToChrootFile $CHROOTFILE "apt-get update"
#addToChrootFile $CHROOTFILE "apt-get -y upgrade"
#addToChrootFile $CHROOTFILE "apt-get --yes upgrade"
exit 0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment