⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ipkg

📁 一个linux下的根文件系统的源码
💻
📖 第 1 页 / 共 2 页
字号:
		for pkg in $new_deps; do			if ! echo $installed_pkgs | grep -q "\<$pkg\>"; then				maybe_new_pkgs="$maybe_new_pkgs $pkg"			fi		done		new_pkgs=		for pkg in $maybe_new_pkgs; do			if ! echo $all_deps | grep -q "\<$pkg\>"; then				if [ -z "`ipkg_info $pkg`" ]; then					echo "ipkg_depends: Warning: $pkg mentioned in dependency but no package found in $IPKG_LISTS_DIR" >&2				else					new_pkgs="$new_pkgs $pkg"				fi			fi		done	done	echo $all_deps}ipkg_get_install_dest() {	local dest="$1"	shift	local sd=$dest/$IPKG_DIR_PREFIX	local info_dir=$sd/info	local pkgs=`ipkg_depends $*`	mkdir -p $info_dir	for pkg in $pkgs; do		if ! ipkg_status_mentioned_sd $sd $pkg; then			echo "Package: $pkgStatus: install ok not-installed" | ipkg_status_update_sd $sd $pkg		fi	done	for pkg in $pkgs; do		local filename=		for src in `ipkg_src_names`; do			if ipkg_require_list $src; then				filename=`ipkg_extract_paragraph $pkg < $IPKG_LISTS_DIR/$src | ipkg_extract_field Filename | ipkg_extract_value`				[ -n "$filename" ] && break			fi		done		if [ -z "$filename" ]; then			echo "ipkg_get_install: ERROR: Cannot find package $pkg in $IPKG_LISTS_DIR"			echo "ipkg_get_install:        Check the spelling and maybe run \`ipkg update'."			ipkg_status_remove_sd $sd $pkg			return 1;		fi		[ -e "$IPKG_TMP" ] || mkdir -p $IPKG_TMP		echo ""		local tmp_pkg_file="$IPKG_TMP/"`ipkg_file_part $filename`		if ! ipkg_download `ipkg_src_byname $src`/$filename $tmp_pkg_file; then			echo "ipkg_get_install: Perhaps you need to run \`ipkg update'?"			return 1		fi		if ! ipkg_install_file_dest $dest $tmp_pkg_file; then			echo "ipkg_get_install: ERROR: Failed to install $tmp_pkg_file"			echo "ipkg_get_install: I'll leave it there for you to try a manual installation"			exit 1		fi		rm $tmp_pkg_file	done}ipkg_get_install() {	if ! ipkg_get_install_dest $IPKG_ROOT $*; then		exit 1	fi}ipkg_install_file_dest() {	local dest="$1"	local filename="$2"	local sd=$dest/$IPKG_DIR_PREFIX	local info_dir=$sd/info	if [ ! -f "$filename" ]; then		echo "ipkg_install_file: ERROR: File $filename not found"		return 1	fi	local pkg=`ipkg_file_part $filename | sed 's/\([a-zA-Z0-9.+-]\+\)_.*/\1/'`	# Check dependencies	local depends=`ipkg_depends $pkg | sed -e "s/\<$pkg\>//"`	# Don't worry about deps that are scheduled for installation	local missing_deps=	for dep in $depends; do		if ! ipkg_status_all $dep | grep -q 'Status:[[:space:]]install'; then			missing_deps="$missing_deps $dep"		fi	done	if [ ! -z "$missing_deps" ]; then		if [ -n "$FORCE_DEPENDS" ]; then			echo "ipkg_install_file: Warning: $pkg depends on the following uninstalled programs: $missing_deps"		else			echo "ipkg_install_file: ERROR: $pkg depends on the following uninstalled programs:	$missing_deps"			echo "ipkg_install_file: You may want to use \`ipkg install' to install these."			return 1		fi	fi	mkdir -p $IPKG_TMP/$pkg/control	mkdir -p $IPKG_TMP/$pkg/data	mkdir -p $info_dir##	if ! tar -xzOf $filename ./control.tar.gz | tar -xzf - -C $IPKG_TMP/$pkg/control; then	if ! zcat -dc $filename | tar -xOf - ./control.tar.gz | zcat -dc - | tar -xf - -C $IPKG_TMP/$pkg/control; then		echo "ipkg_install_file: ERROR unpacking control.tar.gz from $filename"		return 1	fi	if [ -n "$IPKG_OFFLINE_ROOT" ]; then		if grep -q '^InstallsOffline:[[:space:]]*no' $IPKG_TMP/$pkg/control/control; then			echo "*** Warning: Package $pkg may not be installed in offline mode"			echo "*** Warning: Scheduling $filename for pending installation (installing into $IPKG_PENDING_DIR)"			echo "Package: $pkgStatus: install ok pending" | ipkg_status_update_sd $sd $pkg			mkdir -p $IPKG_PENDING_DIR			cp $filename $IPKG_PENDING_DIR			rm -r $IPKG_TMP/$pkg/control			rm -r $IPKG_TMP/$pkg/data			rmdir $IPKG_TMP/$pkg			return 0		fi	fi	echo -n "Unpacking $pkg..."	set +o noglob	for file in $IPKG_TMP/$pkg/control/*; do		local base_file=`ipkg_file_part $file`		mv $file $info_dir/$pkg.$base_file	done	set -o noglob	rm -r $IPKG_TMP/$pkg/control##	if ! tar -xzOf $filename ./data.tar.gz | tar -xzf - -C $IPKG_TMP/$pkg/data; then	if ! zcat -dc $filename | tar -xOf - ./data.tar.gz | zcat -dc - | tar -xf - -C $IPKG_TMP/$pkg/data; then		echo "ipkg_install_file: ERROR unpacking data.tar.gz from $filename"		return 1	fi	echo "Done."	echo -n "Configuring $pkg..."	export PKG_ROOT=$dest	# for package made in windows	if [ -e "$info_dir/$pkg.preinst" ]; then		chmod a+x $info_dir/$pkg.preinst	fi	if [ -x "$info_dir/$pkg.preinst" ]; then		if ! $info_dir/$pkg.preinst install; then			echo "$info_dir/$pkg.preinst failed. Aborting installation of $pkg"			rm -rf $IPKG_TMP/$pkg/data			rmdir $IPKG_TMP/$pkg			return 1		fi	fi	local old_conffiles=`ipkg_status_sd $sd $pkg Conffiles | ipkg_extract_value`	local new_conffiles=	if [ -f "$info_dir/$pkg.conffiles" ]; then		for conffile in `cat $info_dir/$pkg.conffiles`; do			if [ -f "$dest/$conffile" ] && ! echo " $old_conffiles " | grep -q " $conffile "`md5sum $dest/$conffile | sed 's/ .*//'`; then				local use_maintainers_conffile=				if [ -z "$FORCE_DEFAULTS" ]; then					while true; do						echo -n "Configuration file \`$conffile' ==> File on system created by you or by a script. ==> File also in package provided by package maintainer.   What would you like to do about it ?  Your options are:    Y or I  : install the package maintainer's version    N or O  : keep your currently-installed version      D     : show the differences between the versions (if diff is installed) The default action is to keep your current version.*** `ipkg_file_part $conffile` (Y/I/N/O/D) [default=N] ? "						read response						case "$response" in						[YyIi] | [Yy][Ee][Ss])							use_maintainers_conffile=t							break						;;						[Dd])							echo "diff -u $dest/$conffile $IPKG_TMP/$pkg/data/$conffile"							diff -u $dest/$conffile $IPKG_TMP/$pkg/data/$conffile || true							echo "[Press ENTER to continue]"							read junk						;;						*)							break						;;						esac					done				fi				if [ -n "$use_maintainers_conffile" ]; then					local md5sum=`md5sum $IPKG_TMP/$pkg/data/$conffile | sed 's/ .*//'`					new_conffiles="$new_conffiles $conffile $md5sum"				else					new_conffiles="$new_conffiles $conffile <custom>"					rm $IPKG_TMP/$pkg/data/$conffile				fi			else				md5sum=`md5sum $IPKG_TMP/$pkg/data/$conffile | sed 's/ .*//'`				new_conffiles="$new_conffiles $conffile $md5sum"			fi		done	fi	local owd=`pwd`	(cd $IPKG_TMP/$pkg/data/; tar cf - . | (cd $owd; cd $dest; tar xf -))	rm -rf $IPKG_TMP/$pkg/data	rmdir $IPKG_TMP/$pkg##	tar -xzOf $filename ./data.tar.gz | tar tzf - | sed -e 's/^\.//' > $info_dir/$pkg.list	if ! zcat -dc $filename | tar -xOf - ./data.tar.gz | zcat -dc - | tar tf - | sed -e 's/^\.//' > $info_dir/$pkg.list; then	    echo "install failed. Aborting installation of $pkg"	    rm -rf $IPKG_TMP/$pkg/data	    rmdir $IPKG_TMP/$pkg	    exit 1		fi	# for package made in windows	if [ -e "$info_dir/$pkg.postinst" ]; then		chmod a+x $info_dir/$pkg.postinst	fi	if [ -x "$info_dir/$pkg.postinst" ]; then		$info_dir/$pkg.postinst configure	fi	if [ -n "$new_conffiles" ]; then		new_conffiles='Conffiles: '`echo $new_conffiles | ipkg_protect_slashes`	fi	local destor=`echo "$IPKG_OFFLINE_ROOT" | ipkg_protect_slashes`	local sed_safe_root=`echo $dest | sed -e "s/^${destor}//" | ipkg_protect_slashes`	sed -e "s/\(Package:.*\)/\1\\Status: install ok installed\\Root: ${sed_safe_root}\\${new_conffiles}/" $info_dir/$pkg.control | ipkg_status_update_sd $sd $pkg	rm -f $info_dir/$pkg.control	rm -f $info_dir/$pkg.conffiles	rm -f $info_dir/$pkg.preinst	rm -f $info_dir/$pkg.postinst	echo "Done."}ipkg_install_file() {	ipkg_install_file_dest $IPKG_ROOT $*}ipkg_install() {	while [ $# -gt 0 ]; do		local pkg="$1"		shift			case "$pkg" in		http://* | ftp://*)			local tmp_pkg_file="$IPKG_TMP/"`ipkg_file_part $pkg`			if ipkg_download $pkg $tmp_pkg_file; then				ipkg_install_file $tmp_pkg_file				rm $tmp_pkg_file			fi			;;		*.ipk)			if [ -f "$pkg" ]; then				ipkg_install_file $pkg			else				echo "File not found $pkg" >&2			fi			;;		*)			ipkg_get_install $pkg || true			;;		esac	done}ipkg_install_pending() {	[ -n "$IPKG_OFFLINE_ROOT" ] && return 0	if [ -d "$IPKG_PENDING_DIR" ]; then		set +o noglob		local pending=`ls -1d $IPKG_PENDING_DIR/*.ipk 2> /dev/null` || true		set -o noglob		if [ -n "$pending" ]; then			echo "The following packages in $IPKG_PENDING_DIR will now be installed:"			echo $pending			for filename in $pending; do				if ipkg_install_file $filename; then					rm $filename				fi			done		fi	fi	return 0}ipkg_install_wanted() {	local wanted=`ipkg_status_matching 'Status:[[:space:]]*install.*not-installed'`	if [ -n "$wanted" ]; then		echo "The following package were previously requested but have not been installed:"		echo $wanted		if [ -n "$FORCE_DEFAULTS" ]; then			echo "Installing them now."		else			echo -n "Install them now [Y/n] ? "			read response			case "$response" in			[Nn] | [Nn][Oo])				return 0				;;			esac		fi		ipkg_install $wanted	fi	return 0}ipkg_upgrade_pkg() {	local pkg="$1"	local avail_ver=`ipkg_info $pkg Version | ipkg_extract_value | head -n 1`	is_installed=	for dest_name in `ipkg_dest_names`; do		local dest=`ipkg_dest_byname $dest_name`		local sd=$dest/$IPKG_DIR_PREFIX		local inst_ver=`ipkg_status_sd $sd $pkg Version | ipkg_extract_value`		if [ -n "$inst_ver" ]; then			is_installed=t			if [ -z "$avail_ver" ]; then				echo "Assuming locally installed package $pkg ($inst_ver) is up to date"				return 0			fi			if [ "$avail_ver" = "$inst_ver" ]; then 				echo "Package $pkg ($inst_ver) installed in $dest_name is up to date"			elif ipkg-compare-versions $avail_ver '>>' $inst_ver; then				echo "Upgrading $pkg ($dest_name) from $inst_ver to $avail_ver"				ipkg_get_install_dest $dest $pkg			else				echo "Not downgrading package $pkg from $inst_ver to $avail_ver"			fi		fi	done	if [ -z "$is_installed" ]; then		echo "Package $pkg does not appear to be installed"		return 0	fi}ipkg_upgrade() {	if [ $# -lt 1 ]; then		local pkgs=`ipkg_status_matching 'Status:.*[[:space:]]installed'`	else		pkgs="$*"	fi		for pkg in $pkgs; do		ipkg_upgrade_pkg $pkg	done}ipkg_remove_pkg_dest() {	local dest="$1"	local pkg="$2"	local sd=$dest/$IPKG_DIR_PREFIX	local info_dir=$sd/info	if ! ipkg_status_installed_sd $sd $pkg; then		echo "ipkg_remove: Package $pkg does not appear to be installed in $dest"		if ipkg_status_mentioned_sd $sd $pkg; then			echo "Purging mention of $pkg from the ipkg database"			ipkg_status_remove_sd $sd $pkg		fi		return 1	fi	echo "ipkg_remove: Removing $pkg... "	local files=`cat $info_dir/$pkg.list`	export PKG_ROOT=$dest	# for package made in windows	if [ -e "$info_dir/$pkg.prerm" ]; then		chmod a+x $info_dir/$pkg.prerm	fi	if [ -x "$info_dir/$pkg.prerm" ]; then		$info_dir/$pkg.prerm remove	fi	local conffiles=`ipkg_status_sd $sd $pkg Conffiles | ipkg_extract_value`	local dirs_to_remove=	for file in $files; do		if [ -d "$dest/$file" ]; then			dirs_to_remove="$dirs_to_remove $dest/$file"		else			if echo " $conffiles " | grep -q " $file "; then				if echo " $conffiles " | grep -q " $file "`md5sum $dest/$file | sed 's/ .*//'`; then					rm -f $dest/$file				fi			else				rm -f $dest/$file			fi		fi	done	local removed_a_dir=t	while [ -n "$removed_a_dir" ]; do		removed_a_dir=		local new_dirs_to_remove=		for dir in $dirs_to_remove; do			if rmdir $dir >/dev/null 2>&1; then				removed_a_dir=t			else				new_dirs_to_remove="$new_dirs_to_remove $dir"			fi		done		dirs_to_remove="$new_dirs_to_remove"	done##	if [ -n "$dirs_to_remove" ]; then## no problem##		echo "ipkg_remove: Warning: Not removing the following directories since they are not empty:" >&2##		echo "$dirs_to_remove" | sed -e 's/\/[/]\+/\//g' >&2##	fi	# for package made in windows	if [ -e "$info_dir/$pkg.postrm" ]; then		chmod a+x $info_dir/$pkg.postrm	fi	if [ -x "$info_dir/$pkg.postrm" ]; then		$info_dir/$pkg.postrm remove	fi	ipkg_status_remove_sd $sd $pkg	set +o noglob	rm -f $info_dir/$pkg.*	set -o noglob	echo "Done."}ipkg_remove_pkg() {	local pkg="$1"	for dest in `ipkg_dests_all`; do		local sd=$dest/$IPKG_DIR_PREFIX		if ipkg_status_mentioned_sd $sd $pkg; then			ipkg_remove_pkg_dest $dest $pkg		fi	done}ipkg_remove() {	while [ $# -gt 0 ]; do		local pkg="$1"		shift		if [ -n "$DEST_NAME" ]; then			ipkg_remove_pkg_dest $IPKG_ROOT $pkg		else			ipkg_remove_pkg $pkg		fi	done}############ ipkg main############ Parse optionswhile [ $# -gt 0 ]; do	arg="$1"	case $arg in	-d | -dest)		[ $# -gt 1 ] || ipkg_usage "option $arg requires an argument"		DEST_NAME="$2"		shift		;;	-force-depends)		FORCE_DEPENDS=t		;;	-force-defaults)		FORCE_DEFAULTS=t		;;	-*)		ipkg_usage "unknown option $arg"		;;	*)		break		;;	esac	shiftdone[ $# -lt 1 ] && ipkg_usage "ipkg must have one sub-command argument"cmd="$1"shiftipkg_load_configurationcase "$cmd" inupdate|upgrade|list|info|status|install_pending)	;;install|depends|remove|files|search)	[ $# -lt 1 ] && ipkg_usage "ERROR: the \`\`$cmd'' command requires an argument"	;;*)	echo "ERROR: unknown sub-command \`$cmd'"	ipkg_usage	;;esac# Only install pending if we have an interactive sub-commandcase "$cmd" inupgrade|install)	ipkg_install_pending	ipkg_install_wanted	;;esacipkg_$cmd $*

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -