#               Woobuntu woobuntu_build.sh hacking
# 说明:
# 有时候因为一些需求,我们需要定制一些系统,包括Ubuntu系统,于是
# 我们自然需要知道如何去解包一个Ubuntu镜像,如何合成一个Ubuntu镜像。
# 当然这也有助于后续对Linux整套系统的定制。
#
# -- 深圳 南山平山村 曾剑锋
#
#
# 参考文档:
# . linux 下如何制作 iso 格式的启动镜像
# https://www.v2ex.com/t/252789
# . Ubuntu下制作iso文件的简单方法
# http://www.xuebuyuan.com/1292033.html
# . Mount ISO Read/Write
# http://www.linuxquestions.org/questions/linux-software-2/mount-iso-read-write-329688/
# . Woobuntu
# https://github.com/woolabs/Woobuntu #!/bin/bash #Author : woolabs team
#Maintainer : lxj616@wooyun chroot_args="-c" # 帮助信息
show_help() { echo " __ __ _ _ ";
echo "/ / /\ \ \___ ___ | |__ _ _ _ __ | |_ _ _ ";
echo "\ \/ \/ / _ \ / _ \| '_ \| | | | '_ \| __| | | |";
echo " \ /\ / (_) | (_) | |_) | |_| | | | | |_| |_| |";
echo " \/ \/ \___/ \___/|_.__/ \__,_|_| |_|\__|\__,_|";
echo " "; echo "Usage:"
echo "-f The ubuntu base image you wanna use for woobuntu build"
echo "-o The output woobuntu image"
echo "-x Xubuntu optimization for zh_CN & pre-configuration"
echo "-g gnome-ubuntu optimization for zh_CN & pre-configuration"
echo "-u Ubuntu original optimization for zh_CN & pre-configuration"
echo "-N Pre-install NVIDIA driver (Use with causion)"
echo "-V Pre-install Virtualbox-guest additions (Use with causion)"
echo ""
echo "Example:"
echo ""
echo "./woobuntu_build.sh -f xubuntu-15.10-desktop-amd64.iso -o woobuntu-current-amd64.iso -x" } # 参数为0的时候显示帮助信息
if [ $# = ]
then
show_help
exit
fi # 解析命令行参数
while getopts "h?f:o:xguNV" opt; do
case "$opt" in
h|\?)
show_help
exit
;;
f) input_iso=$OPTARG
;;
o) output_iso=$OPTARG
;;
x) chroot_args="$chroot_args -x"
;;
g) chroot_args="$chroot_args -g"
;;
u) chroot_args="$chroot_args -u"
;;
N) chroot_args="$chroot_args -N"
;;
V) chroot_args="$chroot_args -V"
;;
esac
done echo "You need following packages to continue:squashfs-tools dchroot"
#Depends on dchroot to create iso
# 依赖root权限生成iso文件
sudo apt-get install squashfs-tools dchroot mkisofs -y
#Create temp folder to mount origin iso
# 创建temp文件夹用于挂载源iso文件
mkdir /tmp/livecd
#Mount origin iso to temp folder to extract squashfs file
# 挂载源iso文件到/tmp/livecd目录
sudo mount -o loop $input_iso /tmp/livecd
#Create temp folder to store iso image files
# 创建temp目录来存放iso镜像文件
mkdir -p livecd/cd
#Don't copy squashfs file as we will repack this file later
# --exclude: 指定不需要拷贝的文件;
# /casper/filesystem.squashfs文件使用后面合成的文件,所以这里可以忽略拷贝
rsync --exclude=/casper/filesystem.squashfs -a /tmp/livecd/ livecd/cd
#Create temp folder to mount squashfs file & copy everything out for modification
# 创建temp文件夹,用于挂载squashfs文件,并且拷贝出所有的内容用于修改
mkdir livecd/squashfs livecd/custom
#Need to load before use
# 在使用squashfs工具之前,需要加载一下
sudo modprobe squashfs
#Mount the squash file
# 挂载squash文件系统
sudo mount -t squashfs -o loop /tmp/livecd/casper/filesystem.squashfs livecd/squashfs/
#Copy everything out for modification(squashfs file itself is read-only)
# 将squash文件系统内的文件全部拷贝出来,主要是由于squashfs是一个只读文件系统
sudo cp -a livecd/squashfs/* livecd/custom
#Enable network related configuration inside chroot env
# 使能网络功能,因为后续要使用网络更新程序
sudo cp /etc/resolv.conf /etc/hosts livecd/custom/etc/
#Copy wooyun-firefox user-profile into chroot env
# 拷贝wooyun-firefox user-profile到chroot目录,供后续使用
sudo cp -r .mozilla livecd/custom/root
#Drop the chroot install script inside
# 拷贝woobuntu_chroot_build.sh文件到chroot目录
sudo cp woobuntu_chroot_build.sh livecd/custom/root
#Execute the install script inside chroot env
# 执行chroot相关的脚本
sudo chroot livecd/custom /bin/bash -x /root/woobuntu_chroot_build.sh $chroot_args
#Everything should be done except re-check the mount points
sudo umount -lf livecd/custom/proc
sudo umount -lf livecd/custom/sys #Renew the manifest
chmod +w livecd/cd/casper/filesystem.manifest
#chmod +w livecd/cd/preseed/xubuntu.seed
#cat > livecd/cd/preseed/xubuntu.seed <<EOF
#d-i debian-installer/locale string zh_CN
#d-i mirror/http/mirror select CN.archive.ubuntu.com
#d-i clock-setup/utc boolean false
#d-i time/zone string Asia/Shanghai
#d-i clock-setup/ntp boolean true
#tasksel tasksel/first multiselect xubuntu-desktop
#d-i pkgsel/update-policy select none
#d-i finish-install/reboot_in_progress note
#EOF
sudo chroot livecd/custom dpkg-query -W --showformat='${Package} ${Version}\n' > livecd/cd/casper/filesystem.manifest
sudo cp livecd/cd/casper/filesystem.manifest livecd/cd/casper/filesystem.manifest-desktop #Repack the squashfs file
# 重新打包squashfs文件系统
sudo mksquashfs livecd/custom livecd/cd/casper/filesystem.squashfs #Re-create the md5 file
# 重新计算md5文件
sudo rm livecd/cd/md5sum.txt
sudo bash -c 'cd livecd/cd && find . -type f -exec md5sum {} +' > livecd/cd/md5sum.txt #Repack iso file
# 重新生成iso文件
cd livecd/cd
sudo mkisofs -r -V "Woobuntu-Live" -b isolinux/isolinux.bin -c isolinux/boot.cat -cache-inodes -J -l -no-emul-boot -boot-load-size 4 -boot-info-table -o output.iso .
mv output.iso ../../
cd ../../
mv output.iso $output_iso #Umount and clean
# 卸载相关内容
sudo umount livecd/squashfs/
sudo umount /tmp/livecd
#sudo rm -fr livecd/ echo "build finished"

Woobuntu woobuntu_build.sh hacking的更多相关文章

  1. OK335xS psplash make-image-header.sh hacking

    /***************************************************************************** * OK335xS psplash mak ...

  2. ti processor sdk linux am335x evm setup.sh hacking

    #!/bin/sh # # ti processor sdk linux am335x evm setup.sh hacking # 说明: # 本文主要对TI的sdk中的setup.sh脚本进行解读 ...

  3. ti processor sdk linux am335x evm /bin/setup-host-check.sh hacking

    #!/bin/sh # # ti processor sdk linux am335x evm /bin/setup-host-check.sh hacking # 说明: # 本文主要对TI的sdk ...

  4. ti processor sdk linux am335x evm /bin/create-sdcard.sh hacking

    #!/bin/bash # # ti processor sdk linux am335x evm /bin/create-sdcard.sh hacking # 说明: # 本文主要对TI的sdk中 ...

  5. ti processor sdk linux am335x evm /bin/unshallow-repositories.sh hacking

    #!/bin/bash # # ti processor sdk linux am335x evm /bin/unshallow-repositories.sh hacking # 说明: # 本文主 ...

  6. ti processor sdk linux am335x evm /bin/setup-package-install.sh hacking

    #!/bin/sh # # ti processor sdk linux am335x evm /bin/setup-package-install.sh hacking # 说明: # 本文主要对T ...

  7. ti processor sdk linux am335x evm /bin/setup-uboot-env.sh hacking

    #!/bin/sh # # ti processor sdk linux am335x evm /bin/setup-uboot-env.sh hacking # 说明: # 本文主要对TI的sdk中 ...

  8. ti processor sdk linux am335x evm /bin/setup-minicom.sh hacking

    #!/bin/sh # # ti processor sdk linux am335x evm /bin/setup-minicom.sh hacking # 说明: # 本文主要对TI的sdk中的s ...

  9. ti processor sdk linux am335x evm /bin/setup-targetfs-nfs.sh hacking

    #!/bin/sh # # ti processor sdk linux am335x evm /bin/setup-targetfs-nfs.sh hacking # 说明: # 本文主要对TI的s ...

随机推荐

  1. html利用锚点实现定位代码实例

    本章节介绍介绍一下如何利用锚点实现定位,使用锚点实现定位是html固有的功能,当然比较简单,也实现了基本的功能,但是功能相对简单一些,如果想要实现平滑的定位可以参阅jquery实现的点击页面动画方式平 ...

  2. 【BZOJ】【3757】苹果树

    树分块 orz HZWER http://hzwer.com/5259.html 不知为何我原本写的倍增求LCA给WA了……学习了HZWER的倍增新姿势- 树上分块的转移看vfk博客的讲解吧……(其实 ...

  3. Oracle composite index column ordering

    Question:  I have a SQL with multiple columns in my where clause.  I know that Oracle can only choos ...

  4. POJ 2379 ACM Rank Table(排序)

    题很水,数据注意一下四点即可: 1.有些team会在一道题AC了之后还提交,这个时候只需要算第一次ac的时间以及这之前的wa,之后的全部忽略.2.如果一道题没有ac,那么在计算时间时不应该加上它的wa ...

  5. HDU 3047 Zjnu Stadium(带权并查集)

    题意:有一个环形体育场,有n个人坐,给出m个位置关系,A B x表示B所在的列在A的顺时针方向的第x个,在哪一行无所谓,因为假设行有无穷个. 给出的座位安排中可能有与前面矛盾的,求有矛盾冲突的个数. ...

  6. POJ1328Radar Installation

    http://poj.org/problem?id=1328 题的大意就是说在海里有小岛,坐标位置会给出,需要岸边的雷达覆盖所有的小岛,但雷达的覆盖范围有限,所以,需要最少的雷达覆盖所有的小岛,但若是 ...

  7. Android Service 的一些笔记

    绑定服务: 用于间接调用服务里面的方法.如果调用者Activity被销毁了,服务也跟着销毁了,服务也会跟着销毁. 开启服务: 不可以调用服务里面的方法.如果调用者的Activity退出了,服务还会长期 ...

  8. 李洪强iOS开发之OC[017]函数和方法的区别

    // //  main.m //  15 - 函数和对象的方法的区别 // //  Created by vic fan on 16/7/12. //  Copyright © 2016年 李洪强. ...

  9. 【nginx运维基础(3)】Nginx的编译PHP

    Apache默认是把PHP作为本身的一个模块(mod_php)来运行的,而Nginx是以FastCGI方式运行的.所以使用Nginx+PHP就是直接配置为FastCGI模式. 安装PHP 下载地址: ...

  10. Delphi 中的 procedure of object (类方法存在一个隐藏参数self),简单深刻 good

    其实要了解这些东西,适当的学些反汇编,WINDOWS内存管理机制,PE结构,看下李维的VCL架构剖析可以很好理解type TMyEvent = procedure of object;这是一种数据类型 ...