From 5196095c351e624fb82199b50ba75000693a9aa0 Mon Sep 17 00:00:00 2001
From: P. J. McDermott <pj@pehjota.net>
Date: Mon, 18 Aug 2014 17:54:15 -0400
Subject: install: Write opkg.conf

---
diff --git a/lib/cmd/install.sh b/lib/cmd/install.sh
index 3e8119a..efbd551 100644
--- a/lib/cmd/install.sh
+++ b/lib/cmd/install.sh
@@ -20,6 +20,7 @@
 use getopt
 use feed
 use profile
+use fd
 
 cmd_install_optstring='a:P:m:'
 
@@ -96,12 +97,16 @@ cmd_install_find_pkgs()
 	local arch="${3}"
 	local plat="${4}"
 	local chroot="${5}"
+	local opkg_conf_fd=
 	local feed_idx=
 	local feed=
 
-	mkdir -p "${chroot}/var/lib/opkg/lists"
+	mkdir -p "${chroot}/etc/opkg" "${chroot}/var/lib/opkg/lists"
+	fopen "${chroot}/etc/opkg/opkg.conf" 'w'
+	opkg_conf_fd=${FD}
 
 	while read -r feed_idx feed; do
+		printf 'src %s %s\n' "${feed_idx}" "${feed}" >&${opkg_conf_fd}
 		feed_download "${feed}" \
 			>"${chroot}/var/lib/opkg/lists/${feed_idx}"
 		feed_find_pkgs "${chroot}/var/lib/opkg/lists/${feed_idx}" \
@@ -112,4 +117,8 @@ cmd_install_find_pkgs()
 	done <<-EOF
 		$(profile_feeds "${mirror}" "${arch}" "${plat}" "${suite}")
 		EOF
+
+	printf '\ndest root /\n' >&${opkg_conf_fd}
+	printf 'arch %s 1\n' 'all' "${arch}" 'src' >&${opkg_conf_fd}
+	fclose ${opkg_conf_fd}
 }
diff --git a/locale/en_US.sh b/locale/en_US.sh
index b0362c3..3d2946f 100644
--- a/locale/en_US.sh
+++ b/locale/en_US.sh
@@ -66,7 +66,8 @@ msg_prokit_cmd_install_selected_mirror='Using mirror %s'
 msg_prokit_cmd_install_setting_up_chroot='Setting up root...'
 msg_prokit_cmd_install_chroot_dir_exists='Directory "%s" exists"'
 msg_prokit_cmd_install_mkdir_chroot_fail='Failed to create directory "%s"'
-msg_prokit_cmd_install_find_pkgs='Retrieving Packages files...'
+msg_prokit_cmd_install_find_pkgs='Configuring opkg and retrieving Packages '\
+'files...'
 
 # lib/profile.sh
 msg_prokit_profile_not_found='Profile "%s" not found'
--
cgit v0.9.1